Commit 60935ec3 authored by Pascal Lessard's avatar Pascal Lessard Committed by Alexandre Julliard

Change the AddBitmap function. Implement flat toolbar. Change

CreateToolbarEx. Implement partially the hot buttons for toolbar.
parent 14f18bfc
...@@ -629,34 +629,29 @@ CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, ...@@ -629,34 +629,29 @@ CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps,
(WPARAM)uStructSize, 0); (WPARAM)uStructSize, 0);
/* set bitmap and button size */ /* set bitmap and button size */
if (hBMInst == HINST_COMMCTRL) { /*If CreateToolbarEx receive 0, windows set default values*/
if (wBMID & 1) { if (dyBitmap < 0)
SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0, dyBitmap = 16;
MAKELPARAM(26, 25)); if (dxBitmap < 0)
SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0, dxBitmap = 16;
MAKELPARAM(33, 32));
}
else {
SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
MAKELPARAM(16, 15));
SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
MAKELPARAM(23, 22));
}
}
else {
SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0, SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0,
MAKELPARAM((WORD)dyBitmap, (WORD)dxBitmap)); MAKELPARAM((WORD)dyBitmap, (WORD)dxBitmap));
SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0, SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0,
MAKELPARAM((WORD)dyButton, (WORD)dxButton)); MAKELPARAM((WORD)dyButton, (WORD)dxButton));
}
/* add bitmaps */ /* add bitmaps */
if (nBitmaps > 0)
{
tbab.hInst = hBMInst; tbab.hInst = hBMInst;
tbab.nID = wBMID; tbab.nID = wBMID;
SendMessageA (hwndTB, TB_ADDBITMAP, SendMessageA (hwndTB, TB_ADDBITMAP,
(WPARAM)nBitmaps, (LPARAM)&tbab); (WPARAM)nBitmaps, (LPARAM)&tbab);
}
/* add buttons */ /* add buttons */
if(iNumButtons > 0)
SendMessageA (hwndTB, TB_ADDBUTTONSA, SendMessageA (hwndTB, TB_ADDBUTTONSA,
(WPARAM)iNumButtons, (LPARAM)lpButtons); (WPARAM)iNumButtons, (LPARAM)lpButtons);
} }
......
...@@ -2107,7 +2107,7 @@ ImageList_SetImageCount (HIMAGELIST himl, INT iImageCount) ...@@ -2107,7 +2107,7 @@ ImageList_SetImageCount (HIMAGELIST himl, INT iImageCount)
if (!himl) if (!himl)
return FALSE; return FALSE;
if (himl->cCurImage <= iImageCount) if (himl->cCurImage >= iImageCount)
return FALSE; return FALSE;
if (himl->cMaxImage > iImageCount) if (himl->cMaxImage > iImageCount)
return TRUE; return TRUE;
......
/* /*
* Toolbar control * Toolbar control
* *
...@@ -224,11 +225,17 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -224,11 +225,17 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
TOOLBAR_DrawPattern (hdc, &rc); TOOLBAR_DrawPattern (hdc, &rc);
if (dwStyle & TBSTYLE_FLAT) if (dwStyle & TBSTYLE_FLAT)
{
if (infoPtr->himlDef != NULL)
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left+2, rc.top+2, ILD_NORMAL); rc.left+2, rc.top+2, ILD_NORMAL);
else else
ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
rc.left+2, rc.top+2, ILD_NORMAL); rc.left+2, rc.top+2, ILD_NORMAL);
}
else
ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
rc.left+2, rc.top+2, ILD_NORMAL);
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
return; return;
} }
...@@ -244,16 +251,27 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) ...@@ -244,16 +251,27 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc)
return; return;
} }
if (dwStyle & TBSTYLE_FLAT)
{
if(btnPtr->bHot)
DrawEdge (hdc, &rc, BDR_RAISEDINNER,
BF_RECT | BF_MIDDLE | BF_SOFT);
if(infoPtr->himlDef != NULL)
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left +2, rc.top +2, ILD_NORMAL);
else
ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
rc.left +2, rc.top +2, ILD_NORMAL);
}
else{
/* normal state */ /* normal state */
DrawEdge (hdc, &rc, EDGE_RAISED, DrawEdge (hdc, &rc, EDGE_RAISED,
BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST); BF_SOFT | BF_RECT | BF_MIDDLE | BF_ADJUST);
if (dwStyle & TBSTYLE_FLAT)
ImageList_Draw (infoPtr->himlDef, btnPtr->iBitmap, hdc,
rc.left+1, rc.top+1, ILD_NORMAL);
else
ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc, ImageList_Draw (infoPtr->himlStd, btnPtr->iBitmap, hdc,
rc.left+1, rc.top+1, ILD_NORMAL); rc.left+1, rc.top+1, ILD_NORMAL);
}
TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState); TOOLBAR_DrawString (infoPtr, btnPtr, hdc, btnPtr->fsState);
} }
...@@ -610,7 +628,10 @@ TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, ...@@ -610,7 +628,10 @@ TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg); SendMessageA (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
} }
/***********************************************************************
* TOOLBAR_AddBitmap: Add the bitmaps to the default image list.
*
*/
static LRESULT static LRESULT
TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
...@@ -623,26 +644,42 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -623,26 +644,42 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
TRACE (toolbar, "adding %d bitmaps!\n", wParam); TRACE (toolbar, "adding %d bitmaps!\n", wParam);
if (!(infoPtr->himlDef)) { if (!(infoPtr->himlStd)) {
/* create new default image list */ /* create new standard image list */
TRACE (toolbar, "creating default image list!\n");
TRACE (toolbar, "creating standard image list!\n");
/* Windows resize all the buttons to the size of a newly added STandard Image*/
/* TODO: The resizing should be done each time a standard image is added*/
if (lpAddBmp->hInst == HINST_COMMCTRL)
{
if (lpAddBmp->nID & 1)
{
SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
MAKELPARAM((WORD)26, (WORD)26));
SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
MAKELPARAM((WORD)33, (WORD)33));
}
else
{
SendMessageA (hwnd, TB_SETBITMAPSIZE, 0,
MAKELPARAM((WORD)16, (WORD)16));
SendMessageA (hwnd, TB_SETBUTTONSIZE, 0,
MAKELPARAM((WORD)22, (WORD)22));
}
TOOLBAR_CalcToolbar (hwnd);
}
infoPtr->himlStd = infoPtr->himlStd =
ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight, ImageList_Create (infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
ILC_COLOR | ILC_MASK, (INT)wParam, 2); ILC_COLOR | ILC_MASK, (INT)wParam, 2);
} }
#if 0 /* Add bitmaps to the standard image list */
if (!(infoPtr->himlDis)) {
/* create new disabled image list */
TRACE (toolbar, "creating disabled image list!\n");
infoPtr->himlDis =
ImageList_Create (infoPtr->nBitmapWidth,
infoPtr->nBitmapHeight, ILC_COLOR | ILC_MASK,
(INT)wParam, 2);
}
#endif
/* Add bitmaps to the default image list */
if (lpAddBmp->hInst == (HINSTANCE)0) { if (lpAddBmp->hInst == (HINSTANCE)0) {
nIndex = nIndex =
ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID, ImageList_AddMasked (infoPtr->himlStd, (HBITMAP)lpAddBmp->nID,
...@@ -650,23 +687,24 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -650,23 +687,24 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
} }
else if (lpAddBmp->hInst == HINST_COMMCTRL) { else if (lpAddBmp->hInst == HINST_COMMCTRL) {
/* add internal bitmaps */ /* add internal bitmaps */
FIXME (toolbar, "internal bitmaps not supported!\n"); FIXME (toolbar, "internal bitmaps not supported!\n");
/* TODO: Resize all the buttons when a new standard image is added */
/* Hack to "add" some reserved images within the image list /* Hack to "add" some reserved images within the image list
to get the right image indices */ to get the right image indices */
nIndex = ImageList_GetImageCount (infoPtr->himlStd); nIndex = ImageList_GetImageCount (infoPtr->himlStd);
ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam); ImageList_SetImageCount (infoPtr->himlStd, nIndex + (INT)wParam);
} }
else { else {
HBITMAP hBmp = HBITMAP hBmp =
LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT); nIndex = ImageList_AddMasked (infoPtr->himlStd, hBmp, CLR_DEFAULT);
DeleteObject (hBmp); DeleteObject (hBmp);
} }
infoPtr->nNumBitmaps += (INT)wParam; infoPtr->nNumBitmaps += (INT)wParam;
return nIndex; return nIndex;
...@@ -711,6 +749,7 @@ TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -711,6 +749,7 @@ TOOLBAR_AddButtonsA (HWND hwnd, WPARAM wParam, LPARAM lParam)
btnPtr->fsStyle = lpTbb[nCount].fsStyle; btnPtr->fsStyle = lpTbb[nCount].fsStyle;
btnPtr->dwData = lpTbb[nCount].dwData; btnPtr->dwData = lpTbb[nCount].dwData;
btnPtr->iString = lpTbb[nCount].iString; btnPtr->iString = lpTbb[nCount].iString;
btnPtr->bHot = FALSE;
if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) { if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & TBSTYLE_SEP)) {
TTTOOLINFOA ti; TTTOOLINFOA ti;
...@@ -2156,10 +2195,9 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2156,10 +2195,9 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->bUnicode = IsWindowUnicode (hwnd); infoPtr->bUnicode = IsWindowUnicode (hwnd);
infoPtr->nButtonDown = -1; infoPtr->nButtonDown = -1;
infoPtr->nOldHit = -1; infoPtr->nOldHit = -1;
infoPtr->nHotItem = -2; // It has to be initially different from nOldHit
infoPtr->hwndNotify = GetParent (hwnd); infoPtr->hwndNotify = GetParent (hwnd);
infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT); infoPtr->bTransparent = (dwStyle & TBSTYLE_FLAT);
infoPtr->nHotItem = -1;
infoPtr->dwDTFlags = DT_CENTER; infoPtr->dwDTFlags = DT_CENTER;
SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0);
...@@ -2390,8 +2428,8 @@ TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2390,8 +2428,8 @@ TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
static LRESULT static LRESULT
TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
{ {
TBUTTON_INFO *btnPtr, *oldBtnPtr;
TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
TBUTTON_INFO *btnPtr;
POINT pt; POINT pt;
INT nHit; INT nHit;
HDC hdc; HDC hdc;
...@@ -2402,10 +2440,34 @@ TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2402,10 +2440,34 @@ TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
pt.x = (INT)LOWORD(lParam); pt.x = (INT)LOWORD(lParam);
pt.y = (INT)HIWORD(lParam); pt.y = (INT)HIWORD(lParam);
nHit = TOOLBAR_InternalHitTest (hwnd, &pt); nHit = TOOLBAR_InternalHitTest (hwnd, &pt);
if (infoPtr->nOldHit != nHit)
{
//Remove the effect of an old hot button
if(infoPtr->nOldHit == infoPtr->nHotItem)
{
oldBtnPtr = &infoPtr->buttons[infoPtr->nOldHit];
oldBtnPtr->bHot = FALSE;
InvalidateRect (hwnd, &oldBtnPtr->rect, TRUE);
}
// It's not a separator or in nowhere. It's a hot button.
if (nHit >= 0)
{
btnPtr = &infoPtr->buttons[nHit];
btnPtr->bHot = TRUE;
hdc = GetDC (hwnd);
TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
ReleaseDC (hwnd, hdc);
infoPtr->nHotItem = nHit;
}
if (infoPtr->bCaptured) { if (infoPtr->bCaptured) {
if (infoPtr->nOldHit != nHit) {
btnPtr = &infoPtr->buttons[infoPtr->nButtonDown]; btnPtr = &infoPtr->buttons[infoPtr->nButtonDown];
if (infoPtr->nOldHit == infoPtr->nButtonDown) { if (infoPtr->nOldHit == infoPtr->nButtonDown) {
btnPtr->fsState &= ~TBSTATE_PRESSED; btnPtr->fsState &= ~TBSTATE_PRESSED;
...@@ -2422,7 +2484,6 @@ TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -2422,7 +2484,6 @@ TOOLBAR_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
} }
infoPtr->nOldHit = nHit; infoPtr->nOldHit = nHit;
} }
return 0; return 0;
} }
......
...@@ -752,7 +752,7 @@ typedef struct tagNMHDDISPINFOW ...@@ -752,7 +752,7 @@ typedef struct tagNMHDDISPINFOW
/* Toolbar */ /* Toolbar */
#define TOOLBARCLASSNAME16 "ToolbarWindow" #define TOOLBARCLASSNAME16 "ToolbarWindow"
#define TOOLBARCLASSNAMEW L"ToolbarWindow32" #define TOOLBARCLASSNAMEW "ToolbarWindow32"
#define TOOLBARCLASSNAMEA "ToolbarWindow32" #define TOOLBARCLASSNAMEA "ToolbarWindow32"
#define TOOLBARCLASSNAME WINELIB_NAME_AW(TOOLBARCLASSNAME) #define TOOLBARCLASSNAME WINELIB_NAME_AW(TOOLBARCLASSNAME)
......
...@@ -17,6 +17,7 @@ typedef struct tagTBUTTON_INFO ...@@ -17,6 +17,7 @@ typedef struct tagTBUTTON_INFO
DWORD dwData; DWORD dwData;
INT iString; INT iString;
BOOL bHot;
INT nRow; INT nRow;
RECT rect; RECT rect;
} TBUTTON_INFO; } TBUTTON_INFO;
...@@ -45,8 +46,8 @@ typedef struct tagTOOLBAR_INFO ...@@ -45,8 +46,8 @@ typedef struct tagTOOLBAR_INFO
INT nOldHit; INT nOldHit;
INT nHotItem; /* index of the "hot" item */ INT nHotItem; /* index of the "hot" item */
HFONT hFont; /* text font */ HFONT hFont; /* text font */
HIMAGELIST himlStd; /* standard image list */ HIMAGELIST himlStd; /* standard image list for TB_ADDBITMAP command*/
HIMAGELIST himlDef; /* default image list */ HIMAGELIST himlDef; /* default image list for TB_SETIMAGELIST*/
HIMAGELIST himlHot; /* hot image list */ HIMAGELIST himlHot; /* hot image list */
HIMAGELIST himlDis; /* disabled image list */ HIMAGELIST himlDis; /* disabled image list */
HWND hwndToolTip; /* handle to tool tip control */ HWND hwndToolTip; /* handle to tool tip control */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment