diff options
author | Martin Schlemmer <11285613@nwu.ac.za> | 2010-08-30 20:03:04 +0200 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2010-08-30 20:05:09 +0200 |
commit | e14560cf1ebf345feed03356813d73fbe392ded0 (patch) | |
tree | 8940584b29ecc5c9b04224def257f7de35c70150 /modules/engines | |
parent | 8476d22dea987d1183901af40e31a3ddd507a35e (diff) | |
download | gtk+-e14560cf1ebf345feed03356813d73fbe392ded0.tar.gz |
[win32] Properly draw the menu separator for Windows Vista/7.
Also adds the bits for transparency.
Diffstat (limited to 'modules/engines')
-rwxr-xr-x | modules/engines/ms-windows/msw_style.c | 15 | ||||
-rwxr-xr-x | modules/engines/ms-windows/xp_theme.c | 69 | ||||
-rwxr-xr-x | modules/engines/ms-windows/xp_theme.h | 3 | ||||
-rw-r--r-- | modules/engines/ms-windows/xp_theme_defs.h | 6 |
4 files changed, 91 insertions, 2 deletions
diff --git a/modules/engines/ms-windows/msw_style.c b/modules/engines/ms-windows/msw_style.c index e76519b2c8..d08e1cd37b 100755 --- a/modules/engines/ms-windows/msw_style.c +++ b/modules/engines/ms-windows/msw_style.c @@ -2903,8 +2903,21 @@ draw_hline (GtkStyle *style, { if (xp_theme_is_active () && detail && !strcmp (detail, "menuitem")) { + gint cx, cy; + gint new_y, new_height; + gint y_offset; + + xp_theme_get_element_dimensions (XP_THEME_ELEMENT_MENU_SEPARATOR, + state_type, + &cx, &cy); + + /* Center the separator */ + y_offset = (area->height / 2) - (cy / 2); + new_y = y_offset >= 0 ? area->y + y_offset : area->y; + new_height = cy; + if (xp_theme_draw - (window, XP_THEME_ELEMENT_MENU_SEPARATOR, style, x1, y, x2, 1, + (window, XP_THEME_ELEMENT_MENU_SEPARATOR, style, x1, new_y, x2, new_height, state_type, area)) { return; diff --git a/modules/engines/ms-windows/xp_theme.c b/modules/engines/ms-windows/xp_theme.c index f86451570d..79698ac6f6 100755 --- a/modules/engines/ms-windows/xp_theme.c +++ b/modules/engines/ms-windows/xp_theme.c @@ -86,6 +86,7 @@ #define MBI_DISABLEDHOT 5 #define MBI_DISABLEDPUSHED 6 +#define MENU_POPUPGUTTER 13 #define MENU_POPUPITEM 14 #define MENU_POPUPSEPARATOR 15 @@ -188,6 +189,13 @@ typedef BOOL (FAR PASCAL *IsThemeBackgroundPartiallyTransparentFunc) (HTHEME hTh typedef HRESULT (FAR PASCAL *DrawThemeParentBackgroundFunc) (HWND hwnd, HDC hdc, RECT *prc); +typedef HRESULT (FAR PASCAL *GetThemePartSizeFunc) (HTHEME hTheme, + HDC hdc, + int iPartId, + int iStateId, + RECT *prc, + int eSize, + SIZE *psz); static GetThemeSysFontFunc get_theme_sys_font_func = NULL; static GetThemeSysColorFunc get_theme_sys_color_func = NULL; @@ -200,6 +208,7 @@ static IsThemeActiveFunc is_theme_active_func = NULL; static IsAppThemedFunc is_app_themed_func = NULL; static IsThemeBackgroundPartiallyTransparentFunc is_theme_partially_transparent_func = NULL; static DrawThemeParentBackgroundFunc draw_theme_parent_background_func = NULL; +static GetThemePartSizeFunc get_theme_part_size_func = NULL; static void xp_theme_close_open_handles (void) @@ -242,6 +251,7 @@ xp_theme_init (void) get_theme_sys_metric_func = (GetThemeSysSizeFunc) GetProcAddress (uxtheme_dll, "GetThemeSysSize"); is_theme_partially_transparent_func = (IsThemeBackgroundPartiallyTransparentFunc) GetProcAddress (uxtheme_dll, "IsThemeBackgroundPartiallyTransparent"); draw_theme_parent_background_func = (DrawThemeParentBackgroundFunc) GetProcAddress (uxtheme_dll, "DrawThemeParentBackground"); + get_theme_part_size_func = (GetThemePartSizeFunc) GetProcAddress (uxtheme_dll, "GetThemePartSize"); } if (is_app_themed_func && is_theme_active_func) @@ -292,6 +302,7 @@ xp_theme_exit (void) get_theme_sys_metric_func = NULL; is_theme_partially_transparent_func = NULL; draw_theme_parent_background_func = NULL; + get_theme_part_size_func = NULL; } static HTHEME @@ -782,8 +793,11 @@ xp_theme_map_gtk_state (XpThemeElement element, GtkStateType state) ret = 1; break; - case XP_THEME_ELEMENT_MENU_ITEM: case XP_THEME_ELEMENT_MENU_SEPARATOR: + ret = TS_NORMAL; + break; + + case XP_THEME_ELEMENT_MENU_ITEM: switch (state) { case GTK_STATE_SELECTED: @@ -934,6 +948,10 @@ xp_theme_draw (GdkWindow *win, XpThemeElement element, GtkStyle *style, part_state = xp_theme_map_gtk_state (element, state_type); + /* Support transparency */ + if (is_theme_partially_transparent_func (theme, element_part_map[element], part_state)) + draw_theme_parent_background_func (GDK_WINDOW_HWND (win), dc, pClip); + draw_theme_background_func (theme, dc, element_part_map[element], part_state, &rect, pClip); @@ -958,6 +976,55 @@ xp_theme_is_drawable (XpThemeElement element) } gboolean +xp_theme_get_element_dimensions (XpThemeElement element, + GtkStateType state_type, + gint *cx, gint *cy) +{ + HTHEME theme; + SIZE part_size; + int part_state; + + if (!xp_theme_is_active ()) + return FALSE; + + theme = xp_theme_get_handle_by_element (element); + if (!theme) + return FALSE; + + part_state = xp_theme_map_gtk_state (element, state_type); + + get_theme_part_size_func (theme, + NULL, + element_part_map[element], + part_state, + NULL, + TS_MIN, + &part_size); + + *cx = part_size.cx; + *cy = part_size.cy; + + if (element == XP_THEME_ELEMENT_MENU_ITEM || + element == XP_THEME_ELEMENT_MENU_SEPARATOR) + { + SIZE gutter_size; + + get_theme_part_size_func (theme, + NULL, + MENU_POPUPGUTTER, + 0, + NULL, + TS_MIN, + &gutter_size); + + *cx += gutter_size.cx * 2; + *cy += gutter_size.cy * 2; + } + + return TRUE; +} + +gboolean xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, OUT LOGFONTW *lf) { diff --git a/modules/engines/ms-windows/xp_theme.h b/modules/engines/ms-windows/xp_theme.h index 2d172f3529..dfacb434cc 100755 --- a/modules/engines/ms-windows/xp_theme.h +++ b/modules/engines/ms-windows/xp_theme.h @@ -141,6 +141,9 @@ gboolean xp_theme_draw (GdkWindow *win, XpThemeElement element, int height, GtkStateType state_type, GdkRectangle *area); gboolean xp_theme_is_drawable (XpThemeElement element); +gboolean xp_theme_get_element_dimensions (XpThemeElement element, + GtkStateType state_type, + gint *cx, gint *cy); gboolean xp_theme_get_system_font (XpThemeClass klazz, XpThemeFont fontId, OUT LOGFONTW *lf); gboolean xp_theme_get_system_color (XpThemeClass klazz, int colorId, OUT DWORD *pColor); gboolean xp_theme_get_system_metric (XpThemeClass klazz, int metricId, OUT int *pVal); diff --git a/modules/engines/ms-windows/xp_theme_defs.h b/modules/engines/ms-windows/xp_theme_defs.h index 49f5179fdb..aaae6d9316 100644 --- a/modules/engines/ms-windows/xp_theme_defs.h +++ b/modules/engines/ms-windows/xp_theme_defs.h @@ -756,4 +756,10 @@ enum { VTS_DISABLED = 4 }; +enum { + TS_MIN, + TS_TRUE, + TS_DRAW +}; + #endif /* XP_THEME_DFNS_H */ |