[COMCTL32]

* Begin implementing TB_GETMETRICS/TB_SETMETRICS. Will send to wine once the button spacing setting works (after writing tests and whatever else may be necessary).

svn path=/branches/shell-experiments/; revision=65275
This commit is contained in:
David Quintana 2014-11-05 23:00:23 +00:00
parent a2cc12f3e7
commit fb929febc6

View file

@ -33,11 +33,9 @@
* - TBSTYLE_REGISTERDROP
* - TBSTYLE_EX_DOUBLEBUFFER
* - Messages:
* - TB_GETMETRICS
* - TB_GETOBJECT
* - TB_INSERTMARKHITTEST
* - TB_SAVERESTORE
* - TB_SETMETRICS
* - WM_WININICHANGE
* - Notifications:
* - NM_CHAR
@ -126,6 +124,8 @@ typedef struct
INT nOldHit;
INT nHotItem; /* index of the "hot" item */
SIZE szPadding; /* padding values around button */
SIZE szBarPadding; /* padding values around the toolbar (NOT USED BUT STORED) */
SIZE szSpacing; /* spacing values between buttons */
INT iTopMargin; /* the top margin */
INT iListGap; /* default gap between text and image for toolbar with list style */
HFONT hDefaultFont;
@ -191,12 +191,18 @@ typedef enum
#define ARROW_HEIGHT 3
#define INSERTMARK_WIDTH 2
/* default padding inside a button */
#define DEFPAD_CX 7
#define DEFPAD_CY 6
/* default space between buttons and between rows */
#define DEFSPACE_CX 7
#define DEFSPACE_CY 6
#define DEFLISTGAP 4
/* vertical padding used in list mode when image is present */
#define LISTPAD_CY 9
#define LISTPAD_CY 2
/* how wide to treat the bitmap if it isn't present */
#define NONLIST_NOTEXT_OFFSET 2
@ -1421,7 +1427,8 @@ TOOLBAR_WrapToolbar(TOOLBAR_INFO *infoPtr)
bButtonWrap = TRUE;
}
}
else {
else
{
TRACE("wrap point 6 btn %d style %02x, x=%d, cx=%d\n",
i, btnPtr[i].fsStyle, x, cx);
x += cx;
@ -1551,9 +1558,8 @@ static inline SIZE TOOLBAR_MeasureButton(const TOOLBAR_INFO *infoPtr, SIZE sizeS
/* ... add on the necessary padding */
if (bValidImageList)
{
if (bHasBitmap)
sizeButton.cy += DEFPAD_CY;
else
sizeButton.cy += infoPtr->szPadding.cy;
if (!bHasBitmap)
sizeButton.cy += LISTPAD_CY;
}
else
@ -1570,7 +1576,7 @@ static inline SIZE TOOLBAR_MeasureButton(const TOOLBAR_INFO *infoPtr, SIZE sizeS
{
if (bHasBitmap)
{
sizeButton.cy = infoPtr->nBitmapHeight + DEFPAD_CY;
sizeButton.cy = infoPtr->nBitmapHeight + infoPtr->szPadding.cy;
if (sizeString.cy > 0)
sizeButton.cy += 1 + sizeString.cy;
sizeButton.cx = infoPtr->szPadding.cx +
@ -1663,19 +1669,25 @@ TOOLBAR_LayoutToolbar(TOOLBAR_INFO *infoPtr)
cy = infoPtr->nButtonHeight;
if (btnPtr->fsStyle & BTNS_SEP) {
if (infoPtr->dwStyle & CCS_VERT) {
if (btnPtr->fsStyle & BTNS_SEP)
{
if (infoPtr->dwStyle & CCS_VERT)
{
cy = (btnPtr->iBitmap > 0) ? btnPtr->iBitmap : SEPARATOR_WIDTH;
cx = (btnPtr->cx > 0) ? btnPtr->cx : infoPtr->nButtonWidth;
}
else
{
cx = (btnPtr->cx > 0) ? btnPtr->cx :
(btnPtr->iBitmap > 0) ? btnPtr->iBitmap : SEPARATOR_WIDTH;
}
}
else
{
if (btnPtr->cx)
{
cx = btnPtr->cx;
}
else if ((infoPtr->dwExStyle & TBSTYLE_EX_MIXEDBUTTONS) ||
(btnPtr->fsStyle & BTNS_AUTOSIZE))
{
@ -1941,6 +1953,16 @@ TOOLBAR_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg,
SendMessageW (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
}
static LRESULT
TOOLBAR_ThemeChanged(HWND hwnd)
{
HTHEME theme = GetWindowTheme(hwnd);
CloseThemeData(theme);
OpenThemeData(hwnd, themeClass);
return 0;
}
static void
TOOLBAR_TooltipAddTool(const TOOLBAR_INFO *infoPtr, const TBUTTON_INFO *button)
{
@ -3530,6 +3552,36 @@ TOOLBAR_GetMaxSize (const TOOLBAR_INFO *infoPtr, LPSIZE lpSize)
}
static LRESULT
TOOLBAR_GetMetrics (const TOOLBAR_INFO *infoPtr, TBMETRICS *pMetrics)
{
if (pMetrics == NULL)
return FALSE;
/* TODO: check if cbSize is a valid value */
if (pMetrics->dwMask & TBMF_PAD)
{
pMetrics->cxPad = infoPtr->szPadding.cx;
pMetrics->cyPad = infoPtr->szPadding.cy;
}
if (pMetrics->dwMask & TBMF_BARPAD)
{
pMetrics->cxBarPad = infoPtr->szBarPadding.cx;
pMetrics->cyBarPad = infoPtr->szBarPadding.cy;
}
if (pMetrics->dwMask & TBMF_BUTTONSPACING)
{
pMetrics->cxButtonSpacing = infoPtr->szSpacing.cx;
pMetrics->cyButtonSpacing = infoPtr->szSpacing.cy;
}
return TRUE;
}
/* << TOOLBAR_GetObject >> */
@ -4711,6 +4763,43 @@ TOOLBAR_SetMaxTextRows (TOOLBAR_INFO *infoPtr, INT nMaxRows)
}
static LRESULT
TOOLBAR_SetMetrics (TOOLBAR_INFO *infoPtr, TBMETRICS *pMetrics)
{
BOOL changed = FALSE;
if (!pMetrics)
return FALSE;
/* TODO: check if cbSize is a valid value */
if (pMetrics->dwMask & TBMF_PAD)
{
infoPtr->szPadding.cx = pMetrics->cxPad;
infoPtr->szPadding.cy = pMetrics->cyPad;
changed = TRUE;
}
if (pMetrics->dwMask & TBMF_PAD)
{
infoPtr->szBarPadding.cx = pMetrics->cxBarPad;
infoPtr->szBarPadding.cy = pMetrics->cyBarPad;
changed = TRUE;
}
if (pMetrics->dwMask & TBMF_BUTTONSPACING)
{
infoPtr->szSpacing.cx = pMetrics->cxButtonSpacing;
infoPtr->szSpacing.cy = pMetrics->cyButtonSpacing;
changed = TRUE;
}
if (changed)
TOOLBAR_CalcToolbar(infoPtr);
return TRUE;
}
/* MSDN gives slightly wrong info on padding.
* 1. It is not only used on buttons with the BTNS_AUTOSIZE style
* 2. It is not used to create a blank area between the edge of the button
@ -5926,6 +6015,8 @@ TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, const CREATESTRUCTW *lpcs)
infoPtr->clrBtnShadow = CLR_DEFAULT;
infoPtr->szPadding.cx = DEFPAD_CX;
infoPtr->szPadding.cy = DEFPAD_CY;
infoPtr->szSpacing.cx = DEFSPACE_CX;
infoPtr->szSpacing.cy = DEFSPACE_CY;
infoPtr->iListGap = DEFLISTGAP;
infoPtr->iTopMargin = default_top_margin(infoPtr);
infoPtr->dwStyle = lpcs->style;
@ -6359,16 +6450,6 @@ TOOLBAR_SysColorChange (void)
}
/* update theme after a WM_THEMECHANGED message */
static LRESULT theme_changed (HWND hwnd)
{
HTHEME theme = GetWindowTheme (hwnd);
CloseThemeData (theme);
OpenThemeData (hwnd, themeClass);
return 0;
}
static LRESULT WINAPI
ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -6473,6 +6554,9 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case TB_GETMAXSIZE:
return TOOLBAR_GetMaxSize (infoPtr, (LPSIZE)lParam);
case TB_GETMETRICS:
return TOOLBAR_GetMetrics (infoPtr, (TBMETRICS*)lParam);
/* case TB_GETOBJECT: */ /* 4.71 */
case TB_GETPADDING:
@ -6613,6 +6697,9 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
case TB_SETMAXTEXTROWS:
return TOOLBAR_SetMaxTextRows (infoPtr, wParam);
case TB_SETMETRICS:
return TOOLBAR_SetMetrics (infoPtr, (TBMETRICS*)lParam);
case TB_SETPADDING:
return TOOLBAR_SetPadding (infoPtr, lParam);
@ -6753,7 +6840,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return TOOLBAR_SysColorChange ();
case WM_THEMECHANGED:
return theme_changed (hwnd);
return TOOLBAR_ThemeChanged(hwnd);
/* case WM_WININICHANGE: */