Improved drawing and placement code. Explorer style common dialogs are
looking good now.
This commit is contained in:
parent
1b1bf2be84
commit
6ef6825cdc
|
@ -4,10 +4,11 @@
|
||||||
* Copyright 1998 Eric Kohl
|
* Copyright 1998 Eric Kohl
|
||||||
*
|
*
|
||||||
* TODO:
|
* TODO:
|
||||||
* - Button wrapping.
|
* - A little bug in TOOLBAR_DrawMasked()
|
||||||
|
* - Button wrapping (under construction).
|
||||||
* - Messages.
|
* - Messages.
|
||||||
* - Notifications.
|
* - Notifications.
|
||||||
* - Fix TB_GETROWS and TB_SETROWS.
|
* - Fix TB_SETROWS.
|
||||||
* - Tooltip support (almost complete).
|
* - Tooltip support (almost complete).
|
||||||
* - Unicode suppport.
|
* - Unicode suppport.
|
||||||
* - Internal COMMCTL32 bitmaps.
|
* - Internal COMMCTL32 bitmaps.
|
||||||
|
@ -32,6 +33,7 @@
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
|
|
||||||
|
// #define __NEW_WRAP_CODE__
|
||||||
|
|
||||||
#define SEPARATOR_WIDTH 8
|
#define SEPARATOR_WIDTH 8
|
||||||
#define SEPARATOR_HEIGHT 5
|
#define SEPARATOR_HEIGHT 5
|
||||||
|
@ -126,23 +128,40 @@ TOOLBAR_DrawMasked (TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr,
|
||||||
internals directly */
|
internals directly */
|
||||||
|
|
||||||
HDC32 hdcImageList = CreateCompatibleDC32 (0);
|
HDC32 hdcImageList = CreateCompatibleDC32 (0);
|
||||||
|
HDC32 hdcMask = CreateCompatibleDC32 (0);
|
||||||
HIMAGELIST himl = infoPtr->himlDef;
|
HIMAGELIST himl = infoPtr->himlDef;
|
||||||
|
HBITMAP32 hbmMask;
|
||||||
|
|
||||||
/* draw the mask */
|
/* create new bitmap */
|
||||||
|
hbmMask = CreateBitmap32 (himl->cx, himl->cy, 1, 1, NULL);
|
||||||
|
SelectObject32 (hdcMask, hbmMask);
|
||||||
|
|
||||||
|
/* copy the mask bitmap */
|
||||||
SelectObject32 (hdcImageList, himl->hbmMask);
|
SelectObject32 (hdcImageList, himl->hbmMask);
|
||||||
SetBkColor32 (hdcImageList, RGB(255, 255, 255));
|
SetBkColor32 (hdcImageList, RGB(255, 255, 255));
|
||||||
SetTextColor32 (hdcImageList, RGB(0, 0, 0));
|
SetTextColor32 (hdcImageList, RGB(0, 0, 0));
|
||||||
|
BitBlt32 (hdcMask, 0, 0, himl->cx, himl->cy,
|
||||||
|
hdcImageList, himl->cx * btnPtr->iBitmap, 0, SRCCOPY);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
/* add white mask from image */
|
||||||
|
SelectObject32 (hdcImageList, himl->hbmImage);
|
||||||
|
SetBkColor32 (hdcImageList, RGB(0, 0, 0));
|
||||||
|
BitBlt32 (hdcMask, 0, 0, himl->cx, himl->cy,
|
||||||
|
hdcImageList, himl->cx * btnPtr->iBitmap, 0, MERGEPAINT);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* draw the new mask */
|
||||||
SelectObject32 (hdc, GetSysColorBrush32 (COLOR_3DHILIGHT));
|
SelectObject32 (hdc, GetSysColorBrush32 (COLOR_3DHILIGHT));
|
||||||
BitBlt32 (hdc, x+1, y+1, himl->cx, himl->cy,
|
BitBlt32 (hdc, x+1, y+1, himl->cx, himl->cy,
|
||||||
hdcImageList, himl->cx * btnPtr->iBitmap, 0,
|
hdcMask, 0, 0, 0xB8074A);
|
||||||
0xB8074A);
|
|
||||||
|
|
||||||
SelectObject32 (hdc, GetSysColorBrush32 (COLOR_3DSHADOW));
|
SelectObject32 (hdc, GetSysColorBrush32 (COLOR_3DSHADOW));
|
||||||
BitBlt32 (hdc, x, y, himl->cx, himl->cy,
|
BitBlt32 (hdc, x, y, himl->cx, himl->cy,
|
||||||
hdcImageList, himl->cx * btnPtr->iBitmap, 0,
|
hdcMask, 0, 0, 0xB8074A);
|
||||||
0xB8074A);
|
|
||||||
|
|
||||||
|
DeleteObject32 (hbmMask);
|
||||||
|
DeleteDC32 (hdcMask);
|
||||||
DeleteDC32 (hdcImageList);
|
DeleteDC32 (hdcImageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,11 +294,15 @@ static void
|
||||||
TOOLBAR_CalcToolbar (WND *wndPtr)
|
TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
{
|
{
|
||||||
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
||||||
TBUTTON_INFO *btnPtr;
|
TBUTTON_INFO *btnPtr, *grpPtr;
|
||||||
INT32 i, j, nRows;
|
INT32 i, j, nRows;
|
||||||
INT32 x, y, cx, cy;
|
INT32 x, y, cx, cy;
|
||||||
BOOL32 bVertical;
|
BOOL32 bWrap;
|
||||||
SIZE32 sizeString;
|
SIZE32 sizeString;
|
||||||
|
/* --- new --- */
|
||||||
|
INT32 nGrpCount = 0;
|
||||||
|
INT32 grpX;
|
||||||
|
/* --- end new --- */
|
||||||
|
|
||||||
TOOLBAR_CalcStrings (wndPtr, &sizeString);
|
TOOLBAR_CalcStrings (wndPtr, &sizeString);
|
||||||
|
|
||||||
|
@ -297,7 +320,10 @@ TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
y = TOP_BORDER;
|
y = TOP_BORDER;
|
||||||
cx = infoPtr->nButtonWidth;
|
cx = infoPtr->nButtonWidth;
|
||||||
cy = infoPtr->nButtonHeight;
|
cy = infoPtr->nButtonHeight;
|
||||||
nRows = 1;
|
nRows = 0;
|
||||||
|
|
||||||
|
/* calculate the size of each button according to it's style */
|
||||||
|
// TOOLBAR_CalcButtons (wndPtr);
|
||||||
|
|
||||||
infoPtr->rcBound.top = y;
|
infoPtr->rcBound.top = y;
|
||||||
infoPtr->rcBound.left = x;
|
infoPtr->rcBound.left = x;
|
||||||
|
@ -306,11 +332,86 @@ TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
|
|
||||||
btnPtr = infoPtr->buttons;
|
btnPtr = infoPtr->buttons;
|
||||||
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
for (i = 0; i < infoPtr->nNumButtons; i++, btnPtr++) {
|
||||||
bVertical = FALSE;
|
bWrap = FALSE;
|
||||||
|
|
||||||
if (btnPtr->fsState & TBSTATE_HIDDEN)
|
if (btnPtr->fsState & TBSTATE_HIDDEN) {
|
||||||
|
SetRectEmpty32 (&btnPtr->rect);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __NEW_WRAP_CODE__
|
||||||
|
//#if 0
|
||||||
|
if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
||||||
|
/* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
||||||
|
/* it is the actual width of the separator. This is used for */
|
||||||
|
/* custom controls in toolbars. */
|
||||||
|
if ((wndPtr->dwStyle & TBSTYLE_WRAPABLE) &&
|
||||||
|
(btnPtr->fsState & TBSTATE_WRAP)) {
|
||||||
|
x = 0;
|
||||||
|
y += cy;
|
||||||
|
cx = infoPtr->nWidth;
|
||||||
|
cy = ((btnPtr->iBitmap > 0) ?
|
||||||
|
btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 / 3;
|
||||||
|
// nRows++;
|
||||||
|
// bWrap = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
cx = (btnPtr->iBitmap > 0) ?
|
||||||
|
btnPtr->iBitmap : SEPARATOR_WIDTH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* this must be a button */
|
||||||
|
cx = infoPtr->nButtonWidth;
|
||||||
|
}
|
||||||
|
//#endif
|
||||||
|
|
||||||
|
/* --- begin test --- */
|
||||||
|
if ((i >= nGrpCount) && (btnPtr->fsStyle & TBSTYLE_GROUP)) {
|
||||||
|
for (j = i, grpX = x, nGrpCount = 0; j < infoPtr->nNumButtons; j++) {
|
||||||
|
grpPtr = &infoPtr->buttons[j];
|
||||||
|
if (grpPtr->fsState & TBSTATE_HIDDEN)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
grpX += cx;
|
||||||
|
|
||||||
|
if ((grpPtr->fsStyle & TBSTYLE_SEP) ||
|
||||||
|
!(grpPtr->fsStyle & TBSTYLE_GROUP) ||
|
||||||
|
(grpX > infoPtr->nWidth)) {
|
||||||
|
nGrpCount = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (grpX + x > infoPtr->nWidth) {
|
||||||
|
bWrap = TRUE;
|
||||||
|
nGrpCount = j;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bWrap = ((bWrap || (x + cx > infoPtr->nWidth)) &&
|
||||||
|
(wndPtr->dwStyle & TBSTYLE_WRAPABLE));
|
||||||
|
if (bWrap) {
|
||||||
|
nRows++;
|
||||||
|
y += cy;
|
||||||
|
x = infoPtr->nIndent;
|
||||||
|
bWrap = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetRect32 (&btnPtr->rect, x, y, x + cx, y + cy);
|
||||||
|
|
||||||
|
btnPtr->nRow = nRows;
|
||||||
|
x += cx;
|
||||||
|
|
||||||
|
if (btnPtr->fsState & TBSTATE_WRAP) {
|
||||||
|
nRows++;
|
||||||
|
y += (cy + SEPARATOR_HEIGHT);
|
||||||
|
x = infoPtr->nIndent;
|
||||||
|
}
|
||||||
|
|
||||||
|
infoPtr->nRows = nRows + 1;
|
||||||
|
|
||||||
|
/* --- end test --- */
|
||||||
|
#else
|
||||||
if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
if (btnPtr->fsStyle & TBSTYLE_SEP) {
|
||||||
/* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
/* UNDOCUMENTED: If a separator has a non zero bitmap index, */
|
||||||
/* it is the actual width of the separator. This is used for */
|
/* it is the actual width of the separator. This is used for */
|
||||||
|
@ -323,7 +424,7 @@ TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
cy = ((btnPtr->iBitmap > 0) ?
|
cy = ((btnPtr->iBitmap > 0) ?
|
||||||
btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 / 3;
|
btnPtr->iBitmap : SEPARATOR_WIDTH) * 2 / 3;
|
||||||
nRows++;
|
nRows++;
|
||||||
bVertical = TRUE;
|
bWrap = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cx = (btnPtr->iBitmap > 0) ?
|
cx = (btnPtr->iBitmap > 0) ?
|
||||||
|
@ -358,7 +459,7 @@ TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
0, (LPARAM)&ti);
|
0, (LPARAM)&ti);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bVertical) {
|
if (bWrap) {
|
||||||
x = 0;
|
x = 0;
|
||||||
y += cy;
|
y += cy;
|
||||||
if (i < infoPtr->nNumButtons)
|
if (i < infoPtr->nNumButtons)
|
||||||
|
@ -366,6 +467,7 @@ TOOLBAR_CalcToolbar (WND *wndPtr)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
x += cx;
|
x += cx;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
infoPtr->nHeight = y + cy + BOTTOM_BORDER;
|
infoPtr->nHeight = y + cy + BOTTOM_BORDER;
|
||||||
|
@ -621,7 +723,7 @@ TOOLBAR_AddString32A (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
||||||
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
||||||
INT32 nIndex;
|
INT32 nIndex;
|
||||||
|
|
||||||
if (wParam) {
|
if ((wParam) && (HIWORD(lParam) == 0)) {
|
||||||
char szString[256];
|
char szString[256];
|
||||||
INT32 len;
|
INT32 len;
|
||||||
TRACE (toolbar, "adding string from resource!\n");
|
TRACE (toolbar, "adding string from resource!\n");
|
||||||
|
@ -704,7 +806,7 @@ TOOLBAR_AutoSize (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
||||||
GetClientRect32(parent, &parent_rect);
|
GetClientRect32(parent, &parent_rect);
|
||||||
|
|
||||||
if (wndPtr->dwStyle & CCS_NORESIZE) {
|
if (wndPtr->dwStyle & CCS_NORESIZE) {
|
||||||
uPosFlags |= SWP_NOSIZE;
|
uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
||||||
cx = 0;
|
cx = 0;
|
||||||
cy = 0;
|
cy = 0;
|
||||||
}
|
}
|
||||||
|
@ -1187,7 +1289,7 @@ TOOLBAR_GetRows (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
||||||
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(wndPtr);
|
||||||
|
|
||||||
if (wndPtr->dwStyle & TBSTYLE_WRAPABLE)
|
if (wndPtr->dwStyle & TBSTYLE_WRAPABLE)
|
||||||
return infoPtr->nMaxRows;
|
return infoPtr->nRows;
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1929,7 +2031,7 @@ TOOLBAR_Create (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
||||||
infoPtr->nBitmapWidth = 16;
|
infoPtr->nBitmapWidth = 16;
|
||||||
|
|
||||||
infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
infoPtr->nHeight = infoPtr->nButtonHeight + TOP_BORDER + BOTTOM_BORDER;
|
||||||
infoPtr->nMaxRows = 1;
|
infoPtr->nRows = 1;
|
||||||
infoPtr->nMaxTextRows = 1;
|
infoPtr->nMaxTextRows = 1;
|
||||||
infoPtr->cxMin = -1;
|
infoPtr->cxMin = -1;
|
||||||
infoPtr->cxMax = -1;
|
infoPtr->cxMax = -1;
|
||||||
|
@ -2368,7 +2470,7 @@ TOOLBAR_Size (WND *wndPtr, WPARAM32 wParam, LPARAM lParam)
|
||||||
GetClientRect32(parent, &parent_rect);
|
GetClientRect32(parent, &parent_rect);
|
||||||
|
|
||||||
if (wndPtr->dwStyle & CCS_NORESIZE) {
|
if (wndPtr->dwStyle & CCS_NORESIZE) {
|
||||||
uPosFlags |= SWP_NOSIZE;
|
uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE);
|
||||||
|
|
||||||
/* FIXME */
|
/* FIXME */
|
||||||
// infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
// infoPtr->nWidth = parent_rect.right - parent_rect.left;
|
||||||
|
|
|
@ -17,8 +17,8 @@ typedef struct tagTBUTTON_INFO
|
||||||
DWORD dwData;
|
DWORD dwData;
|
||||||
INT32 iString;
|
INT32 iString;
|
||||||
|
|
||||||
|
INT32 nRow;
|
||||||
RECT32 rect;
|
RECT32 rect;
|
||||||
|
|
||||||
} TBUTTON_INFO;
|
} TBUTTON_INFO;
|
||||||
|
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ typedef struct tagTOOLBAR_INFO
|
||||||
INT32 nBitmapHeight;
|
INT32 nBitmapHeight;
|
||||||
INT32 nBitmapWidth;
|
INT32 nBitmapWidth;
|
||||||
INT32 nIndent;
|
INT32 nIndent;
|
||||||
INT32 nMaxRows; /* maximum number of button rows */
|
INT32 nRows; /* number of button rows */
|
||||||
INT32 nMaxTextRows; /* maximum number of text rows */
|
INT32 nMaxTextRows; /* maximum number of text rows */
|
||||||
INT32 cxMin; /* minimum button width */
|
INT32 cxMin; /* minimum button width */
|
||||||
INT32 cxMax; /* maximum button width */
|
INT32 cxMax; /* maximum button width */
|
||||||
|
|
Loading…
Reference in New Issue