Author: gadamopoulos Date: Tue Jul 25 22:41:26 2017 New Revision: 75406
URL: http://svn.reactos.org/svn/reactos?rev=75406&view=rev Log: [COMCTL32] -Implement taking into account the contents margins from the theme when calculating the size of the toolbar button. Using it while painting the button will be implemented in a later commit as it caused me some problems.
Modified: trunk/reactos/dll/win32/comctl32/toolbar.c
Modified: trunk/reactos/dll/win32/comctl32/toolbar.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comctl32/toolbar.... ============================================================================== --- trunk/reactos/dll/win32/comctl32/toolbar.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/comctl32/toolbar.c [iso-8859-1] Tue Jul 25 22:41:26 2017 @@ -126,6 +126,7 @@ #ifdef __REACTOS__ SIZE szBarPadding; /* padding values around the toolbar (NOT USED BUT STORED) */ SIZE szSpacing; /* spacing values between buttons */ + MARGINS themeMargins; #endif INT iTopMargin; /* the top margin */ INT iListGap; /* default gap between text and image for toolbar with list style */ @@ -1706,6 +1707,12 @@ max(2*GetSystemMetrics(SM_CXEDGE) + sizeString.cx, infoPtr->nBitmapWidth); } } + +#ifdef __REACTOS__ + sizeButton.cx += infoPtr->themeMargins.cxLeftWidth + infoPtr->themeMargins.cxRightWidth; + sizeButton.cy += infoPtr->themeMargins.cyTopHeight + infoPtr->themeMargins.cyBottomHeight; +#endif + return sizeButton; }
@@ -2064,16 +2071,6 @@ SendMessageW (hwndTip, TTM_RELAYEVENT, 0, (LPARAM)&msg); }
-#ifdef __REACTOS__ -static LRESULT -TOOLBAR_ThemeChanged(HWND hwnd) -{ - HTHEME theme = GetWindowTheme(hwnd); - CloseThemeData(theme); - OpenThemeData(hwnd, themeClass); - return 0; -} -#endif
static void TOOLBAR_TooltipAddTool(const TOOLBAR_INFO *infoPtr, const TBUTTON_INFO *button) @@ -4601,8 +4598,13 @@ if (cx == 0) cx = 24; if (cy == 0) cy = 22;
+#ifdef __REACTOS__ + cx = max(cx, infoPtr->szPadding.cx + infoPtr->nBitmapWidth + infoPtr->themeMargins.cxLeftWidth + infoPtr->themeMargins.cxRightWidth); + cy = max(cy, infoPtr->szPadding.cy + infoPtr->nBitmapHeight + infoPtr->themeMargins.cyTopHeight + infoPtr->themeMargins.cyBottomHeight); +#else cx = max(cx, infoPtr->szPadding.cx + infoPtr->nBitmapWidth); cy = max(cy, infoPtr->szPadding.cy + infoPtr->nBitmapHeight); +#endif
if (cx != infoPtr->nButtonWidth || cy != infoPtr->nButtonHeight || top != infoPtr->iTopMargin) @@ -5463,8 +5465,16 @@
SystemParametersInfoW (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW (&logFont); - + +#ifdef __REACTOS__ + { + HTHEME theme = OpenThemeData (hwnd, themeClass); + if (theme) + GetThemeMargins(theme, NULL, TP_BUTTON, TS_NORMAL, TMT_CONTENTMARGINS, NULL, &infoPtr->themeMargins); + } +#else OpenThemeData (hwnd, themeClass); +#endif
TOOLBAR_CheckStyle (infoPtr);
@@ -6239,6 +6249,7 @@ #ifdef __REACTOS__ infoPtr->szSpacing.cx = DEFSPACE_CX; infoPtr->szSpacing.cy = DEFSPACE_CY; + memset(&infoPtr->themeMargins, 0 , sizeof(infoPtr->themeMargins)); #endif infoPtr->iListGap = DEFLISTGAP; infoPtr->iTopMargin = default_top_margin(infoPtr); @@ -6649,8 +6660,22 @@ return 0; }
-#ifndef __REACTOS__ +#ifdef __REACTOS__ /* update theme after a WM_THEMECHANGED message */ +static LRESULT theme_changed (TOOLBAR_INFO *infoPtr) +{ + HTHEME theme = GetWindowTheme (infoPtr->hwndSelf); + CloseThemeData (theme); + OpenThemeData (infoPtr->hwndSelf, themeClass); + theme = GetWindowTheme (infoPtr->hwndSelf); + if (theme) + GetThemeMargins(theme, NULL, TP_BUTTON, TS_NORMAL, TMT_CONTENTMARGINS, NULL, &infoPtr->themeMargins); + else + memset(&infoPtr->themeMargins, 0 ,sizeof(infoPtr->themeMargins)); + + return 0; +} +#else static LRESULT theme_changed (HWND hwnd) { HTHEME theme = GetWindowTheme (hwnd); @@ -7056,10 +7081,9 @@
case WM_SYSCOLORCHANGE: return TOOLBAR_SysColorChange (); - - case WM_THEMECHANGED: + case WM_THEMECHANGED: #ifdef __REACTOS__ - return TOOLBAR_ThemeChanged(hwnd); + return theme_changed (infoPtr); #else return theme_changed (hwnd); #endif