1 /* MS-Windows Engine (aka GTK-Wimp)
3 * Copyright (C) 2003, 2004 Raymond Penners <raymond@dotsphinx.com>
4 * Includes code adapted from redmond95 by Owen Taylor, and
5 * gtk-nativewin by Evan Martin
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
26 * http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsNativeThemeWin.cpp
27 * http://lxr.mozilla.org/seamonkey/source/widget/src/windows/nsLookAndFeel.cpp
28 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/functions/drawthemebackground.asp
29 * http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4b3g.asp
32 #include "msw_style.h"
43 /* #include <gdk/gdkwin32.h> */
44 #include "gdk/win32/gdkwin32.h"
47 /* Default values, not normally used
49 static const GtkRequisition default_option_indicator_size = { 9, 8 };
50 static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 };
52 static GtkStyleClass *parent_class;
73 static const guint8 check_aa_bits[] = {
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
78 static const guint8 check_base_bits[] = {
79 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07,
81 0x07, 0xfc, 0x07, 0xfc, 0x07, 0xfc, 0x07, 0x00, 0x00, 0x00, 0x00
83 static const guint8 check_black_bits[] = {
84 0x00, 0x00, 0xfe, 0x0f, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00,
86 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00
88 static const guint8 check_dark_bits[] = {
89 0xff, 0x1f, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00,
91 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00
93 static const guint8 check_light_bits[] = {
94 0x00, 0x00, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10,
96 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0x00, 0x10, 0xfe, 0x1f
98 static const guint8 check_mid_bits[] = {
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08,
101 0x08, 0x00, 0x08, 0x00, 0x08, 0x00, 0x08, 0xfc, 0x0f, 0x00, 0x00
103 static const guint8 check_text_bits[] = {
104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x88, 0x03,
106 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
108 static const guint8 radio_base_bits[] = {
109 0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0xf8, 0x03, 0xfc, 0x07, 0xfc, 0x07,
111 0x07, 0xfc, 0x07, 0xf8, 0x03, 0xf0, 0x01, 0x00, 0x00, 0x00, 0x00
113 static const guint8 radio_black_bits[] = {
114 0x00, 0x00, 0xf0, 0x01, 0x0c, 0x02, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00,
116 0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
118 static const guint8 radio_dark_bits[] = {
119 0xf0, 0x01, 0x0c, 0x06, 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0x01, 0x00,
121 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
123 static const guint8 radio_light_bits[] = {
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x08, 0x00, 0x10, 0x00, 0x10,
126 0x10, 0x00, 0x10, 0x00, 0x08, 0x00, 0x08, 0x0c, 0x06, 0xf0, 0x01
128 static const guint8 radio_mid_bits[] = {
129 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x08, 0x00, 0x08,
131 0x08, 0x00, 0x08, 0x00, 0x04, 0x0c, 0x06, 0xf0, 0x01, 0x00, 0x00
133 static const guint8 radio_text_bits[] = {
134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0xf0, 0x01,
136 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
145 {check_aa_bits, NULL},
146 {check_base_bits, NULL},
147 {check_black_bits, NULL},
148 {check_dark_bits, NULL},
149 {check_light_bits, NULL},
150 {check_mid_bits, NULL},
151 {check_text_bits, NULL},
152 {radio_base_bits, NULL},
153 {radio_black_bits, NULL},
154 {radio_dark_bits, NULL},
155 {radio_light_bits, NULL},
156 {radio_mid_bits, NULL},
157 {radio_text_bits, NULL}
161 get_system_font (XpThemeClass klazz, XpThemeFont type, LOGFONT * out_lf)
164 /* TODO: this causes crashes later because the font name is in UCS2, and
165 the pango fns don't deal with that gracefully */
166 if (xp_theme_get_system_font (klazz, type, out_lf))
171 NONCLIENTMETRICS ncm;
173 ncm.cbSize = sizeof (NONCLIENTMETRICS);
175 if (SystemParametersInfo (SPI_GETNONCLIENTMETRICS,
176 sizeof (NONCLIENTMETRICS), &ncm, 0))
178 if (type == XP_THEME_FONT_CAPTION)
179 *out_lf = ncm.lfCaptionFont;
180 else if (type == XP_THEME_FONT_MENU)
181 *out_lf = ncm.lfMenuFont;
182 else if (type == XP_THEME_FONT_STATUS)
183 *out_lf = ncm.lfStatusFont;
185 *out_lf = ncm.lfMessageFont;
193 /***************************** BEGIN STOLEN FROM PANGO *****************************/
196 This code is stolen from Pango 1.4. It attempts to address the following problems:
198 http://bugzilla.gnome.org/show_bug.cgi?id=135098
199 http://sourceforge.net/tracker/index.php?func=detail&aid=895762&group_id=76416&atid=547655
201 As Owen suggested in bug 135098, once Pango 1.6 is released, we need to get rid of this code.
204 #define PING(printlist)
206 /* TrueType defines: */
208 #define MAKE_TT_TABLE_NAME(c1, c2, c3, c4) \
209 (((guint32)c4) << 24 | ((guint32)c3) << 16 | ((guint32)c2) << 8 | ((guint32)c1))
211 #define CMAP (MAKE_TT_TABLE_NAME('c','m','a','p'))
212 #define CMAP_HEADER_SIZE 4
214 #define NAME (MAKE_TT_TABLE_NAME('n','a','m','e'))
215 #define NAME_HEADER_SIZE 6
217 #define ENCODING_TABLE_SIZE 8
219 #define APPLE_UNICODE_PLATFORM_ID 0
220 #define MACINTOSH_PLATFORM_ID 1
221 #define ISO_PLATFORM_ID 2
222 #define MICROSOFT_PLATFORM_ID 3
224 #define SYMBOL_ENCODING_ID 0
225 #define UNICODE_ENCODING_ID 1
226 #define UCS4_ENCODING_ID 10
230 guint16 format_selector;
232 guint16 string_storage_offset;
241 guint16 string_length;
242 guint16 string_offset;
246 pango_win32_get_name_header (HDC hdc, struct name_header *header)
248 if (GetFontData (hdc, NAME, 0, header, sizeof (*header)) !=
252 header->num_records = GUINT16_FROM_BE (header->num_records);
253 header->string_storage_offset =
254 GUINT16_FROM_BE (header->string_storage_offset);
260 pango_win32_get_name_record (HDC hdc, gint i, struct name_record *record)
262 if (GetFontData (hdc, NAME, 6 + i * sizeof (*record),
263 record, sizeof (*record)) != sizeof (*record))
266 record->platform_id = GUINT16_FROM_BE (record->platform_id);
267 record->encoding_id = GUINT16_FROM_BE (record->encoding_id);
268 record->language_id = GUINT16_FROM_BE (record->language_id);
269 record->name_id = GUINT16_FROM_BE (record->name_id);
270 record->string_length = GUINT16_FROM_BE (record->string_length);
271 record->string_offset = GUINT16_FROM_BE (record->string_offset);
277 get_family_name (LOGFONT * lfp, HDC pango_win32_hdc)
282 struct name_header header;
283 struct name_record record;
285 gint unicode_ix = -1, mac_ix = -1, microsoft_ix = -1;
289 gchar *string = NULL;
294 /* If lfFaceName is ASCII, assume it is the common (English) name for the
295 font. Is this valid? Do some TrueType fonts have different names in
296 French, German, etc, and does the system return these if the locale is
297 set to use French, German, etc? */
298 l = strlen (lfp->lfFaceName);
299 for (i = 0; i < l; i++)
300 if (lfp->lfFaceName[i] < ' ' || lfp->lfFaceName[i] > '~')
304 return g_strdup (lfp->lfFaceName);
306 if ((hfont = CreateFontIndirect (lfp)) == NULL)
309 if ((oldhfont = (HFONT) SelectObject (pango_win32_hdc, hfont)) == NULL)
312 if (!pango_win32_get_name_header (pango_win32_hdc, &header))
315 PING (("%d name records", header.num_records));
317 for (i = 0; i < header.num_records; i++)
319 if (!pango_win32_get_name_record (pango_win32_hdc, i, &record))
322 if ((record.name_id != 1 && record.name_id != 16)
323 || record.string_length <= 0)
326 PING (("platform:%d encoding:%d language:%04x name_id:%d",
327 record.platform_id, record.encoding_id, record.language_id,
330 if (record.platform_id == APPLE_UNICODE_PLATFORM_ID ||
331 record.platform_id == ISO_PLATFORM_ID)
333 else if (record.platform_id == MACINTOSH_PLATFORM_ID && record.encoding_id == 0 && /* Roman
335 record.language_id == 0) /* English */
337 else if (record.platform_id == MICROSOFT_PLATFORM_ID)
338 if ((microsoft_ix == -1 ||
339 PRIMARYLANGID (record.language_id) == LANG_ENGLISH) &&
340 (record.encoding_id == SYMBOL_ENCODING_ID ||
341 record.encoding_id == UNICODE_ENCODING_ID ||
342 record.encoding_id == UCS4_ENCODING_ID))
346 if (microsoft_ix >= 0)
347 name_ix = microsoft_ix;
348 else if (mac_ix >= 0)
350 else if (unicode_ix >= 0)
351 name_ix = unicode_ix;
355 if (!pango_win32_get_name_record (pango_win32_hdc, name_ix, &record))
358 string = g_malloc (record.string_length + 1);
359 if (GetFontData (pango_win32_hdc, NAME,
360 header.string_storage_offset + record.string_offset,
361 string, record.string_length) != record.string_length)
364 string[record.string_length] = '\0';
366 if (name_ix == microsoft_ix)
367 if (record.encoding_id == SYMBOL_ENCODING_ID ||
368 record.encoding_id == UNICODE_ENCODING_ID)
369 codeset = "UTF-16BE";
372 else if (name_ix == mac_ix)
373 codeset = "MacRoman";
374 else /* name_ix == unicode_ix */
378 g_convert (string, record.string_length, "UTF-8", codeset, NULL,
386 SelectObject (pango_win32_hdc, oldhfont);
387 DeleteObject (hfont);
393 SelectObject (pango_win32_hdc, oldhfont);
396 DeleteObject (hfont);
399 return g_locale_to_utf8 (lfp->lfFaceName, -1, NULL, NULL, NULL);
402 /***************************** END STOLEN FROM PANGO *****************************/
405 sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char *buf,
416 if (get_system_font (klazz, type, &lf))
422 weight = "Ultra-Light";
434 weight = "Semi-Bold";
438 weight = "Ultra-Bold";
455 hwnd = GetDesktopWindow ();
459 pt_size = -MulDiv (lf.lfHeight, 72,
460 GetDeviceCaps (hDC, LOGPIXELSY));
461 ReleaseDC (hwnd, hDC);
466 font = get_family_name (&lf, hDC);
470 g_snprintf (buf, bufsiz, "%s %s %s %d", font, style, weight, pt_size);
479 /* missing from ms's header files */
480 #ifndef SPI_GETMENUSHOWDELAY
481 #define SPI_GETMENUSHOWDELAY 106
484 /* I don't know the proper XP theme class for things like
485 HIGHLIGHTTEXT, so we'll just define it to be "BUTTON"
487 #define XP_THEME_CLASS_TEXT XP_THEME_CLASS_BUTTON
490 setup_menu_settings (GtkSettings * settings)
493 gboolean win95 = FALSE;
494 OSVERSIONINFOEX osvi;
495 GObjectClass *klazz = G_OBJECT_GET_CLASS (G_OBJECT (settings));
497 ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX));
498 osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX);
500 if (!GetVersionEx ((OSVERSIONINFO *) & osvi))
501 win95 = TRUE; /* assume the worst */
503 if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
504 if (osvi.dwMajorVersion == 4 && osvi.dwMinorVersion == 0)
509 if (SystemParametersInfo
510 (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0))
514 if (g_object_class_find_property
515 (klazz, "gtk-menu-bar-popup-delay"))
517 g_object_set (settings,
518 "gtk-menu-bar-popup-delay",
521 if (g_object_class_find_property
522 (klazz, "gtk-menu-popup-delay"))
524 g_object_set (settings,
525 "gtk-menu-popup-delay",
528 if (g_object_class_find_property
529 (klazz, "gtk-menu-popdown-delay"))
531 g_object_set (settings,
532 "gtk-menu-popdown-delay",
541 msw_style_setup_system_settings (void)
543 GtkSettings *settings;
544 int cursor_blink_time;
546 settings = gtk_settings_get_default ();
550 cursor_blink_time = GetCaretBlinkTime ();
551 g_object_set (settings, "gtk-cursor-blink", cursor_blink_time > 0, NULL);
553 if (cursor_blink_time > 0)
554 g_object_set (settings, "gtk-cursor-blink-time",
555 2 * cursor_blink_time, NULL);
557 g_object_set (settings, "gtk-double-click-distance",
558 GetSystemMetrics (SM_CXDOUBLECLK), NULL);
559 g_object_set (settings, "gtk-double-click-time", GetDoubleClickTime (),
561 g_object_set (settings, "gtk-dnd-drag-threshold",
562 GetSystemMetrics (SM_CXDRAG), NULL);
564 setup_menu_settings (settings);
567 http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html
568 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp
569 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp */
573 setup_system_font (GtkStyle * style)
575 char buf[256], *font; /* It's okay, lfFaceName is smaller than 32
578 if ((font = sys_font_to_pango_font (XP_THEME_CLASS_TEXT,
579 XP_THEME_FONT_MESSAGE,
580 buf, sizeof (buf))) != NULL)
582 if (style->font_desc)
583 pango_font_description_free (style->font_desc);
585 style->font_desc = pango_font_description_from_string (font);
590 sys_color_to_gtk_color (XpThemeClass klazz, int id, GdkColor * pcolor)
594 if (!xp_theme_get_system_color (klazz, id, &color))
595 color = GetSysColor (id);
597 pcolor->pixel = color;
598 pcolor->red = (GetRValue (color) << 8) | GetRValue (color);
599 pcolor->green = (GetGValue (color) << 8) | GetGValue (color);
600 pcolor->blue = (GetBValue (color) << 8) | GetBValue (color);
604 get_system_metric (XpThemeClass klazz, int id)
608 if (!xp_theme_get_system_metric (klazz, id, &rval))
609 rval = GetSystemMetrics (id);
615 setup_msw_rc_style (void)
617 char buf[1024], font_buf[256], *font_ptr;
620 GdkColor menu_text_color;
621 GdkColor tooltip_back;
622 GdkColor tooltip_fore;
625 GdkColor progress_back;
627 GdkColor fg_prelight;
628 GdkColor bg_prelight;
629 GdkColor base_prelight;
630 GdkColor text_prelight;
633 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
635 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
637 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
639 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
642 sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENUTEXT,
644 sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENU, &menu_color);
647 sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOTEXT,
649 sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOBK,
652 /* text on push buttons. TODO: button shadows, backgrounds, and
654 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btn_fore);
655 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &btn_face);
657 /* progress bar background color */
658 sys_color_to_gtk_color (XP_THEME_CLASS_PROGRESS, COLOR_HIGHLIGHT,
661 /* Enable coloring for menus. */
663 sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU,
664 font_buf, sizeof (font_buf));
665 g_snprintf (buf, sizeof (buf),
666 "style \"msw-menu\" = \"msw-default\"\n" "{\n"
667 "GtkMenuItem::toggle-spacing = 8\n"
668 "fg[PRELIGHT] = { %d, %d, %d }\n"
669 "bg[PRELIGHT] = { %d, %d, %d }\n"
670 "text[PRELIGHT] = { %d, %d, %d }\n"
671 "base[PRELIGHT] = { %d, %d, %d }\n"
672 "fg[NORMAL] = { %d, %d, %d }\n"
673 "bg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n"
674 "}widget_class \"*MenuItem*\" style \"msw-menu\"\n"
675 "widget_class \"*GtkMenu\" style \"msw-menu\"\n"
676 "widget_class \"*GtkMenuShell*\" style \"msw-menu\"\n",
677 fg_prelight.red, fg_prelight.green, fg_prelight.blue,
678 bg_prelight.red, bg_prelight.green, bg_prelight.blue,
679 text_prelight.red, text_prelight.green, text_prelight.blue,
680 base_prelight.red, base_prelight.green, base_prelight.blue,
681 menu_text_color.red, menu_text_color.green,
682 menu_text_color.blue, menu_color.red, menu_color.green,
683 menu_color.blue, (font_ptr ? "font_name" : "#"),
684 (font_ptr ? font_ptr : " font name should go here"));
685 gtk_rc_parse_string (buf);
687 /* Enable coloring for menu bars. */
688 g_snprintf (buf, sizeof (buf),
689 "style \"msw-menu-bar\" = \"msw-menu\"\n"
691 "bg[NORMAL] = { %d, %d, %d }\n"
692 "GtkMenuBar::shadow-type = %s\n"
693 "}widget_class \"*MenuBar*\" style \"msw-menu-bar\"\n",
694 btn_face.red, btn_face.green, btn_face.blue, "etched-in");
695 gtk_rc_parse_string (buf);
697 g_snprintf (buf, sizeof (buf),
698 "style \"msw-toolbar\" = \"msw-default\"\n"
700 "GtkHandleBox::shadow-type = %s\n"
701 "GtkToolbar::shadow-type = %s\n"
702 "}widget_class \"*HandleBox*\" style \"msw-toolbar\"\n",
703 "etched-in", "etched-in");
704 gtk_rc_parse_string (buf);
706 /* enable tooltip fonts */
708 sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,
709 font_buf, sizeof (font_buf));
710 g_snprintf (buf, sizeof (buf),
711 "style \"msw-tooltips-caption\" = \"msw-default\"\n"
712 "{fg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n"
713 "}widget \"gtk-tooltips.GtkLabel\" style \"msw-tooltips-caption\"\n",
714 tooltip_fore.red, tooltip_fore.green, tooltip_fore.blue,
715 (font_ptr ? "font_name" : "#"),
716 (font_ptr ? font_ptr : " font name should go here"));
717 gtk_rc_parse_string (buf);
719 g_snprintf (buf, sizeof (buf),
720 "style \"msw-tooltips\" = \"msw-default\"\n"
721 "{bg[NORMAL] = { %d, %d, %d }\n"
722 "}widget \"gtk-tooltips*\" style \"msw-tooltips\"\n",
723 tooltip_back.red, tooltip_back.green, tooltip_back.blue);
724 gtk_rc_parse_string (buf);
726 /* enable font theming for status bars */
728 sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS,
729 font_buf, sizeof (font_buf));
730 g_snprintf (buf, sizeof (buf),
731 "style \"msw-status\" = \"msw-default\"\n" "{%s = \"%s\"\n"
732 "bg[NORMAL] = { %d, %d, %d }\n"
733 "}widget_class \"*Status*\" style \"msw-status\"\n",
734 (font_ptr ? "font_name" : "#"),
735 (font_ptr ? font_ptr : " font name should go here"),
736 btn_face.red, btn_face.green, btn_face.blue);
737 gtk_rc_parse_string (buf);
739 /* enable coloring for text on buttons TODO: use GetThemeMetric for the
740 border and outside border */
741 g_snprintf (buf, sizeof (buf),
742 "style \"msw-button\" = \"msw-default\"\n"
744 "bg[NORMAL] = { %d, %d, %d }\n"
745 "bg[PRELIGHT] = { %d, %d, %d }\n"
746 "bg[INSENSITIVE] = { %d, %d, %d }\n"
747 "fg[PRELIGHT] = { %d, %d, %d }\n"
748 "GtkButton::default-border = { 1, 1, 1, 1 }\n"
749 "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n"
750 "GtkButton::child-displacement-x = 1\n"
751 "GtkButton::child-displacement-y = 1\n"
752 "}widget_class \"*Button*\" style \"msw-button\"\n",
753 btn_face.red, btn_face.green, btn_face.blue,
754 btn_face.red, btn_face.green, btn_face.blue,
755 btn_face.red, btn_face.green, btn_face.blue,
756 btn_fore.red, btn_fore.green, btn_fore.blue);
757 gtk_rc_parse_string (buf);
759 /* enable coloring for progress bars */
760 g_snprintf (buf, sizeof (buf),
761 "style \"msw-progress\" = \"msw-default\"\n"
762 "{bg[PRELIGHT] = { %d, %d, %d }\n"
763 "bg[NORMAL] = { %d, %d, %d }\n"
764 "}widget_class \"*Progress*\" style \"msw-progress\"\n",
768 btn_face.red, btn_face.green, btn_face.blue);
769 gtk_rc_parse_string (buf);
771 /* scrollbar thumb width and height */
772 g_snprintf (buf, sizeof (buf),
773 "style \"msw-vscrollbar\" = \"msw-default\"\n"
774 "{GtkRange::slider-width = %d\n"
775 "GtkRange::stepper-size = %d\n"
776 "GtkRange::stepper-spacing = 0\n"
777 "GtkRange::trough_border = 0\n"
778 "GtkScale::slider-length = %d\n"
779 "GtkScrollbar::min-slider-length = 8\n"
780 "}widget_class \"*VScrollbar*\" style \"msw-vscrollbar\"\n"
781 "widget_class \"*VScale*\" style \"msw-vscrollbar\"\n",
782 GetSystemMetrics (SM_CYVTHUMB),
783 get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CXVSCROLL),
785 gtk_rc_parse_string (buf);
787 g_snprintf (buf, sizeof (buf),
788 "style \"msw-hscrollbar\" = \"msw-default\"\n"
789 "{GtkRange::slider-width = %d\n"
790 "GtkRange::stepper-size = %d\n"
791 "GtkRange::stepper-spacing = 0\n"
792 "GtkRange::trough_border = 0\n"
793 "GtkScale::slider-length = %d\n"
794 "GtkScrollbar::min-slider-length = 8\n"
795 "}widget_class \"*HScrollbar*\" style \"msw-hscrollbar\"\n"
796 "widget_class \"*HScale*\" style \"msw-hscrollbar\"\n",
797 GetSystemMetrics (SM_CXHTHUMB),
798 get_system_metric (XP_THEME_CLASS_SCROLLBAR, SM_CYHSCROLL),
800 gtk_rc_parse_string (buf);
802 /* radio/check button sizes */
803 g_snprintf (buf, sizeof (buf),
804 "style \"msw-checkbutton\" = \"msw-button\"\n"
805 "{GtkCheckButton::indicator-size = 13\n"
806 "}widget_class \"*CheckButton*\" style \"msw-checkbutton\"\n"
807 "widget_class \"*RadioButton*\" style \"msw-checkbutton\"\n");
808 gtk_rc_parse_string (buf);
810 if(xp_theme_is_active()) {
811 g_snprintf (buf, sizeof(buf),
812 "style \"msw-combobox-toggle\" = \"msw-default\"\n"
816 "GtkButton::default-border = { 0, 0, 0, 0 }\n"
817 "GtkButton::default-outside-border = { 0, 0, 0, 0 }\n"
818 "GtkButton::child-displacement-x = 0\n"
819 "GtkButton::child-displacement-y = 0\n"
820 "GtkWidget::focus-padding = 0\n"
821 "GtkWidget::focus-line-width = 0\n"
823 "widget_class \"*ComboBox*ToggleButton*\" style \"msw-combobox-toggle\"\n");
824 gtk_rc_parse_string (buf);
829 setup_system_styles (GtkStyle * style)
833 /* Default background */
834 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
835 &style->bg[GTK_STATE_NORMAL]);
836 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
837 &style->bg[GTK_STATE_SELECTED]);
838 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
839 &style->bg[GTK_STATE_INSENSITIVE]);
840 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
841 &style->bg[GTK_STATE_ACTIVE]);
842 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
843 &style->bg[GTK_STATE_PRELIGHT]);
846 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOW,
847 &style->base[GTK_STATE_NORMAL]);
848 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT,
849 &style->base[GTK_STATE_SELECTED]);
850 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
851 &style->base[GTK_STATE_INSENSITIVE]);
852 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE,
853 &style->base[GTK_STATE_ACTIVE]);
854 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOW,
855 &style->base[GTK_STATE_PRELIGHT]);
858 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
859 &style->text[GTK_STATE_NORMAL]);
860 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
861 &style->text[GTK_STATE_SELECTED]);
862 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_GRAYTEXT,
863 &style->text[GTK_STATE_INSENSITIVE]);
864 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
865 &style->text[GTK_STATE_ACTIVE]);
866 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
867 &style->text[GTK_STATE_PRELIGHT]);
869 /* Default foreground */
870 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
871 &style->fg[GTK_STATE_NORMAL]);
872 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT,
873 &style->fg[GTK_STATE_SELECTED]);
874 sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_GRAYTEXT,
875 &style->fg[GTK_STATE_INSENSITIVE]);
876 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT,
877 &style->fg[GTK_STATE_ACTIVE]);
878 sys_color_to_gtk_color (XP_THEME_CLASS_WINDOW, COLOR_WINDOWTEXT,
879 &style->fg[GTK_STATE_PRELIGHT]);
881 for (i = 0; i < 5; i++)
883 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW,
885 sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT,
889 (style->light[i].red + style->dark[i].red) / 2;
890 style->mid[i].green =
891 (style->light[i].green + style->dark[i].green) / 2;
893 (style->light[i].blue + style->dark[i].blue) / 2;
895 style->text_aa[i].red =
896 (style->text[i].red + style->base[i].red) / 2;
897 style->text_aa[i].green =
898 (style->text[i].green + style->base[i].green) / 2;
899 style->text_aa[i].blue =
900 (style->text[i].blue + style->base[i].blue) / 2;
905 sanitize_size (GdkWindow * window, gint * width, gint * height)
907 gboolean set_bg = FALSE;
909 if ((*width == -1) && (*height == -1))
911 set_bg = GDK_IS_WINDOW (window);
912 gdk_drawable_get_size (window, width, height);
914 else if (*width == -1)
915 gdk_drawable_get_size (window, width, NULL);
916 else if (*height == -1)
917 gdk_drawable_get_size (window, NULL, height);
922 static XpThemeElement
923 map_gtk_progress_bar_to_xp (GtkProgressBar * progress_bar, gboolean trough)
927 switch (progress_bar->orientation)
929 case GTK_PROGRESS_LEFT_TO_RIGHT:
930 case GTK_PROGRESS_RIGHT_TO_LEFT:
932 ? XP_THEME_ELEMENT_PROGRESS_TROUGH_H
933 : XP_THEME_ELEMENT_PROGRESS_BAR_H;
937 ? XP_THEME_ELEMENT_PROGRESS_TROUGH_V
938 : XP_THEME_ELEMENT_PROGRESS_BAR_V;
945 is_combo_box_child (GtkWidget* w)
952 for (tmp = w->parent; tmp; tmp = tmp->parent)
954 if (GTK_IS_COMBO_BOX(tmp))
962 combo_box_draw_arrow (GtkStyle * style,
968 if (xp_theme_draw (window, XP_THEME_ELEMENT_COMBOBUTTON,
969 style, widget->allocation.x, widget->allocation.y,
970 widget->allocation.width, widget->allocation.height,
979 /* This is ugly because no box drawing function is invoked for the combo
980 box as a whole, so we draw part of the entire box in every subwidget.
981 We do this by finding the allocation of the combo box in the given
982 window's coordinates and drawing. The xp drawing routines take care
985 combo_box_draw_box (GtkStyle * style,
987 GtkStateType state_type,
988 GtkShadowType shadow_type,
991 const gchar * detail, gint x, gint y, gint width, gint height)
993 GtkWidget* combo_box;
994 GdkRectangle combo_alloc;
998 for (combo_box = widget->parent; combo_box; combo_box = combo_box->parent)
1000 if (GTK_IS_COMBO_BOX(combo_box))
1006 combo_alloc = combo_box->allocation;
1007 if (window != combo_box->window)
1010 for (tmp = widget; tmp && tmp != combo_box; tmp = widget->parent)
1012 if (tmp->parent && tmp->window != tmp->parent->window)
1014 combo_alloc.x -= tmp->allocation.x;
1015 combo_alloc.y -= tmp->allocation.y;
1020 if (xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT,
1021 style, combo_alloc.x, combo_alloc.y,
1022 combo_alloc.width, combo_alloc.height,
1030 draw_part (GdkDrawable * drawable,
1031 GdkGC * gc, GdkRectangle * area, gint x, gint y, Part part)
1034 gdk_gc_set_clip_rectangle (gc, area);
1036 if (!parts[part].bmap)
1037 parts[part].bmap = gdk_bitmap_create_from_data (drawable,
1039 PART_SIZE, PART_SIZE);
1041 gdk_gc_set_ts_origin (gc, x, y);
1042 gdk_gc_set_stipple (gc, parts[part].bmap);
1043 gdk_gc_set_fill (gc, GDK_STIPPLED);
1045 gdk_draw_rectangle (drawable, gc, TRUE, x, y, PART_SIZE, PART_SIZE);
1047 gdk_gc_set_fill (gc, GDK_SOLID);
1050 gdk_gc_set_clip_rectangle (gc, NULL);
1054 draw_check (GtkStyle * style,
1057 GtkShadowType shadow,
1058 GdkRectangle * area,
1060 const gchar * detail, gint x, gint y, gint width, gint height)
1062 x -= (1 + PART_SIZE - width) / 2;
1063 y -= (1 + PART_SIZE - height) / 2;
1065 if (detail && strcmp (detail, "check") == 0) /* Menu item */
1067 if (shadow == GTK_SHADOW_IN)
1069 draw_part (window, style->black_gc, area, x, y,
1071 draw_part (window, style->dark_gc[state], area, x, y,
1077 if (!xp_theme_draw (window, shadow == GTK_SHADOW_IN
1078 ? XP_THEME_ELEMENT_PRESSED_CHECKBOX
1079 : XP_THEME_ELEMENT_CHECKBOX,
1080 style, x, y, width, height, state, area))
1082 draw_part (window, style->black_gc, area, x, y,
1084 draw_part (window, style->dark_gc[state], area, x, y,
1086 draw_part (window, style->mid_gc[state], area, x, y,
1088 draw_part (window, style->light_gc[state], area, x, y,
1090 draw_part (window, style->base_gc[state], area, x, y,
1093 if (shadow == GTK_SHADOW_IN)
1095 draw_part (window, style->text_gc[state], area, x,
1097 draw_part (window, style->text_aa_gc[state], area,
1105 draw_expander (GtkStyle * style,
1108 GdkRectangle * area,
1110 const gchar * detail,
1111 gint x, gint y, GtkExpanderStyle expander_style)
1114 gint expander_semi_size;
1118 XpThemeElement xp_expander;
1120 gtk_widget_style_get (widget, "expander_size", &expander_size, NULL);
1122 switch (expander_style)
1124 case GTK_EXPANDER_COLLAPSED:
1125 case GTK_EXPANDER_SEMI_COLLAPSED:
1126 xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED;
1129 xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED;
1133 if ((expander_size % 2) == 0)
1136 if (expander_size > 2)
1140 gdk_gc_set_clip_rectangle (style->fg_gc[state], area);
1142 expander_semi_size = expander_size / 2;
1143 x -= expander_semi_size;
1144 y -= expander_semi_size;
1146 gdk_gc_get_values (style->fg_gc[state], &values);
1148 if (!xp_theme_draw (window, xp_expander, style,
1149 x, y, expander_size, expander_size, state, area))
1151 /* RGB values to emulate Windows Classic style */
1152 color.red = color.green = color.blue = 128 << 8;
1154 success = gdk_colormap_alloc_color
1155 (gtk_widget_get_default_colormap (), &color, FALSE, TRUE);
1158 gdk_gc_set_foreground (style->fg_gc[state], &color);
1161 (window, style->fg_gc[state], FALSE, x, y,
1162 expander_size - 1, expander_size - 1);
1165 (window, style->fg_gc[state], x + 2, y + expander_semi_size,
1166 x + expander_size - 3, y + expander_semi_size);
1168 switch (expander_style)
1170 case GTK_EXPANDER_COLLAPSED:
1171 case GTK_EXPANDER_SEMI_COLLAPSED:
1173 (window, style->fg_gc[state], x + expander_semi_size,
1174 y + 2, x + expander_semi_size,
1175 y + expander_size - 3);
1183 gdk_gc_set_foreground (style->fg_gc[state],
1184 &values.foreground);
1188 gdk_gc_set_clip_rectangle (style->fg_gc[state], NULL);
1192 draw_option (GtkStyle * style,
1195 GtkShadowType shadow,
1196 GdkRectangle * area,
1198 const gchar * detail, gint x, gint y, gint width, gint height)
1200 x -= (1 + PART_SIZE - width) / 2;
1201 y -= (1 + PART_SIZE - height) / 2;
1203 if (detail && strcmp (detail, "option") == 0) /* Menu item */
1205 if (shadow == GTK_SHADOW_IN)
1206 draw_part (window, style->fg_gc[state], area, x, y,
1211 if (xp_theme_draw (window, shadow == GTK_SHADOW_IN
1212 ? XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON
1213 : XP_THEME_ELEMENT_RADIO_BUTTON,
1214 style, x, y, width, height, state, area))
1219 draw_part (window, style->black_gc, area, x, y,
1221 draw_part (window, style->dark_gc[state], area, x, y,
1223 draw_part (window, style->mid_gc[state], area, x, y,
1225 draw_part (window, style->light_gc[state], area, x, y,
1227 draw_part (window, style->base_gc[state], area, x, y,
1230 if (shadow == GTK_SHADOW_IN)
1231 draw_part (window, style->text_gc[state], area, x, y,
1238 draw_varrow (GdkWindow * window,
1240 GtkShadowType shadow_type,
1241 GdkRectangle * area,
1242 GtkArrowType arrow_type, gint x, gint y, gint width, gint height)
1245 gint y_start, y_increment;
1249 gdk_gc_set_clip_rectangle (gc, area);
1251 width = width + width % 2 - 1; /* Force odd */
1252 steps = 1 + width / 2;
1253 extra = height - steps;
1255 if (arrow_type == GTK_ARROW_DOWN)
1262 y_start = y + height - 1;
1266 for (i = extra; i < height; i++)
1268 gdk_draw_line (window, gc,
1269 x + (i - extra), y_start + i * y_increment,
1270 x + width - (i - extra) - 1,
1271 y_start + i * y_increment);
1275 gdk_gc_set_clip_rectangle (gc, NULL);
1279 draw_harrow (GdkWindow * window,
1281 GtkShadowType shadow_type,
1282 GdkRectangle * area,
1283 GtkArrowType arrow_type, gint x, gint y, gint width, gint height)
1286 gint x_start, x_increment;
1290 gdk_gc_set_clip_rectangle (gc, area);
1292 height = height + height % 2 - 1; /* Force odd */
1293 steps = 1 + height / 2;
1294 extra = width - steps;
1296 if (arrow_type == GTK_ARROW_RIGHT)
1303 x_start = x + width - 1;
1307 for (i = extra; i < width; i++)
1309 gdk_draw_line (window, gc,
1310 x_start + i * x_increment, y + (i - extra),
1311 x_start + i * x_increment,
1312 y + height - (i - extra) - 1);
1317 gdk_gc_set_clip_rectangle (gc, NULL);
1320 /* This function makes up for some brokeness in gtkrange.c
1321 * where we never get the full arrow of the stepper button
1322 * and the type of button in a single drawing function.
1324 * It doesn't work correctly when the scrollbar is squished
1325 * to the point we don't have room for full-sized steppers.
1328 reverse_engineer_stepper_box (GtkWidget * range,
1329 GtkArrowType arrow_type,
1330 gint * x, gint * y, gint * width, gint * height)
1332 gint slider_width = 14, stepper_size = 14;
1338 gtk_widget_style_get (range,
1339 "slider_width", &slider_width,
1340 "stepper_size", &stepper_size, NULL);
1343 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
1345 box_width = slider_width;
1346 box_height = stepper_size;
1350 box_width = stepper_size;
1351 box_height = slider_width;
1354 *x = *x - (box_width - *width) / 2;
1355 *y = *y - (box_height - *height) / 2;
1357 *height = box_height;
1360 static XpThemeElement
1361 to_xp_arrow (GtkArrowType arrow_type)
1363 XpThemeElement xp_arrow;
1368 xp_arrow = XP_THEME_ELEMENT_ARROW_UP;
1370 case GTK_ARROW_DOWN:
1371 xp_arrow = XP_THEME_ELEMENT_ARROW_DOWN;
1373 case GTK_ARROW_LEFT:
1374 xp_arrow = XP_THEME_ELEMENT_ARROW_LEFT;
1377 xp_arrow = XP_THEME_ELEMENT_ARROW_RIGHT;
1385 draw_arrow (GtkStyle * style,
1388 GtkShadowType shadow,
1389 GdkRectangle * area,
1391 const gchar * detail,
1392 GtkArrowType arrow_type,
1393 gboolean fill, gint x, gint y, gint width, gint height)
1397 name = gtk_widget_get_name (widget);
1399 sanitize_size (window, &width, &height);
1401 if (GTK_IS_ARROW(widget) && is_combo_box_child(widget))
1403 if (combo_box_draw_arrow (style, window, state, area, widget))
1409 if (detail && strcmp (detail, "spinbutton") == 0)
1411 if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP))
1417 x += (width - 7) / 2;
1419 if (arrow_type == GTK_ARROW_UP)
1420 y += (height - 4) / 2;
1422 y += (1 + height - 4) / 2;
1423 draw_varrow (window, style->fg_gc[state], shadow, area,
1424 arrow_type, x, y, 7, 4);
1427 else if (detail && (!strcmp (detail, "vscrollbar")
1428 || !strcmp (detail, "hscrollbar")))
1430 gboolean is_disabled = FALSE;
1431 GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget);
1434 gint box_width = width;
1435 gint box_height = height;
1437 reverse_engineer_stepper_box (widget, arrow_type,
1438 &box_x, &box_y, &box_width,
1441 if (scrollbar->range.adjustment->page_size >=
1442 (scrollbar->range.adjustment->upper -
1443 scrollbar->range.adjustment->lower))
1447 (window, to_xp_arrow (arrow_type), style, box_x, box_y,
1448 box_width, box_height, state, area))
1451 else if (arrow_type == GTK_ARROW_UP
1452 || arrow_type == GTK_ARROW_DOWN)
1454 x += (width - 7) / 2;
1455 y += (height - 5) / 2;
1457 draw_varrow (window,
1458 is_disabled ? style->
1459 text_aa_gc[state] : style->fg_gc[state],
1460 shadow, area, arrow_type, x, y, 7, 5);
1464 y += (height - 7) / 2;
1465 x += (width - 5) / 2;
1467 draw_harrow (window,
1468 is_disabled ? style->
1469 text_aa_gc[state] : style->fg_gc[state],
1470 shadow, area, arrow_type, x, y, 5, 7);
1475 /* draw the toolbar chevrons - waiting for GTK 2.4 */
1476 if (name && !strcmp (name, "gtk-toolbar-arrow"))
1479 (window, XP_THEME_ELEMENT_REBAR_CHEVRON, style, x, y,
1480 width, height, state, area))
1483 /* probably a gtk combo box on a toolbar */
1484 else if (0 /* widget->parent && GTK_IS_BUTTON
1485 (widget->parent) */ )
1488 (window, XP_THEME_ELEMENT_COMBOBUTTON, style, x - 3,
1489 widget->allocation.y + 1, width + 5,
1490 widget->allocation.height - 4, state, area))
1494 if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN)
1496 x += (width - 7) / 2;
1497 y += (height - 5) / 2;
1499 draw_varrow (window, style->fg_gc[state], shadow, area,
1500 arrow_type, x, y, 7, 5);
1504 x += (width - 5) / 2;
1505 y += (height - 7) / 2;
1507 draw_harrow (window, style->fg_gc[state], shadow, area,
1508 arrow_type, x, y, 5, 7);
1514 option_menu_get_props (GtkWidget * widget,
1515 GtkRequisition * indicator_size,
1516 GtkBorder * indicator_spacing)
1518 GtkRequisition *tmp_size = NULL;
1519 GtkBorder *tmp_spacing = NULL;
1522 gtk_widget_style_get (widget,
1523 "indicator_size", &tmp_size,
1524 "indicator_spacing", &tmp_spacing, NULL);
1528 *indicator_size = *tmp_size;
1532 *indicator_size = default_option_indicator_size;
1536 *indicator_spacing = *tmp_spacing;
1537 g_free (tmp_spacing);
1540 *indicator_spacing = default_option_indicator_spacing;
1544 is_toolbar_child (GtkWidget * wid)
1548 if (GTK_IS_TOOLBAR (wid) || GTK_IS_HANDLE_BOX (wid))
1557 static HDC get_window_dc(GtkStyle * style, GdkWindow * window, GtkStateType state_type, gint x, gint y, gint width, gint height, RECT *rect)
1560 GdkDrawable *drawable;
1562 if (!GDK_IS_WINDOW (window))
1570 gdk_window_get_internal_paint_info (window, &drawable, &xoff, &yoff);
1573 rect->left = x - xoff;
1574 rect->top = y - yoff;
1575 rect->right = rect->left + width;
1576 rect->bottom = rect->top + height;
1578 return gdk_win32_hdc_get (drawable, style->dark_gc[state_type], 0);
1581 static void release_window_dc(GtkStyle * style, GdkWindow * window, GtkStateType state_type)
1583 GdkDrawable *drawable;
1585 if (!GDK_IS_WINDOW (window))
1591 gdk_window_get_internal_paint_info (window, &drawable, NULL, NULL);
1594 gdk_win32_hdc_release (drawable, style->dark_gc[state_type], 0);
1598 draw_box (GtkStyle * style,
1600 GtkStateType state_type,
1601 GtkShadowType shadow_type,
1602 GdkRectangle * area,
1604 const gchar * detail, gint x, gint y, gint width, gint height)
1606 if (is_combo_box_child (widget)
1607 && combo_box_draw_box (style, window, state_type, shadow_type,
1608 area, widget, detail, x, y, width, height))
1613 (!strcmp (detail, "button") || !strcmp (detail, "buttondefault")))
1615 if (GTK_IS_TREE_VIEW (widget->parent)
1616 || GTK_IS_CLIST (widget->parent))
1619 (window, XP_THEME_ELEMENT_LIST_HEADER, style, x, y,
1620 width, height, state_type, area))
1623 else if (is_toolbar_child (widget->parent))
1626 (window, XP_THEME_ELEMENT_TOOLBAR_BUTTON, style, x, y,
1627 width, height, state_type, area))
1632 gboolean is_default = !strcmp (detail, "buttondefault");
1636 is_default ? XP_THEME_ELEMENT_DEFAULT_BUTTON :
1637 XP_THEME_ELEMENT_BUTTON, style, x, y, width, height,
1642 else if (detail && !strcmp (detail, "spinbutton"))
1644 if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP))
1649 else if (detail && (!strcmp (detail, "spinbutton_up")
1650 || !strcmp (detail, "spinbutton_down")))
1652 if (xp_theme_draw (window,
1653 (!strcmp (detail, "spinbutton_up"))
1654 ? XP_THEME_ELEMENT_SPIN_BUTTON_UP
1655 : XP_THEME_ELEMENT_SPIN_BUTTON_DOWN,
1656 style, x, y, width, height, state_type, area))
1661 else if (detail && !strcmp (detail, "slider"))
1663 if (GTK_IS_SCROLLBAR (widget))
1665 GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget);
1666 gboolean is_v = GTK_IS_VSCROLLBAR (widget);
1668 if (xp_theme_draw (window,
1670 ? XP_THEME_ELEMENT_SCROLLBAR_V
1671 : XP_THEME_ELEMENT_SCROLLBAR_H,
1672 style, x, y, width, height, state_type,
1675 XpThemeElement gripper =
1676 (is_v ? XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V :
1677 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H);
1679 /* Do not display grippers on tiny scroll bars,
1680 the limit imposed is rather arbitrary, perhaps
1681 we can fetch the gripper geometry from
1682 somewhere and use that... */
1684 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H
1687 XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V
1693 xp_theme_draw (window, gripper, style, x, y,
1694 width, height, state_type, area);
1699 if (scrollbar->range.adjustment->page_size >=
1700 (scrollbar->range.adjustment->upper -
1701 scrollbar->range.adjustment->lower))
1706 else if (detail && !strcmp (detail, "bar"))
1708 if (widget && GTK_IS_PROGRESS_BAR (widget))
1710 GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget);
1711 XpThemeElement xp_progress_bar =
1712 map_gtk_progress_bar_to_xp (progress_bar, FALSE);
1714 (window, xp_progress_bar, style, x, y, width, height,
1721 else if (detail && strcmp (detail, "menuitem") == 0)
1723 shadow_type = GTK_SHADOW_NONE;
1725 (window, XP_THEME_ELEMENT_MENU_ITEM, style, x, y, width,
1726 height, state_type, area))
1731 else if (detail && !strcmp (detail, "trough"))
1733 if (widget && GTK_IS_PROGRESS_BAR (widget))
1735 GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget);
1736 XpThemeElement xp_progress_bar =
1737 map_gtk_progress_bar_to_xp (progress_bar, TRUE);
1739 (window, xp_progress_bar, style, x, y, width, height,
1746 /* Blank in classic Windows */
1749 else if (widget && GTK_IS_SCROLLBAR (widget))
1751 gboolean is_vertical = GTK_IS_VSCROLLBAR (widget);
1753 if (xp_theme_draw (window,
1755 ? XP_THEME_ELEMENT_TROUGH_V
1756 : XP_THEME_ELEMENT_TROUGH_H,
1758 x, y, width, height, state_type, area))
1764 GdkGCValues gc_values;
1768 sanitize_size (window, &width, &height);
1770 pixmap = gdk_pixmap_new (window, 2, 2, -1);
1772 gdk_draw_point (pixmap,
1773 style->bg_gc[GTK_STATE_NORMAL], 0,
1775 gdk_draw_point (pixmap,
1776 style->bg_gc[GTK_STATE_NORMAL], 1,
1778 gdk_draw_point (pixmap,
1779 style->light_gc[GTK_STATE_NORMAL],
1781 gdk_draw_point (pixmap,
1782 style->light_gc[GTK_STATE_NORMAL],
1785 gc_values.fill = GDK_TILED;
1786 gc_values.tile = pixmap;
1787 gc_values.ts_x_origin = x;
1788 gc_values.ts_y_origin = y;
1789 gc = gdk_gc_new_with_values (window, &gc_values,
1790 GDK_GC_TS_X_ORIGIN |
1791 GDK_GC_TS_Y_ORIGIN |
1796 gdk_gc_set_clip_rectangle (gc, area);
1798 gdk_draw_rectangle (window, gc, TRUE, x, y, width,
1801 g_object_unref (gc);
1802 g_object_unref (pixmap);
1807 else if (widget && GTK_IS_SCALE (widget))
1809 gboolean is_vertical = GTK_IS_VSCALE (widget);
1811 if (!xp_theme_is_active ())
1813 parent_class->draw_box (style, window, state_type,
1814 GTK_SHADOW_NONE, area,
1815 widget, detail, x, y,
1822 (window, XP_THEME_ELEMENT_SCALE_TROUGH_V,
1823 style, (2 * x + width) / 2, y, 2, height,
1827 parent_class->draw_box (style, window, state_type,
1828 GTK_SHADOW_ETCHED_IN,
1830 (2 * x + width) / 2, y, 1,
1836 (window, XP_THEME_ELEMENT_SCALE_TROUGH_H,
1837 style, x, (2 * y + height) / 2, width, 2,
1841 parent_class->draw_box (style, window, state_type,
1842 GTK_SHADOW_ETCHED_IN,
1843 area, NULL, NULL, x,
1844 (2 * y + height) / 2,
1850 else if (detail && strcmp (detail, "optionmenu") == 0)
1852 if (xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT,
1853 style, x, y, width, height, state_type, area))
1859 && (strcmp (detail, "vscrollbar") == 0
1860 || strcmp (detail, "hscrollbar") == 0))
1864 && (strcmp (detail, "handlebox_bin") == 0
1865 || strcmp (detail, "toolbar") == 0
1866 || strcmp (detail, "menubar") == 0))
1868 if (xp_theme_draw (window, XP_THEME_ELEMENT_REBAR,
1869 style, x, y, width, height, state_type, area))
1874 else if (detail && (!strcmp (detail, "handlebox"))) /* grip */
1879 const gchar *name = gtk_widget_get_name (widget);
1881 if (name && !strcmp (name, "gtk-tooltips"))
1884 (window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width,
1885 height, state_type, area))
1895 hdc = get_window_dc(style, window, state_type, x, y, width, height, &rect);
1897 brush = GetSysColorBrush (COLOR_3DDKSHADOW);
1899 FrameRect (hdc, &rect, brush);
1900 InflateRect (&rect, -1, -1);
1901 FillRect (hdc, &rect,
1902 (HBRUSH) (COLOR_INFOBK + 1));
1904 release_window_dc (style, window, state_type);
1912 parent_class->draw_box (style, window, state_type, shadow_type, area,
1913 widget, detail, x, y, width, height);
1915 if (detail && strcmp (detail, "optionmenu") == 0)
1917 GtkRequisition indicator_size;
1918 GtkBorder indicator_spacing;
1921 option_menu_get_props (widget, &indicator_size,
1922 &indicator_spacing);
1924 sanitize_size (window, &width, &height);
1926 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
1928 x + indicator_size.width + indicator_spacing.left +
1929 indicator_spacing.right;
1932 x + width - (indicator_size.width +
1933 indicator_spacing.left +
1934 indicator_spacing.right) - style->xthickness;
1936 parent_class->draw_vline (style, window, state_type, area, widget,
1938 y + style->ythickness + 1,
1939 y + height - style->ythickness - 3,
1945 draw_tab (GtkStyle * style,
1948 GtkShadowType shadow,
1949 GdkRectangle * area,
1951 const gchar * detail, gint x, gint y, gint width, gint height)
1953 GtkRequisition indicator_size;
1954 GtkBorder indicator_spacing;
1958 g_return_if_fail (style != NULL);
1959 g_return_if_fail (window != NULL);
1961 if (detail && !strcmp (detail, "optionmenutab"))
1963 if (xp_theme_draw (window, XP_THEME_ELEMENT_COMBOBUTTON,
1964 style, x - 5, widget->allocation.y + 1,
1965 width + 10, widget->allocation.height - 2,
1973 gtk_widget_style_get (widget, "indicator_size", &indicator_size,
1976 option_menu_get_props (widget, &indicator_size, &indicator_spacing);
1978 x += (width - indicator_size.width) / 2;
1979 arrow_height = (indicator_size.width + 1) / 2;
1981 y += (height - arrow_height) / 2;
1983 draw_varrow (window, style->black_gc, shadow, area, GTK_ARROW_DOWN,
1984 x, y, indicator_size.width, arrow_height);
1987 /* Draw classic Windows tab - thanks Mozilla!
1988 (no system API for this, but DrawEdge can draw all the parts of a tab) */
1989 static void DrawTab(HDC hdc, const RECT R, gint32 aPosition, gboolean aSelected,
1990 gboolean aDrawLeft, gboolean aDrawRight)
1992 gint32 leftFlag, topFlag, rightFlag, lightFlag, shadeFlag;
1993 RECT topRect, sideRect, bottomRect, lightRect, shadeRect;
1994 gint32 selectedOffset, lOffset, rOffset;
1996 selectedOffset = aSelected ? 1 : 0;
1997 lOffset = aDrawLeft ? 2 : 0;
1998 rOffset = aDrawRight ? 2 : 0;
2000 /* Get info for tab orientation/position (Left, Top, Right, Bottom) */
2001 switch (aPosition) {
2003 leftFlag = BF_TOP; topFlag = BF_LEFT;
2004 rightFlag = BF_BOTTOM;
2005 lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
2006 shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
2008 SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
2009 SetRect(&sideRect, R.left+2, R.top, R.right-2+selectedOffset, R.bottom);
2010 SetRect(&bottomRect, R.right-2, R.top, R.right, R.bottom);
2011 SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);
2012 SetRect(&shadeRect, R.left+1, R.bottom-2, R.left+2, R.bottom-1);
2015 leftFlag = BF_LEFT; topFlag = BF_TOP;
2016 rightFlag = BF_RIGHT;
2017 lightFlag = BF_DIAGONAL_ENDTOPRIGHT;
2018 shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT;
2020 SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
2021 SetRect(&sideRect, R.left, R.top+2, R.right, R.bottom-1+selectedOffset);
2022 SetRect(&bottomRect, R.left, R.bottom-1, R.right, R.bottom);
2023 SetRect(&lightRect, R.left, R.top, R.left+3, R.top+3);
2024 SetRect(&shadeRect, R.right-2, R.top+1, R.right-1, R.top+2);
2027 leftFlag = BF_TOP; topFlag = BF_RIGHT;
2028 rightFlag = BF_BOTTOM;
2029 lightFlag = BF_DIAGONAL_ENDTOPLEFT;
2030 shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
2032 SetRect(&topRect, R.left, R.top+lOffset, R.right, R.bottom-rOffset);
2033 SetRect(&sideRect, R.left+2-selectedOffset, R.top, R.right-2, R.bottom);
2034 SetRect(&bottomRect, R.left, R.top, R.left+2, R.bottom);
2035 SetRect(&lightRect, R.right-3, R.top, R.right-1, R.top+2);
2036 SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
2039 leftFlag = BF_LEFT; topFlag = BF_BOTTOM;
2040 rightFlag = BF_RIGHT;
2041 lightFlag = BF_DIAGONAL_ENDTOPLEFT;
2042 shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT;
2044 SetRect(&topRect, R.left+lOffset, R.top, R.right-rOffset, R.bottom);
2045 SetRect(&sideRect, R.left, R.top+2-selectedOffset, R.right, R.bottom-2);
2046 SetRect(&bottomRect, R.left, R.top, R.right, R.top+2);
2047 SetRect(&lightRect, R.left, R.bottom-3, R.left+2, R.bottom-1);
2048 SetRect(&shadeRect, R.right-2, R.bottom-3, R.right, R.bottom-1);
2053 FillRect(hdc, &R, (HBRUSH) (COLOR_3DFACE+1) );
2056 DrawEdge(hdc, &topRect, EDGE_RAISED, BF_SOFT | topFlag);
2060 DrawEdge(hdc, &bottomRect, EDGE_RAISED, BF_SOFT | topFlag);
2067 DrawEdge(hdc, &sideRect, EDGE_RAISED, BF_SOFT | leftFlag | rightFlag);
2069 /* Tab Diagonal Corners */
2071 DrawEdge(hdc, &lightRect, EDGE_RAISED, BF_SOFT | lightFlag);
2074 DrawEdge(hdc, &shadeRect, EDGE_RAISED, BF_SOFT | shadeFlag);
2078 draw_extension (GtkStyle * style,
2080 GtkStateType state_type,
2081 GtkShadowType shadow_type,
2082 GdkRectangle * area,
2084 const gchar * detail,
2086 gint y, gint width, gint height, GtkPositionType gap_side)
2088 if (widget && GTK_IS_NOTEBOOK (widget) && detail && !strcmp (detail, "tab"))
2090 GtkNotebook *notebook = GTK_NOTEBOOK (widget);
2091 gint x2, y2, w2, h2;
2092 int tab_part = XP_THEME_ELEMENT_TAB_ITEM;
2093 int real_gap_side = gtk_notebook_get_tab_pos (notebook);
2095 /* why this differs from the above gap_side, i have no idea... */
2101 if (xp_theme_draw (window, tab_part,
2102 style, x2, y2, w2, h2, (real_gap_side == GTK_POS_TOP ? state_type : GTK_STATE_SELECTED), area))
2105 } else if (real_gap_side == GTK_POS_TOP || real_gap_side == GTK_POS_BOTTOM) {
2106 /* experimental tab-drawing code from mozilla */
2111 dc = get_window_dc(style, window, state_type, x, y, width, height, &rect);
2113 if (real_gap_side == GTK_POS_TOP)
2115 else if (real_gap_side == GTK_POS_BOTTOM)
2116 aPosition = BF_BOTTOM;
2117 else if (real_gap_side == GTK_POS_LEFT)
2118 aPosition = BF_LEFT;
2120 aPosition = BF_RIGHT;
2123 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2124 DrawTab (dc, rect, aPosition, state_type != GTK_STATE_PRELIGHT, (real_gap_side != GTK_POS_LEFT), (real_gap_side != GTK_POS_RIGHT));
2126 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2128 release_window_dc (style, window, state_type);
2131 parent_class->draw_extension
2132 (style, window, state_type, shadow_type, area, widget, detail,
2133 x, y, width, height, gap_side);
2137 draw_box_gap (GtkStyle * style, GdkWindow * window, GtkStateType state_type,
2138 GtkShadowType shadow_type, GdkRectangle * area,
2139 GtkWidget * widget, const gchar * detail, gint x,
2140 gint y, gint width, gint height, GtkPositionType gap_side,
2141 gint gap_x, gint gap_width)
2143 if (GTK_IS_NOTEBOOK (widget) && detail && !strcmp (detail, "notebook"))
2145 if (xp_theme_draw (window, XP_THEME_ELEMENT_TAB_PANE, style, x,
2146 y, width, height, state_type, area))
2151 parent_class->draw_box_gap (style, window, state_type, shadow_type,
2152 area, widget, detail, x, y, width, height,
2153 gap_side, gap_x, gap_width);
2157 draw_flat_box (GtkStyle * style, GdkWindow * window,
2158 GtkStateType state_type, GtkShadowType shadow_type,
2159 GdkRectangle * area, GtkWidget * widget,
2160 const gchar * detail, gint x, gint y, gint width, gint height)
2162 if (detail && !strcmp (detail, "checkbutton"))
2164 if (state_type == GTK_STATE_PRELIGHT)
2170 parent_class->draw_flat_box (style, window, state_type, shadow_type,
2171 area, widget, detail, x, y, width, height);
2175 draw_shadow (GtkStyle * style,
2177 GtkStateType state_type,
2178 GtkShadowType shadow_type,
2179 GdkRectangle * area,
2181 const gchar * detail, gint x, gint y, gint width, gint height)
2183 gboolean is_handlebox_grippie = (detail && !strcmp (detail, "handlebox"));
2185 if (is_combo_box_child (widget)
2186 && combo_box_draw_box (style, window, state_type, shadow_type,
2187 area, widget, detail, x, y, width, height))
2191 if (detail && !strcmp (detail, "entry"))
2193 if (xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT, style,
2194 x, y, width, height, state_type, area))
2200 if (is_handlebox_grippie
2201 || (widget && (shadow_type == GTK_SHADOW_ETCHED_IN)
2202 && (GTK_IS_MENU_BAR (widget) || GTK_IS_TOOLBAR (widget)
2203 || GTK_IS_HANDLE_BOX (widget))))
2207 gint thickness_light;
2208 gint thickness_dark;
2211 gc1 = style->light_gc[state_type];
2212 gc2 = style->dark_gc[state_type];
2214 sanitize_size (window, &width, &height);
2218 gdk_gc_set_clip_rectangle (gc1, area);
2219 gdk_gc_set_clip_rectangle (gc2, area);
2220 if (shadow_type == GTK_SHADOW_IN ||
2221 shadow_type == GTK_SHADOW_OUT)
2223 gdk_gc_set_clip_rectangle (style->black_gc, area);
2224 gdk_gc_set_clip_rectangle (style->
2230 if (style->xthickness > 0)
2232 if (style->xthickness > 1)
2234 thickness_light = 1;
2237 for (i = 0; i < thickness_dark; i++)
2239 if (!is_handlebox_grippie)
2240 gdk_draw_line (window, gc1,
2244 y + height - i - 1);
2245 if (is_handlebox_grippie
2247 && GTK_IS_MENU_BAR (widget)))
2248 gdk_draw_line (window, gc2, x + i,
2250 y + height - i - 1);
2253 for (i = 0; i < thickness_light; i++)
2255 if (is_handlebox_grippie
2257 && GTK_IS_MENU_BAR (widget)))
2258 gdk_draw_line (window, gc1,
2259 x + thickness_dark + i,
2260 y + thickness_dark + i,
2261 x + thickness_dark + i,
2263 thickness_dark - i -
2265 if (!is_handlebox_grippie)
2266 gdk_draw_line (window, gc2,
2268 thickness_light - i -
2270 y + thickness_dark + i,
2272 thickness_light - i -
2275 thickness_light - 1);
2280 gdk_draw_line (window,
2281 style->dark_gc[state_type],
2282 x, y, x, y + height);
2283 gdk_draw_line (window,
2284 style->dark_gc[state_type],
2285 x + width, y, x + width,
2290 if (style->ythickness > 0)
2292 if (style->ythickness > 1)
2294 thickness_light = 1;
2297 for (i = 0; i < thickness_dark; i++)
2299 gdk_draw_line (window, gc1,
2303 y + height - i - 1);
2305 if (widget && GTK_IS_MENU_BAR (widget))
2306 gdk_draw_line (window, gc2,
2313 for (i = 0; i < thickness_light; i++)
2315 gdk_draw_line (window, gc2,
2316 x + thickness_dark + i,
2318 thickness_light - i - 1,
2320 thickness_light - 1,
2322 thickness_light - i - 1);
2324 if (widget && GTK_IS_MENU_BAR (widget))
2325 gdk_draw_line (window, gc1,
2326 x + thickness_dark + i,
2327 y + thickness_dark + i,
2329 thickness_dark - i - 2,
2330 y + thickness_dark +
2336 gdk_draw_line (window,
2337 style->dark_gc[state_type],
2338 x, y, x + width, y);
2340 gdk_draw_line (window,
2341 style->dark_gc[state_type],
2342 x, y + height, x + width,
2350 gdk_gc_set_clip_rectangle (gc1, NULL);
2351 gdk_gc_set_clip_rectangle (gc2, NULL);
2352 if (shadow_type == GTK_SHADOW_IN ||
2353 shadow_type == GTK_SHADOW_OUT)
2355 gdk_gc_set_clip_rectangle (style->black_gc, NULL);
2356 gdk_gc_set_clip_rectangle (style->
2364 parent_class->draw_shadow (style, window, state_type, shadow_type, area,
2365 widget, detail, x, y, width, height);
2369 draw_hline (GtkStyle * style,
2371 GtkStateType state_type,
2372 GdkRectangle * area,
2374 const gchar * detail, gint x1, gint x2, gint y)
2376 parent_class->draw_hline (style, window, state_type, area, widget,
2381 draw_vline (GtkStyle * style,
2383 GtkStateType state_type,
2384 GdkRectangle * area,
2386 const gchar * detail, gint y1, gint y2, gint x)
2388 parent_class->draw_vline (style, window, state_type, area, widget,
2393 draw_slider (GtkStyle * style,
2395 GtkStateType state_type,
2396 GtkShadowType shadow_type,
2397 GdkRectangle * area,
2399 const gchar * detail,
2401 gint y, gint width, gint height, GtkOrientation orientation)
2403 if (GTK_IS_SCALE (widget) &&
2404 xp_theme_draw (window,
2406 GTK_ORIENTATION_VERTICAL) ?
2407 XP_THEME_ELEMENT_SCALE_SLIDER_V :
2408 XP_THEME_ELEMENT_SCALE_SLIDER_H), style, x, y, width,
2409 height, state_type, area))
2414 parent_class->draw_slider (style, window, state_type, shadow_type, area,
2415 widget, detail, x, y, width, height,
2420 draw_resize_grip (GtkStyle * style,
2422 GtkStateType state_type,
2423 GdkRectangle * area,
2425 const gchar * detail,
2426 GdkWindowEdge edge, gint x, gint y, gint width, gint height)
2428 if (detail && !strcmp (detail, "statusbar"))
2431 (window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width,
2432 height, state_type, area))
2436 HDC dc = get_window_dc(style, window, state_type, x, y, width, height, &rect);
2439 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], area);
2440 DrawFrameControl(dc, &rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
2441 release_window_dc(style, window, state_type);
2443 gdk_gc_set_clip_rectangle (style->dark_gc[state_type], NULL);
2448 parent_class->draw_resize_grip (style, window, state_type, area,
2449 widget, detail, edge, x, y, width,
2454 draw_handle (GtkStyle * style,
2456 GtkStateType state_type,
2457 GtkShadowType shadow_type,
2458 GdkRectangle * area,
2460 const gchar * detail,
2462 gint y, gint width, gint height, GtkOrientation orientation)
2464 if (is_toolbar_child (widget))
2466 XpThemeElement hndl;
2468 sanitize_size (window, &width, &height);
2470 if (orientation == GTK_ORIENTATION_VERTICAL)
2471 hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V;
2473 hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H;
2475 if (xp_theme_draw (window, hndl, style, x, y, width, height,
2482 if (!GTK_IS_PANED (widget))
2484 gint xthick, ythick;
2485 GdkGC *light_gc, *dark_gc, *shadow_gc;
2488 sanitize_size (window, &width, &height);
2490 gtk_paint_box (style, window, state_type, shadow_type, area,
2491 widget, detail, x, y, width, height);
2493 light_gc = style->light_gc[state_type];
2494 dark_gc = style->dark_gc[state_type];
2495 shadow_gc = style->mid_gc[state_type];
2497 xthick = style->xthickness;
2498 ythick = style->ythickness;
2500 dest.x = x + xthick;
2501 dest.y = y + ythick;
2502 dest.width = width - (xthick * 2);
2503 dest.height = height - (ythick * 2);
2505 if (dest.width < dest.height)
2510 gdk_gc_set_clip_rectangle (light_gc, &dest);
2511 gdk_gc_set_clip_rectangle (dark_gc, &dest);
2512 gdk_gc_set_clip_rectangle (shadow_gc, &dest);
2514 if (dest.width < dest.height)
2516 gdk_draw_line (window, light_gc, dest.x, dest.y, dest.x,
2518 gdk_draw_line (window, dark_gc, dest.x + (dest.width / 2),
2519 dest.y, dest.x + (dest.width / 2),
2521 gdk_draw_line (window, shadow_gc, dest.x + dest.width,
2522 dest.y, dest.x + dest.width, dest.height);
2526 gdk_draw_line (window, light_gc, dest.x, dest.y,
2527 dest.x + dest.width, dest.y);
2528 gdk_draw_line (window, dark_gc, dest.x,
2529 dest.y + (dest.height / 2),
2530 dest.x + dest.width,
2531 dest.y + (dest.height / 2));
2532 gdk_draw_line (window, shadow_gc, dest.x,
2533 dest.y + dest.height, dest.x + dest.width,
2534 dest.y + dest.height);
2537 gdk_gc_set_clip_rectangle (shadow_gc, NULL);
2538 gdk_gc_set_clip_rectangle (light_gc, NULL);
2539 gdk_gc_set_clip_rectangle (dark_gc, NULL);
2544 msw_style_init_from_rc (GtkStyle * style, GtkRcStyle * rc_style)
2546 setup_system_font (style);
2547 setup_menu_settings (gtk_settings_get_default ());
2548 setup_system_styles (style);
2549 parent_class->init_from_rc (style, rc_style);
2553 msw_style_class_init (MswStyleClass * klass)
2555 GtkStyleClass *style_class = GTK_STYLE_CLASS (klass);
2557 parent_class = g_type_class_peek_parent (klass);
2559 style_class->init_from_rc = msw_style_init_from_rc;
2560 style_class->draw_arrow = draw_arrow;
2561 style_class->draw_box = draw_box;
2562 style_class->draw_check = draw_check;
2563 style_class->draw_option = draw_option;
2564 style_class->draw_tab = draw_tab;
2565 style_class->draw_flat_box = draw_flat_box;
2566 style_class->draw_expander = draw_expander;
2567 style_class->draw_extension = draw_extension;
2568 style_class->draw_box_gap = draw_box_gap;
2569 style_class->draw_shadow = draw_shadow;
2570 style_class->draw_hline = draw_hline;
2571 style_class->draw_vline = draw_vline;
2572 style_class->draw_handle = draw_handle;
2573 style_class->draw_resize_grip = draw_resize_grip;
2574 style_class->draw_slider = draw_slider;
2577 GType msw_type_style = 0;
2580 msw_style_register_type (GTypeModule * module)
2582 static const GTypeInfo object_info = {
2583 sizeof (MswStyleClass),
2584 (GBaseInitFunc) NULL,
2585 (GBaseFinalizeFunc) NULL,
2586 (GClassInitFunc) msw_style_class_init,
2587 NULL, /* class_finalize */
2588 NULL, /* class_data */
2590 0, /* n_preallocs */
2591 (GInstanceInitFunc) NULL,
2594 msw_type_style = g_type_module_register_type (module,
2601 msw_style_init (void)
2604 msw_style_setup_system_settings ();
2605 setup_msw_rc_style ();