From dc825592f45d07bb4e39e6a878a44e22760977da Mon Sep 17 00:00:00 2001 From: cinamod Date: Mon, 6 Oct 2003 16:38:53 +0000 Subject: [PATCH] xp theme definitions for platforms NOT winxp, catch system settings changes, disable theme switching --- modules/engines/ms-windows/ChangeLog.old | 7 + modules/engines/ms-windows/wimp_style.c | 82 +++++----- modules/engines/ms-windows/wimp_style.h | 1 + modules/engines/ms-windows/wimp_theme_main.c | 35 +++-- modules/engines/ms-windows/xp_theme.c | 9 +- modules/engines/ms-windows/xp_theme.h | 4 +- modules/engines/ms-windows/xp_theme_dfns.h | 152 +++++++++++++++++++ 7 files changed, 235 insertions(+), 55 deletions(-) create mode 100644 modules/engines/ms-windows/xp_theme_dfns.h diff --git a/modules/engines/ms-windows/ChangeLog.old b/modules/engines/ms-windows/ChangeLog.old index c1ed97d67..e89efada6 100755 --- a/modules/engines/ms-windows/ChangeLog.old +++ b/modules/engines/ms-windows/ChangeLog.old @@ -1,3 +1,10 @@ +2003-10-06 Dom Lachowicz + + * src/wimp_style_main.c: Catch system settings changes, disable theme and color changes as they're too experimental + * src/wimp_style.[ch]: Export some things, make them accept 0 args + * src/xp_theme_dfns.h: New file. WinXP's UXTHEME constants, for building on platforms without them + * src/xp_theme.c: Should be able to build on Win32 != [WinXP,2k3] now + 2003-10-03 Dom Lachowicz * src/wimp_style.c wimp_style_main.c: Refactor how we're doing styles. Much faster, lower memory consumption diff --git a/modules/engines/ms-windows/wimp_style.c b/modules/engines/ms-windows/wimp_style.c index ec87d2b2f..a8706b0a8 100755 --- a/modules/engines/ms-windows/wimp_style.c +++ b/modules/engines/ms-windows/wimp_style.c @@ -221,49 +221,49 @@ sys_font_to_pango_font (SystemFontType type, char * buf) static void setup_menu_settings (void) { - int menu_delay; - gboolean win95 = FALSE; - - GtkSettings * settings; - OSVERSIONINFOEX osvi; - - settings = gtk_settings_get_default (); - if (!settings) - return; - - ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); - osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - - if (!GetVersionEx ( (OSVERSIONINFO *) &osvi)) - win95 = TRUE; /* assume the worst */ - - if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) - if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) - win95 = TRUE; - - if (!win95) { - if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0)) { - GObjectClass * klazz = G_OBJECT_GET_CLASS(G_OBJECT(settings)); - - if (klazz) { - if (g_object_class_find_property (klazz, "gtk-menu-bar-popup-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-bar-popup-delay", - 0, NULL); - } - if (g_object_class_find_property (klazz, "gtk-menu-popup-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-popup-delay", - menu_delay, NULL); - } - if (g_object_class_find_property (klazz, "gtk-menu-popdown-delay")) { - g_object_set (G_OBJECT (settings), "gtk-menu-popdown-delay", - menu_delay, NULL); - } - } - } + int menu_delay; + gboolean win95 = FALSE; + + GtkSettings * settings; + OSVERSIONINFOEX osvi; + + settings = gtk_settings_get_default (); + if (!settings) + return; + + ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX)); + osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); + + if (!GetVersionEx ( (OSVERSIONINFO *) &osvi)) + win95 = TRUE; /* assume the worst */ + + if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0) + win95 = TRUE; + + if (!win95) { + if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0)) { + GObjectClass * klazz = G_OBJECT_GET_CLASS(G_OBJECT(settings)); + + if (klazz) { + if (g_object_class_find_property (klazz, "gtk-menu-bar-popup-delay")) { + g_object_set (G_OBJECT (settings), "gtk-menu-bar-popup-delay", + 0, NULL); } + if (g_object_class_find_property (klazz, "gtk-menu-popup-delay")) { + g_object_set (G_OBJECT (settings), "gtk-menu-popup-delay", + menu_delay, NULL); + } + if (g_object_class_find_property (klazz, "gtk-menu-popdown-delay")) { + g_object_set (G_OBJECT (settings), "gtk-menu-popdown-delay", + menu_delay, NULL); + } + } + } + } } -static void +void setup_system_settings (void) { GtkSettings * settings; @@ -1593,4 +1593,4 @@ wimp_init (void) xp_theme_init (); setup_system_settings (); setup_wimp_rc_style (); -} \ No newline at end of file +} diff --git a/modules/engines/ms-windows/wimp_style.h b/modules/engines/ms-windows/wimp_style.h index 7a35e4aac..873841a04 100755 --- a/modules/engines/ms-windows/wimp_style.h +++ b/modules/engines/ms-windows/wimp_style.h @@ -49,5 +49,6 @@ struct _WimpStyleClass void wimp_style_register_type (GTypeModule *module); void wimp_style_init (void); +void setup_system_settings (void); #endif /* WIMP_TYPE_STYLE */ diff --git a/modules/engines/ms-windows/wimp_theme_main.c b/modules/engines/ms-windows/wimp_theme_main.c index ac48578fa..1147be7e4 100755 --- a/modules/engines/ms-windows/wimp_theme_main.c +++ b/modules/engines/ms-windows/wimp_theme_main.c @@ -31,6 +31,12 @@ #define WM_THEMECHANGED 0x031A /* winxp only */ #endif +/* TODO - look into whether we need to handle these: + * + * WM_STYLECHANGED + * WM_PALETTECHANGED + */ + static GdkFilterReturn global_filter_func (void *xevent, GdkEvent *event, @@ -40,15 +46,25 @@ global_filter_func (void *xevent, switch (msg->message) { +#if ENABLE_THEME_CHANGING + /* catch theme changes */ case WM_THEMECHANGED: - case WM_SYSCOLORCHANGE: - xp_theme_exit(); - wimp_init (); - gtk_rc_reparse_all_for_settings (gtk_settings_get_default(), TRUE); - return GDK_FILTER_REMOVE; - default: - return GDK_FILTER_CONTINUE; - } + case WM_SYSCOLORCHANGE: + xp_theme_exit(); + wimp_init (); + + /* force all gtkwidgets to redraw */ + gtk_rc_reparse_all_for_settings (gtk_settings_get_default(), TRUE); + return GDK_FILTER_REMOVE; +#endif + + case WM_SETTINGCHANGE: + setup_system_settings (); /* catch cursor blink, etc... changes */ + return GDK_FILTER_REMOVE; + + default: + return GDK_FILTER_CONTINUE; + } } G_MODULE_EXPORT void @@ -64,7 +80,7 @@ theme_init (GTypeModule *module) G_MODULE_EXPORT void theme_exit (void) { - gdk_window_remove_filter (NULL, global_filter_func, NULL); + gdk_window_remove_filter (NULL, global_filter_func, NULL); } G_MODULE_EXPORT GtkRcStyle * @@ -85,4 +101,3 @@ g_module_check_init (GModule *module) GTK_MINOR_VERSION, GTK_MICRO_VERSION - GTK_INTERFACE_AGE); } - diff --git a/modules/engines/ms-windows/xp_theme.c b/modules/engines/ms-windows/xp_theme.c index 44166d1d2..190a429b5 100755 --- a/modules/engines/ms-windows/xp_theme.c +++ b/modules/engines/ms-windows/xp_theme.c @@ -29,6 +29,11 @@ #include +/* MS defines this when it includes its schema definitions */ +#ifndef TMSCHEMA_H +#include "xp_theme_dfns.h" +#endif + static const LPCWSTR class_descriptors[] = { L"Scrollbar", @@ -112,7 +117,7 @@ static DrawThemeBackgroundFunc draw_theme_background_func = NULL; static EnableThemeDialogTextureFunc enable_theme_dialog_texture_func = NULL; void -xp_theme_init() +xp_theme_init(void) { if (uxtheme_dll) return; @@ -128,7 +133,7 @@ xp_theme_init() } void -xp_theme_exit() +xp_theme_exit(void) { int i; diff --git a/modules/engines/ms-windows/xp_theme.h b/modules/engines/ms-windows/xp_theme.h index 900621ec4..e877e075d 100755 --- a/modules/engines/ms-windows/xp_theme.h +++ b/modules/engines/ms-windows/xp_theme.h @@ -85,8 +85,8 @@ typedef enum XP_THEME_ELEMENT__SIZEOF } XpThemeElement; -void xp_theme_init(); -void xp_theme_exit(); +void xp_theme_init(void); +void xp_theme_exit(void); gboolean xp_theme_draw(GdkWindow *win, XpThemeElement element, GtkStyle *style, int x, int y, int width, int height, GtkStateType state_type, GdkRectangle *area); diff --git a/modules/engines/ms-windows/xp_theme_dfns.h b/modules/engines/ms-windows/xp_theme_dfns.h new file mode 100644 index 000000000..de449cbed --- /dev/null +++ b/modules/engines/ms-windows/xp_theme_dfns.h @@ -0,0 +1,152 @@ +/* Wimp "Windows Impersonator" Engine + * + * Copyright (C) 2003 Dom Lachowicz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +/* + * These are the real values of these UXTHEME constants, provided so that we can + * compile/link on Win32 platforms that aren't WinXP, and also build against + * MinGW 1.0/1.1, which also doesn't have these things defined in its header files + */ + +#ifndef XP_THEME_DFNS_H +#define XP_THEME_DFNS_H + +#define BP_PUSHBUTTON 1 +#define BP_CHECKBOX 3 + +#define HP_HEADERITEM 1 + +#define CP_DROPDOWNBUTTON 1 + +#define TABP_TABITEM 1 +#define TABP_TABITEMLEFTEDGE 2 +#define TABP_PANE 9 +#define TABP_BODY 10 + +#define SBP_ARROWBTN 1 +#define SBP_THUMBBTNHORZ 2 +#define SBP_THUMBBTNVERT 3 +#define SBP_LOWERTRACKHORZ 5 +#define SBP_LOWERTRACKVERT 6 +#define SBP_GRIPPERHORZ 8 +#define SBP_GRIPPERVERT 9 + +#define EP_EDITTEXT 1 + +#define SPNP_UP 1 +#define SPNP_DOWN 2 + +#define BP_RADIOBUTTON 2 + +#define TVP_GLYPH 2 + +#define PP_BAR 1 +#define PP_BARVERT 2 +#define PP_CHUNK 3 +#define PP_CHUNKVERT 4 + +#define TTP_STANDARD 1 + +#define RP_GRIPPER 1 +#define RP_GRIPPERVERT 2 +#define RP_BAND 3 +#define RP_CHEVRON 4 + +#define TP_BUTTON 1 + +#define TTSS_NORMAL 1 + +#define CHEVS_NORMAL 1 +#define CHEVS_HOT 2 +#define CHEVS_PRESSED 3 + +#define TIS_NORMAL 1 +#define TIS_HOT 2 +#define TIS_SELECTED 3 +#define TIS_DISABLED 4 + +#define ETS_NORMAL 1 +#define ETS_FOCUSED 5 +#define ETS_READONLY 6 + +#define SCRBS_NORMAL 1 +#define SCRBS_HOT 2 +#define SCRBS_PRESSED 3 +#define SCRBS_DISABLED 4 + +#define ABS_UPNORMAL 1 +#define ABS_UPHOT 2 +#define ABS_UPPRESSED 3 +#define ABS_UPDISABLED 4 +#define ABS_DOWNNORMAL 5 +#define ABS_DOWNHOT 6 +#define ABS_DOWNDISABLED 8 +#define ABS_LEFTNORMAL 9 +#define ABS_LEFTHOT 10 +#define ABS_LEFTPRESSED 11 +#define ABS_LEFTDISABLED 12 +#define ABS_RIGHTNORMAL 13 +#define ABS_RIGHTHOT 14 +#define ABS_RIGHTPRESSED 15 +#define ABS_RIGHTDISABLED 16 + +#define CBS_UNCHECKEDNORMAL 1 +#define CBS_UNCHECKEDHOT 2 +#define CBS_UNCHECKEDPRESSED 3 +#define CBS_UNCHECKEDDISABLED 4 +#define CBS_CHECKEDNORMAL 5 +#define CBS_CHECKEDHOT 6 +#define CBS_CHECKEDPRESSED 7 +#define CBS_CHECKEDDISABLED 8 + +#define PBS_NORMAL 1 +#define PBS_HOT 2 +#define PBS_PRESSED 3 +#define PBS_DISABLED 4 +#define PBS_DEFAULTED 5 + +#define DNS_NORMAL 1 +#define DNS_HOT 2 +#define DNS_PRESSED 3 +#define DNS_DISABLED 4 + +#define UPS_NORMAL 1 +#define UPS_HOT 2 +#define UPS_PRESSED 3 +#define UPS_DISABLED 4 + +#define GLPS_OPENED 1 +#define GLPS_CLOSED 2 + +#if UXTHEME_HAS_LINES + +#error unknown/undocumented uxtheme values + +/* #define GP_LINEHORZ */ +/* #define GP_LINEVERT */ +/* #define LHS_RAISED */ +/* #define LHS_SUNKEN */ +/* #define LHS_FLAT */ +/* #define LVS_RAISED */ +/* #define LVS_SUNKEN */ +/* #define LHS_FLAT */ + +#endif /* UXTHEME_HAS_LINES */ + +#endif /* XP_THEME_DFNS_H */