diff options
author | Benjamin Otte <otte@gnome.org> | 2016-02-15 00:49:29 +0100 |
---|---|---|
committer | Benjamin Otte <otte@gnome.org> | 2016-02-15 04:41:12 +0100 |
commit | f425b5549c49146ba3b751672e79f70d5e5572d7 (patch) | |
tree | f220558aef5fd83194c2ee8e30ecf1fbaa399630 /gtk/gtkwin32theme.c | |
parent | b43844f9f91d4c24ef1300c2a088050ef960bc6b (diff) | |
download | gtk+-f425b5549c49146ba3b751672e79f70d5e5572d7.tar.gz |
win32: Add support for -gtk-win32-part-width/height to CSS
It's unused by now, but I want it for min-width of checks/radios.
Diffstat (limited to 'gtk/gtkwin32theme.c')
-rw-r--r-- | gtk/gtkwin32theme.c | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/gtk/gtkwin32theme.c b/gtk/gtkwin32theme.c index e1de2c9de9..d2fb6f0551 100644 --- a/gtk/gtkwin32theme.c +++ b/gtk/gtkwin32theme.c @@ -74,7 +74,7 @@ static IsThemeActiveFunc is_theme_active = NULL; static IsAppThemedFunc is_app_themed = NULL; static IsThemeBackgroundPartiallyTransparentFunc is_theme_partially_transparent = NULL; static DrawThemeParentBackgroundFunc draw_theme_parent_background = NULL; -static GetThemePartSizeFunc get_theme_part_size = NULL; +static GetThemePartSizeFunc GetThemePartSize = NULL; #endif @@ -209,7 +209,7 @@ gtk_win32_theme_init (void) get_theme_sys_metric = (GetThemeSysSizeFunc) GetProcAddress (uxtheme_dll, "GetThemeSysSize"); is_theme_partially_transparent = (IsThemeBackgroundPartiallyTransparentFunc) GetProcAddress (uxtheme_dll, "IsThemeBackgroundPartiallyTransparent"); draw_theme_parent_background = (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground"); - get_theme_part_size = (GetThemePartSizeFunc) GetProcAddress (uxtheme_dll, "GetThemePartSize"); + GetThemePartSize = (GetThemePartSizeFunc) GetProcAddress (uxtheme_dll, "GetThemePartSize"); } if (is_app_themed && is_theme_active) @@ -337,7 +337,7 @@ gtk_win32_theme_create_surface (GtkWin32Theme *theme, rect.bottom = height; hdc = GetDC (NULL); - res = get_theme_part_size (htheme, hdc, xp_part, state, &rect, 2, &size); + res = GetThemePartSize (htheme, hdc, xp_part, state, &rect, 2 /*TS_DRAW*/, &size); ReleaseDC (NULL, hdc); if (res == S_OK) @@ -389,6 +389,53 @@ gtk_win32_theme_create_surface (GtkWin32Theme *theme, return surface; } +void +gtk_win32_theme_get_part_size (GtkWin32Theme *theme, + int part, + int state, + int *width, + int *height) +{ +#if 0 + /* Known fallback sizes copied from Wine */ + struct { + int part; + int width; + int height; + } fallback_sizes[] = { + { BP_RADIOBUTTON, 13, 13 }, + { BP_CHECKBOX, 13, 13 }, + }; +#endif +#ifdef G_OS_WIN32 + HTHEME htheme = gtk_win32_theme_get_htheme (theme); + SIZE size; + HDC hdc; + HRESULT res; + + if (use_xp_theme && GetThemePartSize != NULL && htheme != NULL) + { + hdc = GetDC (NULL); + res = GetThemePartSize (htheme, hdc, part, state, NULL, 2 /*TS_DRAW*/, &size); + ReleaseDC (NULL, hdc); + + if (SUCCEEDED (res)) + { + if (width) + *width = size.cx; + if (height) + *height = size.cy; + return; + } + } +#endif + + if (width) + *width = 1; + if (height) + *height = 1; +} + int gtk_win32_theme_get_size (GtkWin32Theme *theme, int id) |