1 /* MS-Windows Engine (aka GTK-Wimp)
3 * Copyright (C) 2003, 2004 Raymond Penners <raymond@dotsphinx.com>
4 * Copyright (C) 2006 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
5 * Includes code adapted from redmond95 by Owen Taylor, and
6 * gtk-nativewin by Evan Martin
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
27 * http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsNativeThemeWin.cpp
28 * http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsLookAndFeel.cpp
29 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/functions/drawthemebackground.asp
30 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4b3g.asp
33 /* Include first, else we get redefinition warnings about STRICT */
34 #include "pango/pangowin32.h"
36 #include "msw_style.h"
46 #ifndef GTK_COMPILATION
47 #define GTK_COMPILATION
49 #include "gtk/gtkmenushellprivate.h"
51 #ifdef BUILDING_STANDALONE
52 #include "gdk/gdkwin32.h"
54 #include "gdk/win32/gdkwin32.h"
58 /* Default values, not normally used
60 static const GtkRequisition default_option_indicator_size = { 9, 8 };
61 static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
63 static GtkStyleClass *parent_class;
64 static HBRUSH g_dither_brush = NULL;
66 static HPEN g_light_pen = NULL;
67 static HPEN g_dark_pen = NULL;
89 static const unsigned char check_aa_bits[] = {
90 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
95 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
96 0x00, 0x00, 0x00, 0x00
98 static const unsigned char check_base_bits[] = {
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
101 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
102 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
103 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
104 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105 0x00, 0x00, 0x00, 0x00
107 static const unsigned char check_black_bits[] = {
108 0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00,
109 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
110 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
111 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
112 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
113 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00
116 static const unsigned char check_dark_bits[] = {
117 0xff, 0x1f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
118 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
119 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
120 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
121 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
122 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
123 0x01, 0x00, 0x00, 0x00
125 static const unsigned char check_light_bits[] = {
126 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
127 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
128 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
129 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
130 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
131 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
132 0xfe, 0x1f, 0x00, 0x00
134 static const unsigned char check_mid_bits[] = {
135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
136 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
137 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
138 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
139 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
140 0x00, 0x08, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00,
141 0x00, 0x00, 0x00, 0x00
143 static const unsigned char check_text_bits[] = {
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
146 0x00, 0x03, 0x00, 0x00, 0x88, 0x03, 0x00, 0x00,
147 0xd8, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00,
148 0x70, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
150 0x00, 0x00, 0x00, 0x00
152 static const unsigned char check_inconsistent_bits[] = {
153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
156 0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00,
157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
159 0x00, 0x00, 0x00, 0x00
161 static const unsigned char radio_base_bits[] = {
162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
163 0xf0, 0x01, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00,
164 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
165 0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00,
166 0xfc, 0x07, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00,
167 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
168 0x00, 0x00, 0x00, 0x00
170 static const unsigned char radio_black_bits[] = {
171 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
172 0x0c, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
173 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
174 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
175 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00
179 static const unsigned char radio_dark_bits[] = {
180 0xf0, 0x01, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00,
181 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
182 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
183 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
184 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
185 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
186 0x00, 0x00, 0x00, 0x00
188 static const unsigned char radio_light_bits[] = {
189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
190 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
191 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
192 0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
193 0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
194 0x00, 0x08, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00,
195 0xf0, 0x01, 0x00, 0x00
197 static const unsigned char radio_mid_bits[] = {
198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
200 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
201 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
202 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00,
203 0x0c, 0x06, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x00
206 static const unsigned char radio_text_bits[] = {
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
210 0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00,
211 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x00, 0x00, 0x00
218 const unsigned char *bits;
219 cairo_surface_t *bmap;
221 { check_aa_bits, NULL },
222 { check_base_bits, NULL },
223 { check_black_bits, NULL },
224 { check_dark_bits, NULL },
225 { check_light_bits, NULL },
226 { check_mid_bits, NULL },
227 { check_text_bits, NULL },
228 { check_inconsistent_bits, NULL },
229 { radio_base_bits, NULL },
230 { radio_black_bits, NULL },
231 { radio_dark_bits, NULL },
232 { radio_light_bits, NULL },
233 { radio_mid_bits, NULL },
234 { radio_text_bits, NULL }
238 _cairo_draw_line (cairo_t *cr,
247 gdk_cairo_set_source_color (cr, color);
248 cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
249 cairo_set_line_width (cr, 1.0);
251 cairo_move_to (cr, x1 + 0.5, y1 + 0.5);
252 cairo_line_to (cr, x2 + 0.5, y2 + 0.5);
259 _cairo_draw_rectangle (cairo_t *cr,
267 gdk_cairo_set_source_color (cr, color);
271 cairo_rectangle (cr, x, y, width, height);
276 cairo_rectangle (cr, x + 0.5, y + 0.5, width, height);
282 get_system_font (XpThemeClass klazz, XpThemeFont type, LOGFONTW *out_lf)
284 if (xp_theme_get_system_font (klazz, type, out_lf))
290 /* Use wide char versions here, as the theming functions only support
291 * wide chars versions of the structures. */
292 NONCLIENTMETRICSW ncm;
294 ncm.cbSize = sizeof (NONCLIENTMETRICSW);
296 if (SystemParametersInfoW (SPI_GETNONCLIENTMETRICS,
297 sizeof (NONCLIENTMETRICSW), &ncm, 0))
299 if (type == XP_THEME_FONT_CAPTION)
300 *out_lf = ncm.lfCaptionFont;
301 else if (type == XP_THEME_FONT_MENU)
302 *out_lf = ncm.lfMenuFont;
303 else if (type == XP_THEME_FONT_STATUS)
304 *out_lf = ncm.lfStatusFont;
306 *out_lf = ncm.lfMessageFont;
316 sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char *buf,
321 if (get_system_font (klazz, type, &lf))
323 PangoFontDescription *desc = NULL;
327 desc = pango_win32_font_description_from_logfontw (&lf);
331 font = pango_font_description_to_string (desc);
332 pt_size = pango_font_description_get_size (desc);
334 if (!(font && *font))
336 pango_font_description_free (desc);
345 hwnd = GetDesktopWindow ();
349 pt_size = -MulDiv (lf.lfHeight, 72, GetDeviceCaps (hDC, LOGPIXELSY));
354 ReleaseDC (hwnd, hDC);
356 g_snprintf (buf, bufsiz, "%s %d", font, pt_size);
360 g_snprintf (buf, bufsiz, "%s", font);
364 pango_font_description_free (desc);
372 /* missing from ms's header files */
373 #ifndef SPI_GETMENUSHOWDELAY
374 #define SPI_GETMENUSHOWDELAY 106
377 /* I don't know the proper XP theme class for things like
378 HIGHLIGHTTEXT, so we'll just define it to be "BUTTON"
380 #define XP_THEME_CLASS_TEXT XP_THEME_CLASS_BUTTON
382 #define WIN95_VERSION 0x400
383 #define WIN2K_VERSION 0x500
384 #define WINXP_VERSION 0x501
385 #define WIN2K3_VERSION 0x502
386 #define VISTA_VERSION 0x600
389 get_windows_version ()
391 static gint32 version = 0;
392 static gboolean have_version = FALSE;
396 OSVERSIONINFOEX osvi;
399 ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX));
400 osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
402 GetVersionEx((OSVERSIONINFO*) &osvi);
404 version = (osvi.dwMajorVersion & 0xff) << 8 | (osvi.dwMinorVersion & 0xff);
411 setup_menu_settings (GtkSettings *settings)
414 GObjectClass *klazz = G_OBJECT_GET_CLASS (G_OBJECT (settings));
416 if (get_windows_version () > WIN95_VERSION)
418 if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0))
422 if (g_object_class_find_property
423 (klazz, "gtk-menu-bar-popup-delay"))
425 g_object_set (settings,
426 "gtk-menu-bar-popup-delay", 0, NULL);
428 if (g_object_class_find_property
429 (klazz, "gtk-menu-popup-delay"))
431 g_object_set (settings,
432 "gtk-menu-popup-delay", menu_delay, NULL);
434 if (g_object_class_find_property
435 (klazz, "gtk-menu-popdown-delay"))
437 g_object_set (settings,
438 "gtk-menu-popdown-delay", menu_delay, NULL);
446 msw_style_setup_system_settings (void)
448 GtkSettings *settings;
449 int cursor_blink_time;
451 settings = gtk_settings_get_default ();
455 cursor_blink_time = GetCaretBlinkTime ();
456 g_object_set (settings, "gtk-cursor-blink", cursor_blink_time > 0, NULL);
458 if (cursor_blink_time > 0)
460 g_object_set (settings, "gtk-cursor-blink-time",
461 2 * cursor_blink_time, NULL);
464 g_object_set (settings, "gtk-double-click-distance",
465 GetSystemMetrics (SM_CXDOUBLECLK), NULL);
466 g_object_set (settings, "gtk-double-click-time", GetDoubleClickTime (),
468 g_object_set (settings, "gtk-dnd-drag-threshold",
469 GetSystemMetrics (SM_CXDRAG), NULL);
471 setup_menu_settings (settings);
474 http://library.gnome.org/devel/gtk/stable/GtkSettings.html
475 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp
476 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp */
480 setup_system_font (GtkStyle *style)
482 char buf[256], *font; /* It's okay, lfFaceName is smaller than 32
485 if ((font = sys_font_to_pango_font (XP_THEME_CLASS_TEXT,
486 XP_THEME_FONT_MESSAGE,
487 buf, sizeof (buf))) != NULL)
489 if (style->font_desc)
491 pango_font_description_free (style->font_desc);
494 style->font_desc = pango_font_description_from_string (font);
499 sys_color_to_gtk_color (XpThemeClass klazz, int id, GdkColor * pcolor)
503 if (!xp_theme_get_system_color (klazz, id, &color))
504 color = GetSysColor (id);
506 pcolor->pixel = color;
507 pcolor->red = (GetRValue (color) << 8) | GetRValue (color);
508 pcolor->green = (GetGValue (color) << 8) | GetGValue (color);
509 pcolor->blue = (GetBValue (color) << 8) | GetBValue (color);
513 get_system_metric (XpThemeClass klazz, int id)
517 if (!xp_theme_get_system_metric (klazz, id, &rval))
518 rval = GetSystemMetrics (id);
524 setup_msw_rc_style (void)
526 char buf[1024], font_buf[256], *font_ptr;
527 char menu_bar_prelight_str[128];
530 GdkColor menu_text_color;
531 GdkColor tooltip_back;
532 GdkColor tooltip_fore;
535 GdkColor progress_back;
537 GdkColor fg_prelight;
538 GdkColor bg_prelight;
539 GdkColor base_prelight;
540 GdkColor text_prelight;
543 sys_color_to_gtk_color (get_windows_version () >= VISTA_VERSION ? XP_THEME_CLASS_MENU : XP_THEME_CLASS_TEXT,
544 get_windows_version () >= VISTA_VERSION ? COLOR_MENUTEXT : COLOR_HIGHLIGHTTEXT,
546 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &bg_prelight);
547 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
549 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
552 sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENUTEXT,
554 sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENU, &menu_color);
557 sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOTEXT,
559 sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOBK,
562 /* text on push buttons. TODO: button shadows, backgrounds, and
564 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btn_fore);
565 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &btn_face);
567 /* progress bar background color */
568 sys_color_to_gtk_color (XP_THEME_CLASS_PROGRESS, COLOR_HIGHLIGHT,
571 /* Enable coloring for menus. */
573 sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU,
574 font_buf, sizeof (font_buf));
575 g_snprintf (buf, sizeof (buf),
576 "style \"msw-menu\" = \"msw-default\"\n" "{\n"
577 "GtkMenuItem::toggle-spacing = 8\n"
578 "fg[PRELIGHT] = { %d, %d, %d }\n"
579 "bg[PRELIGHT] = { %d, %d, %d }\n"
580 "text[PRELIGHT] = { %d, %d, %d }\n"
581 "base[PRELIGHT] = { %d, %d, %d }\n"
582 "fg[NORMAL] = { %d, %d, %d }\n"
583 "bg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n"
584 "}widget_class \"*MenuItem*\" style \"msw-menu\"\n"
585 "widget_class \"*GtkMenu\" style \"msw-menu\"\n"
586 "widget_class \"*GtkMenuShell*\" style \"msw-menu\"\n",
587 fg_prelight.red, fg_prelight.green, fg_prelight.blue,
588 bg_prelight.red, bg_prelight.green, bg_prelight.blue,
589 text_prelight.red, text_prelight.green, text_prelight.blue,
590 base_prelight.red, base_prelight.green, base_prelight.blue,
591 menu_text_color.red, menu_text_color.green,
592 menu_text_color.blue, menu_color.red, menu_color.green,
593 menu_color.blue, (font_ptr ? "font_name" : "#"),
594 (font_ptr ? font_ptr : " font name should go here"));
595 gtk_rc_parse_string (buf);
597 if (xp_theme_is_active ())
599 *menu_bar_prelight_str = '\0';
603 g_snprintf (menu_bar_prelight_str, sizeof (menu_bar_prelight_str),
604 "fg[PRELIGHT] = { %d, %d, %d }\n",
605 menu_text_color.red, menu_text_color.green,
606 menu_text_color.blue);
609 /* Enable coloring for menu bars. */
610 g_snprintf (buf, sizeof (buf),
611 "style \"msw-menu-bar\" = \"msw-menu\"\n"
613 "bg[NORMAL] = { %d, %d, %d }\n"
614 "%s" "GtkMenuBar::shadow-type = %d\n"
616 FIXME: This should be enabled once gtk+ support
617 GtkMenuBar::prelight-item style property.
619 /* "GtkMenuBar::prelight-item = 1\n" */
620 "}widget_class \"*MenuBar*\" style \"msw-menu-bar\"\n",
621 btn_face.red, btn_face.green, btn_face.blue,
622 menu_bar_prelight_str, xp_theme_is_active ()? 0 : 2);
623 gtk_rc_parse_string (buf);
625 g_snprintf (buf, sizeof (buf),
626 "style \"msw-toolbar\" = \"msw-default\"\n"
628 "GtkHandleBox::shadow-type = %s\n"
629 "GtkToolbar::shadow-type = %s\n"
630 "}widget_class \"*HandleBox*\" style \"msw-toolbar\"\n",
631 "etched-in", "etched-in");
632 gtk_rc_parse_string (buf);
634 /* enable tooltip fonts */
635 font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,
636 font_buf, sizeof (font_buf));
637 g_snprintf (buf, sizeof (buf),
638 "style \"msw-tooltips-caption\" = \"msw-default\"\n"
639 "{fg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n"
640 "}widget \"gtk-tooltips.GtkLabel\" style \"msw-tooltips-caption\"\n"
641 "widget \"gtk-tooltip.GtkLabel\" style \"msw-tooltips-caption\"\n",
642 tooltip_fore.red, tooltip_fore.green, tooltip_fore.blue,
643 (font_ptr ? "font_name" : "#"),
644 (font_ptr ? font_ptr : " font name should go here"));
645 gtk_rc_parse_string (buf);
647 g_snprintf (buf, sizeof (buf),
648 "style \"msw-tooltips\" = \"msw-default\"\n"
649 "{bg[NORMAL] = { %d, %d, %d }\n"
650 "}widget \"gtk-tooltips*\" style \"msw-tooltips\"\n"
651 "widget \"gtk-tooltip*\" style \"msw-tooltips\"\n",
652 tooltip_back.red, tooltip_back.green, tooltip_back.blue);
653 gtk_rc_parse_string (buf);
655 /* enable font theming for status bars */
656 font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,
657 font_buf, sizeof (font_buf));
658 g_snprintf (buf, sizeof (buf),
659 "style \"msw-status\" = \"msw-default\"\n" "{%s = \"%s\"\n"
660 "bg[NORMAL] = { %d, %d, %d }\n"
661 "}widget_class \"*Status*\" style \"msw-status\"\n",
662 (font_ptr ? "font_name" : "#"),
663 (font_ptr ? font_ptr : " font name should go here"),
664 btn_face.red, btn_face.green, btn_face.blue);
665 gtk_rc_parse_string (buf);
667 /* enable coloring for text on buttons
668 * TODO: use GetThemeMetric for the border and outside border
669 * TODO: child-displacement-x & y should be 0 when XP theme is active */
670 g_snprintf (buf, sizeof (buf),
671 "style \"msw-button\" = \"msw-default\"\n"
673 "bg[NORMAL] = { %d, %d, %d }\n"
674 "bg[PRELIGHT] = { %d, %d, %d }\n"
675 "bg[INSENSITIVE] = { %d, %d, %d }\n"
676 "fg[PRELIGHT] = { %d, %d, %d }\n"
677 "GtkButton::default-border = { 0, 0, 0, 0 }\n"
678 "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n"
679 "GtkButton::child-displacement-x = 1\n"
680 "GtkButton::child-displacement-y = 1\n"
681 "GtkButton::focus-padding = %d\n"
682 "}widget_class \"*Button*\" style \"msw-button\"\n",
683 btn_face.red, btn_face.green, btn_face.blue,
684 btn_face.red, btn_face.green, btn_face.blue,
685 btn_face.red, btn_face.green, btn_face.blue,
686 btn_fore.red, btn_fore.green, btn_fore.blue,
687 xp_theme_is_active ()? 1 : 2);
688 gtk_rc_parse_string (buf);
690 /* enable coloring for progress bars */
691 g_snprintf (buf, sizeof (buf),
692 "style \"msw-progress\" = \"msw-default\"\n"
693 "{bg[PRELIGHT] = { %d, %d, %d }\n"
694 "bg[NORMAL] = { %d, %d, %d }\n"
695 "}widget_class \"*Progress*\" style \"msw-progress\"\n",
699 btn_face.red, btn_face.green, btn_face.blue);
700 gtk_rc_parse_string (buf);
702 /* scrollbar thumb width and height */
703 g_snprintf (buf, sizeof (buf),
704 "style \"msw-vscrollbar\" = \"msw-default\"\n"
705 "{GtkRange::slider-width = %d\n"
706 "GtkRange::stepper-size = %d\n"
707 "GtkRange::stepper-spacing = 0\n"
708 "GtkRange::trough_border = 0\n"
709 "GtkScale::slider-length = %d\n"
710 "GtkScrollbar::min-slider-length = 8\n"
711 "}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n"
712 "widget_class \"*VScale*\" style \"msw-vscrollbar\"\n",
713 GetSystemMetrics (SM_CYVTHUMB),
714 get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL), 11);
715 gtk_rc_parse_string (buf);
717 g_snprintf (buf, sizeof (buf),
718 "style \"msw-hscrollbar\" = \"msw-default\"\n"
719 "{GtkRange::slider-width = %d\n"
720 "GtkRange::stepper-size = %d\n"
721 "GtkRange::stepper-spacing = 0\n"
722 "GtkRange::trough_border = 0\n"
723 "GtkScale::slider-length = %d\n"
724 "GtkScrollbar::min-slider-length = 8\n"
725 "}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n"
726 "widget_class \"*HScale*\" style \"msw-hscrollbar\"\n",
727 GetSystemMetrics (SM_CXHTHUMB),
728 get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL), 11);
729 gtk_rc_parse_string (buf);
731 gtk_rc_parse_string ("style \"msw-scrolled-window\" = \"msw-default\"\n"
732 "{GtkScrolledWindow::scrollbars-within-bevel = 1}\n"
733 "class \"GtkScrolledWindow\" style \"msw-scrolled-window\"\n");
735 /* radio/check button sizes */
736 g_snprintf (buf, sizeof (buf),
737 "style \"msw-checkbutton\" = \"msw-button\"\n"
738 "{GtkCheckButton::indicator-size = 13\n"
739 "}widget_class \"*CheckButton*\" style \"msw-checkbutton\"\n"
740 "widget_class \"*RadioButton*\" style \"msw-checkbutton\"\n");
741 gtk_rc_parse_string (buf);
743 /* size of combo box toggle button */
744 g_snprintf (buf, sizeof (buf),
745 "style \"msw-combobox-button\" = \"msw-default\"\n"
749 "GtkButton::default-border = { 0, 0, 0, 0 }\n"
750 "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n"
751 "GtkButton::child-displacement-x = 0\n"
752 "GtkButton::child-displacement-y = 0\n"
753 "GtkWidget::focus-padding = 0\n"
754 "GtkWidget::focus-line-width = 0\n"
756 "widget_class \"*ComboBox*ToggleButton*\" style \"msw-combobox-button\"\n");
757 gtk_rc_parse_string (buf);
759 g_snprintf (buf, sizeof (buf),
760 "style \"msw-combobox\" = \"msw-default\"\n"
762 "GtkComboBox::shadow-type = in\n"
766 "class \"GtkComboBox\" style \"msw-combobox\"\n",
767 xp_theme_is_active()? 1 : GetSystemMetrics (SM_CXEDGE),
768 xp_theme_is_active()? 1 : GetSystemMetrics (SM_CYEDGE));
769 gtk_rc_parse_string (buf);
771 /* size of tree view header */
772 g_snprintf (buf, sizeof (buf),
773 "style \"msw-header-button\" = \"msw-default\"\n"
777 "GtkWidget::draw-border = {0, 0, 0, 0}\n"
778 "GtkButton::default-border = { 0, 0, 0, 0 }\n"
779 "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n"
780 "GtkButton::child-displacement-x = 0\n"
781 "GtkButton::child-displacement-y = 0\n"
782 "GtkWidget::focus-padding = 0\n"
783 "GtkWidget::focus-line-width = 0\n"
785 "widget_class \"*TreeView*Button*\" style \"msw-header-button\"\n");
786 gtk_rc_parse_string (buf);
788 /* FIXME: This should be enabled once gtk+ support GtkNotebok::prelight-tab */
789 /* enable prelight tab of GtkNotebook */
791 g_snprintf (buf, sizeof (buf),
792 "style \"msw-notebook\" = \"msw-default\"\n"
793 "{GtkNotebook::prelight-tab=1\n"
794 "}widget_class \"*Notebook*\" style \"msw-notebook\"\n");
795 gtk_rc_parse_string (buf);
798 /* FIXME: This should be enabled once gtk+ support GtkTreeView::full-row-focus */
800 g_snprintf (buf, sizeof (buf),
801 "style \"msw-treeview\" = \"msw-default\"\n"
802 "{GtkTreeView::full-row-focus=0\n"
803 "}widget_class \"*TreeView*\" style \"msw-treeview\"\n");
804 gtk_rc_parse_string (buf);
809 setup_system_styles (GtkStyle *style)
813 /* Default background */
814 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
815 &style->bg[GTK_STATE_NORMAL]);
816 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
817 &style->bg[GTK_STATE_SELECTED]);
818 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
819 &style->bg[GTK_STATE_INSENSITIVE]);
820 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
821 &style->bg[GTK_STATE_ACTIVE]);
822 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
823 &style->bg[GTK_STATE_PRELIGHT]);
826 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOW,
827 &style->base[GTK_STATE_NORMAL]);
828 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
829 &style->base[GTK_STATE_SELECTED]);
830 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
831 &style->base[GTK_STATE_INSENSITIVE]);
832 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
833 &style->base[GTK_STATE_ACTIVE]);
834 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOW,
835 &style->base[GTK_STATE_PRELIGHT]);
838 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
839 &style->text[GTK_STATE_NORMAL]);
840 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
841 &style->text[GTK_STATE_SELECTED]);
842 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_GRAYTEXT,
843 &style->text[GTK_STATE_INSENSITIVE]);
844 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
845 &style->text[GTK_STATE_ACTIVE]);
846 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
847 &style->text[GTK_STATE_PRELIGHT]);
849 /* Default foreground */
850 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
851 &style->fg[GTK_STATE_NORMAL]);
852 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
853 &style->fg[GTK_STATE_SELECTED]);
854 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_GRAYTEXT,
855 &style->fg[GTK_STATE_INSENSITIVE]);
856 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
857 &style->fg[GTK_STATE_ACTIVE]);
858 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
859 &style->fg[GTK_STATE_PRELIGHT]);
861 for (i = 0; i < 5; i++)
863 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW,
865 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT,
868 style->mid[i].red = (style->light[i].red + style->dark[i].red) / 2;
869 style->mid[i].green =
870 (style->light[i].green + style->dark[i].green) / 2;
871 style->mid[i].blue = (style->light[i].blue + style->dark[i].blue) / 2;
873 style->text_aa[i].red = (style->text[i].red + style->base[i].red) / 2;
874 style->text_aa[i].green =
875 (style->text[i].green + style->base[i].green) / 2;
876 style->text_aa[i].blue =
877 (style->text[i].blue + style->base[i].blue) / 2;
881 static XpThemeElement
882 map_gtk_progress_bar_to_xp (GtkProgressBar *progress_bar, gboolean trough)
886 switch (gtk_orientable_get_orientation (GTK_ORIENTABLE (progress_bar)))
888 case GTK_ORIENTATION_HORIZONTAL:
890 ? XP_THEME_ELEMENT_PROGRESS_TROUGH_H
891 : XP_THEME_ELEMENT_PROGRESS_BAR_H;
896 ? XP_THEME_ELEMENT_PROGRESS_TROUGH_V
897 : XP_THEME_ELEMENT_PROGRESS_BAR_V;
905 is_combo_box_child (GtkWidget *w)
912 for (tmp = gtk_widget_get_parent (w); tmp; tmp = gtk_widget_get_parent (tmp))
914 if (GTK_IS_COMBO_BOX (tmp))
921 /* This function is not needed anymore */
923 combo_box_draw_arrow (GtkStyle *style,
928 if (xp_theme_is_active ())
931 if (widget && GTK_IS_TOGGLE_BUTTON (widget->parent))
938 dc = get_window_dc (style, cr, state, &dc_info, area->x, area->y, area->width,
939 area->height, &rect);
940 border = (GTK_TOGGLE_BUTTON (gtk_widget_get_parent (widget))->
941 active ? DFCS_PUSHED | DFCS_FLAT : 0);
943 InflateRect (&rect, 1, 1);
944 DrawFrameControl (dc, &rect, DFC_SCROLL, DFCS_SCROLLDOWN | border);
946 release_window_dc (&dc_info);
955 draw_part (cairo_t *cr,
956 GdkColor *gc, gint x, gint y, Part part)
958 if (!parts[part].bmap)
960 parts[part].bmap = cairo_image_surface_create_for_data ((unsigned char *)parts[part].bits,
962 PART_SIZE, PART_SIZE, 4);
965 gdk_cairo_set_source_color (cr, gc);
966 cairo_mask_surface (cr, parts[part].bmap, x, y);
970 draw_check (GtkStyle *style,
973 GtkShadowType shadow,
975 const gchar *detail, gint x, gint y, gint width, gint height)
977 x -= (1 + PART_SIZE - width) / 2;
978 y -= (1 + PART_SIZE - height) / 2;
980 if (detail && strcmp (detail, "check") == 0) /* Menu item */
982 if (shadow == GTK_SHADOW_IN)
984 draw_part (cr, &style->black, x, y, CHECK_TEXT);
985 draw_part (cr, &style->dark[state], x, y, CHECK_AA);
990 XpThemeElement theme_elt = XP_THEME_ELEMENT_CHECKBOX;
993 case GTK_SHADOW_ETCHED_IN:
994 theme_elt = XP_THEME_ELEMENT_INCONSISTENT_CHECKBOX;
998 theme_elt = XP_THEME_ELEMENT_PRESSED_CHECKBOX;
1005 if (!xp_theme_draw (cr, theme_elt,
1006 style, x, y, width, height, state))
1008 if (detail && !strcmp (detail, "cellcheck"))
1009 state = GTK_STATE_NORMAL;
1011 draw_part (cr, &style->black, x, y, CHECK_BLACK);
1012 draw_part (cr, &style->dark[state], x, y, CHECK_DARK);
1013 draw_part (cr, &style->mid[state], x, y, CHECK_MID);
1014 draw_part (cr, &style->light[state], x, y, CHECK_LIGHT);
1015 draw_part (cr, &style->base[state], x, y, CHECK_BASE);
1017 if (shadow == GTK_SHADOW_IN)
1019 draw_part (cr, &style->text[state], x, y, CHECK_TEXT);
1020 draw_part (cr, &style->text_aa[state], x, y, CHECK_AA);
1022 else if (shadow == GTK_SHADOW_ETCHED_IN)
1024 draw_part (cr, &style->text[state], x, y, CHECK_INCONSISTENT);
1025 draw_part (cr, &style->text_aa[state], x, y, CHECK_AA);
1032 draw_expander (GtkStyle *style,
1036 const gchar *detail,
1037 gint x, gint y, GtkExpanderStyle expander_style)
1040 gint expander_semi_size;
1041 XpThemeElement xp_expander;
1043 gtk_widget_style_get (widget, "expander_size", &expander_size, NULL);
1045 switch (expander_style)
1047 case GTK_EXPANDER_COLLAPSED:
1048 case GTK_EXPANDER_SEMI_COLLAPSED:
1049 xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED;
1053 xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED;
1057 if ((expander_size % 2) == 0)
1060 if (expander_size > 2)
1064 gdk_cairo_set_source_color (cr, &style->fg[state]);
1067 expander_semi_size = expander_size / 2;
1068 x -= expander_semi_size;
1069 y -= expander_semi_size;
1071 if (!xp_theme_draw (cr, xp_expander, style,
1072 x, y, expander_size, expander_size, state))
1080 dc = get_window_dc (style, cr, state, &dc_info, x, y, expander_size,
1081 expander_size, &rect);
1082 FrameRect (dc, &rect, GetSysColorBrush (COLOR_GRAYTEXT));
1083 InflateRect (&rect, -1, -1);
1084 FillRect (dc, &rect,
1085 GetSysColorBrush (state ==
1086 GTK_STATE_INSENSITIVE ? COLOR_BTNFACE :
1089 InflateRect (&rect, -1, -1);
1091 pen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT));
1092 old_pen = SelectObject (dc, pen);
1094 MoveToEx (dc, rect.left, rect.top - 2 + expander_semi_size, NULL);
1095 LineTo (dc, rect.right, rect.top - 2 + expander_semi_size);
1097 if (expander_style == GTK_EXPANDER_COLLAPSED ||
1098 expander_style == GTK_EXPANDER_SEMI_COLLAPSED)
1100 MoveToEx (dc, rect.left - 2 + expander_semi_size, rect.top, NULL);
1101 LineTo (dc, rect.left - 2 + expander_semi_size, rect.bottom);
1104 SelectObject (dc, old_pen);
1106 release_window_dc (&dc_info);
1111 draw_option (GtkStyle *style,
1114 GtkShadowType shadow,
1116 const gchar *detail, gint x, gint y, gint width, gint height)
1118 x -= (1 + PART_SIZE - width) / 2;
1119 y -= (1 + PART_SIZE - height) / 2;
1121 if (detail && strcmp (detail, "option") == 0) /* Menu item */
1123 if (shadow == GTK_SHADOW_IN)
1125 draw_part (cr, &style->fg[state], x, y, RADIO_TEXT);
1130 if (xp_theme_draw (cr, shadow == GTK_SHADOW_IN
1131 ? XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON
1132 : XP_THEME_ELEMENT_RADIO_BUTTON,
1133 style, x, y, width, height, state))
1138 if (detail && !strcmp (detail, "cellradio"))
1139 state = GTK_STATE_NORMAL;
1141 draw_part (cr, &style->black, x, y, RADIO_BLACK);
1142 draw_part (cr, &style->dark[state], x, y, RADIO_DARK);
1143 draw_part (cr, &style->mid[state], x, y, RADIO_MID);
1144 draw_part (cr, &style->light[state], x, y, RADIO_LIGHT);
1145 draw_part (cr, &style->base[state], x, y, RADIO_BASE);
1147 if (shadow == GTK_SHADOW_IN)
1148 draw_part (cr, &style->text[state], x, y, RADIO_TEXT);
1154 draw_varrow (cairo_t *cr,
1156 GtkShadowType shadow_type,
1157 GtkArrowType arrow_type, gint x, gint y, gint width, gint height)
1160 gint y_start, y_increment;
1163 width = width + width % 2 - 1; /* Force odd */
1164 steps = 1 + width / 2;
1165 extra = height - steps;
1167 if (arrow_type == GTK_ARROW_DOWN)
1174 y_start = y + height - 1;
1178 for (i = extra; i < height; i++)
1180 _cairo_draw_line (cr, gc,
1181 x + (i - extra), y_start + i * y_increment,
1182 x + width - (i - extra) - 1, y_start + i * y_increment);
1187 draw_harrow (cairo_t *cr,
1189 GtkShadowType shadow_type,
1190 GtkArrowType arrow_type, gint x, gint y, gint width, gint height)
1193 gint x_start, x_increment;
1196 height = height + height % 2 - 1; /* Force odd */
1197 steps = 1 + height / 2;
1198 extra = width - steps;
1200 if (arrow_type == GTK_ARROW_RIGHT)
1207 x_start = x + width - 1;
1211 for (i = extra; i < width; i++)
1213 _cairo_draw_line (cr, gc,
1214 x_start + i * x_increment, y + (i - extra),
1215 x_start + i * x_increment, y + height - (i - extra) - 1);
1219 /* This function makes up for some brokeness in gtkrange.c
1220 * where we never get the full arrow of the stepper button
1221 * and the type of button in a single drawing function.
1223 * It doesn't work correctly when the scrollbar is squished
1224 * to the point we don't have room for full-sized steppers.
1227 reverse_engineer_stepper_box (GtkWidget *range,
1228 GtkArrowType arrow_type,
1229 gint *x, gint *y, gint *width, gint *height)
1231 gint slider_width = 14, stepper_size = 14;
1237 gtk_widget_style_get (range,
1238 "slider_width", &slider_width,
1239 "stepper_size", &stepper_size, NULL);
1242 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
1244 box_width = slider_width;
1245 box_height = stepper_size;
1249 box_width = stepper_size;
1250 box_height = slider_width;
1253 *x = *x - (box_width - *width) / 2;
1254 *y = *y - (box_height - *height) / 2;
1256 *height = box_height;
1259 static XpThemeElement
1260 to_xp_arrow (GtkArrowType arrow_type)
1262 XpThemeElement xp_arrow;
1267 xp_arrow = XP_THEME_ELEMENT_ARROW_UP;
1270 case GTK_ARROW_DOWN:
1271 xp_arrow = XP_THEME_ELEMENT_ARROW_DOWN;
1274 case GTK_ARROW_LEFT:
1275 xp_arrow = XP_THEME_ELEMENT_ARROW_LEFT;
1279 xp_arrow = XP_THEME_ELEMENT_ARROW_RIGHT;
1287 draw_arrow (GtkStyle *style,
1290 GtkShadowType shadow,
1292 const gchar *detail,
1293 GtkArrowType arrow_type,
1294 gboolean fill, gint x, gint y, gint width, gint height)
1301 name = gtk_widget_get_name (widget);
1303 if (GTK_IS_ARROW (widget) && is_combo_box_child (widget) && xp_theme_is_active ())
1306 if (detail && strcmp (detail, "spinbutton") == 0)
1308 if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP))
1315 if (arrow_type == GTK_ARROW_DOWN)
1319 if (state == GTK_STATE_ACTIVE)
1325 draw_varrow (cr, &style->fg[state], shadow,
1326 arrow_type, x, y, width, height);
1330 else if (detail && (!strcmp (detail, "vscrollbar")
1331 || !strcmp (detail, "hscrollbar")))
1333 gboolean is_disabled = FALSE;
1335 GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget);
1339 gint box_width = width;
1340 gint box_height = height;
1342 reverse_engineer_stepper_box (widget, arrow_type,
1343 &box_x, &box_y, &box_width, &box_height);
1345 if (gtk_adjustment_get_page_size(gtk_range_get_adjustment(&scrollbar->range)) >=
1346 (gtk_adjustment_get_upper(gtk_range_get_adjustment(&scrollbar->range)) -
1347 gtk_adjustment_get_lower(gtk_range_get_adjustment(&scrollbar->range))))
1352 if (xp_theme_draw (cr, to_xp_arrow (arrow_type), style, box_x, box_y,
1353 box_width, box_height, state))
1361 btn_type = DFCS_SCROLLUP;
1364 case GTK_ARROW_DOWN:
1365 btn_type = DFCS_SCROLLDOWN;
1368 case GTK_ARROW_LEFT:
1369 btn_type = DFCS_SCROLLLEFT;
1372 case GTK_ARROW_RIGHT:
1373 btn_type = DFCS_SCROLLRIGHT;
1376 case GTK_ARROW_NONE:
1380 if (state == GTK_STATE_INSENSITIVE)
1382 btn_type |= DFCS_INACTIVE;
1387 dc = get_window_dc (style, cr, state, &dc_info,
1388 box_x, box_y, box_width, box_height, &rect);
1389 DrawFrameControl (dc, &rect, DFC_SCROLL,
1390 btn_type | (shadow ==
1391 GTK_SHADOW_IN ? (DFCS_PUSHED |
1393 release_window_dc (&dc_info);
1399 /* draw the toolbar chevrons - waiting for GTK 2.4 */
1400 if (name && !strcmp (name, "gtk-toolbar-arrow"))
1403 (cr, XP_THEME_ELEMENT_REBAR_CHEVRON, style, x, y,
1404 width, height, state))
1409 /* probably a gtk combo box on a toolbar */
1410 else if (0 /* gtk_widget_get_parent (widget) && GTK_IS_BUTTON
1411 (gtk_widget_get_parent (widget)) */ )
1413 GtkAllocation allocation;
1415 gtk_widget_get_allocation (widget, &allocation);
1417 (cr, XP_THEME_ELEMENT_COMBOBUTTON, style, x - 3,
1418 allocation.y + 1, width + 5,
1419 allocation.height - 4, state))
1425 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
1427 x += (width - 7) / 2;
1428 y += (height - 5) / 2;
1430 draw_varrow (cr, &style->fg[state], shadow,
1431 arrow_type, x, y, 7, 5);
1435 x += (width - 5) / 2;
1436 y += (height - 7) / 2;
1438 draw_harrow (cr, &style->fg[state], shadow,
1439 arrow_type, x, y, 5, 7);
1445 option_menu_get_props (GtkWidget *widget,
1446 GtkRequisition *indicator_size,
1447 GtkBorder *indicator_spacing)
1449 GtkRequisition *tmp_size = NULL;
1450 GtkBorder *tmp_spacing = NULL;
1453 gtk_widget_style_get (widget,
1454 "indicator_size", &tmp_size,
1455 "indicator_spacing", &tmp_spacing, NULL);
1459 *indicator_size = *tmp_size;
1460 gtk_requisition_free (tmp_size);
1464 *indicator_size = default_option_indicator_size;
1469 *indicator_spacing = *tmp_spacing;
1470 gtk_border_free (tmp_spacing);
1474 *indicator_spacing = default_option_indicator_spacing;
1479 is_toolbar_child (GtkWidget *wid)
1483 if (GTK_IS_TOOLBAR (wid) || GTK_IS_HANDLE_BOX (wid))
1486 wid = gtk_widget_get_parent (wid);
1493 is_menu_tool_button_child (GtkWidget *wid)
1497 if (GTK_IS_MENU_TOOL_BUTTON (wid))
1500 wid = gtk_widget_get_parent (wid);
1510 g_light_pen = CreatePen (PS_SOLID | PS_INSIDEFRAME, 1,
1511 GetSysColor (COLOR_BTNHIGHLIGHT));
1522 g_dark_pen = CreatePen (PS_SOLID | PS_INSIDEFRAME, 1,
1523 GetSysColor (COLOR_BTNSHADOW));
1530 draw_3d_border (HDC hdc, RECT *rc, gboolean sunken)
1537 pen1 = get_dark_pen ();
1538 pen2 = get_light_pen ();
1542 pen1 = get_light_pen ();
1543 pen2 = get_dark_pen ();
1546 MoveToEx (hdc, rc->left, rc->bottom - 1, NULL);
1548 old_pen = SelectObject (hdc, pen1);
1549 LineTo (hdc, rc->left, rc->top);
1550 LineTo (hdc, rc->right - 1, rc->top);
1551 SelectObject (hdc, old_pen);
1553 old_pen = SelectObject (hdc, pen2);
1554 LineTo (hdc, rc->right - 1, rc->bottom - 1);
1555 LineTo (hdc, rc->left, rc->bottom - 1);
1556 SelectObject (hdc, old_pen);
1560 draw_menu_item (cairo_t *cr, GtkWidget *widget, GtkStyle *style,
1561 gint x, gint y, gint width, gint height,
1562 GtkStateType state_type)
1570 if (xp_theme_is_active ())
1572 return (xp_theme_draw (cr, XP_THEME_ELEMENT_MENU_ITEM, style,
1573 x, y, width, height, state_type));
1576 if ((parent = gtk_widget_get_parent (widget))
1577 && GTK_IS_MENU_BAR (parent) && !xp_theme_is_active ())
1579 bar = GTK_MENU_SHELL (parent);
1581 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1583 if (state_type == GTK_STATE_PRELIGHT)
1585 draw_3d_border (dc, &rect, bar->priv->active);
1588 release_window_dc (&dc_info);
1597 get_dither_brush (void)
1600 HBITMAP pattern_bmp;
1604 return g_dither_brush;
1606 for (i = 0; i < 8; i++)
1608 pattern[i] = (WORD) (0x5555 << (i & 1));
1611 pattern_bmp = CreateBitmap (8, 8, 1, 1, &pattern);
1615 g_dither_brush = CreatePatternBrush (pattern_bmp);
1616 DeleteObject (pattern_bmp);
1619 return g_dither_brush;
1623 draw_tool_button (cairo_t *cr, GtkWidget *widget, GtkStyle *style,
1624 gint x, gint y, gint width, gint height,
1625 GtkStateType state_type)
1630 gboolean is_toggled = FALSE;
1632 if (xp_theme_is_active ())
1634 return (xp_theme_draw (cr, XP_THEME_ELEMENT_TOOLBAR_BUTTON, style,
1635 x, y, width, height, state_type));
1638 if (GTK_IS_TOGGLE_BUTTON (widget))
1640 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
1646 if (state_type != GTK_STATE_PRELIGHT
1647 && state_type != GTK_STATE_ACTIVE && !is_toggled)
1652 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1653 if (state_type == GTK_STATE_PRELIGHT)
1657 FillRect (dc, &rect, GetSysColorBrush (COLOR_BTNFACE));
1660 draw_3d_border (dc, &rect, is_toggled);
1662 else if (state_type == GTK_STATE_ACTIVE)
1664 if (is_toggled && !is_menu_tool_button_child (gtk_widget_get_parent (widget)))
1666 SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT));
1667 SetBkColor (dc, GetSysColor (COLOR_BTNFACE));
1668 FillRect (dc, &rect, get_dither_brush ());
1671 draw_3d_border (dc, &rect, TRUE);
1674 release_window_dc (&dc_info);
1680 draw_push_button (cairo_t *cr, GtkWidget *widget, GtkStyle *style,
1681 gint x, gint y, gint width, gint height,
1682 GtkStateType state_type, gboolean is_default)
1688 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1690 if (GTK_IS_TOGGLE_BUTTON (widget))
1692 if (state_type == GTK_STATE_PRELIGHT &&
1693 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
1695 state_type = GTK_STATE_ACTIVE;
1699 if (state_type == GTK_STATE_ACTIVE)
1701 if (GTK_IS_TOGGLE_BUTTON (widget))
1703 DrawEdge (dc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
1704 SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT));
1705 SetBkColor (dc, GetSysColor (COLOR_BTNFACE));
1706 FillRect (dc, &rect, get_dither_brush ());
1710 FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME));
1711 InflateRect (&rect, -1, -1);
1712 FrameRect (dc, &rect, GetSysColorBrush (COLOR_BTNSHADOW));
1713 InflateRect (&rect, -1, -1);
1714 FillRect (dc, &rect, GetSysColorBrush (COLOR_BTNFACE));
1719 if (is_default || gtk_widget_has_focus (widget))
1721 FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME));
1722 InflateRect (&rect, -1, -1);
1725 DrawFrameControl (dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH);
1728 release_window_dc (&dc_info);
1732 draw_box (GtkStyle *style,
1734 GtkStateType state_type,
1735 GtkShadowType shadow_type,
1737 const gchar *detail, gint x, gint y, gint width, gint height)
1739 if (is_combo_box_child (widget) && detail && !strcmp (detail, "button"))
1747 border = (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? DFCS_PUSHED | DFCS_FLAT : 0);
1749 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1750 DrawFrameControl (dc, &rect, DFC_SCROLL, DFCS_SCROLLDOWN | border);
1751 release_window_dc (&dc_info);
1753 if (xp_theme_is_active ()
1754 && xp_theme_draw (cr, XP_THEME_ELEMENT_COMBOBUTTON, style, x, y,
1755 width, height, state_type))
1757 cx = GetSystemMetrics(SM_CXVSCROLL);
1762 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width - cx, height, &rect);
1763 FillRect (dc, &rect, GetSysColorBrush (COLOR_WINDOW));
1764 release_window_dc (&dc_info);
1770 (!strcmp (detail, "button") || !strcmp (detail, "buttondefault")))
1772 if (GTK_IS_TREE_VIEW (gtk_widget_get_parent (widget)))
1775 (cr, XP_THEME_ELEMENT_LIST_HEADER, style, x, y,
1776 width, height, state_type))
1785 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1787 DrawFrameControl (dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH |
1789 GTK_STATE_ACTIVE ? (DFCS_PUSHED | DFCS_FLAT)
1791 release_window_dc (&dc_info);
1794 else if (is_toolbar_child (gtk_widget_get_parent (widget))
1795 || (!GTK_IS_BUTTON (widget) ||
1796 (GTK_RELIEF_NONE == gtk_button_get_relief (GTK_BUTTON (widget)))))
1798 if (draw_tool_button (cr, widget, style, x, y,
1799 width, height, state_type))
1806 gboolean is_default = gtk_widget_has_default (widget);
1809 is_default ? XP_THEME_ELEMENT_DEFAULT_BUTTON :
1810 XP_THEME_ELEMENT_BUTTON, style, x, y, width, height,
1816 draw_push_button (cr, widget, style,
1817 x, y, width, height, state_type, is_default);
1824 else if (detail && !strcmp (detail, "spinbutton"))
1826 if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP))
1831 else if (detail && (!strcmp (detail, "spinbutton_up")
1832 || !strcmp (detail, "spinbutton_down")))
1834 if (!xp_theme_draw (cr,
1835 (!strcmp (detail, "spinbutton_up"))
1836 ? XP_THEME_ELEMENT_SPIN_BUTTON_UP
1837 : XP_THEME_ELEMENT_SPIN_BUTTON_DOWN,
1838 style, x, y, width, height, state_type))
1844 dc = get_window_dc (style, cr, state_type, &dc_info,
1845 x, y, width, height, &rect);
1846 DrawEdge (dc, &rect,
1848 GTK_STATE_ACTIVE ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT);
1849 release_window_dc (&dc_info);
1853 else if (detail && !strcmp (detail, "slider"))
1855 if (GTK_IS_SCROLLBAR (widget))
1857 GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget);
1858 gboolean is_v = GTK_IS_VSCROLLBAR (widget);
1860 if (xp_theme_draw (cr,
1862 ? XP_THEME_ELEMENT_SCROLLBAR_V
1863 : XP_THEME_ELEMENT_SCROLLBAR_H,
1864 style, x, y, width, height, state_type))
1866 XpThemeElement gripper =
1867 (is_v ? XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V :
1868 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H);
1870 /* Do not display grippers on tiny scroll bars,
1871 the limit imposed is rather arbitrary, perhaps
1872 we can fetch the gripper geometry from
1873 somewhere and use that... */
1875 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H
1878 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V && height < 16))
1883 xp_theme_draw (cr, gripper, style, x, y,
1884 width, height, state_type);
1889 if (gtk_adjustment_get_page_size(gtk_range_get_adjustment(&scrollbar->range)) >=
1890 (gtk_adjustment_get_page_size(gtk_range_get_adjustment(&scrollbar->range)) -
1891 gtk_adjustment_get_page_size(gtk_range_get_adjustment(&scrollbar->range))))
1898 else if (detail && !strcmp (detail, "bar"))
1900 if (widget && GTK_IS_PROGRESS_BAR (widget))
1902 GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget);
1903 XpThemeElement xp_progress_bar =
1904 map_gtk_progress_bar_to_xp (progress_bar, FALSE);
1906 if (xp_theme_draw (cr, xp_progress_bar, style, x, y,
1907 width, height, state_type))
1912 shadow_type = GTK_SHADOW_NONE;
1915 else if (detail && strcmp (detail, "menuitem") == 0)
1917 shadow_type = GTK_SHADOW_NONE;
1918 if (draw_menu_item (cr, widget, style,
1919 x, y, width, height, state_type))
1924 else if (detail && !strcmp (detail, "trough"))
1926 if (widget && GTK_IS_PROGRESS_BAR (widget))
1928 GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget);
1929 XpThemeElement xp_progress_bar =
1930 map_gtk_progress_bar_to_xp (progress_bar, TRUE);
1932 (cr, xp_progress_bar, style, x, y, width, height,
1939 /* Blank in classic Windows */
1942 else if (widget && GTK_IS_SCROLLBAR (widget))
1944 gboolean is_vertical = GTK_IS_VSCROLLBAR (widget);
1946 if (xp_theme_draw (cr,
1948 ? XP_THEME_ELEMENT_TROUGH_V
1949 : XP_THEME_ELEMENT_TROUGH_H,
1950 style, x, y, width, height, state_type))
1960 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
1962 SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT));
1963 SetBkColor (dc, GetSysColor (COLOR_BTNFACE));
1964 FillRect (dc, &rect, get_dither_brush ());
1966 release_window_dc (&dc_info);
1971 else if (widget && GTK_IS_SCALE (widget))
1973 gboolean is_vertical = GTK_IS_VSCALE (widget);
1975 if (!xp_theme_is_active ())
1977 parent_class->draw_box (style, cr, state_type,
1979 widget, detail, x, y, width, height);
1985 (cr, XP_THEME_ELEMENT_SCALE_TROUGH_V,
1986 style, (2 * x + width) / 2, y, 2, height,
1992 parent_class->draw_box (style, cr, state_type,
1993 GTK_SHADOW_ETCHED_IN,
1995 (2 * x + width) / 2, y, 1, height);
2000 (cr, XP_THEME_ELEMENT_SCALE_TROUGH_H,
2001 style, x, (2 * y + height) / 2, width, 2,
2007 parent_class->draw_box (style, cr, state_type,
2008 GTK_SHADOW_ETCHED_IN,
2010 (2 * y + height) / 2, width, 1);
2016 else if (detail && strcmp (detail, "optionmenu") == 0)
2018 if (xp_theme_draw (cr, XP_THEME_ELEMENT_EDIT_TEXT,
2019 style, x, y, width, height, state_type))
2025 && (strcmp (detail, "vscrollbar") == 0
2026 || strcmp (detail, "hscrollbar") == 0))
2031 && (strcmp (detail, "handlebox_bin") == 0
2032 || strcmp (detail, "toolbar") == 0
2033 || strcmp (detail, "menubar") == 0))
2035 if (xp_theme_draw (cr, XP_THEME_ELEMENT_REBAR,
2036 style, x, y, width, height, state_type))
2041 else if (detail && (!strcmp (detail, "handlebox"))) /* grip */
2043 if (!xp_theme_is_active ())
2048 else if (detail && !strcmp (detail, "notebook") && GTK_IS_NOTEBOOK (widget))
2050 if (xp_theme_draw (cr, XP_THEME_ELEMENT_TAB_PANE, style,
2051 x, y, width, height, state_type))
2059 const gchar *name = gtk_widget_get_name (widget);
2061 if (name && !strcmp (name, "gtk-tooltips"))
2064 (cr, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width,
2065 height, state_type))
2076 hdc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
2078 brush = GetSysColorBrush (COLOR_3DDKSHADOW);
2082 FrameRect (hdc, &rect, brush);
2085 InflateRect (&rect, -1, -1);
2086 FillRect (hdc, &rect, (HBRUSH) (COLOR_INFOBK + 1));
2088 release_window_dc (&dc_info);
2095 parent_class->draw_box (style, cr, state_type, shadow_type,
2096 widget, detail, x, y, width, height);
2098 if (detail && strcmp (detail, "optionmenu") == 0)
2100 GtkRequisition indicator_size;
2101 GtkBorder indicator_spacing;
2104 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2106 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
2109 x + indicator_size.width + indicator_spacing.left +
2110 indicator_spacing.right;
2114 vline_x = x + width - (indicator_size.width +
2115 indicator_spacing.left +
2116 indicator_spacing.right) - style->xthickness;
2118 parent_class->draw_vline (style, cr, state_type, widget,
2120 y + style->ythickness + 1,
2121 y + height - style->ythickness - 3, vline_x);
2127 draw_tab (GtkStyle *style,
2130 GtkShadowType shadow,
2132 const gchar *detail, gint x, gint y, gint width, gint height)
2134 GtkRequisition indicator_size;
2135 GtkBorder indicator_spacing;
2139 g_return_if_fail (style != NULL);
2140 g_return_if_fail (cr != NULL);
2142 if (detail && !strcmp (detail, "optionmenutab"))
2144 GtkAllocation allocation;
2146 gtk_widget_get_allocation (widget, &allocation);
2147 if (xp_theme_draw (cr, XP_THEME_ELEMENT_COMBOBUTTON,
2148 style, x - 5, allocation.y + 1,
2149 width + 10, allocation.height - 2,
2156 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
2158 x += (width - indicator_size.width) / 2;
2159 arrow_height = (indicator_size.width + 1) / 2;
2161 y += (height - arrow_height) / 2;
2163 draw_varrow (cr, &style->black, shadow, GTK_ARROW_DOWN,
2164 x, y, indicator_size.width, arrow_height);
2167 /* Draw classic Windows tab - thanks Mozilla!
2168 (no system API for this, but DrawEdge can draw all the parts of a tab) */
2170 DrawTab (HDC hdc, const RECT R, gint32 aPosition, gboolean aSelected,
2171 gboolean aDrawLeft, gboolean aDrawRight)
2173 gint32 leftFlag, topFlag, rightFlag, lightFlag, shadeFlag;
2174 RECT topRect, sideRect, bottomRect, lightRect, shadeRect;
2175 gint32 selectedOffset, lOffset, rOffset;
2177 selectedOffset = aSelected ? 1 : 0;
2178 lOffset = aDrawLeft ? 2 : 0;
2179 rOffset = aDrawRight ? 2 : 0;
2181 /* Get info for tab orientation/position (Left, Top, Right, Bottom) */
2187 rightFlag = BF_BOTTOM;
2188 lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
2189 shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
2191 SetRect (&topRect, R.left, R.top + lOffset, R.right,
2192 R.bottom - rOffset);
2193 SetRect (&sideRect, R.left + 2, R.top, R.right - 2 + selectedOffset,
2195 SetRect (&bottomRect, R.right - 2, R.top, R.right, R.bottom);
2196 SetRect (&lightRect, R.left, R.top, R.left + 3, R.top + 3);
2197 SetRect (&shadeRect, R.left + 1, R.bottom - 2, R.left + 2,
2204 rightFlag = BF_RIGHT;
2205 lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
2206 shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
2208 SetRect (&topRect, R.left + lOffset, R.top, R.right - rOffset,
2210 SetRect (&sideRect, R.left, R.top + 2, R.right,
2211 R.bottom - 1 + selectedOffset);
2212 SetRect (&bottomRect, R.left, R.bottom - 1, R.right, R.bottom);
2213 SetRect (&lightRect, R.left, R.top, R.left + 3, R.top + 3);
2214 SetRect (&shadeRect, R.right - 2, R.top + 1, R.right - 1, R.top + 2);
2220 rightFlag = BF_BOTTOM;
2221 lightFlag = BF_DIAGONAL_ENDTOPLEFT;
2222 shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
2224 SetRect (&topRect, R.left, R.top + lOffset, R.right,
2225 R.bottom - rOffset);
2226 SetRect (&sideRect, R.left + 2 - selectedOffset, R.top, R.right - 2,
2228 SetRect (&bottomRect, R.left, R.top, R.left + 2, R.bottom);
2229 SetRect (&lightRect, R.right - 3, R.top, R.right - 1, R.top + 2);
2230 SetRect (&shadeRect, R.right - 2, R.bottom - 3, R.right, R.bottom - 1);
2235 topFlag = BF_BOTTOM;
2236 rightFlag = BF_RIGHT;
2237 lightFlag = BF_DIAGONAL_ENDTOPLEFT;
2238 shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
2240 SetRect (&topRect, R.left + lOffset, R.top, R.right - rOffset,
2242 SetRect (&sideRect, R.left, R.top + 2 - selectedOffset, R.right,
2244 SetRect (&bottomRect, R.left, R.top, R.right, R.top + 2);
2245 SetRect (&lightRect, R.left, R.bottom - 3, R.left + 2, R.bottom - 1);
2246 SetRect (&shadeRect, R.right - 2, R.bottom - 3, R.right, R.bottom - 1);
2250 g_return_if_reached ();
2254 FillRect (hdc, &R, (HBRUSH) (COLOR_3DFACE + 1));
2257 DrawEdge (hdc, &topRect, EDGE_RAISED, BF_SOFT | topFlag);
2261 DrawEdge (hdc, &bottomRect, EDGE_RAISED, BF_SOFT | topFlag);
2269 DrawEdge (hdc, &sideRect, EDGE_RAISED, BF_SOFT | leftFlag | rightFlag);
2271 /* Tab Diagonal Corners */
2273 DrawEdge (hdc, &lightRect, EDGE_RAISED, BF_SOFT | lightFlag);
2276 DrawEdge (hdc, &shadeRect, EDGE_RAISED, BF_SOFT | shadeFlag);
2280 draw_themed_tab_button (GtkStyle *style,
2282 GtkStateType state_type,
2283 GtkNotebook *notebook,
2285 gint width, gint height, gint gap_side)
2288 GdkPixmap *pixmap = NULL;
2291 gtk_container_get_border_width (GTK_CONTAINER (notebook));
2292 GtkWidget *widget = GTK_WIDGET (notebook);
2293 GdkRectangle draw_rect;
2294 GdkPixbufRotation rotation = GDK_PIXBUF_ROTATE_NONE;
2295 GtkAllocation allocation;
2297 gtk_widget_get_allocation (widget, &allocation);
2299 if (gap_side == GTK_POS_TOP)
2303 if (state_type == GTK_STATE_NORMAL)
2307 draw_rect.width = width + 2;
2308 draw_rect.height = height;
2316 draw_rect.x = x + 2;
2318 draw_rect.width = width - 2;
2319 draw_rect.height = height - 2;
2322 /* If we are currently drawing the right-most tab, and if that tab is the selected tab... */
2323 widget_right = allocation.x + allocation.width - border_width - 2;
2325 if (draw_rect.x + draw_rect.width >= widget_right)
2327 draw_rect.width = widget_right - draw_rect.x;
2330 if (gap_side == GTK_POS_BOTTOM)
2334 if (state_type == GTK_STATE_NORMAL)
2338 draw_rect.width = width + 2;
2339 draw_rect.height = height;
2343 draw_rect.x = x + 2;
2344 draw_rect.y = y + 2;
2345 draw_rect.width = width - 2;
2346 draw_rect.height = height - 2;
2349 /* If we are currently drawing the right-most tab, and if that tab is the selected tab... */
2350 widget_right = allocation.x + allocation.width - border_width - 2;
2352 if (draw_rect.x + draw_rect.width >= widget_right)
2354 draw_rect.width = widget_right - draw_rect.x;
2357 rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
2359 else if (gap_side == GTK_POS_LEFT)
2363 if (state_type == GTK_STATE_NORMAL)
2367 draw_rect.width = width;
2368 draw_rect.height = height + 2;
2377 draw_rect.y = y + 2;
2378 draw_rect.width = width - 2;
2379 draw_rect.height = height - 2;
2382 /* If we are currently drawing the bottom-most tab, and if that tab is the selected tab... */
2383 widget_bottom = allocation.x + allocation.height - border_width - 2;
2385 if (draw_rect.y + draw_rect.height >= widget_bottom)
2387 draw_rect.height = widget_bottom - draw_rect.y;
2390 rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
2392 else if (gap_side == GTK_POS_RIGHT)
2396 if (state_type == GTK_STATE_NORMAL)
2398 draw_rect.x = x + 1;
2400 draw_rect.width = width;
2401 draw_rect.height = height + 2;
2409 draw_rect.x = x + 2;
2410 draw_rect.y = y + 2;
2411 draw_rect.width = width - 2;
2412 draw_rect.height = height - 2;
2415 /* If we are currently drawing the bottom-most tab, and if that tab is the selected tab... */
2416 widget_bottom = allocation.x + allocation.height - border_width - 2;
2418 if (draw_rect.y + draw_rect.height >= widget_bottom)
2420 draw_rect.height = widget_bottom - draw_rect.y;
2423 rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
2426 if (gap_side == GTK_POS_TOP)
2428 if (!xp_theme_draw (cr, XP_THEME_ELEMENT_TAB_ITEM, style,
2429 draw_rect.x, draw_rect.y,
2430 draw_rect.width, draw_rect.height,
2443 if (gap_side == GTK_POS_LEFT || gap_side == GTK_POS_RIGHT)
2445 pixmap = gdk_pixmap_new (cr, draw_rect.height, draw_rect.width, -1);
2447 if (!xp_theme_draw (pixmap, XP_THEME_ELEMENT_TAB_ITEM, style,
2449 draw_rect.y - draw_rect.y, draw_rect.x - draw_rect.x,
2450 draw_rect.height, draw_rect.width, state_type, 0))
2452 g_object_unref (pixmap);
2456 pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL, 0, 0, 0, 0,
2457 draw_rect.height, draw_rect.width);
2458 g_object_unref (pixmap);
2462 pixmap = gdk_pixmap_new (cr, draw_rect.width, draw_rect.height, -1);
2464 if (!xp_theme_draw (pixmap, XP_THEME_ELEMENT_TAB_ITEM, style,
2466 draw_rect.x - draw_rect.x, draw_rect.y - draw_rect.y,
2467 draw_rect.width, draw_rect.height, state_type, 0))
2469 g_object_unref (pixmap);
2473 pixbuf = gdk_pixbuf_get_from_drawable (NULL, pixmap, NULL, 0, 0, 0, 0,
2474 draw_rect.width, draw_rect.height);
2475 g_object_unref (pixmap);
2478 rotated = gdk_pixbuf_rotate_simple (pixbuf, rotation);
2479 g_object_unref (pixbuf);
2482 // XXX - This is really hacky and evil. When we're drawing the left-most tab
2483 // while it is active on a bottom-oriented notebook, there is one white
2484 // pixel at the top. There may be a better solution than this if someone
2485 // has time to discover it.
2486 if (gap_side == GTK_POS_BOTTOM && state_type == GTK_STATE_NORMAL
2487 && x == allocation.x)
2489 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
2490 int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
2493 guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
2494 guchar *p = pixels + rowstride;
2496 for (psub = 0; psub < n_channels; psub++)
2498 pixels[psub] = p[psub];
2502 gdk_cairo_set_source_pixbuf (cr, pixbuf, clip_rect.x, clip_rect.y);
2504 g_object_unref (pixbuf);
2512 draw_tab_button (GtkStyle *style,
2514 GtkStateType state_type,
2515 GtkShadowType shadow_type,
2517 const gchar *detail,
2518 gint x, gint y, gint width, gint height, gint gap_side)
2520 if (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM)
2522 /* experimental tab-drawing code from mozilla */
2528 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
2530 if (gap_side == GTK_POS_TOP)
2532 else if (gap_side == GTK_POS_BOTTOM)
2533 aPosition = BF_BOTTOM;
2534 else if (gap_side == GTK_POS_LEFT)
2535 aPosition = BF_LEFT;
2537 aPosition = BF_RIGHT;
2539 if (state_type == GTK_STATE_PRELIGHT)
2540 state_type = GTK_STATE_NORMAL;
2543 gdk_cairo_set_source_color (cr, &style->dark[state_type]);
2546 DrawTab (dc, rect, aPosition,
2547 state_type != GTK_STATE_PRELIGHT,
2548 (gap_side != GTK_POS_LEFT), (gap_side != GTK_POS_RIGHT));
2550 release_window_dc (&dc_info);
2559 draw_extension (GtkStyle *style,
2561 GtkStateType state_type,
2562 GtkShadowType shadow_type,
2564 const gchar *detail,
2566 gint width, gint height, GtkPositionType gap_side)
2568 if (widget && GTK_IS_NOTEBOOK (widget) && detail && !strcmp (detail, "tab"))
2570 GtkNotebook *notebook = GTK_NOTEBOOK (widget);
2572 /* Why this differs from gap_side, I have no idea.. */
2573 int real_gap_side = gtk_notebook_get_tab_pos (notebook);
2575 if (!draw_themed_tab_button (style, cr, state_type,
2576 GTK_NOTEBOOK (widget), x, y,
2577 width, height, real_gap_side))
2579 if (!draw_tab_button (style, cr, state_type,
2580 shadow_type, widget,
2581 detail, x, y, width, height, real_gap_side))
2583 parent_class->draw_extension (style, cr, state_type,
2584 shadow_type, widget, detail,
2585 x, y, width, height,
2593 draw_box_gap (GtkStyle *style, cairo_t *cr, GtkStateType state_type,
2594 GtkShadowType shadow_type,
2595 GtkWidget *widget, const gchar *detail, gint x,
2596 gint y, gint width, gint height, GtkPositionType gap_side,
2597 gint gap_x, gint gap_width)
2599 if (GTK_IS_NOTEBOOK (widget) && detail && !strcmp (detail, "notebook"))
2601 GtkNotebook *notebook = GTK_NOTEBOOK (widget);
2602 int side = gtk_notebook_get_tab_pos (notebook);
2603 int x2 = x, y2 = y, w2 = width, h2 = height;
2605 if (side == GTK_POS_TOP)
2608 y2 = y - gtk_notebook_get_tab_vborder (notebook);
2610 h2 = height + gtk_notebook_get_tab_vborder (notebook) * 2;
2612 else if (side == GTK_POS_BOTTOM)
2617 h2 = height + gtk_notebook_get_tab_vborder (notebook) * 2;
2619 else if (side == GTK_POS_LEFT)
2621 x2 = x - gtk_notebook_get_tab_hborder (notebook);
2623 w2 = width + gtk_notebook_get_tab_hborder (notebook);
2626 else if (side == GTK_POS_RIGHT)
2630 w2 = width + gtk_notebook_get_tab_hborder (notebook) * 2;
2634 if (xp_theme_draw (cr, XP_THEME_ELEMENT_TAB_PANE, style,
2635 x2, y2, w2, h2, state_type))
2641 parent_class->draw_box_gap (style, cr, state_type, shadow_type,
2642 widget, detail, x, y, width, height,
2643 gap_side, gap_x, gap_width);
2647 is_popup_window_child (GtkWidget *widget)
2650 GtkWindowType type = -1;
2652 top = gtk_widget_get_toplevel (widget);
2654 if (top && GTK_IS_WINDOW (top))
2656 g_object_get (top, "type", &type, NULL);
2658 if (type == GTK_WINDOW_POPUP)
2659 { /* Hack for combo boxes */
2668 draw_flat_box (GtkStyle *style, cairo_t *cr,
2669 GtkStateType state_type, GtkShadowType shadow_type,
2671 const gchar *detail, gint x, gint y, gint width, gint height)
2675 if (state_type == GTK_STATE_SELECTED &&
2676 (!strncmp ("cell_even", detail, 9) || !strncmp ("cell_odd", detail, 8)))
2678 GdkColor *gc = gtk_widget_has_focus (widget) ? &style->base[state_type] : &style->base[GTK_STATE_ACTIVE];
2680 _cairo_draw_rectangle (cr, gc, TRUE, x, y, width, height);
2684 else if (!strcmp (detail, "checkbutton"))
2686 if (state_type == GTK_STATE_PRELIGHT)
2693 parent_class->draw_flat_box (style, cr, state_type, shadow_type,
2694 widget, detail, x, y, width, height);
2698 draw_menu_border (cairo_t *cr, GtkStyle *style,
2699 gint x, gint y, gint width, gint height)
2705 dc = get_window_dc (style, cr, GTK_STATE_NORMAL, &dc_info, x, y, width, height, &rect);
2710 if (xp_theme_is_active ())
2712 FrameRect (dc, &rect, GetSysColorBrush (COLOR_3DSHADOW));
2716 DrawEdge (dc, &rect, EDGE_RAISED, BF_RECT);
2719 release_window_dc (&dc_info);
2725 draw_shadow (GtkStyle *style,
2727 GtkStateType state_type,
2728 GtkShadowType shadow_type,
2730 const gchar *detail, gint x, gint y, gint width, gint height)
2732 gboolean is_handlebox;
2733 gboolean is_toolbar;
2735 if (detail && !strcmp (detail, "frame"))
2744 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
2745 if (is_combo_box_child (widget))
2747 FillRect (dc, &rect, GetSysColorBrush (COLOR_WINDOW));
2749 else if (is_popup_window_child (widget))
2751 FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME));
2755 switch (shadow_type)
2758 draw_3d_border (dc, &rect, TRUE);
2761 case GTK_SHADOW_OUT:
2762 draw_3d_border (dc, &rect, FALSE);
2765 case GTK_SHADOW_ETCHED_IN:
2766 draw_3d_border (dc, &rect, TRUE);
2767 InflateRect (&rect, -1, -1);
2768 draw_3d_border (dc, &rect, FALSE);
2771 case GTK_SHADOW_ETCHED_OUT:
2772 draw_3d_border (dc, &rect, FALSE);
2773 InflateRect (&rect, -1, -1);
2774 draw_3d_border (dc, &rect, TRUE);
2777 case GTK_SHADOW_NONE:
2782 release_window_dc (&dc_info);
2786 if (detail && (!strcmp (detail, "entry") || !strcmp (detail, "combobox")))
2788 if (shadow_type != GTK_SHADOW_IN)
2791 if (!xp_theme_draw (cr, XP_THEME_ELEMENT_EDIT_TEXT, style,
2792 x, y, width, height, state_type))
2798 dc = get_window_dc (style, cr, state_type, &dc_info,
2799 x, y, width, height, &rect);
2801 DrawEdge (dc, &rect, EDGE_SUNKEN, BF_RECT);
2802 release_window_dc (&dc_info);
2808 if (detail && !strcmp (detail, "scrolled_window") &&
2809 xp_theme_draw (cr, XP_THEME_ELEMENT_EDIT_TEXT, style,
2810 x, y, width, height, state_type))
2815 if (detail && !strcmp (detail, "spinbutton"))
2818 if (detail && !strcmp (detail, "menu"))
2820 if (draw_menu_border (cr, style, x, y, width, height))
2826 if (detail && !strcmp (detail, "handlebox"))
2829 is_handlebox = (detail && !strcmp (detail, "handlebox_bin"));
2830 is_toolbar = (detail
2831 && (!strcmp (detail, "toolbar")
2832 || !strcmp (detail, "menubar")));
2834 if (is_toolbar || is_handlebox)
2836 if (shadow_type == GTK_SHADOW_NONE)
2846 HGDIOBJ old_pen = NULL;
2847 GtkPositionType pos;
2851 pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (widget));
2853 If the handle box is at left side,
2854 we shouldn't draw its right border.
2855 The same holds true for top, right, and bottom.
2860 pos = GTK_POS_RIGHT;
2868 pos = GTK_POS_BOTTOM;
2871 case GTK_POS_BOTTOM:
2878 GtkWidget *parent = gtk_widget_get_parent (widget);
2880 /* Dirty hack for toolbars contained in handle boxes */
2881 if (GTK_IS_HANDLE_BOX (parent))
2883 pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (parent));
2889 Make pos != all legal enum vaules of GtkPositionType.
2890 So every border will be draw.
2892 pos = (GtkPositionType) - 1;
2896 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
2898 if (pos != GTK_POS_LEFT)
2900 old_pen = SelectObject (dc, get_light_pen ());
2901 MoveToEx (dc, rect.left, rect.top, NULL);
2902 LineTo (dc, rect.left, rect.bottom);
2904 if (pos != GTK_POS_TOP)
2906 old_pen = SelectObject (dc, get_light_pen ());
2907 MoveToEx (dc, rect.left, rect.top, NULL);
2908 LineTo (dc, rect.right, rect.top);
2910 if (pos != GTK_POS_RIGHT)
2912 old_pen = SelectObject (dc, get_dark_pen ());
2913 MoveToEx (dc, rect.right - 1, rect.top, NULL);
2914 LineTo (dc, rect.right - 1, rect.bottom);
2916 if (pos != GTK_POS_BOTTOM)
2918 old_pen = SelectObject (dc, get_dark_pen ());
2919 MoveToEx (dc, rect.left, rect.bottom - 1, NULL);
2920 LineTo (dc, rect.right, rect.bottom - 1);
2923 SelectObject (dc, old_pen);
2924 release_window_dc (&dc_info);
2930 if (detail && !strcmp (detail, "statusbar"))
2935 parent_class->draw_shadow (style, cr, state_type, shadow_type,
2936 widget, detail, x, y, width, height);
2940 draw_hline (GtkStyle *style,
2942 GtkStateType state_type,
2944 const gchar *detail, gint x1, gint x2, gint y)
2946 if (xp_theme_is_active () && detail && !strcmp (detail, "menuitem"))
2949 gint new_y, new_height;
2952 xp_theme_get_element_dimensions (XP_THEME_ELEMENT_MENU_SEPARATOR,
2956 /* Center the separator */
2957 y_offset = (cy / 2) - 1;
2958 new_y = (y - y_offset) >= 0 ? y - y_offset : y;
2962 (cr, XP_THEME_ELEMENT_MENU_SEPARATOR, style, x1, new_y, x2, new_height,
2969 _cairo_draw_line (cr, &style->dark[state_type], x1, y, x2, y);
2975 if (style->ythickness == 2)
2977 _cairo_draw_line (cr, &style->dark[state_type], x1, y, x2, y);
2979 _cairo_draw_line (cr, &style->light[state_type], x1, y, x2, y);
2984 parent_class->draw_hline (style, cr, state_type, widget,
2991 draw_vline (GtkStyle *style,
2993 GtkStateType state_type,
2995 const gchar *detail, gint y1, gint y2, gint x)
2997 if (style->xthickness == 2)
2999 _cairo_draw_line (cr, &style->dark[state_type], x, y1, x, y2);
3001 _cairo_draw_line (cr, &style->light[state_type], x, y1, x, y2);
3006 parent_class->draw_vline (style, cr, state_type, widget,
3012 draw_slider (GtkStyle *style,
3014 GtkStateType state_type,
3015 GtkShadowType shadow_type,
3017 const gchar *detail,
3019 gint y, gint width, gint height, GtkOrientation orientation)
3021 if (GTK_IS_SCALE (widget) &&
3022 xp_theme_draw (cr, ((orientation == GTK_ORIENTATION_VERTICAL) ?
3023 XP_THEME_ELEMENT_SCALE_SLIDER_V :
3024 XP_THEME_ELEMENT_SCALE_SLIDER_H), style, x, y, width,
3025 height, state_type))
3030 parent_class->draw_slider (style, cr, state_type, shadow_type,
3031 widget, detail, x, y, width, height,
3036 draw_resize_grip (GtkStyle *style,
3038 GtkStateType state_type,
3040 const gchar *detail,
3041 GdkWindowEdge edge, gint x, gint y, gint width, gint height)
3043 if (detail && !strcmp (detail, "statusbar"))
3046 (cr, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width,
3047 height, state_type))
3055 HDC dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
3058 gdk_cairo_set_source_color (cr, &style->dark[state_type]);
3061 DrawFrameControl (dc, &rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
3062 release_window_dc (&dc_info);
3068 parent_class->draw_resize_grip (style, cr, state_type,
3069 widget, detail, edge, x, y, width, height);
3073 draw_handle (GtkStyle *style,
3075 GtkStateType state_type,
3076 GtkShadowType shadow_type,
3078 const gchar *detail,
3080 gint y, gint width, gint height, GtkOrientation orientation)
3086 if (is_toolbar_child (widget))
3088 XpThemeElement hndl;
3090 if (GTK_IS_HANDLE_BOX (widget))
3092 GtkPositionType pos;
3093 pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (widget));
3095 if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM)
3097 orientation = GTK_ORIENTATION_HORIZONTAL;
3101 orientation = GTK_ORIENTATION_VERTICAL;
3105 if (orientation == GTK_ORIENTATION_VERTICAL)
3106 hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V;
3108 hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H;
3110 if (xp_theme_draw (cr, hndl, style, x, y, width, height,
3116 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
3118 if (orientation == GTK_ORIENTATION_VERTICAL)
3121 rect.right = rect.left + 3;
3128 rect.bottom = rect.top + 3;
3133 draw_3d_border (dc, &rect, FALSE);
3134 release_window_dc (&dc_info);
3138 if (!GTK_IS_PANED (widget))
3140 gint xthick, ythick;
3141 GdkColor *light, *dark, *shadow;
3144 gtk_paint_box (style, cr, state_type, shadow_type,
3145 widget, detail, x, y, width, height);
3147 light = &style->light[state_type];
3148 dark = &style->dark[state_type];
3149 shadow = &style->mid[state_type];
3151 xthick = style->xthickness;
3152 ythick = style->ythickness;
3154 dest.x = x + xthick;
3155 dest.y = y + ythick;
3156 dest.width = width - (xthick * 2);
3157 dest.height = height - (ythick * 2);
3159 if (dest.width < dest.height)
3164 if (dest.width < dest.height)
3166 _cairo_draw_line (cr, light, dest.x, dest.y, dest.x,
3168 _cairo_draw_line (cr, dark, dest.x + (dest.width / 2),
3169 dest.y, dest.x + (dest.width / 2), dest.height);
3170 _cairo_draw_line (cr, shadow, dest.x + dest.width,
3171 dest.y, dest.x + dest.width, dest.height);
3175 _cairo_draw_line (cr, light, dest.x, dest.y,
3176 dest.x + dest.width, dest.y);
3177 _cairo_draw_line (cr, dark, dest.x,
3178 dest.y + (dest.height / 2),
3179 dest.x + dest.width, dest.y + (dest.height / 2));
3180 _cairo_draw_line (cr, shadow, dest.x,
3181 dest.y + dest.height, dest.x + dest.width,
3182 dest.y + dest.height);
3188 draw_focus (GtkStyle *style,
3190 GtkStateType state_type,
3192 const gchar *detail, gint x, gint y, gint width, gint height)
3198 if (!gtk_widget_get_can_focus (widget))
3203 if (is_combo_box_child (widget)
3204 && (GTK_IS_ARROW (widget) || GTK_IS_BUTTON (widget)))
3208 if (GTK_IS_TREE_VIEW (gtk_widget_get_parent (widget)) /* list view bheader */)
3213 dc = get_window_dc (style, cr, state_type, &dc_info, x, y, width, height, &rect);
3214 DrawFocusRect (dc, &rect);
3215 release_window_dc (&dc_info);
3217 parent_class->draw_focus (style, cr, state_type,
3218 widget, detail, x, y, width, height);
3223 draw_layout (GtkStyle *style,
3225 GtkStateType state_type,
3228 const gchar *detail,
3229 gint old_x, gint old_y, PangoLayout *layout)
3231 GtkNotebook *notebook = NULL;
3235 /* In the XP theme, labels don't appear correctly centered inside
3236 * notebook tabs, so we give them a gentle nudge two pixels to the
3237 * right. A little hackish, but what are 'ya gonna do? -- Cody
3239 if (xp_theme_is_active () && detail && !strcmp (detail, "label"))
3241 if (gtk_widget_get_parent (widget) != NULL)
3243 if (GTK_IS_NOTEBOOK (gtk_widget_get_parent (widget)))
3246 notebook = GTK_NOTEBOOK (gtk_widget_get_parent (widget));
3247 side = gtk_notebook_get_tab_pos (notebook);
3249 if (side == GTK_POS_TOP || side == GTK_POS_BOTTOM)
3257 parent_class->draw_layout (style, cr, state_type,
3258 use_text, widget, detail, x, y, layout);
3262 msw_style_init_from_rc (GtkStyle *style, GtkRcStyle *rc_style)
3264 setup_system_font (style);
3265 setup_menu_settings (gtk_settings_get_default ());
3266 setup_system_styles (style);
3267 parent_class->init_from_rc (style, rc_style);
3271 msw_style_class_init (MswStyleClass *klass)
3273 GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
3275 parent_class = g_type_class_peek_parent (klass);
3277 style_class->init_from_rc = msw_style_init_from_rc;
3278 style_class->draw_arrow = draw_arrow;
3279 style_class->draw_box = draw_box;
3280 style_class->draw_check = draw_check;
3281 style_class->draw_option = draw_option;
3282 style_class->draw_tab = draw_tab;
3283 style_class->draw_flat_box = draw_flat_box;
3284 style_class->draw_expander = draw_expander;
3285 style_class->draw_extension = draw_extension;
3286 style_class->draw_box_gap = draw_box_gap;
3287 style_class->draw_shadow = draw_shadow;
3288 style_class->draw_hline = draw_hline;
3289 style_class->draw_vline = draw_vline;
3290 style_class->draw_handle = draw_handle;
3291 style_class->draw_resize_grip = draw_resize_grip;
3292 style_class->draw_slider = draw_slider;
3293 style_class->draw_focus = draw_focus;
3294 style_class->draw_layout = draw_layout;
3297 GType msw_type_style = 0;
3300 msw_style_register_type (GTypeModule *module)
3302 const GTypeInfo object_info = {
3303 sizeof (MswStyleClass),
3304 (GBaseInitFunc) NULL,
3305 (GBaseFinalizeFunc) NULL,
3306 (GClassInitFunc) msw_style_class_init,
3307 NULL, /* class_finalize */
3308 NULL, /* class_data */
3310 0, /* n_preallocs */
3311 (GInstanceInitFunc) NULL,
3314 msw_type_style = g_type_module_register_type (module,
3316 "MswStyle", &object_info, 0);
3320 msw_style_init (void)
3323 msw_style_setup_system_settings ();
3324 setup_msw_rc_style ();
3328 DeleteObject (g_light_pen);
3334 DeleteObject (g_dark_pen);
3340 msw_style_finalize (void)
3344 DeleteObject (g_dither_brush);
3349 DeleteObject (g_light_pen);
3354 DeleteObject (g_dark_pen);