| 1 |
/* MS-Windows Engine (aka GTK-Wimp) |
| 2 |
* |
| 3 |
* Copyright (C) 2003, 2004 Raymond Penners <[email protected]> |
| 4 |
* Copyright (C) 2006 Hong Jen Yee (PCMan) <[email protected]> |
| 5 |
* Includes code adapted from redmond95 by Owen Taylor, and |
| 6 |
* gtk-nativewin by Evan Martin |
| 7 |
* |
| 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. |
| 12 |
* |
| 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. |
| 17 |
* |
| 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. |
| 22 |
*/ |
| 23 |
|
| 24 |
/* |
| 25 |
* Useful resources: |
| 26 |
* |
| 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 |
| 31 |
*/ |
| 32 |
|
| 33 |
/* Include first, else we get redefinition warnings about STRICT */ |
| 34 |
#include "pango/pangowin32.h" |
| 35 |
|
| 36 |
#include "msw_style.h" |
| 37 |
#include "xp_theme.h" |
| 38 |
|
| 39 |
#include <windows.h> |
| 40 |
#include <math.h> |
| 41 |
#include <string.h> |
| 42 |
#include <stdio.h> |
| 43 |
|
| 44 |
#include "gdk/gdk.h" |
| 45 |
#include "gtk/gtk.h" |
| 46 |
|
| 47 |
#ifdef BUILDING_STANDALONE |
| 48 |
#include "gdk/gdkwin32.h" |
| 49 |
#else |
| 50 |
#include "gdk/win32/gdkwin32.h" |
| 51 |
#endif |
| 52 |
|
| 53 |
|
| 54 |
#define DETAIL(xx) ((detail) && (!strcmp(xx, detail))) |
| 55 |
|
| 56 |
|
| 57 |
/* Default values, not normally used |
| 58 |
*/ |
| 59 |
static const GtkRequisition default_option_indicator_size = { 9, 8 }; |
| 60 |
static const GtkBorder default_option_indicator_spacing = { 7, 5, 2, 2 }; |
| 61 |
|
| 62 |
static GtkStyleClass *parent_class; |
| 63 |
static HBRUSH g_dither_brush = NULL; |
| 64 |
|
| 65 |
static HPEN g_light_pen = NULL; |
| 66 |
static HPEN g_dark_pen = NULL; |
| 67 |
|
| 68 |
typedef enum |
| 69 |
{ |
| 70 |
CHECK_AA, |
| 71 |
CHECK_BASE, |
| 72 |
CHECK_BLACK, |
| 73 |
CHECK_DARK, |
| 74 |
CHECK_LIGHT, |
| 75 |
CHECK_MID, |
| 76 |
CHECK_TEXT, |
| 77 |
CHECK_INCONSISTENT, |
| 78 |
RADIO_BASE, |
| 79 |
RADIO_BLACK, |
| 80 |
RADIO_DARK, |
| 81 |
RADIO_LIGHT, |
| 82 |
RADIO_MID, |
| 83 |
RADIO_TEXT |
| 84 |
} Part; |
| 85 |
|
| 86 |
#define PART_SIZE 13 |
| 87 |
|
| 88 |
static const unsigned char check_aa_bits[] = { |
| 89 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 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 |
| 96 |
}; |
| 97 |
static const unsigned char check_base_bits[] = { |
| 98 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 99 |
0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 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, 0x00, 0x00, 0x00, 0x00, |
| 104 |
0x00, 0x00, 0x00, 0x00 |
| 105 |
}; |
| 106 |
static const unsigned char check_black_bits[] = { |
| 107 |
0x00, 0x00, 0x00, 0x00, 0xfe, 0x0f, 0x00, 0x00, |
| 108 |
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 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 |
0x00, 0x00, 0x00, 0x00 |
| 114 |
}; |
| 115 |
static const unsigned char check_dark_bits[] = { |
| 116 |
0xff, 0x1f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 117 |
0x01, 0x00, 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 |
| 123 |
}; |
| 124 |
static const unsigned char check_light_bits[] = { |
| 125 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, |
| 126 |
0x00, 0x10, 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 |
0xfe, 0x1f, 0x00, 0x00 |
| 132 |
}; |
| 133 |
static const unsigned char check_mid_bits[] = { |
| 134 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 135 |
0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 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, 0xfc, 0x0f, 0x00, 0x00, |
| 140 |
0x00, 0x00, 0x00, 0x00 |
| 141 |
}; |
| 142 |
static const unsigned char check_text_bits[] = { |
| 143 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 144 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, |
| 145 |
0x00, 0x03, 0x00, 0x00, 0x88, 0x03, 0x00, 0x00, |
| 146 |
0xd8, 0x01, 0x00, 0x00, 0xf8, 0x00, 0x00, 0x00, |
| 147 |
0x70, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, |
| 148 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 149 |
0x00, 0x00, 0x00, 0x00 |
| 150 |
}; |
| 151 |
static const unsigned char check_inconsistent_bits[] = { |
| 152 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 153 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 154 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 155 |
0xf0, 0x03, 0x00, 0x00, 0xf0, 0x03, 0x00, 0x00, |
| 156 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 157 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 158 |
0x00, 0x00, 0x00, 0x00 |
| 159 |
}; |
| 160 |
static const unsigned char radio_base_bits[] = { |
| 161 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 162 |
0xf0, 0x01, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, |
| 163 |
0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, |
| 164 |
0xfc, 0x07, 0x00, 0x00, 0xfc, 0x07, 0x00, 0x00, |
| 165 |
0xfc, 0x07, 0x00, 0x00, 0xf8, 0x03, 0x00, 0x00, |
| 166 |
0xf0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 167 |
0x00, 0x00, 0x00, 0x00 |
| 168 |
}; |
| 169 |
static const unsigned char radio_black_bits[] = { |
| 170 |
0x00, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, |
| 171 |
0x0c, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, |
| 172 |
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 173 |
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 174 |
0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, |
| 175 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 176 |
0x00, 0x00, 0x00, 0x00 |
| 177 |
}; |
| 178 |
static const unsigned char radio_dark_bits[] = { |
| 179 |
0xf0, 0x01, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00, |
| 180 |
0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 181 |
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 182 |
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, |
| 183 |
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, |
| 184 |
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 185 |
0x00, 0x00, 0x00, 0x00 |
| 186 |
}; |
| 187 |
static const unsigned char radio_light_bits[] = { |
| 188 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 189 |
0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, |
| 190 |
0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, |
| 191 |
0x00, 0x10, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, |
| 192 |
0x00, 0x10, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, |
| 193 |
0x00, 0x08, 0x00, 0x00, 0x0c, 0x06, 0x00, 0x00, |
| 194 |
0xf0, 0x01, 0x00, 0x00 |
| 195 |
}; |
| 196 |
static const unsigned char radio_mid_bits[] = { |
| 197 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 198 |
0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, |
| 199 |
0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, |
| 200 |
0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, |
| 201 |
0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, |
| 202 |
0x0c, 0x06, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, |
| 203 |
0x00, 0x00, 0x00, 0x00 |
| 204 |
}; |
| 205 |
static const unsigned char radio_text_bits[] = { |
| 206 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 207 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 208 |
0xe0, 0x00, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, |
| 209 |
0xf0, 0x01, 0x00, 0x00, 0xf0, 0x01, 0x00, 0x00, |
| 210 |
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 211 |
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 212 |
0x00, 0x00, 0x00, 0x00 |
| 213 |
}; |
| 214 |
|
| 215 |
static struct |
| 216 |
{ |
| 217 |
const unsigned char *bits; |
| 218 |
cairo_surface_t *bmap; |
| 219 |
} parts[] = { |
| 220 |
{ check_aa_bits, NULL }, |
| 221 |
{ check_base_bits, NULL }, |
| 222 |
{ check_black_bits, NULL }, |
| 223 |
{ check_dark_bits, NULL }, |
| 224 |
{ check_light_bits, NULL }, |
| 225 |
{ check_mid_bits, NULL }, |
| 226 |
{ check_text_bits, NULL }, |
| 227 |
{ check_inconsistent_bits, NULL }, |
| 228 |
{ radio_base_bits, NULL }, |
| 229 |
{ radio_black_bits, NULL }, |
| 230 |
{ radio_dark_bits, NULL }, |
| 231 |
{ radio_light_bits, NULL }, |
| 232 |
{ radio_mid_bits, NULL }, |
| 233 |
{ radio_text_bits, NULL } |
| 234 |
}; |
| 235 |
|
| 236 |
static void |
| 237 |
_cairo_draw_line (cairo_t *cr, |
| 238 |
GdkColor *color, |
| 239 |
gint x1, |
| 240 |
gint y1, |
| 241 |
gint x2, |
| 242 |
gint y2) |
| 243 |
{ |
| 244 |
cairo_save (cr); |
| 245 |
|
| 246 |
gdk_cairo_set_source_color (cr, color); |
| 247 |
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); |
| 248 |
cairo_set_line_width (cr, 1.0); |
| 249 |
|
| 250 |
cairo_move_to (cr, x1 + 0.5, y1 + 0.5); |
| 251 |
cairo_line_to (cr, x2 + 0.5, y2 + 0.5); |
| 252 |
cairo_stroke (cr); |
| 253 |
|
| 254 |
cairo_restore (cr); |
| 255 |
} |
| 256 |
|
| 257 |
static void |
| 258 |
_cairo_draw_rectangle (cairo_t *cr, |
| 259 |
GdkColor *color, |
| 260 |
gboolean filled, |
| 261 |
gint x, |
| 262 |
gint y, |
| 263 |
gint width, |
| 264 |
gint height) |
| 265 |
{ |
| 266 |
gdk_cairo_set_source_color (cr, color); |
| 267 |
|
| 268 |
if (filled) |
| 269 |
{ |
| 270 |
cairo_rectangle (cr, x, y, width, height); |
| 271 |
cairo_fill (cr); |
| 272 |
} |
| 273 |
else |
| 274 |
{ |
| 275 |
cairo_rectangle (cr, x + 0.5, y + 0.5, width, height); |
| 276 |
cairo_stroke (cr); |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
static gboolean |
| 281 |
get_system_font (XpThemeClass klazz, XpThemeFont type, LOGFONTW *out_lf) |
| 282 |
{ |
| 283 |
if (xp_theme_get_system_font (klazz, type, out_lf)) |
| 284 |
{ |
| 285 |
return TRUE; |
| 286 |
} |
| 287 |
else |
| 288 |
{ |
| 289 |
/* Use wide char versions here, as the theming functions only support |
| 290 |
* wide chars versions of the structures. */ |
| 291 |
NONCLIENTMETRICSW ncm; |
| 292 |
|
| 293 |
ncm.cbSize = sizeof (NONCLIENTMETRICSW); |
| 294 |
|
| 295 |
if (SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, |
| 296 |
sizeof (NONCLIENTMETRICSW), &ncm, 0)) |
| 297 |
{ |
| 298 |
if (type == XP_THEME_FONT_CAPTION) |
| 299 |
*out_lf = ncm.lfCaptionFont; |
| 300 |
else if (type == XP_THEME_FONT_MENU) |
| 301 |
*out_lf = ncm.lfMenuFont; |
| 302 |
else if (type == XP_THEME_FONT_STATUS) |
| 303 |
*out_lf = ncm.lfStatusFont; |
| 304 |
else |
| 305 |
*out_lf = ncm.lfMessageFont; |
| 306 |
|
| 307 |
return TRUE; |
| 308 |
} |
| 309 |
} |
| 310 |
|
| 311 |
return FALSE; |
| 312 |
} |
| 313 |
|
| 314 |
static char * |
| 315 |
sys_font_to_pango_font (XpThemeClass klazz, XpThemeFont type, char *buf, |
| 316 |
size_t bufsiz) |
| 317 |
{ |
| 318 |
LOGFONTW lf; |
| 319 |
|
| 320 |
if (get_system_font (klazz, type, &lf)) |
| 321 |
{ |
| 322 |
PangoFontDescription *desc = NULL; |
| 323 |
int pt_size; |
| 324 |
const char *font; |
| 325 |
|
| 326 |
desc = pango_win32_font_description_from_logfontw (&lf); |
| 327 |
if (!desc) |
| 328 |
return NULL; |
| 329 |
|
| 330 |
font = pango_font_description_to_string (desc); |
| 331 |
pt_size = pango_font_description_get_size (desc); |
| 332 |
|
| 333 |
if (!(font && *font)) |
| 334 |
{ |
| 335 |
pango_font_description_free (desc); |
| 336 |
return NULL; |
| 337 |
} |
| 338 |
|
| 339 |
if (pt_size == 0) |
| 340 |
{ |
| 341 |
HDC hDC; |
| 342 |
HWND hwnd; |
| 343 |
|
| 344 |
hwnd = GetDesktopWindow (); |
| 345 |
hDC = GetDC (hwnd); |
| 346 |
|
| 347 |
if (hDC) |
| 348 |
pt_size = -MulDiv (lf.lfHeight, 72, GetDeviceCaps (hDC, LOGPIXELSY)); |
| 349 |
else |
| 350 |
pt_size = 10; |
| 351 |
|
| 352 |
if (hDC) |
| 353 |
ReleaseDC (hwnd, hDC); |
| 354 |
|
| 355 |
g_snprintf (buf, bufsiz, "%s %d", font, pt_size); |
| 356 |
} |
| 357 |
else |
| 358 |
{ |
| 359 |
g_snprintf (buf, bufsiz, "%s", font); |
| 360 |
} |
| 361 |
|
| 362 |
if (desc) |
| 363 |
pango_font_description_free (desc); |
| 364 |
|
| 365 |
return buf; |
| 366 |
} |
| 367 |
|
| 368 |
return NULL; |
| 369 |
} |
| 370 |
|
| 371 |
/* missing from ms's header files */ |
| 372 |
#ifndef SPI_GETMENUSHOWDELAY |
| 373 |
#define SPI_GETMENUSHOWDELAY 106 |
| 374 |
#endif |
| 375 |
|
| 376 |
/* I don't know the proper XP theme class for things like |
| 377 |
HIGHLIGHTTEXT, so we'll just define it to be "BUTTON" |
| 378 |
for now */ |
| 379 |
#define XP_THEME_CLASS_TEXT XP_THEME_CLASS_BUTTON |
| 380 |
|
| 381 |
#define WIN95_VERSION 0x400 |
| 382 |
#define WIN2K_VERSION 0x500 |
| 383 |
#define WINXP_VERSION 0x501 |
| 384 |
#define WIN2K3_VERSION 0x502 |
| 385 |
#define VISTA_VERSION 0x600 |
| 386 |
|
| 387 |
static gint32 |
| 388 |
get_windows_version () |
| 389 |
{ |
| 390 |
static gint32 version = 0; |
| 391 |
static gboolean have_version = FALSE; |
| 392 |
|
| 393 |
if (!have_version) |
| 394 |
{ |
| 395 |
OSVERSIONINFOEX osvi; |
| 396 |
have_version = TRUE; |
| 397 |
|
| 398 |
ZeroMemory (&osvi, sizeof (OSVERSIONINFOEX)); |
| 399 |
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEX); |
| 400 |
|
| 401 |
GetVersionEx((OSVERSIONINFO*) &osvi); |
| 402 |
|
| 403 |
version = (osvi.dwMajorVersion & 0xff) << 8 | (osvi.dwMinorVersion & 0xff); |
| 404 |
} |
| 405 |
|
| 406 |
return version; |
| 407 |
} |
| 408 |
|
| 409 |
static void |
| 410 |
setup_menu_settings (GtkSettings *settings) |
| 411 |
{ |
| 412 |
int menu_delay; |
| 413 |
GObjectClass *klazz = G_OBJECT_GET_CLASS (G_OBJECT (settings)); |
| 414 |
|
| 415 |
if (get_windows_version () > WIN95_VERSION) |
| 416 |
{ |
| 417 |
if (SystemParametersInfo (SPI_GETMENUSHOWDELAY, 0, &menu_delay, 0)) |
| 418 |
{ |
| 419 |
if (klazz) |
| 420 |
{ |
| 421 |
if (g_object_class_find_property |
| 422 |
(klazz, "gtk-menu-bar-popup-delay")) |
| 423 |
{ |
| 424 |
g_object_set (settings, |
| 425 |
"gtk-menu-bar-popup-delay", 0, NULL); |
| 426 |
} |
| 427 |
if (g_object_class_find_property |
| 428 |
(klazz, "gtk-menu-popup-delay")) |
| 429 |
{ |
| 430 |
g_object_set (settings, |
| 431 |
"gtk-menu-popup-delay", menu_delay, NULL); |
| 432 |
} |
| 433 |
if (g_object_class_find_property |
| 434 |
(klazz, "gtk-menu-popdown-delay")) |
| 435 |
{ |
| 436 |
g_object_set (settings, |
| 437 |
"gtk-menu-popdown-delay", menu_delay, NULL); |
| 438 |
} |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
} |
| 443 |
|
| 444 |
void |
| 445 |
msw_style_setup_system_settings (void) |
| 446 |
{ |
| 447 |
GtkSettings *settings; |
| 448 |
int cursor_blink_time; |
| 449 |
|
| 450 |
settings = gtk_settings_get_default (); |
| 451 |
if (!settings) |
| 452 |
return; |
| 453 |
|
| 454 |
cursor_blink_time = GetCaretBlinkTime (); |
| 455 |
g_object_set (settings, "gtk-cursor-blink", cursor_blink_time > 0, NULL); |
| 456 |
|
| 457 |
if (cursor_blink_time > 0) |
| 458 |
{ |
| 459 |
g_object_set (settings, "gtk-cursor-blink-time", |
| 460 |
2 * cursor_blink_time, NULL); |
| 461 |
} |
| 462 |
|
| 463 |
g_object_set (settings, "gtk-double-click-distance", |
| 464 |
GetSystemMetrics (SM_CXDOUBLECLK), NULL); |
| 465 |
g_object_set (settings, "gtk-double-click-time", GetDoubleClickTime (), |
| 466 |
NULL); |
| 467 |
g_object_set (settings, "gtk-dnd-drag-threshold", |
| 468 |
GetSystemMetrics (SM_CXDRAG), NULL); |
| 469 |
|
| 470 |
setup_menu_settings (settings); |
| 471 |
|
| 472 |
/* |
| 473 |
http://developer.gnome.org/doc/API/2.0/gtk/GtkSettings.html |
| 474 |
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/systemparametersinfo.asp |
| 475 |
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/getsystemmetrics.asp */ |
| 476 |
} |
| 477 |
|
| 478 |
static void |
| 479 |
setup_system_font (GtkStyle *style) |
| 480 |
{ |
| 481 |
char buf[256], *font; /* It's okay, lfFaceName is smaller than 32 |
| 482 |
chars */ |
| 483 |
|
| 484 |
if ((font = sys_font_to_pango_font (XP_THEME_CLASS_TEXT, |
| 485 |
XP_THEME_FONT_MESSAGE, |
| 486 |
buf, sizeof (buf))) != NULL) |
| 487 |
{ |
| 488 |
if (style->font_desc) |
| 489 |
{ |
| 490 |
pango_font_description_free (style->font_desc); |
| 491 |
} |
| 492 |
|
| 493 |
style->font_desc = pango_font_description_from_string (font); |
| 494 |
} |
| 495 |
} |
| 496 |
|
| 497 |
static void |
| 498 |
sys_color_to_gtk_color (XpThemeClass klazz, int id, GdkColor * pcolor) |
| 499 |
{ |
| 500 |
DWORD color; |
| 501 |
|
| 502 |
if (!xp_theme_get_system_color (klazz, id, &color)) |
| 503 |
color = GetSysColor (id); |
| 504 |
|
| 505 |
pcolor->pixel = color; |
| 506 |
pcolor->red = (GetRValue (color) << 8) | GetRValue (color); |
| 507 |
pcolor->green = (GetGValue (color) << 8) | GetGValue (color); |
| 508 |
pcolor->blue = (GetBValue (color) << 8) | GetBValue (color); |
| 509 |
} |
| 510 |
|
| 511 |
static int |
| 512 |
get_system_metric (XpThemeClass klazz, int id) |
| 513 |
{ |
| 514 |
int rval; |
| 515 |
|
| 516 |
if (!xp_theme_get_system_metric (klazz, id, &rval)) |
| 517 |
rval = GetSystemMetrics (id); |
| 518 |
|
| 519 |
return rval; |
| 520 |
} |
| 521 |
|
| 522 |
static void |
| 523 |
setup_msw_rc_style (void) |
| 524 |
{ |
| 525 |
char buf[1024], font_buf[256], *font_ptr; |
| 526 |
char menu_bar_prelight_str[128]; |
| 527 |
|
| 528 |
GdkColor menu_color; |
| 529 |
GdkColor menu_text_color; |
| 530 |
GdkColor tooltip_back; |
| 531 |
GdkColor tooltip_fore; |
| 532 |
GdkColor btn_fore; |
| 533 |
GdkColor btn_face; |
| 534 |
GdkColor progress_back; |
| 535 |
|
| 536 |
GdkColor fg_prelight; |
| 537 |
GdkColor bg_prelight; |
| 538 |
GdkColor base_prelight; |
| 539 |
GdkColor text_prelight; |
| 540 |
|
| 541 |
/* Prelight */ |
| 542 |
sys_color_to_gtk_color (get_windows_version () >= VISTA_VERSION ? XP_THEME_CLASS_MENU : XP_THEME_CLASS_TEXT, |
| 543 |
get_windows_version () >= VISTA_VERSION ? COLOR_MENUTEXT : COLOR_HIGHLIGHTTEXT, |
| 544 |
&fg_prelight); |
| 545 |
sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, &bg_prelight); |
| 546 |
sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHT, |
| 547 |
&base_prelight); |
| 548 |
sys_color_to_gtk_color (XP_THEME_CLASS_TEXT, COLOR_HIGHLIGHTTEXT, |
| 549 |
&text_prelight); |
| 550 |
|
| 551 |
sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENUTEXT, |
| 552 |
&menu_text_color); |
| 553 |
sys_color_to_gtk_color (XP_THEME_CLASS_MENU, COLOR_MENU, &menu_color); |
| 554 |
|
| 555 |
/* tooltips */ |
| 556 |
sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOTEXT, |
| 557 |
&tooltip_fore); |
| 558 |
sys_color_to_gtk_color (XP_THEME_CLASS_TOOLTIP, COLOR_INFOBK, |
| 559 |
&tooltip_back); |
| 560 |
|
| 561 |
/* text on push buttons. TODO: button shadows, backgrounds, and |
| 562 |
highlights */ |
| 563 |
sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNTEXT, &btn_fore); |
| 564 |
sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_BTNFACE, &btn_face); |
| 565 |
|
| 566 |
/* progress bar background color */ |
| 567 |
sys_color_to_gtk_color (XP_THEME_CLASS_PROGRESS, COLOR_HIGHLIGHT, |
| 568 |
&progress_back); |
| 569 |
|
| 570 |
/* Enable coloring for menus. */ |
| 571 |
font_ptr = |
| 572 |
sys_font_to_pango_font (XP_THEME_CLASS_MENU, XP_THEME_FONT_MENU, |
| 573 |
font_buf, sizeof (font_buf)); |
| 574 |
g_snprintf (buf, sizeof (buf), |
| 575 |
"style \"msw-menu\" = \"msw-default\"\n" "{\n" |
| 576 |
"GtkMenuItem::toggle-spacing = 8\n" |
| 577 |
"fg[PRELIGHT] = { %d, %d, %d }\n" |
| 578 |
"bg[PRELIGHT] = { %d, %d, %d }\n" |
| 579 |
"text[PRELIGHT] = { %d, %d, %d }\n" |
| 580 |
"base[PRELIGHT] = { %d, %d, %d }\n" |
| 581 |
"fg[NORMAL] = { %d, %d, %d }\n" |
| 582 |
"bg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n" |
| 583 |
"}widget_class \"*MenuItem*\" style \"msw-menu\"\n" |
| 584 |
"widget_class \"*GtkMenu\" style \"msw-menu\"\n" |
| 585 |
"widget_class \"*GtkMenuShell*\" style \"msw-menu\"\n", |
| 586 |
fg_prelight.red, fg_prelight.green, fg_prelight.blue, |
| 587 |
bg_prelight.red, bg_prelight.green, bg_prelight.blue, |
| 588 |
text_prelight.red, text_prelight.green, text_prelight.blue, |
| 589 |
base_prelight.red, base_prelight.green, base_prelight.blue, |
| 590 |
menu_text_color.red, menu_text_color.green, |
| 591 |
menu_text_color.blue, menu_color.red, menu_color.green, |
| 592 |
menu_color.blue, (font_ptr ? "font_name" : "#"), |
| 593 |
(font_ptr ? font_ptr : " font name should go here")); |
| 594 |
gtk_rc_parse_string (buf); |
| 595 |
|
| 596 |
if (xp_theme_is_active ()) |
| 597 |
{ |
| 598 |
*menu_bar_prelight_str = '\0'; |
| 599 |
} |
| 600 |
else |
| 601 |
{ |
| 602 |
g_snprintf (menu_bar_prelight_str, sizeof (menu_bar_prelight_str), |
| 603 |
"fg[PRELIGHT] = { %d, %d, %d }\n", |
| 604 |
menu_text_color.red, menu_text_color.green, |
| 605 |
menu_text_color.blue); |
| 606 |
} |
| 607 |
|
| 608 |
/* Enable coloring for menu bars. */ |
| 609 |
g_snprintf (buf, sizeof (buf), |
| 610 |
"style \"msw-menu-bar\" = \"msw-menu\"\n" |
| 611 |
"{\n" |
| 612 |
"bg[NORMAL] = { %d, %d, %d }\n" |
| 613 |
"%s" "GtkMenuBar::shadow-type = %d\n" |
| 614 |
/* |
| 615 |
FIXME: This should be enabled once gtk+ support |
| 616 |
GtkMenuBar::prelight-item style property. |
| 617 |
*/ |
| 618 |
/* "GtkMenuBar::prelight-item = 1\n" */ |
| 619 |
"}widget_class \"*MenuBar*\" style \"msw-menu-bar\"\n", |
| 620 |
btn_face.red, btn_face.green, btn_face.blue, |
| 621 |
menu_bar_prelight_str, xp_theme_is_active ()? 0 : 2); |
| 622 |
gtk_rc_parse_string (buf); |
| 623 |
|
| 624 |
g_snprintf (buf, sizeof (buf), |
| 625 |
"style \"msw-toolbar\" = \"msw-default\"\n" |
| 626 |
"{\n" |
| 627 |
"GtkHandleBox::shadow-type = %s\n" |
| 628 |
"GtkToolbar::shadow-type = %s\n" |
| 629 |
"}widget_class \"*HandleBox*\" style \"msw-toolbar\"\n", |
| 630 |
"etched-in", "etched-in"); |
| 631 |
gtk_rc_parse_string (buf); |
| 632 |
|
| 633 |
/* enable tooltip fonts */ |
| 634 |
font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS, |
| 635 |
font_buf, sizeof (font_buf)); |
| 636 |
g_snprintf (buf, sizeof (buf), |
| 637 |
"style \"msw-tooltips-caption\" = \"msw-default\"\n" |
| 638 |
"{fg[NORMAL] = { %d, %d, %d }\n" "%s = \"%s\"\n" |
| 639 |
"}widget \"gtk-tooltips.GtkLabel\" style \"msw-tooltips-caption\"\n" |
| 640 |
"widget \"gtk-tooltip.GtkLabel\" style \"msw-tooltips-caption\"\n", |
| 641 |
tooltip_fore.red, tooltip_fore.green, tooltip_fore.blue, |
| 642 |
(font_ptr ? "font_name" : "#"), |
| 643 |
(font_ptr ? font_ptr : " font name should go here")); |
| 644 |
gtk_rc_parse_string (buf); |
| 645 |
|
| 646 |
g_snprintf (buf, sizeof (buf), |
| 647 |
"style \"msw-tooltips\" = \"msw-default\"\n" |
| 648 |
"{bg[NORMAL] = { %d, %d, %d }\n" |
| 649 |
"}widget \"gtk-tooltips*\" style \"msw-tooltips\"\n" |
| 650 |
"widget \"gtk-tooltip*\" style \"msw-tooltips\"\n", |
| 651 |
tooltip_back.red, tooltip_back.green, tooltip_back.blue); |
| 652 |
gtk_rc_parse_string (buf); |
| 653 |
|
| 654 |
/* enable font theming for status bars */ |
| 655 |
font_ptr = sys_font_to_pango_font (XP_THEME_CLASS_STATUS, XP_THEME_FONT_STATUS, |
| 656 |
font_buf, sizeof (font_buf)); |
| 657 |
g_snprintf (buf, sizeof (buf), |
| 658 |
"style \"msw-status\" = \"msw-default\"\n" "{%s = \"%s\"\n" |
| 659 |
"bg[NORMAL] = { %d, %d, %d }\n" |
| 660 |
"}widget_class \"*Status*\" style \"msw-status\"\n", |
| 661 |
(font_ptr ? "font_name" : "#"), |
| 662 |
(font_ptr ? font_ptr : " font name should go here"), |
| 663 |
btn_face.red, btn_face.green, btn_face.blue); |
| 664 |
gtk_rc_parse_string (buf); |
| 665 |
|
| 666 |
/* enable coloring for text on buttons |
| 667 |
* TODO: use GetThemeMetric for the border and outside border */ |
| 668 |
g_snprintf (buf, sizeof (buf), |
| 669 |
"style \"msw-button\" = \"msw-default\"\n" |
| 670 |
"{\n" |
| 671 |
"bg[NORMAL] = { %d, %d, %d }\n" |
| 672 |
"bg[PRELIGHT] = { %d, %d, %d }\n" |
| 673 |
"bg[INSENSITIVE] = { %d, %d, %d }\n" |
| 674 |
"fg[PRELIGHT] = { %d, %d, %d }\n" |
| 675 |
"GtkButton::default-border = { 0, 0, 0, 0 }\n" |
| 676 |
"GtkButton::default-outside-border = { 0, 0, 0, 0 }\n" |
| 677 |
"GtkButton::child-displacement-x = %d\n" |
| 678 |
"GtkButton::child-displacement-y = %d\n" |
| 679 |
"GtkWidget::focus-padding = %d\n" |
| 680 |
"}widget_class \"*Button*\" style \"msw-button\"\n", |
| 681 |
btn_face.red, btn_face.green, btn_face.blue, |
| 682 |
btn_face.red, btn_face.green, btn_face.blue, |
| 683 |
btn_face.red, btn_face.green, btn_face.blue, |
| 684 |
btn_fore.red, btn_fore.green, btn_fore.blue, |
| 685 |
xp_theme_is_active ()? 0 : 1, |
| 686 |
xp_theme_is_active ()? 0 : 1, |
| 687 |
xp_theme_is_active ()? 1 : 2); |
| 688 |
gtk_rc_parse_string (buf); |
| 689 |
|
| 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", |
| 696 |
progress_back.red, |
| 697 |
progress_back.green, |
| 698 |
progress_back.blue, |
| 699 |
btn_face.red, btn_face.green, btn_face.blue); |
| 700 |
gtk_rc_parse_string (buf); |
| 701 |
|
| 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); |
| 716 |
|
| 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); |
| 730 |
|
| 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"); |
| 734 |
|
| 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); |
| 742 |
|
| 743 |
/* size of combo box toggle button */ |
| 744 |
g_snprintf (buf, sizeof (buf), |
| 745 |
"style \"msw-combobox-button\" = \"msw-default\"\n" |
| 746 |
"{\n" |
| 747 |
"xthickness = 0\n" |
| 748 |
"ythickness = 0\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" |
| 755 |
"}\n" |
| 756 |
"widget_class \"*ComboBox*ToggleButton*\" style \"msw-combobox-button\"\n"); |
| 757 |
gtk_rc_parse_string (buf); |
| 758 |
|
| 759 |
g_snprintf (buf, sizeof (buf), |
| 760 |
"style \"msw-combobox\" = \"msw-default\"\n" |
| 761 |
"{\n" |
| 762 |
"GtkComboBox::shadow-type = in\n" |
| 763 |
"xthickness = %d\n" |
| 764 |
"ythickness = %d\n" |
| 765 |
"}\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); |
| 770 |
|
| 771 |
/* size of tree view header */ |
| 772 |
g_snprintf (buf, sizeof (buf), |
| 773 |
"style \"msw-header-button\" = \"msw-default\"\n" |
| 774 |
"{\n" |
| 775 |
"xthickness = 0\n" |
| 776 |
"ythickness = 0\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" |
| 784 |
"}\n" |
| 785 |
"widget_class \"*TreeView*Button*\" style \"msw-header-button\"\n"); |
| 786 |
gtk_rc_parse_string (buf); |
| 787 |
|
| 788 |
/* FIXME: This should be enabled once gtk+ support GtkNotebok::prelight-tab */ |
| 789 |
/* enable prelight tab of GtkNotebook */ |
| 790 |
/* |
| 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); |
| 796 |
*/ |
| 797 |
|
| 798 |
/* FIXME: This should be enabled once gtk+ support GtkTreeView::full-row-focus */ |
| 799 |
/* |
| 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); |
| 805 |
*/ |
| 806 |
} |
| 807 |
|
| 808 |
static void |
| 809 |
setup_system_styles (GtkStyle *style) |
| 810 |
{ |
| 811 |
int i; |
| 812 |
|
| 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]); |
| 824 |
|
| 825 |
/* Default base */ |
| 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]); |
| 836 |
|
| 837 |
/* Default text */ |
| 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]); |
| 848 |
|
| 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]); |
| 860 |
|
| 861 |
for (i = 0; i < 5; i++) |
| 862 |
{ |
| 863 |
sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DSHADOW, |
| 864 |
&style->dark[i]); |
| 865 |
sys_color_to_gtk_color (XP_THEME_CLASS_BUTTON, COLOR_3DHILIGHT, |
| 866 |
&style->light[i]); |
| 867 |
|
| 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; |
| 872 |
|
| 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; |
| 878 |
} |
| 879 |
} |
| 880 |
|
| 881 |
static gboolean |
| 882 |
sanitize_size (GdkWindow *window, gint *width, gint *height) |
| 883 |
{ |
| 884 |
gboolean set_bg = FALSE; |
| 885 |
|
| 886 |
if ((*width == -1) && (*height == -1)) |
| 887 |
{ |
| 888 |
set_bg = GDK_IS_WINDOW (window); |
| 889 |
gdk_drawable_get_size (window, width, height); |
| 890 |
} |
| 891 |
else if (*width == -1) |
| 892 |
{ |
| 893 |
gdk_drawable_get_size (window, width, NULL); |
| 894 |
} |
| 895 |
else if (*height == -1) |
| 896 |
{ |
| 897 |
gdk_drawable_get_size (window, NULL, height); |
| 898 |
} |
| 899 |
|
| 900 |
return set_bg; |
| 901 |
} |
| 902 |
|
| 903 |
static XpThemeElement |
| 904 |
map_gtk_progress_bar_to_xp (GtkProgressBar *progress_bar, gboolean trough) |
| 905 |
{ |
| 906 |
XpThemeElement ret; |
| 907 |
|
| 908 |
switch (gtk_progress_bar_get_orientation (progress_bar)) |
| 909 |
{ |
| 910 |
case GTK_PROGRESS_LEFT_TO_RIGHT: |
| 911 |
case GTK_PROGRESS_RIGHT_TO_LEFT: |
| 912 |
ret = trough |
| 913 |
? XP_THEME_ELEMENT_PROGRESS_TROUGH_H |
| 914 |
: XP_THEME_ELEMENT_PROGRESS_BAR_H; |
| 915 |
break; |
| 916 |
|
| 917 |
default: |
| 918 |
ret = trough |
| 919 |
? XP_THEME_ELEMENT_PROGRESS_TROUGH_V |
| 920 |
: XP_THEME_ELEMENT_PROGRESS_BAR_V; |
| 921 |
break; |
| 922 |
} |
| 923 |
|
| 924 |
return ret; |
| 925 |
} |
| 926 |
|
| 927 |
static gboolean |
| 928 |
is_combo_box_child (GtkWidget *w) |
| 929 |
{ |
| 930 |
GtkWidget *tmp; |
| 931 |
|
| 932 |
if (w == NULL) |
| 933 |
return FALSE; |
| 934 |
|
| 935 |
for (tmp = w->parent; tmp; tmp = tmp->parent) |
| 936 |
{ |
| 937 |
if (GTK_IS_COMBO_BOX (tmp)) |
| 938 |
return TRUE; |
| 939 |
} |
| 940 |
|
| 941 |
return FALSE; |
| 942 |
} |
| 943 |
|
| 944 |
static void |
| 945 |
draw_part (GdkDrawable *drawable, |
| 946 |
GdkColor *gc, GdkRectangle *area, gint x, gint y, Part part) |
| 947 |
{ |
| 948 |
cairo_t *cr = gdk_cairo_create (drawable); |
| 949 |
|
| 950 |
if (area) |
| 951 |
{ |
| 952 |
gdk_cairo_rectangle (cr, area); |
| 953 |
cairo_clip (cr); |
| 954 |
} |
| 955 |
|
| 956 |
if (!parts[part].bmap) |
| 957 |
{ |
| 958 |
parts[part].bmap = cairo_image_surface_create_for_data ((unsigned char *)parts[part].bits, |
| 959 |
CAIRO_FORMAT_A1, |
| 960 |
PART_SIZE, PART_SIZE, 4); |
| 961 |
} |
| 962 |
|
| 963 |
gdk_cairo_set_source_color (cr, gc); |
| 964 |
cairo_mask_surface (cr, parts[part].bmap, x, y); |
| 965 |
|
| 966 |
cairo_destroy(cr); |
| 967 |
} |
| 968 |
|
| 969 |
static void |
| 970 |
draw_check (GtkStyle *style, |
| 971 |
GdkWindow *window, |
| 972 |
GtkStateType state, |
| 973 |
GtkShadowType shadow, |
| 974 |
GdkRectangle *area, |
| 975 |
GtkWidget *widget, |
| 976 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 977 |
{ |
| 978 |
x -= (1 + PART_SIZE - width) / 2; |
| 979 |
y -= (1 + PART_SIZE - height) / 2; |
| 980 |
|
| 981 |
if (DETAIL("check")) /* Menu item */ |
| 982 |
{ |
| 983 |
if (shadow == GTK_SHADOW_IN) |
| 984 |
{ |
| 985 |
draw_part (window, &style->black, area, x, y, CHECK_TEXT); |
| 986 |
draw_part (window, &style->dark[state], area, x, y, CHECK_AA); |
| 987 |
} |
| 988 |
} |
| 989 |
else |
| 990 |
{ |
| 991 |
XpThemeElement theme_elt = XP_THEME_ELEMENT_CHECKBOX; |
| 992 |
switch (shadow) |
| 993 |
{ |
| 994 |
case GTK_SHADOW_ETCHED_IN: |
| 995 |
theme_elt = XP_THEME_ELEMENT_INCONSISTENT_CHECKBOX; |
| 996 |
break; |
| 997 |
|
| 998 |
case GTK_SHADOW_IN: |
| 999 |
theme_elt = XP_THEME_ELEMENT_PRESSED_CHECKBOX; |
| 1000 |
break; |
| 1001 |
|
| 1002 |
default: |
| 1003 |
break; |
| 1004 |
} |
| 1005 |
|
| 1006 |
if (!xp_theme_draw (window, theme_elt, |
| 1007 |
style, x, y, width, height, state, area)) |
| 1008 |
{ |
| 1009 |
if (DETAIL("cellcheck")) |
| 1010 |
state = GTK_STATE_NORMAL; |
| 1011 |
|
| 1012 |
draw_part (window, &style->black, area, x, y, CHECK_BLACK); |
| 1013 |
draw_part (window, &style->dark[state], area, x, y, CHECK_DARK); |
| 1014 |
draw_part (window, &style->mid[state], area, x, y, CHECK_MID); |
| 1015 |
draw_part (window, &style->light[state], area, x, y, CHECK_LIGHT); |
| 1016 |
draw_part (window, &style->base[state], area, x, y, CHECK_BASE); |
| 1017 |
|
| 1018 |
if (shadow == GTK_SHADOW_IN) |
| 1019 |
{ |
| 1020 |
draw_part (window, &style->text[state], area, x, |
| 1021 |
y, CHECK_TEXT); |
| 1022 |
draw_part (window, &style->text_aa[state], area, |
| 1023 |
x, y, CHECK_AA); |
| 1024 |
} |
| 1025 |
else if (shadow == GTK_SHADOW_ETCHED_IN) |
| 1026 |
{ |
| 1027 |
draw_part (window, &style->text[state], area, x, y, |
| 1028 |
CHECK_INCONSISTENT); |
| 1029 |
draw_part (window, &style->text_aa[state], area, x, y, |
| 1030 |
CHECK_AA); |
| 1031 |
} |
| 1032 |
} |
| 1033 |
} |
| 1034 |
} |
| 1035 |
|
| 1036 |
static void |
| 1037 |
draw_expander (GtkStyle *style, |
| 1038 |
GdkWindow *window, |
| 1039 |
GtkStateType state, |
| 1040 |
GdkRectangle *area, |
| 1041 |
GtkWidget *widget, |
| 1042 |
const gchar *detail, |
| 1043 |
gint x, |
| 1044 |
gint y, |
| 1045 |
GtkExpanderStyle expander_style) |
| 1046 |
{ |
| 1047 |
cairo_t *cr = gdk_cairo_create (window); |
| 1048 |
|
| 1049 |
gint expander_size; |
| 1050 |
gint expander_semi_size; |
| 1051 |
XpThemeElement xp_expander; |
| 1052 |
GtkOrientation orientation; |
| 1053 |
|
| 1054 |
gtk_widget_style_get (widget, "expander_size", &expander_size, NULL); |
| 1055 |
|
| 1056 |
if (DETAIL("tool-palette-header")) |
| 1057 |
{ |
| 1058 |
/* Expanders are usually drawn as little triangles and unfortunately |
| 1059 |
* do not support rotated drawing modes. So a hack is applied (see |
| 1060 |
* gtk_tool_item_group_header_expose_event_cb for details) when |
| 1061 |
* drawing a GtkToolItemGroup's header for horizontal GtkToolShells, |
| 1062 |
* forcing the triangle to point in the right direction. Except we |
| 1063 |
* don't draw expanders as triangles on Windows. Usually, expanders |
| 1064 |
* are represented as "+" and "-". It sucks for "+" to become "-" and |
| 1065 |
* the inverse when we don't want to, so reverse the hack here. */ |
| 1066 |
|
| 1067 |
orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (widget)); |
| 1068 |
|
| 1069 |
if (orientation == GTK_ORIENTATION_HORIZONTAL) |
| 1070 |
expander_style = GTK_EXPANDER_EXPANDED - expander_style; |
| 1071 |
} |
| 1072 |
|
| 1073 |
switch (expander_style) |
| 1074 |
{ |
| 1075 |
case GTK_EXPANDER_COLLAPSED: |
| 1076 |
case GTK_EXPANDER_SEMI_COLLAPSED: |
| 1077 |
xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_CLOSED; |
| 1078 |
break; |
| 1079 |
|
| 1080 |
case GTK_EXPANDER_EXPANDED: |
| 1081 |
case GTK_EXPANDER_SEMI_EXPANDED: |
| 1082 |
xp_expander = XP_THEME_ELEMENT_TREEVIEW_EXPANDER_OPENED; |
| 1083 |
break; |
| 1084 |
|
| 1085 |
default: |
| 1086 |
g_assert_not_reached (); |
| 1087 |
} |
| 1088 |
|
| 1089 |
if ((expander_size % 2) == 0) |
| 1090 |
expander_size--; |
| 1091 |
|
| 1092 |
if (expander_size > 2) |
| 1093 |
expander_size -= 2; |
| 1094 |
|
| 1095 |
if (area) |
| 1096 |
{ |
| 1097 |
gdk_cairo_rectangle (cr, area); |
| 1098 |
cairo_clip (cr); |
| 1099 |
gdk_cairo_set_source_color (cr, &style->fg[state]); |
| 1100 |
} |
| 1101 |
|
| 1102 |
expander_semi_size = expander_size / 2; |
| 1103 |
x -= expander_semi_size; |
| 1104 |
y -= expander_semi_size; |
| 1105 |
|
| 1106 |
if (!xp_theme_draw (window, xp_expander, style, |
| 1107 |
x, y, expander_size, expander_size, state, area)) |
| 1108 |
{ |
| 1109 |
HDC dc; |
| 1110 |
RECT rect; |
| 1111 |
HPEN pen; |
| 1112 |
HGDIOBJ old_pen; |
| 1113 |
XpDCInfo dc_info; |
| 1114 |
|
| 1115 |
dc = get_window_dc (style, window, state, &dc_info, x, y, expander_size, |
| 1116 |
expander_size, &rect); |
| 1117 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_GRAYTEXT)); |
| 1118 |
InflateRect (&rect, -1, -1); |
| 1119 |
FillRect (dc, &rect, |
| 1120 |
GetSysColorBrush (state == |
| 1121 |
GTK_STATE_INSENSITIVE ? COLOR_BTNFACE : |
| 1122 |
COLOR_WINDOW)); |
| 1123 |
|
| 1124 |
InflateRect (&rect, -1, -1); |
| 1125 |
|
| 1126 |
pen = CreatePen (PS_SOLID, 1, GetSysColor (COLOR_WINDOWTEXT)); |
| 1127 |
old_pen = SelectObject (dc, pen); |
| 1128 |
|
| 1129 |
MoveToEx (dc, rect.left, rect.top - 2 + expander_semi_size, NULL); |
| 1130 |
LineTo (dc, rect.right, rect.top - 2 + expander_semi_size); |
| 1131 |
|
| 1132 |
if (expander_style == GTK_EXPANDER_COLLAPSED || |
| 1133 |
expander_style == GTK_EXPANDER_SEMI_COLLAPSED) |
| 1134 |
{ |
| 1135 |
MoveToEx (dc, rect.left - 2 + expander_semi_size, rect.top, NULL); |
| 1136 |
LineTo (dc, rect.left - 2 + expander_semi_size, rect.bottom); |
| 1137 |
} |
| 1138 |
|
| 1139 |
SelectObject (dc, old_pen); |
| 1140 |
DeleteObject (pen); |
| 1141 |
release_window_dc (&dc_info); |
| 1142 |
} |
| 1143 |
|
| 1144 |
cairo_destroy(cr); |
| 1145 |
} |
| 1146 |
|
| 1147 |
static void |
| 1148 |
draw_option (GtkStyle *style, |
| 1149 |
GdkWindow *window, |
| 1150 |
GtkStateType state, |
| 1151 |
GtkShadowType shadow, |
| 1152 |
GdkRectangle *area, |
| 1153 |
GtkWidget *widget, |
| 1154 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 1155 |
{ |
| 1156 |
x -= (1 + PART_SIZE - width) / 2; |
| 1157 |
y -= (1 + PART_SIZE - height) / 2; |
| 1158 |
|
| 1159 |
if (DETAIL("option")) /* Menu item */ |
| 1160 |
{ |
| 1161 |
if (shadow == GTK_SHADOW_IN) |
| 1162 |
{ |
| 1163 |
draw_part (window, &style->fg[state], area, x, y, RADIO_TEXT); |
| 1164 |
} |
| 1165 |
} |
| 1166 |
else |
| 1167 |
{ |
| 1168 |
if (xp_theme_draw (window, shadow == GTK_SHADOW_IN |
| 1169 |
? XP_THEME_ELEMENT_PRESSED_RADIO_BUTTON |
| 1170 |
: XP_THEME_ELEMENT_RADIO_BUTTON, |
| 1171 |
style, x, y, width, height, state, area)) |
| 1172 |
{ |
| 1173 |
} |
| 1174 |
else |
| 1175 |
{ |
| 1176 |
if (DETAIL("cellradio")) |
| 1177 |
state = GTK_STATE_NORMAL; |
| 1178 |
|
| 1179 |
draw_part (window, &style->black, area, x, y, RADIO_BLACK); |
| 1180 |
draw_part (window, &style->dark[state], area, x, y, RADIO_DARK); |
| 1181 |
draw_part (window, &style->mid[state], area, x, y, RADIO_MID); |
| 1182 |
draw_part (window, &style->light[state], area, x, y, RADIO_LIGHT); |
| 1183 |
draw_part (window, &style->base[state], area, x, y, RADIO_BASE); |
| 1184 |
|
| 1185 |
if (shadow == GTK_SHADOW_IN) |
| 1186 |
draw_part (window, &style->text[state], area, x, y, RADIO_TEXT); |
| 1187 |
} |
| 1188 |
} |
| 1189 |
} |
| 1190 |
|
| 1191 |
static void |
| 1192 |
draw_varrow (GdkWindow *window, |
| 1193 |
GdkColor *gc, |
| 1194 |
GtkShadowType shadow_type, |
| 1195 |
GdkRectangle *area, |
| 1196 |
GtkArrowType arrow_type, gint x, gint y, gint width, gint height) |
| 1197 |
{ |
| 1198 |
gint steps, extra; |
| 1199 |
gint y_start, y_increment; |
| 1200 |
gint i; |
| 1201 |
cairo_t *cr; |
| 1202 |
|
| 1203 |
cr = gdk_cairo_create (window); |
| 1204 |
|
| 1205 |
if (area) |
| 1206 |
{ |
| 1207 |
gdk_cairo_rectangle (cr, area); |
| 1208 |
cairo_clip (cr); |
| 1209 |
} |
| 1210 |
|
| 1211 |
width = width + width % 2 - 1; /* Force odd */ |
| 1212 |
steps = 1 + width / 2; |
| 1213 |
extra = height - steps; |
| 1214 |
|
| 1215 |
if (arrow_type == GTK_ARROW_DOWN) |
| 1216 |
{ |
| 1217 |
y_start = y; |
| 1218 |
y_increment = 1; |
| 1219 |
} |
| 1220 |
else |
| 1221 |
{ |
| 1222 |
y_start = y + height - 1; |
| 1223 |
y_increment = -1; |
| 1224 |
} |
| 1225 |
|
| 1226 |
gdk_cairo_set_source_color (cr, gc); |
| 1227 |
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); |
| 1228 |
cairo_set_line_width (cr, 1.0); |
| 1229 |
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); |
| 1230 |
|
| 1231 |
cairo_move_to (cr, x + 0.5, y_start + extra * y_increment + 0.5); |
| 1232 |
cairo_line_to (cr, x + width - 1 + 0.5, y_start + extra * y_increment + 0.5); |
| 1233 |
cairo_line_to (cr, x + (height - 1 - extra) + 0.5, y_start + (height - 1) * y_increment + 0.5); |
| 1234 |
cairo_close_path (cr); |
| 1235 |
cairo_stroke_preserve (cr); |
| 1236 |
cairo_fill (cr); |
| 1237 |
|
| 1238 |
cairo_destroy(cr); |
| 1239 |
} |
| 1240 |
|
| 1241 |
static void |
| 1242 |
draw_harrow (GdkWindow *window, |
| 1243 |
GdkColor *gc, |
| 1244 |
GtkShadowType shadow_type, |
| 1245 |
GdkRectangle *area, |
| 1246 |
GtkArrowType arrow_type, gint x, gint y, gint width, gint height) |
| 1247 |
{ |
| 1248 |
gint steps, extra; |
| 1249 |
gint x_start, x_increment; |
| 1250 |
gint i; |
| 1251 |
cairo_t *cr; |
| 1252 |
|
| 1253 |
cr = gdk_cairo_create (window); |
| 1254 |
|
| 1255 |
if (area) |
| 1256 |
{ |
| 1257 |
gdk_cairo_rectangle (cr, area); |
| 1258 |
cairo_clip (cr); |
| 1259 |
} |
| 1260 |
|
| 1261 |
height = height + height % 2 - 1; /* Force odd */ |
| 1262 |
steps = 1 + height / 2; |
| 1263 |
extra = width - steps; |
| 1264 |
|
| 1265 |
if (arrow_type == GTK_ARROW_RIGHT) |
| 1266 |
{ |
| 1267 |
x_start = x; |
| 1268 |
x_increment = 1; |
| 1269 |
} |
| 1270 |
else |
| 1271 |
{ |
| 1272 |
x_start = x + width - 1; |
| 1273 |
x_increment = -1; |
| 1274 |
} |
| 1275 |
|
| 1276 |
gdk_cairo_set_source_color (cr, gc); |
| 1277 |
cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE); |
| 1278 |
cairo_set_line_width (cr, 1.0); |
| 1279 |
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE); |
| 1280 |
|
| 1281 |
cairo_move_to (cr, x_start + extra * x_increment + 0.5, y + 0.5); |
| 1282 |
cairo_line_to (cr, x_start + extra * x_increment + 0.5, y + height - 1 + 0.5); |
| 1283 |
cairo_line_to (cr, x_start + (width - 1) * x_increment + 0.5, y + height - (width - 1 - extra) - 1 + 0.5); |
| 1284 |
cairo_close_path (cr); |
| 1285 |
cairo_stroke_preserve (cr); |
| 1286 |
cairo_fill (cr); |
| 1287 |
|
| 1288 |
cairo_destroy(cr); |
| 1289 |
} |
| 1290 |
|
| 1291 |
/* This function makes up for some brokeness in gtkrange.c |
| 1292 |
* where we never get the full arrow of the stepper button |
| 1293 |
* and the type of button in a single drawing function. |
| 1294 |
* |
| 1295 |
* It doesn't work correctly when the scrollbar is squished |
| 1296 |
* to the point we don't have room for full-sized steppers. |
| 1297 |
*/ |
| 1298 |
static void |
| 1299 |
reverse_engineer_stepper_box (GtkWidget *range, |
| 1300 |
GtkArrowType arrow_type, |
| 1301 |
gint *x, gint *y, gint *width, gint *height) |
| 1302 |
{ |
| 1303 |
gint slider_width = 14, stepper_size = 14; |
| 1304 |
gint box_width; |
| 1305 |
gint box_height; |
| 1306 |
|
| 1307 |
if (range) |
| 1308 |
{ |
| 1309 |
gtk_widget_style_get (range, |
| 1310 |
"slider_width", &slider_width, |
| 1311 |
"stepper_size", &stepper_size, NULL); |
| 1312 |
} |
| 1313 |
|
| 1314 |
if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) |
| 1315 |
{ |
| 1316 |
box_width = slider_width; |
| 1317 |
box_height = stepper_size; |
| 1318 |
} |
| 1319 |
else |
| 1320 |
{ |
| 1321 |
box_width = stepper_size; |
| 1322 |
box_height = slider_width; |
| 1323 |
} |
| 1324 |
|
| 1325 |
*x = *x - (box_width - *width) / 2; |
| 1326 |
*y = *y - (box_height - *height) / 2; |
| 1327 |
*width = box_width; |
| 1328 |
*height = box_height; |
| 1329 |
} |
| 1330 |
|
| 1331 |
static XpThemeElement |
| 1332 |
to_xp_arrow (GtkArrowType arrow_type) |
| 1333 |
{ |
| 1334 |
XpThemeElement xp_arrow; |
| 1335 |
|
| 1336 |
switch (arrow_type) |
| 1337 |
{ |
| 1338 |
case GTK_ARROW_UP: |
| 1339 |
xp_arrow = XP_THEME_ELEMENT_ARROW_UP; |
| 1340 |
break; |
| 1341 |
|
| 1342 |
case GTK_ARROW_DOWN: |
| 1343 |
xp_arrow = XP_THEME_ELEMENT_ARROW_DOWN; |
| 1344 |
break; |
| 1345 |
|
| 1346 |
case GTK_ARROW_LEFT: |
| 1347 |
xp_arrow = XP_THEME_ELEMENT_ARROW_LEFT; |
| 1348 |
break; |
| 1349 |
|
| 1350 |
default: |
| 1351 |
xp_arrow = XP_THEME_ELEMENT_ARROW_RIGHT; |
| 1352 |
break; |
| 1353 |
} |
| 1354 |
|
| 1355 |
return xp_arrow; |
| 1356 |
} |
| 1357 |
|
| 1358 |
static void |
| 1359 |
draw_arrow (GtkStyle *style, |
| 1360 |
GdkWindow *window, |
| 1361 |
GtkStateType state, |
| 1362 |
GtkShadowType shadow, |
| 1363 |
GdkRectangle *area, |
| 1364 |
GtkWidget *widget, |
| 1365 |
const gchar *detail, |
| 1366 |
GtkArrowType arrow_type, |
| 1367 |
gboolean fill, gint x, gint y, gint width, gint height) |
| 1368 |
{ |
| 1369 |
const gchar *name; |
| 1370 |
HDC dc; |
| 1371 |
RECT rect; |
| 1372 |
XpDCInfo dc_info; |
| 1373 |
|
| 1374 |
name = gtk_widget_get_name (widget); |
| 1375 |
|
| 1376 |
sanitize_size (window, &width, &height); |
| 1377 |
|
| 1378 |
if (GTK_IS_ARROW (widget) && is_combo_box_child (widget) && xp_theme_is_active ()) |
| 1379 |
return; |
| 1380 |
|
| 1381 |
if (DETAIL("spinbutton")) |
| 1382 |
{ |
| 1383 |
if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP)) |
| 1384 |
{ |
| 1385 |
return; |
| 1386 |
} |
| 1387 |
|
| 1388 |
width -= 2; |
| 1389 |
--height; |
| 1390 |
if (arrow_type == GTK_ARROW_DOWN) |
| 1391 |
++y; |
| 1392 |
++x; |
| 1393 |
|
| 1394 |
if (state == GTK_STATE_ACTIVE) |
| 1395 |
{ |
| 1396 |
++x; |
| 1397 |
++y; |
| 1398 |
} |
| 1399 |
|
| 1400 |
draw_varrow (window, &style->fg[state], shadow, area, |
| 1401 |
arrow_type, x, y, width, height); |
| 1402 |
|
| 1403 |
return; |
| 1404 |
} |
| 1405 |
else if (DETAIL("vscrollbar") || DETAIL("hscrollbar")) |
| 1406 |
{ |
| 1407 |
gboolean is_disabled = FALSE; |
| 1408 |
UINT btn_type = 0; |
| 1409 |
GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget); |
| 1410 |
|
| 1411 |
gint box_x = x; |
| 1412 |
gint box_y = y; |
| 1413 |
gint box_width = width; |
| 1414 |
gint box_height = height; |
| 1415 |
|
| 1416 |
reverse_engineer_stepper_box (widget, arrow_type, |
| 1417 |
&box_x, &box_y, &box_width, &box_height); |
| 1418 |
|
| 1419 |
if (gtk_range_get_adjustment(&scrollbar->range)->page_size >= |
| 1420 |
(gtk_range_get_adjustment(&scrollbar->range)->upper - |
| 1421 |
gtk_range_get_adjustment(&scrollbar->range)->lower)) |
| 1422 |
{ |
| 1423 |
is_disabled = TRUE; |
| 1424 |
} |
| 1425 |
|
| 1426 |
if (xp_theme_draw (window, to_xp_arrow (arrow_type), style, box_x, box_y, |
| 1427 |
box_width, box_height, state, area)) |
| 1428 |
{ |
| 1429 |
} |
| 1430 |
else |
| 1431 |
{ |
| 1432 |
switch (arrow_type) |
| 1433 |
{ |
| 1434 |
case GTK_ARROW_UP: |
| 1435 |
btn_type = DFCS_SCROLLUP; |
| 1436 |
break; |
| 1437 |
|
| 1438 |
case GTK_ARROW_DOWN: |
| 1439 |
btn_type = DFCS_SCROLLDOWN; |
| 1440 |
break; |
| 1441 |
|
| 1442 |
case GTK_ARROW_LEFT: |
| 1443 |
btn_type = DFCS_SCROLLLEFT; |
| 1444 |
break; |
| 1445 |
|
| 1446 |
case GTK_ARROW_RIGHT: |
| 1447 |
btn_type = DFCS_SCROLLRIGHT; |
| 1448 |
break; |
| 1449 |
|
| 1450 |
case GTK_ARROW_NONE: |
| 1451 |
break; |
| 1452 |
} |
| 1453 |
|
| 1454 |
if (state == GTK_STATE_INSENSITIVE) |
| 1455 |
{ |
| 1456 |
btn_type |= DFCS_INACTIVE; |
| 1457 |
} |
| 1458 |
|
| 1459 |
if (widget) |
| 1460 |
{ |
| 1461 |
sanitize_size (window, &width, &height); |
| 1462 |
|
| 1463 |
dc = get_window_dc (style, window, state, &dc_info, |
| 1464 |
box_x, box_y, box_width, box_height, &rect); |
| 1465 |
DrawFrameControl (dc, &rect, DFC_SCROLL, |
| 1466 |
btn_type | (shadow == |
| 1467 |
GTK_SHADOW_IN ? (DFCS_PUSHED | |
| 1468 |
DFCS_FLAT) : 0)); |
| 1469 |
release_window_dc (&dc_info); |
| 1470 |
} |
| 1471 |
} |
| 1472 |
} |
| 1473 |
else |
| 1474 |
{ |
| 1475 |
/* draw the toolbar chevrons - waiting for GTK 2.4 */ |
| 1476 |
if (name && !strcmp (name, "gtk-toolbar-arrow")) |
| 1477 |
{ |
| 1478 |
if (xp_theme_draw |
| 1479 |
(window, XP_THEME_ELEMENT_REBAR_CHEVRON, style, x, y, |
| 1480 |
width, height, state, area)) |
| 1481 |
{ |
| 1482 |
return; |
| 1483 |
} |
| 1484 |
} |
| 1485 |
/* probably a gtk combo box on a toolbar */ |
| 1486 |
else if (0 /* widget->parent && GTK_IS_BUTTON |
| 1487 |
(widget->parent) */ ) |
| 1488 |
{ |
| 1489 |
if (xp_theme_draw |
| 1490 |
(window, XP_THEME_ELEMENT_COMBOBUTTON, style, x - 3, |
| 1491 |
widget->allocation.y + 1, width + 5, |
| 1492 |
widget->allocation.height - 4, state, area)) |
| 1493 |
{ |
| 1494 |
return; |
| 1495 |
} |
| 1496 |
} |
| 1497 |
|
| 1498 |
if (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN) |
| 1499 |
{ |
| 1500 |
x += (width - 7) / 2; |
| 1501 |
y += (height - 5) / 2; |
| 1502 |
|
| 1503 |
draw_varrow (window, &style->fg[state], shadow, area, |
| 1504 |
arrow_type, x, y, 7, 5); |
| 1505 |
} |
| 1506 |
else |
| 1507 |
{ |
| 1508 |
x += (width - 5) / 2; |
| 1509 |
y += (height - 7) / 2; |
| 1510 |
|
| 1511 |
draw_harrow (window, &style->fg[state], shadow, area, |
| 1512 |
arrow_type, x, y, 5, 7); |
| 1513 |
} |
| 1514 |
} |
| 1515 |
} |
| 1516 |
|
| 1517 |
static void |
| 1518 |
option_menu_get_props (GtkWidget *widget, |
| 1519 |
GtkRequisition *indicator_size, |
| 1520 |
GtkBorder *indicator_spacing) |
| 1521 |
{ |
| 1522 |
GtkRequisition *tmp_size = NULL; |
| 1523 |
GtkBorder *tmp_spacing = NULL; |
| 1524 |
|
| 1525 |
if (widget) |
| 1526 |
gtk_widget_style_get (widget, |
| 1527 |
"indicator_size", &tmp_size, |
| 1528 |
"indicator_spacing", &tmp_spacing, NULL); |
| 1529 |
|
| 1530 |
if (tmp_size) |
| 1531 |
{ |
| 1532 |
*indicator_size = *tmp_size; |
| 1533 |
gtk_requisition_free (tmp_size); |
| 1534 |
} |
| 1535 |
else |
| 1536 |
{ |
| 1537 |
*indicator_size = default_option_indicator_size; |
| 1538 |
} |
| 1539 |
|
| 1540 |
if (tmp_spacing) |
| 1541 |
{ |
| 1542 |
*indicator_spacing = *tmp_spacing; |
| 1543 |
gtk_border_free (tmp_spacing); |
| 1544 |
} |
| 1545 |
else |
| 1546 |
{ |
| 1547 |
*indicator_spacing = default_option_indicator_spacing; |
| 1548 |
} |
| 1549 |
} |
| 1550 |
|
| 1551 |
static gboolean |
| 1552 |
is_toolbar_child (GtkWidget *wid) |
| 1553 |
{ |
| 1554 |
while (wid) |
| 1555 |
{ |
| 1556 |
if (GTK_IS_TOOLBAR (wid) || GTK_IS_HANDLE_BOX (wid)) |
| 1557 |
return TRUE; |
| 1558 |
else |
| 1559 |
wid = wid->parent; |
| 1560 |
} |
| 1561 |
|
| 1562 |
return FALSE; |
| 1563 |
} |
| 1564 |
|
| 1565 |
static gboolean |
| 1566 |
is_menu_tool_button_child (GtkWidget *wid) |
| 1567 |
{ |
| 1568 |
while (wid) |
| 1569 |
{ |
| 1570 |
if (GTK_IS_MENU_TOOL_BUTTON (wid)) |
| 1571 |
return TRUE; |
| 1572 |
else |
| 1573 |
wid = wid->parent; |
| 1574 |
} |
| 1575 |
return FALSE; |
| 1576 |
} |
| 1577 |
|
| 1578 |
static HPEN |
| 1579 |
get_light_pen () |
| 1580 |
{ |
| 1581 |
if (!g_light_pen) |
| 1582 |
{ |
| 1583 |
g_light_pen = CreatePen (PS_SOLID | PS_INSIDEFRAME, 1, |
| 1584 |
GetSysColor (COLOR_BTNHIGHLIGHT)); |
| 1585 |
} |
| 1586 |
|
| 1587 |
return g_light_pen; |
| 1588 |
} |
| 1589 |
|
| 1590 |
static HPEN |
| 1591 |
get_dark_pen () |
| 1592 |
{ |
| 1593 |
if (!g_dark_pen) |
| 1594 |
{ |
| 1595 |
g_dark_pen = CreatePen (PS_SOLID | PS_INSIDEFRAME, 1, |
| 1596 |
GetSysColor (COLOR_BTNSHADOW)); |
| 1597 |
} |
| 1598 |
|
| 1599 |
return g_dark_pen; |
| 1600 |
} |
| 1601 |
|
| 1602 |
static void |
| 1603 |
draw_3d_border (HDC hdc, RECT *rc, gboolean sunken) |
| 1604 |
{ |
| 1605 |
HPEN pen1, pen2; |
| 1606 |
HGDIOBJ old_pen; |
| 1607 |
|
| 1608 |
if (sunken) |
| 1609 |
{ |
| 1610 |
pen1 = get_dark_pen (); |
| 1611 |
pen2 = get_light_pen (); |
| 1612 |
} |
| 1613 |
else |
| 1614 |
{ |
| 1615 |
pen1 = get_light_pen (); |
| 1616 |
pen2 = get_dark_pen (); |
| 1617 |
} |
| 1618 |
|
| 1619 |
MoveToEx (hdc, rc->left, rc->bottom - 1, NULL); |
| 1620 |
|
| 1621 |
old_pen = SelectObject (hdc, pen1); |
| 1622 |
LineTo (hdc, rc->left, rc->top); |
| 1623 |
LineTo (hdc, rc->right - 1, rc->top); |
| 1624 |
SelectObject (hdc, old_pen); |
| 1625 |
|
| 1626 |
old_pen = SelectObject (hdc, pen2); |
| 1627 |
LineTo (hdc, rc->right - 1, rc->bottom - 1); |
| 1628 |
LineTo (hdc, rc->left, rc->bottom - 1); |
| 1629 |
SelectObject (hdc, old_pen); |
| 1630 |
} |
| 1631 |
|
| 1632 |
static gboolean |
| 1633 |
draw_menu_item (GdkWindow *window, GtkWidget *widget, GtkStyle *style, |
| 1634 |
gint x, gint y, gint width, gint height, |
| 1635 |
GtkStateType state_type, GdkRectangle *area) |
| 1636 |
{ |
| 1637 |
GtkWidget *parent; |
| 1638 |
GtkMenuShell *bar; |
| 1639 |
HDC dc; |
| 1640 |
RECT rect; |
| 1641 |
XpDCInfo dc_info; |
| 1642 |
|
| 1643 |
if (xp_theme_is_active ()) |
| 1644 |
{ |
| 1645 |
return (xp_theme_draw (window, XP_THEME_ELEMENT_MENU_ITEM, style, |
| 1646 |
x, y, width, height, state_type, area)); |
| 1647 |
} |
| 1648 |
|
| 1649 |
if ((parent = gtk_widget_get_parent (widget)) |
| 1650 |
&& GTK_IS_MENU_BAR (parent) && !xp_theme_is_active ()) |
| 1651 |
{ |
| 1652 |
bar = GTK_MENU_SHELL (parent); |
| 1653 |
|
| 1654 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 1655 |
|
| 1656 |
if (state_type == GTK_STATE_PRELIGHT) |
| 1657 |
{ |
| 1658 |
draw_3d_border (dc, &rect, bar->active); |
| 1659 |
} |
| 1660 |
|
| 1661 |
release_window_dc (&dc_info); |
| 1662 |
|
| 1663 |
return TRUE; |
| 1664 |
} |
| 1665 |
|
| 1666 |
return FALSE; |
| 1667 |
} |
| 1668 |
|
| 1669 |
static HBRUSH |
| 1670 |
get_dither_brush (void) |
| 1671 |
{ |
| 1672 |
WORD pattern[8]; |
| 1673 |
HBITMAP pattern_bmp; |
| 1674 |
int i; |
| 1675 |
|
| 1676 |
if (g_dither_brush) |
| 1677 |
return g_dither_brush; |
| 1678 |
|
| 1679 |
for (i = 0; i < 8; i++) |
| 1680 |
{ |
| 1681 |
pattern[i] = (WORD) (0x5555 << (i & 1)); |
| 1682 |
} |
| 1683 |
|
| 1684 |
pattern_bmp = CreateBitmap (8, 8, 1, 1, &pattern); |
| 1685 |
|
| 1686 |
if (pattern_bmp) |
| 1687 |
{ |
| 1688 |
g_dither_brush = CreatePatternBrush (pattern_bmp); |
| 1689 |
DeleteObject (pattern_bmp); |
| 1690 |
} |
| 1691 |
|
| 1692 |
return g_dither_brush; |
| 1693 |
} |
| 1694 |
|
| 1695 |
static gboolean |
| 1696 |
draw_tool_button (GdkWindow *window, GtkWidget *widget, GtkStyle *style, |
| 1697 |
gint x, gint y, gint width, gint height, |
| 1698 |
GtkStateType state_type, GdkRectangle *area) |
| 1699 |
{ |
| 1700 |
HDC dc; |
| 1701 |
RECT rect; |
| 1702 |
XpDCInfo dc_info; |
| 1703 |
gboolean is_toggled = FALSE; |
| 1704 |
|
| 1705 |
if (xp_theme_is_active ()) |
| 1706 |
{ |
| 1707 |
return (xp_theme_draw (window, XP_THEME_ELEMENT_TOOLBAR_BUTTON, style, |
| 1708 |
x, y, width, height, state_type, area)); |
| 1709 |
} |
| 1710 |
|
| 1711 |
if (GTK_IS_TOGGLE_BUTTON (widget)) |
| 1712 |
{ |
| 1713 |
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) |
| 1714 |
{ |
| 1715 |
is_toggled = TRUE; |
| 1716 |
} |
| 1717 |
} |
| 1718 |
|
| 1719 |
if (state_type != GTK_STATE_PRELIGHT |
| 1720 |
&& state_type != GTK_STATE_ACTIVE && !is_toggled) |
| 1721 |
{ |
| 1722 |
return FALSE; |
| 1723 |
} |
| 1724 |
|
| 1725 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 1726 |
if (state_type == GTK_STATE_PRELIGHT) |
| 1727 |
{ |
| 1728 |
if (is_toggled) |
| 1729 |
{ |
| 1730 |
FillRect (dc, &rect, GetSysColorBrush (COLOR_BTNFACE)); |
| 1731 |
} |
| 1732 |
|
| 1733 |
draw_3d_border (dc, &rect, is_toggled); |
| 1734 |
} |
| 1735 |
else if (state_type == GTK_STATE_ACTIVE) |
| 1736 |
{ |
| 1737 |
if (is_toggled && !is_menu_tool_button_child (widget->parent)) |
| 1738 |
{ |
| 1739 |
SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT)); |
| 1740 |
SetBkColor (dc, GetSysColor (COLOR_BTNFACE)); |
| 1741 |
FillRect (dc, &rect, get_dither_brush ()); |
| 1742 |
} |
| 1743 |
|
| 1744 |
draw_3d_border (dc, &rect, TRUE); |
| 1745 |
} |
| 1746 |
|
| 1747 |
release_window_dc (&dc_info); |
| 1748 |
|
| 1749 |
return TRUE; |
| 1750 |
} |
| 1751 |
|
| 1752 |
static void |
| 1753 |
draw_push_button (GdkWindow *window, GtkWidget *widget, GtkStyle *style, |
| 1754 |
gint x, gint y, gint width, gint height, |
| 1755 |
GtkStateType state_type, gboolean is_default) |
| 1756 |
{ |
| 1757 |
HDC dc; |
| 1758 |
RECT rect; |
| 1759 |
XpDCInfo dc_info; |
| 1760 |
|
| 1761 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 1762 |
|
| 1763 |
if (GTK_IS_TOGGLE_BUTTON (widget)) |
| 1764 |
{ |
| 1765 |
if (state_type == GTK_STATE_PRELIGHT && |
| 1766 |
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) |
| 1767 |
{ |
| 1768 |
state_type = GTK_STATE_ACTIVE; |
| 1769 |
} |
| 1770 |
} |
| 1771 |
|
| 1772 |
if (state_type == GTK_STATE_ACTIVE) |
| 1773 |
{ |
| 1774 |
if (GTK_IS_TOGGLE_BUTTON (widget)) |
| 1775 |
{ |
| 1776 |
DrawEdge (dc, &rect, EDGE_SUNKEN, BF_RECT | BF_ADJUST); |
| 1777 |
SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT)); |
| 1778 |
SetBkColor (dc, GetSysColor (COLOR_BTNFACE)); |
| 1779 |
FillRect (dc, &rect, get_dither_brush ()); |
| 1780 |
} |
| 1781 |
else |
| 1782 |
{ |
| 1783 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME)); |
| 1784 |
InflateRect (&rect, -1, -1); |
| 1785 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_BTNSHADOW)); |
| 1786 |
InflateRect (&rect, -1, -1); |
| 1787 |
FillRect (dc, &rect, GetSysColorBrush (COLOR_BTNFACE)); |
| 1788 |
} |
| 1789 |
} |
| 1790 |
else |
| 1791 |
{ |
| 1792 |
if (is_default || gtk_widget_has_focus (widget)) |
| 1793 |
{ |
| 1794 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME)); |
| 1795 |
InflateRect (&rect, -1, -1); |
| 1796 |
} |
| 1797 |
|
| 1798 |
DrawFrameControl (dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH); |
| 1799 |
} |
| 1800 |
|
| 1801 |
release_window_dc (&dc_info); |
| 1802 |
} |
| 1803 |
|
| 1804 |
static void |
| 1805 |
draw_box (GtkStyle *style, |
| 1806 |
GdkWindow *window, |
| 1807 |
GtkStateType state_type, |
| 1808 |
GtkShadowType shadow_type, |
| 1809 |
GdkRectangle *area, |
| 1810 |
GtkWidget *widget, |
| 1811 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 1812 |
{ |
| 1813 |
if (is_combo_box_child (widget) && DETAIL("button")) |
| 1814 |
{ |
| 1815 |
RECT rect; |
| 1816 |
XpDCInfo dc_info; |
| 1817 |
DWORD border; |
| 1818 |
HDC dc; |
| 1819 |
int cx; |
| 1820 |
|
| 1821 |
border = (GTK_TOGGLE_BUTTON (widget)->active ? DFCS_PUSHED | DFCS_FLAT : 0); |
| 1822 |
|
| 1823 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 1824 |
DrawFrameControl (dc, &rect, DFC_SCROLL, DFCS_SCROLLDOWN | border); |
| 1825 |
release_window_dc (&dc_info); |
| 1826 |
|
| 1827 |
if (xp_theme_is_active () |
| 1828 |
&& xp_theme_draw (window, XP_THEME_ELEMENT_COMBOBUTTON, style, x, y, |
| 1829 |
width, height, state_type, area)) |
| 1830 |
{ |
| 1831 |
cx = GetSystemMetrics(SM_CXVSCROLL); |
| 1832 |
x += width - cx; |
| 1833 |
width = cx; |
| 1834 |
|
| 1835 |
|
| 1836 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width - cx, height, &rect); |
| 1837 |
FillRect (dc, &rect, GetSysColorBrush (COLOR_WINDOW)); |
| 1838 |
release_window_dc (&dc_info); |
| 1839 |
return; |
| 1840 |
} |
| 1841 |
} |
| 1842 |
|
| 1843 |
if (DETAIL("button") || DETAIL("buttondefault")) |
| 1844 |
{ |
| 1845 |
if (GTK_IS_TREE_VIEW (widget->parent) || GTK_IS_CLIST (widget->parent)) |
| 1846 |
{ |
| 1847 |
if (xp_theme_draw |
| 1848 |
(window, XP_THEME_ELEMENT_LIST_HEADER, style, x, y, |
| 1849 |
width, height, state_type, area)) |
| 1850 |
{ |
| 1851 |
return; |
| 1852 |
} |
| 1853 |
else |
| 1854 |
{ |
| 1855 |
HDC dc; |
| 1856 |
RECT rect; |
| 1857 |
XpDCInfo dc_info; |
| 1858 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 1859 |
|
| 1860 |
DrawFrameControl (dc, &rect, DFC_BUTTON, DFCS_BUTTONPUSH | |
| 1861 |
(state_type == |
| 1862 |
GTK_STATE_ACTIVE ? (DFCS_PUSHED | DFCS_FLAT) |
| 1863 |
: 0)); |
| 1864 |
release_window_dc (&dc_info); |
| 1865 |
} |
| 1866 |
} |
| 1867 |
else if (is_toolbar_child (widget->parent) |
| 1868 |
|| (!GTK_IS_BUTTON (widget) || |
| 1869 |
(GTK_RELIEF_NONE == gtk_button_get_relief (GTK_BUTTON (widget))))) |
| 1870 |
{ |
| 1871 |
if (draw_tool_button (window, widget, style, x, y, |
| 1872 |
width, height, state_type, area)) |
| 1873 |
{ |
| 1874 |
return; |
| 1875 |
} |
| 1876 |
} |
| 1877 |
else |
| 1878 |
{ |
| 1879 |
gboolean is_default = gtk_widget_has_default (widget); |
| 1880 |
if (xp_theme_draw |
| 1881 |
(window, |
| 1882 |
is_default ? XP_THEME_ELEMENT_DEFAULT_BUTTON : |
| 1883 |
XP_THEME_ELEMENT_BUTTON, style, x, y, width, height, |
| 1884 |
state_type, area)) |
| 1885 |
{ |
| 1886 |
return; |
| 1887 |
} |
| 1888 |
|
| 1889 |
draw_push_button (window, widget, style, |
| 1890 |
x, y, width, height, state_type, is_default); |
| 1891 |
|
| 1892 |
return; |
| 1893 |
} |
| 1894 |
|
| 1895 |
return; |
| 1896 |
} |
| 1897 |
else if (DETAIL("spinbutton")) |
| 1898 |
{ |
| 1899 |
if (xp_theme_is_drawable (XP_THEME_ELEMENT_SPIN_BUTTON_UP)) |
| 1900 |
{ |
| 1901 |
return; |
| 1902 |
} |
| 1903 |
} |
| 1904 |
else if (DETAIL("spinbutton_up") || DETAIL("spinbutton_down")) |
| 1905 |
{ |
| 1906 |
if (!xp_theme_draw (window, |
| 1907 |
DETAIL("spinbutton_up") |
| 1908 |
? XP_THEME_ELEMENT_SPIN_BUTTON_UP |
| 1909 |
: XP_THEME_ELEMENT_SPIN_BUTTON_DOWN, |
| 1910 |
style, x, y, width, height, state_type, area)) |
| 1911 |
{ |
| 1912 |
RECT rect; |
| 1913 |
XpDCInfo dc_info; |
| 1914 |
HDC dc; |
| 1915 |
|
| 1916 |
dc = get_window_dc (style, window, state_type, &dc_info, |
| 1917 |
x, y, width, height, &rect); |
| 1918 |
DrawEdge (dc, &rect, |
| 1919 |
state_type == |
| 1920 |
GTK_STATE_ACTIVE ? EDGE_SUNKEN : EDGE_RAISED, BF_RECT); |
| 1921 |
release_window_dc (&dc_info); |
| 1922 |
} |
| 1923 |
return; |
| 1924 |
} |
| 1925 |
else if (DETAIL("slider")) |
| 1926 |
{ |
| 1927 |
if (GTK_IS_SCROLLBAR (widget)) |
| 1928 |
{ |
| 1929 |
GtkScrollbar *scrollbar = GTK_SCROLLBAR (widget); |
| 1930 |
GtkOrientation orientation; |
| 1931 |
gboolean is_vertical; |
| 1932 |
|
| 1933 |
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); |
| 1934 |
|
| 1935 |
if (orientation == GTK_ORIENTATION_VERTICAL) |
| 1936 |
is_vertical = TRUE; |
| 1937 |
else |
| 1938 |
is_vertical = FALSE; |
| 1939 |
|
| 1940 |
if (xp_theme_draw (window, |
| 1941 |
is_vertical |
| 1942 |
? XP_THEME_ELEMENT_SCROLLBAR_V |
| 1943 |
: XP_THEME_ELEMENT_SCROLLBAR_H, |
| 1944 |
style, x, y, width, height, state_type, area)) |
| 1945 |
{ |
| 1946 |
XpThemeElement gripper = |
| 1947 |
(is_vertical ? XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V : |
| 1948 |
XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H); |
| 1949 |
|
| 1950 |
/* Do not display grippers on tiny scroll bars, |
| 1951 |
the limit imposed is rather arbitrary, perhaps |
| 1952 |
we can fetch the gripper geometry from |
| 1953 |
somewhere and use that... */ |
| 1954 |
if ((gripper == |
| 1955 |
XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_H |
| 1956 |
&& width < 16) |
| 1957 |
|| (gripper == |
| 1958 |
XP_THEME_ELEMENT_SCROLLBAR_GRIPPER_V && height < 16)) |
| 1959 |
{ |
| 1960 |
return; |
| 1961 |
} |
| 1962 |
|
| 1963 |
xp_theme_draw (window, gripper, style, x, y, |
| 1964 |
width, height, state_type, area); |
| 1965 |
return; |
| 1966 |
} |
| 1967 |
else |
| 1968 |
{ |
| 1969 |
if (gtk_range_get_adjustment(&scrollbar->range)->page_size >= |
| 1970 |
(gtk_range_get_adjustment(&scrollbar->range)->upper - |
| 1971 |
gtk_range_get_adjustment(&scrollbar->range)->lower)) |
| 1972 |
{ |
| 1973 |
return; |
| 1974 |
} |
| 1975 |
} |
| 1976 |
} |
| 1977 |
} |
| 1978 |
else if (DETAIL("bar")) |
| 1979 |
{ |
| 1980 |
if (widget && GTK_IS_PROGRESS_BAR (widget)) |
| 1981 |
{ |
| 1982 |
GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget); |
| 1983 |
XpThemeElement xp_progress_bar = |
| 1984 |
map_gtk_progress_bar_to_xp (progress_bar, FALSE); |
| 1985 |
|
| 1986 |
if (xp_theme_draw (window, xp_progress_bar, style, x, y, |
| 1987 |
width, height, state_type, area)) |
| 1988 |
{ |
| 1989 |
return; |
| 1990 |
} |
| 1991 |
|
| 1992 |
shadow_type = GTK_SHADOW_NONE; |
| 1993 |
} |
| 1994 |
} |
| 1995 |
else if (DETAIL("menuitem")) |
| 1996 |
{ |
| 1997 |
shadow_type = GTK_SHADOW_NONE; |
| 1998 |
if (draw_menu_item (window, widget, style, |
| 1999 |
x, y, width, height, state_type, area)) |
| 2000 |
{ |
| 2001 |
return; |
| 2002 |
} |
| 2003 |
} |
| 2004 |
else if (DETAIL("trough")) |
| 2005 |
{ |
| 2006 |
if (widget && GTK_IS_PROGRESS_BAR (widget)) |
| 2007 |
{ |
| 2008 |
GtkProgressBar *progress_bar = GTK_PROGRESS_BAR (widget); |
| 2009 |
XpThemeElement xp_progress_bar = |
| 2010 |
map_gtk_progress_bar_to_xp (progress_bar, TRUE); |
| 2011 |
if (xp_theme_draw |
| 2012 |
(window, xp_progress_bar, style, x, y, width, height, |
| 2013 |
state_type, area)) |
| 2014 |
{ |
| 2015 |
return; |
| 2016 |
} |
| 2017 |
else |
| 2018 |
{ |
| 2019 |
/* Blank in classic Windows */ |
| 2020 |
} |
| 2021 |
} |
| 2022 |
else if (widget && GTK_IS_SCROLLBAR (widget)) |
| 2023 |
{ |
| 2024 |
GtkOrientation orientation; |
| 2025 |
gboolean is_vertical; |
| 2026 |
|
| 2027 |
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); |
| 2028 |
|
| 2029 |
if (orientation == GTK_ORIENTATION_VERTICAL) |
| 2030 |
is_vertical = TRUE; |
| 2031 |
else |
| 2032 |
is_vertical = FALSE; |
| 2033 |
|
| 2034 |
if (xp_theme_draw (window, |
| 2035 |
is_vertical |
| 2036 |
? XP_THEME_ELEMENT_TROUGH_V |
| 2037 |
: XP_THEME_ELEMENT_TROUGH_H, |
| 2038 |
style, x, y, width, height, state_type, area)) |
| 2039 |
{ |
| 2040 |
return; |
| 2041 |
} |
| 2042 |
else |
| 2043 |
{ |
| 2044 |
HDC dc; |
| 2045 |
RECT rect; |
| 2046 |
XpDCInfo dc_info; |
| 2047 |
|
| 2048 |
sanitize_size (window, &width, &height); |
| 2049 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 2050 |
|
| 2051 |
SetTextColor (dc, GetSysColor (COLOR_3DHILIGHT)); |
| 2052 |
SetBkColor (dc, GetSysColor (COLOR_BTNFACE)); |
| 2053 |
FillRect (dc, &rect, get_dither_brush ()); |
| 2054 |
|
| 2055 |
release_window_dc (&dc_info); |
| 2056 |
|
| 2057 |
return; |
| 2058 |
} |
| 2059 |
} |
| 2060 |
else if (widget && GTK_IS_SCALE (widget)) |
| 2061 |
{ |
| 2062 |
GtkOrientation orientation; |
| 2063 |
|
| 2064 |
orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget)); |
| 2065 |
|
| 2066 |
if (!xp_theme_is_active ()) |
| 2067 |
{ |
| 2068 |
parent_class->draw_box (style, window, state_type, |
| 2069 |
GTK_SHADOW_NONE, area, |
| 2070 |
widget, detail, x, y, width, height); |
| 2071 |
} |
| 2072 |
|
| 2073 |
if (orientation == GTK_ORIENTATION_VERTICAL) |
| 2074 |
{ |
| 2075 |
if (xp_theme_draw |
| 2076 |
(window, XP_THEME_ELEMENT_SCALE_TROUGH_V, |
| 2077 |
style, (2 * x + width) / 2, y, 2, height, |
| 2078 |
state_type, area)) |
| 2079 |
{ |
| 2080 |
return; |
| 2081 |
} |
| 2082 |
|
| 2083 |
parent_class->draw_box (style, window, state_type, |
| 2084 |
GTK_SHADOW_ETCHED_IN, |
| 2085 |
area, NULL, NULL, |
| 2086 |
(2 * x + width) / 2, y, 1, height); |
| 2087 |
} |
| 2088 |
else |
| 2089 |
{ |
| 2090 |
if (xp_theme_draw |
| 2091 |
(window, XP_THEME_ELEMENT_SCALE_TROUGH_H, |
| 2092 |
style, x, (2 * y + height) / 2, width, 2, |
| 2093 |
state_type, area)) |
| 2094 |
{ |
| 2095 |
return; |
| 2096 |
} |
| 2097 |
|
| 2098 |
parent_class->draw_box (style, window, state_type, |
| 2099 |
GTK_SHADOW_ETCHED_IN, |
| 2100 |
area, NULL, NULL, x, |
| 2101 |
(2 * y + height) / 2, width, 1); |
| 2102 |
} |
| 2103 |
|
| 2104 |
return; |
| 2105 |
} |
| 2106 |
} |
| 2107 |
else if (DETAIL("optionmenu")) |
| 2108 |
{ |
| 2109 |
if (xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT, |
| 2110 |
style, x, y, width, height, state_type, area)) |
| 2111 |
{ |
| 2112 |
return; |
| 2113 |
} |
| 2114 |
} |
| 2115 |
else if (DETAIL("vscrollbar") || DETAIL("hscrollbar")) |
| 2116 |
{ |
| 2117 |
return; |
| 2118 |
} |
| 2119 |
else if (DETAIL("handlebox_bin") || DETAIL("toolbar") || DETAIL("menubar")) |
| 2120 |
{ |
| 2121 |
sanitize_size (window, &width, &height); |
| 2122 |
if (xp_theme_draw (window, XP_THEME_ELEMENT_REBAR, |
| 2123 |
style, x, y, width, height, state_type, area)) |
| 2124 |
{ |
| 2125 |
return; |
| 2126 |
} |
| 2127 |
} |
| 2128 |
else if (DETAIL("handlebox")) /* grip */ |
| 2129 |
{ |
| 2130 |
if (!xp_theme_is_active ()) |
| 2131 |
{ |
| 2132 |
return; |
| 2133 |
} |
| 2134 |
} |
| 2135 |
else if (DETAIL("notebook") && GTK_IS_NOTEBOOK (widget)) |
| 2136 |
{ |
| 2137 |
if (xp_theme_draw (window, XP_THEME_ELEMENT_TAB_PANE, style, |
| 2138 |
x, y, width, height, state_type, area)) |
| 2139 |
{ |
| 2140 |
return; |
| 2141 |
} |
| 2142 |
} |
| 2143 |
|
| 2144 |
else |
| 2145 |
{ |
| 2146 |
const gchar *name = gtk_widget_get_name (widget); |
| 2147 |
|
| 2148 |
if (name && !strcmp (name, "gtk-tooltips")) |
| 2149 |
{ |
| 2150 |
if (xp_theme_draw |
| 2151 |
(window, XP_THEME_ELEMENT_TOOLTIP, style, x, y, width, |
| 2152 |
height, state_type, area)) |
| 2153 |
{ |
| 2154 |
return; |
| 2155 |
} |
| 2156 |
else |
| 2157 |
{ |
| 2158 |
HBRUSH brush; |
| 2159 |
RECT rect; |
| 2160 |
XpDCInfo dc_info; |
| 2161 |
HDC hdc; |
| 2162 |
|
| 2163 |
hdc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 2164 |
|
| 2165 |
brush = GetSysColorBrush (COLOR_3DDKSHADOW); |
| 2166 |
|
| 2167 |
if (brush) |
| 2168 |
{ |
| 2169 |
FrameRect (hdc, &rect, brush); |
| 2170 |
} |
| 2171 |
|
| 2172 |
InflateRect (&rect, -1, -1); |
| 2173 |
FillRect (hdc, &rect, (HBRUSH) (COLOR_INFOBK + 1)); |
| 2174 |
|
| 2175 |
release_window_dc (&dc_info); |
| 2176 |
|
| 2177 |
return; |
| 2178 |
} |
| 2179 |
} |
| 2180 |
} |
| 2181 |
|
| 2182 |
parent_class->draw_box (style, window, state_type, shadow_type, area, |
| 2183 |
widget, detail, x, y, width, height); |
| 2184 |
|
| 2185 |
if (DETAIL("optionmenu")) |
| 2186 |
{ |
| 2187 |
GtkRequisition indicator_size; |
| 2188 |
GtkBorder indicator_spacing; |
| 2189 |
gint vline_x; |
| 2190 |
|
| 2191 |
option_menu_get_props (widget, &indicator_size, &indicator_spacing); |
| 2192 |
|
| 2193 |
sanitize_size (window, &width, &height); |
| 2194 |
|
| 2195 |
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) |
| 2196 |
{ |
| 2197 |
vline_x = |
| 2198 |
x + indicator_size.width + indicator_spacing.left + |
| 2199 |
indicator_spacing.right; |
| 2200 |
} |
| 2201 |
else |
| 2202 |
{ |
| 2203 |
vline_x = x + width - (indicator_size.width + |
| 2204 |
indicator_spacing.left + |
| 2205 |
indicator_spacing.right) - style->xthickness; |
| 2206 |
|
| 2207 |
parent_class->draw_vline (style, window, state_type, area, widget, |
| 2208 |
detail, |
| 2209 |
y + style->ythickness + 1, |
| 2210 |
y + height - style->ythickness - 3, vline_x); |
| 2211 |
} |
| 2212 |
} |
| 2213 |
} |
| 2214 |
|
| 2215 |
static void |
| 2216 |
draw_tab (GtkStyle *style, |
| 2217 |
GdkWindow *window, |
| 2218 |
GtkStateType state, |
| 2219 |
GtkShadowType shadow, |
| 2220 |
GdkRectangle *area, |
| 2221 |
GtkWidget *widget, |
| 2222 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 2223 |
{ |
| 2224 |
GtkRequisition indicator_size; |
| 2225 |
GtkBorder indicator_spacing; |
| 2226 |
|
| 2227 |
gint arrow_height; |
| 2228 |
|
| 2229 |
g_return_if_fail (style != NULL); |
| 2230 |
g_return_if_fail (window != NULL); |
| 2231 |
|
| 2232 |
if (DETAIL("optionmenutab")) |
| 2233 |
{ |
| 2234 |
if (xp_theme_draw (window, XP_THEME_ELEMENT_COMBOBUTTON, |
| 2235 |
style, x - 5, widget->allocation.y + 1, |
| 2236 |
width + 10, widget->allocation.height - 2, |
| 2237 |
state, area)) |
| 2238 |
{ |
| 2239 |
return; |
| 2240 |
} |
| 2241 |
} |
| 2242 |
|
| 2243 |
option_menu_get_props (widget, &indicator_size, &indicator_spacing); |
| 2244 |
|
| 2245 |
x += (width - indicator_size.width) / 2; |
| 2246 |
arrow_height = (indicator_size.width + 1) / 2; |
| 2247 |
|
| 2248 |
y += (height - arrow_height) / 2; |
| 2249 |
|
| 2250 |
draw_varrow (window, &style->black, shadow, area, GTK_ARROW_DOWN, |
| 2251 |
x, y, indicator_size.width, arrow_height); |
| 2252 |
} |
| 2253 |
|
| 2254 |
/* Draw classic Windows tab - thanks Mozilla! |
| 2255 |
(no system API for this, but DrawEdge can draw all the parts of a tab) */ |
| 2256 |
static void |
| 2257 |
DrawTab (HDC hdc, const RECT R, gint32 aPosition, gboolean aSelected, |
| 2258 |
gboolean aDrawLeft, gboolean aDrawRight) |
| 2259 |
{ |
| 2260 |
gint32 leftFlag, topFlag, rightFlag, lightFlag, shadeFlag; |
| 2261 |
RECT topRect, sideRect, bottomRect, lightRect, shadeRect; |
| 2262 |
gint32 selectedOffset, lOffset, rOffset; |
| 2263 |
|
| 2264 |
selectedOffset = aSelected ? 1 : 0; |
| 2265 |
lOffset = aDrawLeft ? 2 : 0; |
| 2266 |
rOffset = aDrawRight ? 2 : 0; |
| 2267 |
|
| 2268 |
/* Get info for tab orientation/position (Left, Top, Right, Bottom) */ |
| 2269 |
switch (aPosition) |
| 2270 |
{ |
| 2271 |
case BF_LEFT: |
| 2272 |
leftFlag = BF_TOP; |
| 2273 |
topFlag = BF_LEFT; |
| 2274 |
rightFlag = BF_BOTTOM; |
| 2275 |
lightFlag = BF_DIAGONAL_ENDTOPRIGHT; |
| 2276 |
shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT; |
| 2277 |
|
| 2278 |
SetRect (&topRect, R.left, R.top + lOffset, R.right, |
| 2279 |
R.bottom - rOffset); |
| 2280 |
SetRect (&sideRect, R.left + 2, R.top, R.right - 2 + selectedOffset, |
| 2281 |
R.bottom); |
| 2282 |
SetRect (&bottomRect, R.right - 2, R.top, R.right, R.bottom); |
| 2283 |
SetRect (&lightRect, R.left, R.top, R.left + 3, R.top + 3); |
| 2284 |
SetRect (&shadeRect, R.left + 1, R.bottom - 2, R.left + 2, |
| 2285 |
R.bottom - 1); |
| 2286 |
break; |
| 2287 |
|
| 2288 |
case BF_TOP: |
| 2289 |
leftFlag = BF_LEFT; |
| 2290 |
topFlag = BF_TOP; |
| 2291 |
rightFlag = BF_RIGHT; |
| 2292 |
lightFlag = BF_DIAGONAL_ENDTOPRIGHT; |
| 2293 |
shadeFlag = BF_DIAGONAL_ENDBOTTOMRIGHT; |
| 2294 |
|
| 2295 |
SetRect (&topRect, R.left + lOffset, R.top, R.right - rOffset, |
| 2296 |
R.bottom); |
| 2297 |
SetRect (&sideRect, R.left, R.top + 2, R.right, |
| 2298 |
R.bottom - 1 + selectedOffset); |
| 2299 |
SetRect (&bottomRect, R.left, R.bottom - 1, R.right, R.bottom); |
| 2300 |
SetRect (&lightRect, R.left, R.top, R.left + 3, R.top + 3); |
| 2301 |
SetRect (&shadeRect, R.right - 2, R.top + 1, R.right - 1, R.top + 2); |
| 2302 |
break; |
| 2303 |
|
| 2304 |
case BF_RIGHT: |
| 2305 |
leftFlag = BF_TOP; |
| 2306 |
topFlag = BF_RIGHT; |
| 2307 |
rightFlag = BF_BOTTOM; |
| 2308 |
lightFlag = BF_DIAGONAL_ENDTOPLEFT; |
| 2309 |
shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT; |
| 2310 |
|
| 2311 |
SetRect (&topRect, R.left, R.top + lOffset, R.right, |
| 2312 |
R.bottom - rOffset); |
| 2313 |
SetRect (&sideRect, R.left + 2 - selectedOffset, R.top, R.right - 2, |
| 2314 |
R.bottom); |
| 2315 |
SetRect (&bottomRect, R.left, R.top, R.left + 2, R.bottom); |
| 2316 |
SetRect (&lightRect, R.right - 3, R.top, R.right - 1, R.top + 2); |
| 2317 |
SetRect (&shadeRect, R.right - 2, R.bottom - 3, R.right, R.bottom - 1); |
| 2318 |
break; |
| 2319 |
|
| 2320 |
case BF_BOTTOM: |
| 2321 |
leftFlag = BF_LEFT; |
| 2322 |
topFlag = BF_BOTTOM; |
| 2323 |
rightFlag = BF_RIGHT; |
| 2324 |
lightFlag = BF_DIAGONAL_ENDTOPLEFT; |
| 2325 |
shadeFlag = BF_DIAGONAL_ENDBOTTOMLEFT; |
| 2326 |
|
| 2327 |
SetRect (&topRect, R.left + lOffset, R.top, R.right - rOffset, |
| 2328 |
R.bottom); |
| 2329 |
SetRect (&sideRect, R.left, R.top + 2 - selectedOffset, R.right, |
| 2330 |
R.bottom - 2); |
| 2331 |
SetRect (&bottomRect, R.left, R.top, R.right, R.top + 2); |
| 2332 |
SetRect (&lightRect, R.left, R.bottom - 3, R.left + 2, R.bottom - 1); |
| 2333 |
SetRect (&shadeRect, R.right - 2, R.bottom - 3, R.right, R.bottom - 1); |
| 2334 |
break; |
| 2335 |
|
| 2336 |
default: |
| 2337 |
g_return_if_reached (); |
| 2338 |
} |
| 2339 |
|
| 2340 |
/* Background */ |
| 2341 |
FillRect (hdc, &R, (HBRUSH) (COLOR_3DFACE + 1)); |
| 2342 |
|
| 2343 |
/* Tab "Top" */ |
| 2344 |
DrawEdge (hdc, &topRect, EDGE_RAISED, BF_SOFT | topFlag); |
| 2345 |
|
| 2346 |
/* Tab "Bottom" */ |
| 2347 |
if (!aSelected) |
| 2348 |
DrawEdge (hdc, &bottomRect, EDGE_RAISED, BF_SOFT | topFlag); |
| 2349 |
|
| 2350 |
/* Tab "Sides" */ |
| 2351 |
if (!aDrawLeft) |
| 2352 |
leftFlag = 0; |
| 2353 |
if (!aDrawRight) |
| 2354 |
rightFlag = 0; |
| 2355 |
|
| 2356 |
DrawEdge (hdc, &sideRect, EDGE_RAISED, BF_SOFT | leftFlag | rightFlag); |
| 2357 |
|
| 2358 |
/* Tab Diagonal Corners */ |
| 2359 |
if (aDrawLeft) |
| 2360 |
DrawEdge (hdc, &lightRect, EDGE_RAISED, BF_SOFT | lightFlag); |
| 2361 |
|
| 2362 |
if (aDrawRight) |
| 2363 |
DrawEdge (hdc, &shadeRect, EDGE_RAISED, BF_SOFT | shadeFlag); |
| 2364 |
} |
| 2365 |
|
| 2366 |
static void |
| 2367 |
get_notebook_tab_position (GtkNotebook *notebook, |
| 2368 |
gboolean *start, |
| 2369 |
gboolean *end) |
| 2370 |
{ |
| 2371 |
gboolean found_start = FALSE, found_end = FALSE; |
| 2372 |
gint i, n_pages; |
| 2373 |
|
| 2374 |
/* default value */ |
| 2375 |
*start = TRUE; |
| 2376 |
*end = FALSE; |
| 2377 |
|
| 2378 |
n_pages = gtk_notebook_get_n_pages (notebook); |
| 2379 |
for (i = 0; i < n_pages; i++) |
| 2380 |
{ |
| 2381 |
GtkWidget *tab_child; |
| 2382 |
GtkWidget *tab_label; |
| 2383 |
gboolean expand; |
| 2384 |
GtkPackType pack_type; |
| 2385 |
gboolean is_selected; |
| 2386 |
|
| 2387 |
tab_child = gtk_notebook_get_nth_page (notebook, i); |
| 2388 |
is_selected = gtk_notebook_get_current_page (notebook) == i; |
| 2389 |
|
| 2390 |
/* Skip invisible tabs */ |
| 2391 |
tab_label = gtk_notebook_get_tab_label (notebook, tab_child); |
| 2392 |
if (!tab_label || !GTK_WIDGET_VISIBLE (tab_label)) |
| 2393 |
continue; |
| 2394 |
|
| 2395 |
/* Mimics what the notebook does internally. */ |
| 2396 |
if (tab_label && !gtk_widget_get_child_visible (tab_label)) |
| 2397 |
{ |
| 2398 |
/* One child is hidden because scroll arrows are present. |
| 2399 |
* So both corners are rounded. */ |
| 2400 |
*start = FALSE; |
| 2401 |
*end = FALSE; |
| 2402 |
return; |
| 2403 |
} |
| 2404 |
|
| 2405 |
gtk_notebook_query_tab_label_packing (notebook, tab_child, &expand, |
| 2406 |
NULL, /* don't need fill */ |
| 2407 |
&pack_type); |
| 2408 |
|
| 2409 |
if (pack_type == GTK_PACK_START) |
| 2410 |
{ |
| 2411 |
if (!found_start) |
| 2412 |
{ |
| 2413 |
/* This is the first tab with PACK_START pack type */ |
| 2414 |
found_start = TRUE; |
| 2415 |
|
| 2416 |
if (is_selected) |
| 2417 |
{ |
| 2418 |
/* first PACK_START item is selected: set start to TRUE */ |
| 2419 |
*start = TRUE; |
| 2420 |
|
| 2421 |
if (expand && !found_end) |
| 2422 |
{ |
| 2423 |
/* tentatively set end to TRUE: will be invalidated if we |
| 2424 |
* find other items */ |
| 2425 |
*end = TRUE; |
| 2426 |
} |
| 2427 |
} |
| 2428 |
else |
| 2429 |
{ |
| 2430 |
*start = FALSE; |
| 2431 |
} |
| 2432 |
} |
| 2433 |
else if (!found_end && !is_selected) |
| 2434 |
{ |
| 2435 |
/* an unselected item exists, and no item with PACK_END pack type */ |
| 2436 |
*end = FALSE; |
| 2437 |
} |
| 2438 |
} |
| 2439 |
|
| 2440 |
if (pack_type == GTK_PACK_END) |
| 2441 |
{ |
| 2442 |
if (!found_end) |
| 2443 |
{ |
| 2444 |
/* This is the first tab with PACK_END pack type */ |
| 2445 |
found_end = TRUE; |
| 2446 |
|
| 2447 |
if (is_selected) |
| 2448 |
{ |
| 2449 |
/* first PACK_END item is selected: set end to TRUE */ |
| 2450 |
*end = TRUE; |
| 2451 |
|
| 2452 |
if (expand && !found_start) |
| 2453 |
{ |
| 2454 |
/* tentatively set start to TRUE: will be invalidated if |
| 2455 |
* we find other items */ |
| 2456 |
*start = TRUE; |
| 2457 |
} |
| 2458 |
} |
| 2459 |
else |
| 2460 |
{ |
| 2461 |
*end = FALSE; |
| 2462 |
} |
| 2463 |
} |
| 2464 |
else if (!found_start && !is_selected) |
| 2465 |
{ |
| 2466 |
*start = FALSE; |
| 2467 |
} |
| 2468 |
} |
| 2469 |
} |
| 2470 |
} |
| 2471 |
|
| 2472 |
static gboolean |
| 2473 |
draw_themed_tab_button (GtkStyle *style, |
| 2474 |
GdkWindow *window, |
| 2475 |
GtkStateType state_type, |
| 2476 |
GtkNotebook *notebook, |
| 2477 |
gint x, |
| 2478 |
gint y, |
| 2479 |
gint width, |
| 2480 |
gint height, |
| 2481 |
gint gap_side) |
| 2482 |
{ |
| 2483 |
GdkPixmap *pixmap = NULL; |
| 2484 |
GdkRectangle draw_rect, clip_rect; |
| 2485 |
cairo_t *cr; |
| 2486 |
gboolean start, stop; |
| 2487 |
XpThemeElement element; |
| 2488 |
gint d_w, d_h; |
| 2489 |
|
| 2490 |
get_notebook_tab_position (notebook, &start, &stop); |
| 2491 |
|
| 2492 |
if (state_type == GTK_STATE_NORMAL) |
| 2493 |
{ |
| 2494 |
if (start && stop) |
| 2495 |
{ |
| 2496 |
/* Both edges of the notebook are covered by the item */ |
| 2497 |
element = XP_THEME_ELEMENT_TAB_ITEM_BOTH_EDGE; |
| 2498 |
} |
| 2499 |
else if (start) |
| 2500 |
{ |
| 2501 |
/* The start edge is covered by the item */ |
| 2502 |
element = XP_THEME_ELEMENT_TAB_ITEM_LEFT_EDGE; |
| 2503 |
} |
| 2504 |
else if (stop) |
| 2505 |
{ |
| 2506 |
/* the stop edge is reached by the item */ |
| 2507 |
element = XP_THEME_ELEMENT_TAB_ITEM_RIGHT_EDGE; |
| 2508 |
} |
| 2509 |
else |
| 2510 |
{ |
| 2511 |
/* no edge should be aligned with the tab */ |
| 2512 |
element = XP_THEME_ELEMENT_TAB_ITEM; |
| 2513 |
} |
| 2514 |
} |
| 2515 |
else |
| 2516 |
{ |
| 2517 |
/* Ideally, we should do the same here. Unfortunately, we don't have ways |
| 2518 |
* to determine what tab widget is actually being drawn here, so we can't |
| 2519 |
* determine its position relative to the borders */ |
| 2520 |
element = XP_THEME_ELEMENT_TAB_ITEM; |
| 2521 |
} |
| 2522 |
|
| 2523 |
draw_rect.x = x; |
| 2524 |
draw_rect.y = y; |
| 2525 |
draw_rect.width = width; |
| 2526 |
draw_rect.height = height; |
| 2527 |
|
| 2528 |
/* Perform adjustments required to have the theme perfectly aligned */ |
| 2529 |
if (state_type == GTK_STATE_ACTIVE) |
| 2530 |
{ |
| 2531 |
switch (gap_side) |
| 2532 |
{ |
| 2533 |
case GTK_POS_TOP: |
| 2534 |
draw_rect.x += 2; |
| 2535 |
draw_rect.width -= 2; |
| 2536 |
draw_rect.height -= 1; |
| 2537 |
break; |
| 2538 |
case GTK_POS_BOTTOM: |
| 2539 |
draw_rect.x += 2; |
| 2540 |
draw_rect.width -= 2; |
| 2541 |
draw_rect.y += 1; |
| 2542 |
draw_rect.height -= 1; |
| 2543 |
break; |
| 2544 |
case GTK_POS_LEFT: |
| 2545 |
draw_rect.y += 2; |
| 2546 |
draw_rect.height -= 2; |
| 2547 |
draw_rect.width -= 1; |
| 2548 |
break; |
| 2549 |
case GTK_POS_RIGHT: |
| 2550 |
draw_rect.y += 2; |
| 2551 |
draw_rect.height -= 2; |
| 2552 |
draw_rect.x += 1; |
| 2553 |
draw_rect.width -= 1; |
| 2554 |
break; |
| 2555 |
} |
| 2556 |
} |
| 2557 |
else |
| 2558 |
{ |
| 2559 |
switch (gap_side) |
| 2560 |
{ |
| 2561 |
case GTK_POS_TOP: |
| 2562 |
draw_rect.height += 1; |
| 2563 |
draw_rect.width += 2; |
| 2564 |
break; |
| 2565 |
case GTK_POS_BOTTOM: |
| 2566 |
draw_rect.y -= 1; |
| 2567 |
draw_rect.height += 1; |
| 2568 |
draw_rect.width += 2; |
| 2569 |
break; |
| 2570 |
case GTK_POS_LEFT: |
| 2571 |
draw_rect.width += 1; |
| 2572 |
draw_rect.height += 2; |
| 2573 |
break; |
| 2574 |
case GTK_POS_RIGHT: |
| 2575 |
draw_rect.x -= 1; |
| 2576 |
draw_rect.width += 1; |
| 2577 |
draw_rect.height += 2; |
| 2578 |
break; |
| 2579 |
} |
| 2580 |
} |
| 2581 |
|
| 2582 |
clip_rect = draw_rect; |
| 2583 |
|
| 2584 |
/* Take care of obvious case where the clipping is an empty region */ |
| 2585 |
if (clip_rect.width <= 0 || clip_rect.height <= 0) |
| 2586 |
return TRUE; |
| 2587 |
|
| 2588 |
/* Simple case: tabs on top are just drawn as is */ |
| 2589 |
if (gap_side == GTK_POS_TOP) |
| 2590 |
{ |
| 2591 |
return xp_theme_draw (window, element, style, |
| 2592 |
draw_rect.x, draw_rect.y, |
| 2593 |
draw_rect.width, draw_rect.height, |
| 2594 |
state_type, &clip_rect); |
| 2595 |
} |
| 2596 |
|
| 2597 |
/* For other cases, we need to print the tab on a pixmap, and then rotate |
| 2598 |
* it according to the gap side */ |
| 2599 |
if (gap_side == GTK_POS_LEFT || gap_side == GTK_POS_RIGHT) |
| 2600 |
{ |
| 2601 |
/* pixmap will have width/height inverted as we'll rotate +- PI / 2 */ |
| 2602 |
d_w = draw_rect.height; |
| 2603 |
d_h = draw_rect.width; |
| 2604 |
} |
| 2605 |
else |
| 2606 |
{ |
| 2607 |
d_w = draw_rect.width; |
| 2608 |
d_h = draw_rect.height; |
| 2609 |
} |
| 2610 |
|
| 2611 |
pixmap = gdk_pixmap_new (window, d_w, d_h, -1); |
| 2612 |
|
| 2613 |
/* First copy the previously saved window background */ |
| 2614 |
cr = gdk_cairo_create (pixmap); |
| 2615 |
|
| 2616 |
/* pixmaps unfortunately don't handle the alpha channel. We then |
| 2617 |
* paint it first in white, hoping the actual background is clear */ |
| 2618 |
cairo_set_source_rgb (cr, 1, 1, 1); |
| 2619 |
cairo_paint (cr); |
| 2620 |
cairo_destroy (cr); |
| 2621 |
|
| 2622 |
if (!xp_theme_draw (pixmap, element, style, 0, 0, d_w, d_h, state_type, 0)) |
| 2623 |
{ |
| 2624 |
g_object_unref (pixmap); |
| 2625 |
return FALSE; |
| 2626 |
} |
| 2627 |
|
| 2628 |
/* Now we have the pixmap, we need to flip/rotate it according to its |
| 2629 |
* final position. We'll do it using cairo on the dest window */ |
| 2630 |
cr = gdk_cairo_create (window); |
| 2631 |
cairo_rectangle (cr, clip_rect.x, clip_rect.y, |
| 2632 |
clip_rect.width, clip_rect.height); |
| 2633 |
cairo_clip (cr); |
| 2634 |
cairo_translate(cr, draw_rect.x + draw_rect.width * 0.5, |
| 2635 |
draw_rect.y + draw_rect.height * 0.5); |
| 2636 |
|
| 2637 |
if (gap_side == GTK_POS_LEFT || gap_side == GTK_POS_RIGHT) { |
| 2638 |
cairo_rotate (cr, G_PI/2.0); |
| 2639 |
} |
| 2640 |
|
| 2641 |
if (gap_side == GTK_POS_LEFT || gap_side == GTK_POS_BOTTOM) { |
| 2642 |
cairo_scale (cr, 1, -1); |
| 2643 |
} |
| 2644 |
|
| 2645 |
cairo_translate(cr, -d_w * 0.5, -d_h * 0.5); |
| 2646 |
gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0); |
| 2647 |
cairo_paint (cr); |
| 2648 |
cairo_destroy (cr); |
| 2649 |
|
| 2650 |
g_object_unref (pixmap); |
| 2651 |
|
| 2652 |
return TRUE; |
| 2653 |
} |
| 2654 |
|
| 2655 |
static gboolean |
| 2656 |
draw_tab_button (GtkStyle *style, |
| 2657 |
GdkWindow *window, |
| 2658 |
GtkStateType state_type, |
| 2659 |
GtkShadowType shadow_type, |
| 2660 |
GdkRectangle *area, |
| 2661 |
GtkWidget *widget, |
| 2662 |
const gchar *detail, |
| 2663 |
gint x, gint y, gint width, gint height, gint gap_side) |
| 2664 |
{ |
| 2665 |
if (gap_side == GTK_POS_TOP || gap_side == GTK_POS_BOTTOM) |
| 2666 |
{ |
| 2667 |
/* experimental tab-drawing code from mozilla */ |
| 2668 |
RECT rect; |
| 2669 |
XpDCInfo dc_info; |
| 2670 |
HDC dc; |
| 2671 |
gint32 aPosition; |
| 2672 |
cairo_t *cr; |
| 2673 |
|
| 2674 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 2675 |
cr = gdk_cairo_create (window); |
| 2676 |
|
| 2677 |
if (gap_side == GTK_POS_TOP) |
| 2678 |
aPosition = BF_TOP; |
| 2679 |
else if (gap_side == GTK_POS_BOTTOM) |
| 2680 |
aPosition = BF_BOTTOM; |
| 2681 |
else if (gap_side == GTK_POS_LEFT) |
| 2682 |
aPosition = BF_LEFT; |
| 2683 |
else |
| 2684 |
aPosition = BF_RIGHT; |
| 2685 |
|
| 2686 |
if (state_type == GTK_STATE_PRELIGHT) |
| 2687 |
state_type = GTK_STATE_NORMAL; |
| 2688 |
if (area) |
| 2689 |
{ |
| 2690 |
gdk_cairo_rectangle (cr, area); |
| 2691 |
cairo_clip (cr); |
| 2692 |
gdk_cairo_set_source_color (cr, &style->dark[state_type]); |
| 2693 |
} |
| 2694 |
|
| 2695 |
DrawTab (dc, rect, aPosition, |
| 2696 |
state_type != GTK_STATE_PRELIGHT, |
| 2697 |
(gap_side != GTK_POS_LEFT), (gap_side != GTK_POS_RIGHT)); |
| 2698 |
|
| 2699 |
cairo_destroy (cr); |
| 2700 |
|
| 2701 |
release_window_dc (&dc_info); |
| 2702 |
return TRUE; |
| 2703 |
} |
| 2704 |
|
| 2705 |
return FALSE; |
| 2706 |
} |
| 2707 |
|
| 2708 |
static void |
| 2709 |
draw_extension (GtkStyle *style, |
| 2710 |
GdkWindow *window, |
| 2711 |
GtkStateType state_type, |
| 2712 |
GtkShadowType shadow_type, |
| 2713 |
GdkRectangle *area, |
| 2714 |
GtkWidget *widget, |
| 2715 |
const gchar *detail, |
| 2716 |
gint x, gint y, |
| 2717 |
gint width, gint height, GtkPositionType gap_side) |
| 2718 |
{ |
| 2719 |
if (widget && GTK_IS_NOTEBOOK (widget) && DETAIL("tab")) |
| 2720 |
{ |
| 2721 |
GtkNotebook *notebook = GTK_NOTEBOOK (widget); |
| 2722 |
|
| 2723 |
/* draw_themed_tab_button and draw_tab_button expect to work with tab |
| 2724 |
* position, instead of simply taking the "side of the gap" (gap_side). |
| 2725 |
* The gap side, simply said, is the side of the tab that touches the notebook |
| 2726 |
* frame and is always the exact opposite of the tab position... */ |
| 2727 |
int tab_pos = gtk_notebook_get_tab_pos (notebook); |
| 2728 |
|
| 2729 |
if (!draw_themed_tab_button (style, window, state_type, |
| 2730 |
notebook, x, y, |
| 2731 |
width, height, tab_pos)) |
| 2732 |
{ |
| 2733 |
if (!draw_tab_button (style, window, state_type, |
| 2734 |
shadow_type, area, widget, |
| 2735 |
detail, x, y, width, height, tab_pos)) |
| 2736 |
{ |
| 2737 |
/* GtkStyle expects the usual gap_side */ |
| 2738 |
parent_class->draw_extension (style, window, state_type, |
| 2739 |
shadow_type, area, widget, detail, |
| 2740 |
x, y, width, height, |
| 2741 |
gap_side); |
| 2742 |
} |
| 2743 |
} |
| 2744 |
} |
| 2745 |
} |
| 2746 |
|
| 2747 |
static void |
| 2748 |
draw_box_gap (GtkStyle *style, |
| 2749 |
GdkWindow *window, |
| 2750 |
GtkStateType state_type, |
| 2751 |
GtkShadowType shadow_type, |
| 2752 |
GdkRectangle *area, |
| 2753 |
GtkWidget *widget, |
| 2754 |
const gchar *detail, |
| 2755 |
gint x, |
| 2756 |
gint y, |
| 2757 |
gint width, |
| 2758 |
gint height, |
| 2759 |
GtkPositionType gap_side, |
| 2760 |
gint gap_x, |
| 2761 |
gint gap_width) |
| 2762 |
{ |
| 2763 |
if (GTK_IS_NOTEBOOK (widget) && DETAIL("notebook")) |
| 2764 |
{ |
| 2765 |
GtkNotebook *notebook = GTK_NOTEBOOK (widget); |
| 2766 |
|
| 2767 |
int side = gtk_notebook_get_tab_pos (notebook); |
| 2768 |
int x2 = x, y2 = y; |
| 2769 |
int w2 = width + style->xthickness, h2 = height + style->ythickness; |
| 2770 |
|
| 2771 |
switch (side) |
| 2772 |
{ |
| 2773 |
case GTK_POS_TOP: |
| 2774 |
y2 -= 1; |
| 2775 |
break; |
| 2776 |
case GTK_POS_BOTTOM: |
| 2777 |
break; |
| 2778 |
case GTK_POS_LEFT: |
| 2779 |
x2 -= 1; |
| 2780 |
break; |
| 2781 |
case GTK_POS_RIGHT: |
| 2782 |
w2 += 1; |
| 2783 |
break; |
| 2784 |
} |
| 2785 |
|
| 2786 |
if (xp_theme_draw (window, XP_THEME_ELEMENT_TAB_PANE, style, |
| 2787 |
x2, y2, w2, h2, state_type, area)) |
| 2788 |
{ |
| 2789 |
return; |
| 2790 |
} |
| 2791 |
} |
| 2792 |
|
| 2793 |
parent_class->draw_box_gap (style, window, state_type, shadow_type, |
| 2794 |
area, widget, detail, x, y, width, height, |
| 2795 |
gap_side, gap_x, gap_width); |
| 2796 |
} |
| 2797 |
|
| 2798 |
static gboolean |
| 2799 |
is_popup_window_child (GtkWidget *widget) |
| 2800 |
{ |
| 2801 |
GtkWidget *top; |
| 2802 |
GtkWindowType type = -1; |
| 2803 |
|
| 2804 |
top = gtk_widget_get_toplevel (widget); |
| 2805 |
|
| 2806 |
if (top && GTK_IS_WINDOW (top)) |
| 2807 |
{ |
| 2808 |
g_object_get (top, "type", &type, NULL); |
| 2809 |
|
| 2810 |
if (type == GTK_WINDOW_POPUP) |
| 2811 |
{ /* Hack for combo boxes */ |
| 2812 |
return TRUE; |
| 2813 |
} |
| 2814 |
} |
| 2815 |
|
| 2816 |
return FALSE; |
| 2817 |
} |
| 2818 |
|
| 2819 |
static void |
| 2820 |
draw_flat_box (GtkStyle *style, GdkWindow *window, |
| 2821 |
GtkStateType state_type, GtkShadowType shadow_type, |
| 2822 |
GdkRectangle *area, GtkWidget *widget, |
| 2823 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 2824 |
{ |
| 2825 |
if (detail) |
| 2826 |
{ |
| 2827 |
if (state_type == GTK_STATE_SELECTED && |
| 2828 |
(!strncmp ("cell_even", detail, 9) || !strncmp ("cell_odd", detail, 8))) |
| 2829 |
{ |
| 2830 |
GdkColor *gc = gtk_widget_has_focus (widget) ? &style->base[state_type] : &style->base[GTK_STATE_ACTIVE]; |
| 2831 |
cairo_t *cr = gdk_cairo_create (window); |
| 2832 |
|
| 2833 |
_cairo_draw_rectangle (cr, gc, TRUE, x, y, width, height); |
| 2834 |
|
| 2835 |
cairo_destroy (cr); |
| 2836 |
|
| 2837 |
return; |
| 2838 |
} |
| 2839 |
else if (DETAIL("checkbutton")) |
| 2840 |
{ |
| 2841 |
if (state_type == GTK_STATE_PRELIGHT) |
| 2842 |
{ |
| 2843 |
return; |
| 2844 |
} |
| 2845 |
} |
| 2846 |
} |
| 2847 |
|
| 2848 |
parent_class->draw_flat_box (style, window, state_type, shadow_type, |
| 2849 |
area, widget, detail, x, y, width, height); |
| 2850 |
} |
| 2851 |
|
| 2852 |
static gboolean |
| 2853 |
draw_menu_border (GdkWindow *win, GtkStyle *style, |
| 2854 |
gint x, gint y, gint width, gint height) |
| 2855 |
{ |
| 2856 |
RECT rect; |
| 2857 |
XpDCInfo dc_info; |
| 2858 |
HDC dc; |
| 2859 |
|
| 2860 |
dc = get_window_dc (style, win, GTK_STATE_NORMAL, &dc_info, x, y, width, height, &rect); |
| 2861 |
|
| 2862 |
if (!dc) |
| 2863 |
return FALSE; |
| 2864 |
|
| 2865 |
if (xp_theme_is_active ()) |
| 2866 |
{ |
| 2867 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_3DSHADOW)); |
| 2868 |
} |
| 2869 |
else |
| 2870 |
{ |
| 2871 |
DrawEdge (dc, &rect, EDGE_RAISED, BF_RECT); |
| 2872 |
} |
| 2873 |
|
| 2874 |
release_window_dc (&dc_info); |
| 2875 |
|
| 2876 |
return TRUE; |
| 2877 |
} |
| 2878 |
|
| 2879 |
static void |
| 2880 |
draw_shadow (GtkStyle *style, |
| 2881 |
GdkWindow *window, |
| 2882 |
GtkStateType state_type, |
| 2883 |
GtkShadowType shadow_type, |
| 2884 |
GdkRectangle *area, |
| 2885 |
GtkWidget *widget, |
| 2886 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 2887 |
{ |
| 2888 |
gboolean is_handlebox; |
| 2889 |
gboolean is_toolbar; |
| 2890 |
|
| 2891 |
if (DETAIL("frame")) |
| 2892 |
{ |
| 2893 |
|
| 2894 |
HDC dc; |
| 2895 |
RECT rect; |
| 2896 |
XpDCInfo dc_info; |
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 2901 |
if (is_combo_box_child (widget)) |
| 2902 |
{ |
| 2903 |
FillRect (dc, &rect, GetSysColorBrush (COLOR_WINDOW)); |
| 2904 |
} |
| 2905 |
else if (is_popup_window_child (widget)) |
| 2906 |
{ |
| 2907 |
FrameRect (dc, &rect, GetSysColorBrush (COLOR_WINDOWFRAME)); |
| 2908 |
} |
| 2909 |
else |
| 2910 |
{ |
| 2911 |
switch (shadow_type) |
| 2912 |
{ |
| 2913 |
case GTK_SHADOW_IN: |
| 2914 |
draw_3d_border (dc, &rect, TRUE); |
| 2915 |
break; |
| 2916 |
|
| 2917 |
case GTK_SHADOW_OUT: |
| 2918 |
draw_3d_border (dc, &rect, FALSE); |
| 2919 |
break; |
| 2920 |
|
| 2921 |
case GTK_SHADOW_ETCHED_IN: |
| 2922 |
draw_3d_border (dc, &rect, TRUE); |
| 2923 |
InflateRect (&rect, -1, -1); |
| 2924 |
draw_3d_border (dc, &rect, FALSE); |
| 2925 |
break; |
| 2926 |
|
| 2927 |
case GTK_SHADOW_ETCHED_OUT: |
| 2928 |
draw_3d_border (dc, &rect, FALSE); |
| 2929 |
InflateRect (&rect, -1, -1); |
| 2930 |
draw_3d_border (dc, &rect, TRUE); |
| 2931 |
break; |
| 2932 |
|
| 2933 |
case GTK_SHADOW_NONE: |
| 2934 |
break; |
| 2935 |
} |
| 2936 |
} |
| 2937 |
|
| 2938 |
release_window_dc (&dc_info); |
| 2939 |
|
| 2940 |
return; |
| 2941 |
} |
| 2942 |
if (DETAIL("entry") || DETAIL("combobox")) |
| 2943 |
{ |
| 2944 |
if (shadow_type != GTK_SHADOW_IN) |
| 2945 |
return; |
| 2946 |
|
| 2947 |
if (!xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT, style, |
| 2948 |
x, y, width, height, state_type, area)) |
| 2949 |
{ |
| 2950 |
HDC dc; |
| 2951 |
RECT rect; |
| 2952 |
XpDCInfo dc_info; |
| 2953 |
|
| 2954 |
dc = get_window_dc (style, window, state_type, &dc_info, |
| 2955 |
x, y, width, height, &rect); |
| 2956 |
|
| 2957 |
DrawEdge (dc, &rect, EDGE_SUNKEN, BF_RECT); |
| 2958 |
release_window_dc (&dc_info); |
| 2959 |
} |
| 2960 |
|
| 2961 |
return; |
| 2962 |
} |
| 2963 |
|
| 2964 |
if (DETAIL("scrolled_window") && |
| 2965 |
xp_theme_draw (window, XP_THEME_ELEMENT_EDIT_TEXT, style, |
| 2966 |
x, y, width, height, state_type, area)) |
| 2967 |
{ |
| 2968 |
return; |
| 2969 |
} |
| 2970 |
|
| 2971 |
if (DETAIL("spinbutton")) |
| 2972 |
return; |
| 2973 |
|
| 2974 |
if (DETAIL("menu")) |
| 2975 |
{ |
| 2976 |
if (draw_menu_border (window, style, x, y, width, height)) |
| 2977 |
{ |
| 2978 |
return; |
| 2979 |
} |
| 2980 |
} |
| 2981 |
|
| 2982 |
if (DETAIL("handlebox")) |
| 2983 |
return; |
| 2984 |
|
| 2985 |
is_handlebox = (DETAIL("handlebox_bin")); |
| 2986 |
is_toolbar = (DETAIL("toolbar") || DETAIL("menubar")); |
| 2987 |
|
| 2988 |
if (is_toolbar || is_handlebox) |
| 2989 |
{ |
| 2990 |
if (shadow_type == GTK_SHADOW_NONE) |
| 2991 |
{ |
| 2992 |
return; |
| 2993 |
} |
| 2994 |
|
| 2995 |
if (widget) |
| 2996 |
{ |
| 2997 |
HDC dc; |
| 2998 |
RECT rect; |
| 2999 |
XpDCInfo dc_info; |
| 3000 |
HGDIOBJ old_pen = NULL; |
| 3001 |
GtkPositionType pos; |
| 3002 |
|
| 3003 |
sanitize_size (window, &width, &height); |
| 3004 |
|
| 3005 |
if (is_handlebox) |
| 3006 |
{ |
| 3007 |
pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (widget)); |
| 3008 |
/* |
| 3009 |
If the handle box is at left side, |
| 3010 |
we shouldn't draw its right border. |
| 3011 |
The same holds true for top, right, and bottom. |
| 3012 |
*/ |
| 3013 |
switch (pos) |
| 3014 |
{ |
| 3015 |
case GTK_POS_LEFT: |
| 3016 |
pos = GTK_POS_RIGHT; |
| 3017 |
break; |
| 3018 |
|
| 3019 |
case GTK_POS_RIGHT: |
| 3020 |
pos = GTK_POS_LEFT; |
| 3021 |
break; |
| 3022 |
|
| 3023 |
case GTK_POS_TOP: |
| 3024 |
pos = GTK_POS_BOTTOM; |
| 3025 |
break; |
| 3026 |
|
| 3027 |
case GTK_POS_BOTTOM: |
| 3028 |
pos = GTK_POS_TOP; |
| 3029 |
break; |
| 3030 |
} |
| 3031 |
} |
| 3032 |
else |
| 3033 |
{ |
| 3034 |
GtkWidget *parent = gtk_widget_get_parent (widget); |
| 3035 |
|
| 3036 |
/* Dirty hack for toolbars contained in handle boxes */ |
| 3037 |
if (GTK_IS_HANDLE_BOX (parent)) |
| 3038 |
{ |
| 3039 |
pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (parent)); |
| 3040 |
} |
| 3041 |
else |
| 3042 |
{ |
| 3043 |
/* |
| 3044 |
Dirty hack: |
| 3045 |
Make pos != all legal enum vaules of GtkPositionType. |
| 3046 |
So every border will be draw. |
| 3047 |
*/ |
| 3048 |
pos = (GtkPositionType) - 1; |
| 3049 |
} |
| 3050 |
} |
| 3051 |
|
| 3052 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 3053 |
|
| 3054 |
if (pos != GTK_POS_LEFT) |
| 3055 |
{ |
| 3056 |
old_pen = SelectObject (dc, get_light_pen ()); |
| 3057 |
MoveToEx (dc, rect.left, rect.top, NULL); |
| 3058 |
LineTo (dc, rect.left, rect.bottom); |
| 3059 |
} |
| 3060 |
if (pos != GTK_POS_TOP) |
| 3061 |
{ |
| 3062 |
old_pen = SelectObject (dc, get_light_pen ()); |
| 3063 |
MoveToEx (dc, rect.left, rect.top, NULL); |
| 3064 |
LineTo (dc, rect.right, rect.top); |
| 3065 |
} |
| 3066 |
if (pos != GTK_POS_RIGHT) |
| 3067 |
{ |
| 3068 |
old_pen = SelectObject (dc, get_dark_pen ()); |
| 3069 |
MoveToEx (dc, rect.right - 1, rect.top, NULL); |
| 3070 |
LineTo (dc, rect.right - 1, rect.bottom); |
| 3071 |
} |
| 3072 |
if (pos != GTK_POS_BOTTOM) |
| 3073 |
{ |
| 3074 |
old_pen = SelectObject (dc, get_dark_pen ()); |
| 3075 |
MoveToEx (dc, rect.left, rect.bottom - 1, NULL); |
| 3076 |
LineTo (dc, rect.right, rect.bottom - 1); |
| 3077 |
} |
| 3078 |
if (old_pen) |
| 3079 |
SelectObject (dc, old_pen); |
| 3080 |
release_window_dc (&dc_info); |
| 3081 |
} |
| 3082 |
|
| 3083 |
return; |
| 3084 |
} |
| 3085 |
|
| 3086 |
if (DETAIL("statusbar")) |
| 3087 |
{ |
| 3088 |
return; |
| 3089 |
} |
| 3090 |
|
| 3091 |
parent_class->draw_shadow (style, window, state_type, shadow_type, area, |
| 3092 |
widget, detail, x, y, width, height); |
| 3093 |
} |
| 3094 |
|
| 3095 |
static void |
| 3096 |
draw_hline (GtkStyle *style, |
| 3097 |
GdkWindow *window, |
| 3098 |
GtkStateType state_type, |
| 3099 |
GdkRectangle *area, |
| 3100 |
GtkWidget *widget, |
| 3101 |
const gchar *detail, gint x1, gint x2, gint y) |
| 3102 |
{ |
| 3103 |
cairo_t *cr; |
| 3104 |
|
| 3105 |
cr = gdk_cairo_create (window); |
| 3106 |
|
| 3107 |
if (xp_theme_is_active () && DETAIL("menuitem")) |
| 3108 |
{ |
| 3109 |
gint cx, cy; |
| 3110 |
gint new_y, new_height; |
| 3111 |
gint y_offset; |
| 3112 |
|
| 3113 |
xp_theme_get_element_dimensions (XP_THEME_ELEMENT_MENU_SEPARATOR, |
| 3114 |
state_type, |
| 3115 |
&cx, &cy); |
| 3116 |
|
| 3117 |
/* Center the separator */ |
| 3118 |
y_offset = (area->height / 2) - (cy / 2); |
| 3119 |
new_y = y_offset >= 0 ? area->y + y_offset : area->y; |
| 3120 |
new_height = cy; |
| 3121 |
|
| 3122 |
if (xp_theme_draw |
| 3123 |
(window, XP_THEME_ELEMENT_MENU_SEPARATOR, style, x1, new_y, x2, new_height, |
| 3124 |
state_type, area)) |
| 3125 |
{ |
| 3126 |
return; |
| 3127 |
} |
| 3128 |
else |
| 3129 |
{ |
| 3130 |
if (area) |
| 3131 |
{ |
| 3132 |
gdk_cairo_rectangle (cr, area); |
| 3133 |
cairo_clip (cr); |
| 3134 |
} |
| 3135 |
|
| 3136 |
_cairo_draw_line (cr, &style->dark[state_type], x1, y, x2, y); |
| 3137 |
|
| 3138 |
} |
| 3139 |
} |
| 3140 |
else |
| 3141 |
{ |
| 3142 |
if (style->ythickness == 2) |
| 3143 |
{ |
| 3144 |
if (area) |
| 3145 |
{ |
| 3146 |
gdk_cairo_rectangle (cr, area); |
| 3147 |
cairo_clip (cr); |
| 3148 |
} |
| 3149 |
|
| 3150 |
_cairo_draw_line (cr, &style->dark[state_type], x1, y, x2, y); |
| 3151 |
++y; |
| 3152 |
_cairo_draw_line (cr, &style->light[state_type], x1, y, x2, y); |
| 3153 |
|
| 3154 |
} |
| 3155 |
else |
| 3156 |
{ |
| 3157 |
parent_class->draw_hline (style, window, state_type, area, widget, |
| 3158 |
detail, x1, x2, y); |
| 3159 |
} |
| 3160 |
} |
| 3161 |
cairo_destroy (cr); |
| 3162 |
} |
| 3163 |
|
| 3164 |
static void |
| 3165 |
draw_vline (GtkStyle *style, |
| 3166 |
GdkWindow *window, |
| 3167 |
GtkStateType state_type, |
| 3168 |
GdkRectangle *area, |
| 3169 |
GtkWidget *widget, |
| 3170 |
const gchar *detail, gint y1, gint y2, gint x) |
| 3171 |
{ |
| 3172 |
cairo_t *cr; |
| 3173 |
|
| 3174 |
cr = gdk_cairo_create (window); |
| 3175 |
|
| 3176 |
if (style->xthickness == 2) |
| 3177 |
{ |
| 3178 |
if (area) |
| 3179 |
{ |
| 3180 |
gdk_cairo_rectangle (cr, area); |
| 3181 |
cairo_clip (cr); |
| 3182 |
} |
| 3183 |
|
| 3184 |
_cairo_draw_line (cr, &style->dark[state_type], x, y1, x, y2); |
| 3185 |
++x; |
| 3186 |
_cairo_draw_line (cr, &style->light[state_type], x, y1, x, y2); |
| 3187 |
|
| 3188 |
} |
| 3189 |
else |
| 3190 |
{ |
| 3191 |
parent_class->draw_vline (style, window, state_type, area, widget, |
| 3192 |
detail, y1, y2, x); |
| 3193 |
} |
| 3194 |
|
| 3195 |
cairo_destroy (cr); |
| 3196 |
} |
| 3197 |
|
| 3198 |
static void |
| 3199 |
draw_slider (GtkStyle *style, |
| 3200 |
GdkWindow *window, |
| 3201 |
GtkStateType state_type, |
| 3202 |
GtkShadowType shadow_type, |
| 3203 |
GdkRectangle *area, |
| 3204 |
GtkWidget *widget, |
| 3205 |
const gchar *detail, |
| 3206 |
gint x, |
| 3207 |
gint y, gint width, gint height, GtkOrientation orientation) |
| 3208 |
{ |
| 3209 |
if (GTK_IS_SCALE (widget) && |
| 3210 |
xp_theme_draw (window, ((orientation == GTK_ORIENTATION_VERTICAL) ? |
| 3211 |
XP_THEME_ELEMENT_SCALE_SLIDER_V : |
| 3212 |
XP_THEME_ELEMENT_SCALE_SLIDER_H), style, x, y, width, |
| 3213 |
height, state_type, area)) |
| 3214 |
{ |
| 3215 |
return; |
| 3216 |
} |
| 3217 |
|
| 3218 |
parent_class->draw_slider (style, window, state_type, shadow_type, area, |
| 3219 |
widget, detail, x, y, width, height, |
| 3220 |
orientation); |
| 3221 |
} |
| 3222 |
|
| 3223 |
static void |
| 3224 |
draw_resize_grip (GtkStyle *style, |
| 3225 |
GdkWindow *window, |
| 3226 |
GtkStateType state_type, |
| 3227 |
GdkRectangle *area, |
| 3228 |
GtkWidget *widget, |
| 3229 |
const gchar *detail, |
| 3230 |
GdkWindowEdge edge, gint x, gint y, gint width, gint height) |
| 3231 |
{ |
| 3232 |
cairo_t *cr; |
| 3233 |
|
| 3234 |
cr = gdk_cairo_create (window); |
| 3235 |
|
| 3236 |
if (DETAIL("statusbar")) |
| 3237 |
{ |
| 3238 |
if (xp_theme_draw |
| 3239 |
(window, XP_THEME_ELEMENT_STATUS_GRIPPER, style, x, y, width, |
| 3240 |
height, state_type, area)) |
| 3241 |
{ |
| 3242 |
cairo_destroy (cr); |
| 3243 |
return; |
| 3244 |
} |
| 3245 |
else |
| 3246 |
{ |
| 3247 |
RECT rect; |
| 3248 |
XpDCInfo dc_info; |
| 3249 |
HDC dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 3250 |
|
| 3251 |
if (area) |
| 3252 |
{ |
| 3253 |
gdk_cairo_rectangle (cr, area); |
| 3254 |
cairo_clip (cr); |
| 3255 |
gdk_cairo_set_source_color (cr, &style->dark[state_type]); |
| 3256 |
} |
| 3257 |
|
| 3258 |
DrawFrameControl (dc, &rect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP); |
| 3259 |
release_window_dc (&dc_info); |
| 3260 |
|
| 3261 |
cairo_destroy (cr); |
| 3262 |
return; |
| 3263 |
} |
| 3264 |
} |
| 3265 |
|
| 3266 |
parent_class->draw_resize_grip (style, window, state_type, area, |
| 3267 |
widget, detail, edge, x, y, width, height); |
| 3268 |
} |
| 3269 |
|
| 3270 |
static void |
| 3271 |
draw_handle (GtkStyle *style, |
| 3272 |
GdkWindow *window, |
| 3273 |
GtkStateType state_type, |
| 3274 |
GtkShadowType shadow_type, |
| 3275 |
GdkRectangle *area, |
| 3276 |
GtkWidget *widget, |
| 3277 |
const gchar *detail, |
| 3278 |
gint x, |
| 3279 |
gint y, |
| 3280 |
gint width, |
| 3281 |
gint height, |
| 3282 |
GtkOrientation orientation) |
| 3283 |
{ |
| 3284 |
if (is_toolbar_child (widget)) |
| 3285 |
{ |
| 3286 |
HDC dc; |
| 3287 |
RECT rect; |
| 3288 |
XpDCInfo dc_info; |
| 3289 |
XpThemeElement hndl; |
| 3290 |
|
| 3291 |
sanitize_size (window, &width, &height); |
| 3292 |
|
| 3293 |
if (GTK_IS_HANDLE_BOX (widget)) |
| 3294 |
{ |
| 3295 |
GtkPositionType pos; |
| 3296 |
pos = gtk_handle_box_get_handle_position (GTK_HANDLE_BOX (widget)); |
| 3297 |
|
| 3298 |
if (pos == GTK_POS_TOP || pos == GTK_POS_BOTTOM) |
| 3299 |
orientation = GTK_ORIENTATION_HORIZONTAL; |
| 3300 |
else |
| 3301 |
orientation = GTK_ORIENTATION_VERTICAL; |
| 3302 |
} |
| 3303 |
|
| 3304 |
if (orientation == GTK_ORIENTATION_VERTICAL) |
| 3305 |
hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_V; |
| 3306 |
else |
| 3307 |
hndl = XP_THEME_ELEMENT_REBAR_GRIPPER_H; |
| 3308 |
|
| 3309 |
if (xp_theme_draw (window, hndl, style, x, y, width, height, state_type, area)) |
| 3310 |
return; |
| 3311 |
|
| 3312 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 3313 |
|
| 3314 |
if (orientation == GTK_ORIENTATION_VERTICAL) |
| 3315 |
{ |
| 3316 |
rect.left += 3; |
| 3317 |
rect.right = rect.left + 3; |
| 3318 |
rect.bottom -= 3; |
| 3319 |
rect.top += 3; |
| 3320 |
} |
| 3321 |
else |
| 3322 |
{ |
| 3323 |
rect.top += 3; |
| 3324 |
rect.bottom = rect.top + 3; |
| 3325 |
rect.right -= 3; |
| 3326 |
rect.left += 3; |
| 3327 |
} |
| 3328 |
|
| 3329 |
draw_3d_border (dc, &rect, FALSE); |
| 3330 |
release_window_dc (&dc_info); |
| 3331 |
return; |
| 3332 |
} |
| 3333 |
} |
| 3334 |
|
| 3335 |
static void |
| 3336 |
draw_focus (GtkStyle *style, |
| 3337 |
GdkWindow *window, |
| 3338 |
GtkStateType state_type, |
| 3339 |
GdkRectangle *area, |
| 3340 |
GtkWidget *widget, |
| 3341 |
const gchar *detail, gint x, gint y, gint width, gint height) |
| 3342 |
{ |
| 3343 |
HDC dc; |
| 3344 |
RECT rect; |
| 3345 |
XpDCInfo dc_info; |
| 3346 |
|
| 3347 |
if (!gtk_widget_get_can_focus (widget)) |
| 3348 |
{ |
| 3349 |
return; |
| 3350 |
} |
| 3351 |
|
| 3352 |
if (is_combo_box_child (widget) |
| 3353 |
&& (GTK_IS_ARROW (widget) || GTK_IS_BUTTON (widget))) |
| 3354 |
{ |
| 3355 |
return; |
| 3356 |
} |
| 3357 |
if (GTK_IS_TREE_VIEW (widget->parent) /* list view bheader */ |
| 3358 |
|| GTK_IS_CLIST (widget->parent)) |
| 3359 |
{ |
| 3360 |
return; |
| 3361 |
} |
| 3362 |
|
| 3363 |
dc = get_window_dc (style, window, state_type, &dc_info, x, y, width, height, &rect); |
| 3364 |
DrawFocusRect (dc, &rect); |
| 3365 |
release_window_dc (&dc_info); |
| 3366 |
/* |
| 3367 |
parent_class->draw_focus (style, window, state_type, |
| 3368 |
area, widget, detail, x, y, width, height); |
| 3369 |
*/ |
| 3370 |
} |
| 3371 |
|
| 3372 |
static void |
| 3373 |
draw_layout (GtkStyle *style, |
| 3374 |
GdkWindow *window, |
| 3375 |
GtkStateType state_type, |
| 3376 |
gboolean use_text, |
| 3377 |
GdkRectangle *area, |
| 3378 |
GtkWidget *widget, |
| 3379 |
const gchar *detail, |
| 3380 |
gint old_x, gint old_y, PangoLayout *layout) |
| 3381 |
{ |
| 3382 |
GtkNotebook *notebook = NULL; |
| 3383 |
gint x = old_x; |
| 3384 |
gint y = old_y; |
| 3385 |
|
| 3386 |
/* In the XP theme, labels don't appear correctly centered inside |
| 3387 |
* notebook tabs, so we give them a gentle nudge two pixels to the |
| 3388 |
* right. A little hackish, but what are 'ya gonna do? -- Cody |
| 3389 |
*/ |
| 3390 |
if (xp_theme_is_active () && DETAIL("label")) |
| 3391 |
{ |
| 3392 |
if (widget->parent != NULL) |
| 3393 |
{ |
| 3394 |
if (GTK_IS_NOTEBOOK (widget->parent)) |
| 3395 |
{ |
| 3396 |
int side; |
| 3397 |
notebook = GTK_NOTEBOOK (widget->parent); |
| 3398 |
side = gtk_notebook_get_tab_pos (notebook); |
| 3399 |
|
| 3400 |
if (side == GTK_POS_TOP || side == GTK_POS_BOTTOM) |
| 3401 |
{ |
| 3402 |
x += 2; |
| 3403 |
} |
| 3404 |
} |
| 3405 |
} |
| 3406 |
} |
| 3407 |
|
| 3408 |
parent_class->draw_layout (style, window, state_type, |
| 3409 |
use_text, area, widget, detail, x, y, layout); |
| 3410 |
} |
| 3411 |
|
| 3412 |
static void |
| 3413 |
msw_style_init_from_rc (GtkStyle *style, GtkRcStyle *rc_style) |
| 3414 |
{ |
| 3415 |
setup_system_font (style); |
| 3416 |
setup_menu_settings (gtk_settings_get_default ()); |
| 3417 |
setup_system_styles (style); |
| 3418 |
parent_class->init_from_rc (style, rc_style); |
| 3419 |
} |
| 3420 |
|
| 3421 |
static void |
| 3422 |
msw_style_class_init (MswStyleClass *klass) |
| 3423 |
{ |
| 3424 |
GtkStyleClass *style_class = GTK_STYLE_CLASS (klass); |
| 3425 |
|
| 3426 |
parent_class = g_type_class_peek_parent (klass); |
| 3427 |
|
| 3428 |
style_class->init_from_rc = msw_style_init_from_rc; |
| 3429 |
style_class->draw_arrow = draw_arrow; |
| 3430 |
style_class->draw_box = draw_box; |
| 3431 |
style_class->draw_check = draw_check; |
| 3432 |
style_class->draw_option = draw_option; |
| 3433 |
style_class->draw_tab = draw_tab; |
| 3434 |
style_class->draw_flat_box = draw_flat_box; |
| 3435 |
style_class->draw_expander = draw_expander; |
| 3436 |
style_class->draw_extension = draw_extension; |
| 3437 |
style_class->draw_box_gap = draw_box_gap; |
| 3438 |
style_class->draw_shadow = draw_shadow; |
| 3439 |
style_class->draw_hline = draw_hline; |
| 3440 |
style_class->draw_vline = draw_vline; |
| 3441 |
style_class->draw_handle = draw_handle; |
| 3442 |
style_class->draw_resize_grip = draw_resize_grip; |
| 3443 |
style_class->draw_slider = draw_slider; |
| 3444 |
style_class->draw_focus = draw_focus; |
| 3445 |
style_class->draw_layout = draw_layout; |
| 3446 |
} |
| 3447 |
|
| 3448 |
GType msw_type_style = 0; |
| 3449 |
|
| 3450 |
void |
| 3451 |
msw_style_register_type (GTypeModule *module) |
| 3452 |
{ |
| 3453 |
const GTypeInfo object_info = { |
| 3454 |
sizeof (MswStyleClass), |
| 3455 |
(GBaseInitFunc) NULL, |
| 3456 |
(GBaseFinalizeFunc) NULL, |
| 3457 |
(GClassInitFunc) msw_style_class_init, |
| 3458 |
NULL, /* class_finalize */ |
| 3459 |
NULL, /* class_data */ |
| 3460 |
sizeof (MswStyle), |
| 3461 |
0, /* n_preallocs */ |
| 3462 |
(GInstanceInitFunc) NULL, |
| 3463 |
}; |
| 3464 |
|
| 3465 |
msw_type_style = g_type_module_register_type (module, |
| 3466 |
GTK_TYPE_STYLE, |
| 3467 |
"MswStyle", &object_info, 0); |
| 3468 |
} |
| 3469 |
|
| 3470 |
void |
| 3471 |
msw_style_init (void) |
| 3472 |
{ |
| 3473 |
xp_theme_init (); |
| 3474 |
msw_style_setup_system_settings (); |
| 3475 |
setup_msw_rc_style (); |
| 3476 |
|
| 3477 |
if (g_light_pen) |
| 3478 |
{ |
| 3479 |
DeleteObject (g_light_pen); |
| 3480 |
g_light_pen = NULL; |
| 3481 |
} |
| 3482 |
|
| 3483 |
if (g_dark_pen) |
| 3484 |
{ |
| 3485 |
DeleteObject (g_dark_pen); |
| 3486 |
g_dark_pen = NULL; |
| 3487 |
} |
| 3488 |
} |
| 3489 |
|
| 3490 |
void |
| 3491 |
msw_style_finalize (void) |
| 3492 |
{ |
| 3493 |
if (g_dither_brush) |
| 3494 |
{ |
| 3495 |
DeleteObject (g_dither_brush); |
| 3496 |
} |
| 3497 |
|
| 3498 |
if (g_light_pen) |
| 3499 |
{ |
| 3500 |
DeleteObject (g_light_pen); |
| 3501 |
} |
| 3502 |
|
| 3503 |
if (g_dark_pen) |
| 3504 |
{ |
| 3505 |
DeleteObject (g_dark_pen); |
| 3506 |
} |
| 3507 |
} |