1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 See the COPYING file for a copy of the GNU General Public License.
26 #include "obt/paths.h"
29 #include <X11/Xresource.h>
34 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
);
35 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
);
36 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
);
37 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
38 const gchar
*rname
, RrColor
**value
);
39 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
40 RrTheme
*theme
, const gchar
*maskname
,
41 RrPixmapMask
**value
);
42 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
43 const gchar
*rname
, RrAppearance
*value
,
44 gboolean allow_trans
);
45 static int parse_inline_number(const char *p
);
46 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
);
47 static void set_default_appearance(RrAppearance
*a
);
49 static RrFont
*get_font(RrFont
*target
, RrFont
**default_font
,
50 const RrInstance
*inst
)
56 /* Only load the default font once */
58 RrFontRef(*default_font
);
60 *default_font
= RrFontOpenDefault(inst
);
66 #define READ_INT(x_resstr, x_var, x_min, x_max, x_def) \
67 if (!read_int(db, x_resstr, & x_var) || \
68 x_var < x_min || x_var > x_max) \
71 #define READ_COLOR(x_resstr, x_var, x_def) \
72 if (!read_color(db, inst, x_resstr, & x_var)) \
75 #define READ_COLOR_(x_res1, x_res2, x_var, x_def) \
76 if (!read_color(db, inst, x_res1, & x_var) && \
77 !read_color(db, inst, x_res2, & x_var)) \
80 #define READ_MASK_COPY(x_file, x_var, x_copysrc) \
81 if (!read_mask(inst, path, theme, x_file, & x_var)) \
82 x_var = RrPixmapMaskCopy(x_copysrc);
84 #define READ_APPEARANCE(x_resstr, x_var, x_parrel) \
85 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) \
86 set_default_appearance(x_var);
88 #define READ_APPEARANCE_COPY(x_resstr, x_var, x_parrel, x_defval) \
89 if (!read_appearance(db, inst, x_resstr, x_var, x_parrel)) {\
90 RrAppearanceFree(x_var); \
91 x_var = RrAppearanceCopy(x_defval); }
93 #define READ_APPEARANCE_(x_res1, x_res2, x_var, x_parrel, x_defval) \
94 if (!read_appearance(db, inst, x_res1, x_var, x_parrel) && \
95 !read_appearance(db, inst, x_res2, x_var, x_parrel)) {\
96 RrAppearanceFree(x_var); \
97 x_var = RrAppearanceCopy(x_defval); }
99 RrTheme
* RrThemeNew(const RrInstance
*inst
, const gchar
*name
,
100 gboolean allow_fallback
,
101 RrFont
*active_window_font
, RrFont
*inactive_window_font
,
102 RrFont
*menu_title_font
, RrFont
*menu_item_font
,
103 RrFont
*active_osd_font
, RrFont
*inactive_osd_font
)
105 XrmDatabase db
= NULL
;
106 RrJustify winjust
, mtitlejust
;
109 RrFont
*default_font
= NULL
;
112 gint menu_overlap
= 0;
113 RrAppearance
*a_disabled_focused_tmp
;
114 RrAppearance
*a_disabled_unfocused_tmp
;
115 RrAppearance
*a_hover_focused_tmp
;
116 RrAppearance
*a_hover_unfocused_tmp
;
117 RrAppearance
*a_focused_unpressed_tmp
;
118 RrAppearance
*a_focused_pressed_tmp
;
119 RrAppearance
*a_unfocused_unpressed_tmp
;
120 RrAppearance
*a_unfocused_pressed_tmp
;
121 RrAppearance
*a_toggled_hover_focused_tmp
;
122 RrAppearance
*a_toggled_hover_unfocused_tmp
;
123 RrAppearance
*a_toggled_focused_unpressed_tmp
;
124 RrAppearance
*a_toggled_focused_pressed_tmp
;
125 RrAppearance
*a_toggled_unfocused_unpressed_tmp
;
126 RrAppearance
*a_toggled_unfocused_pressed_tmp
;
129 db
= loaddb(name
, &path
);
131 g_message("Unable to load the theme '%s'", name
);
133 g_message("Falling back to the default theme '%s'",
135 /* fallback to the default theme */
140 if (allow_fallback
) {
141 db
= loaddb(DEFAULT_THEME
, &path
);
143 g_message("Unable to load the theme '%s'", DEFAULT_THEME
);
150 /* initialize temp reading textures */
151 a_disabled_focused_tmp
= RrAppearanceNew(inst
, 1);
152 a_disabled_unfocused_tmp
= RrAppearanceNew(inst
, 1);
153 a_hover_focused_tmp
= RrAppearanceNew(inst
, 1);
154 a_hover_unfocused_tmp
= RrAppearanceNew(inst
, 1);
155 a_toggled_focused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
156 a_toggled_unfocused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
157 a_toggled_hover_focused_tmp
= RrAppearanceNew(inst
, 1);
158 a_toggled_hover_unfocused_tmp
= RrAppearanceNew(inst
, 1);
159 a_toggled_focused_pressed_tmp
= RrAppearanceNew(inst
, 1);
160 a_toggled_unfocused_pressed_tmp
= RrAppearanceNew(inst
, 1);
161 a_focused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
162 a_focused_pressed_tmp
= RrAppearanceNew(inst
, 1);
163 a_unfocused_unpressed_tmp
= RrAppearanceNew(inst
, 1);
164 a_unfocused_pressed_tmp
= RrAppearanceNew(inst
, 1);
166 /* initialize theme */
167 theme
= g_slice_new0(RrTheme
, 1);
170 theme
->name
= g_strdup(name
? name
: DEFAULT_THEME
);
172 theme
->a_disabled_focused_max
= RrAppearanceNew(inst
, 1);
173 theme
->a_disabled_unfocused_max
= RrAppearanceNew(inst
, 1);
174 theme
->a_hover_focused_max
= RrAppearanceNew(inst
, 1);
175 theme
->a_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
176 theme
->a_toggled_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
177 theme
->a_toggled_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
178 theme
->a_toggled_hover_focused_max
= RrAppearanceNew(inst
, 1);
179 theme
->a_toggled_hover_unfocused_max
= RrAppearanceNew(inst
, 1);
180 theme
->a_toggled_focused_pressed_max
= RrAppearanceNew(inst
, 1);
181 theme
->a_toggled_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
182 theme
->a_focused_unpressed_max
= RrAppearanceNew(inst
, 1);
183 theme
->a_focused_pressed_max
= RrAppearanceNew(inst
, 1);
184 theme
->a_unfocused_unpressed_max
= RrAppearanceNew(inst
, 1);
185 theme
->a_unfocused_pressed_max
= RrAppearanceNew(inst
, 1);
186 theme
->a_focused_grip
= RrAppearanceNew(inst
, 0);
187 theme
->a_unfocused_grip
= RrAppearanceNew(inst
, 0);
188 theme
->a_focused_title
= RrAppearanceNew(inst
, 0);
189 theme
->a_unfocused_title
= RrAppearanceNew(inst
, 0);
190 theme
->a_focused_label
= RrAppearanceNew(inst
, 1);
191 theme
->a_unfocused_label
= RrAppearanceNew(inst
, 1);
192 theme
->a_icon
= RrAppearanceNew(inst
, 1);
193 theme
->a_focused_handle
= RrAppearanceNew(inst
, 0);
194 theme
->a_unfocused_handle
= RrAppearanceNew(inst
, 0);
195 theme
->a_menu
= RrAppearanceNew(inst
, 0);
196 theme
->a_menu_title
= RrAppearanceNew(inst
, 0);
197 theme
->a_menu_text_title
= RrAppearanceNew(inst
, 1);
198 theme
->a_menu_normal
= RrAppearanceNew(inst
, 0);
199 theme
->a_menu_selected
= RrAppearanceNew(inst
, 0);
200 theme
->a_menu_disabled
= RrAppearanceNew(inst
, 0);
201 /* a_menu_disabled_selected is copied from a_menu_selected */
202 theme
->a_menu_text_normal
= RrAppearanceNew(inst
, 1);
203 theme
->a_menu_text_selected
= RrAppearanceNew(inst
, 1);
204 theme
->a_menu_text_disabled
= RrAppearanceNew(inst
, 1);
205 theme
->a_menu_text_disabled_selected
= RrAppearanceNew(inst
, 1);
206 theme
->a_menu_bullet_normal
= RrAppearanceNew(inst
, 1);
207 theme
->a_menu_bullet_selected
= RrAppearanceNew(inst
, 1);
208 theme
->a_clear
= RrAppearanceNew(inst
, 0);
209 theme
->a_clear_tex
= RrAppearanceNew(inst
, 1);
210 theme
->osd_bg
= RrAppearanceNew(inst
, 0);
211 theme
->osd_hilite_label
= RrAppearanceNew(inst
, 1);
212 theme
->osd_hilite_bg
= RrAppearanceNew(inst
, 0);
213 theme
->osd_unhilite_label
= RrAppearanceNew(inst
, 1);
214 theme
->osd_unhilite_bg
= RrAppearanceNew(inst
, 0);
216 /* load the font stuff */
217 theme
->win_font_focused
= get_font(active_window_font
,
218 &default_font
, inst
);
219 theme
->win_font_unfocused
= get_font(inactive_window_font
,
220 &default_font
, inst
);
222 winjust
= RR_JUSTIFY_LEFT
;
223 if (read_string(db
, "window.label.text.justify", &str
)) {
224 if (!g_ascii_strcasecmp(str
, "right"))
225 winjust
= RR_JUSTIFY_RIGHT
;
226 else if (!g_ascii_strcasecmp(str
, "center"))
227 winjust
= RR_JUSTIFY_CENTER
;
230 theme
->menu_title_font
= get_font(menu_title_font
, &default_font
, inst
);
232 mtitlejust
= RR_JUSTIFY_LEFT
;
233 if (read_string(db
, "menu.title.text.justify", &str
)) {
234 if (!g_ascii_strcasecmp(str
, "right"))
235 mtitlejust
= RR_JUSTIFY_RIGHT
;
236 else if (!g_ascii_strcasecmp(str
, "center"))
237 mtitlejust
= RR_JUSTIFY_CENTER
;
240 theme
->menu_font
= get_font(menu_item_font
, &default_font
, inst
);
242 theme
->osd_font_hilite
= get_font(active_osd_font
, &default_font
, inst
);
243 theme
->osd_font_unhilite
= get_font(inactive_osd_font
, &default_font
,inst
);
245 /* load direct dimensions */
246 READ_INT("menu.overlap", menu_overlap
, -100, 100, 0);
247 READ_INT("menu.overlap.x", theme
->menu_overlap_x
, -100, 100, menu_overlap
);
248 READ_INT("menu.overlap.y", theme
->menu_overlap_y
, -100, 100, menu_overlap
);
249 READ_INT("window.handle.width", theme
->handle_height
, 0, 100, 6);
250 READ_INT("padding.width", theme
->paddingx
, 0, 100, 3);
251 READ_INT("padding.height", theme
->paddingy
, 0, 100, theme
->paddingx
);
252 READ_INT("border.width", theme
->fbwidth
, 0, 100, 1);
253 READ_INT("menu.border.width", theme
->mbwidth
, 0, 100, theme
->fbwidth
);
254 READ_INT("osd.border.width", theme
->obwidth
, 0, 100, theme
->fbwidth
);
255 READ_INT("menu.separator.width", theme
->menu_sep_width
, 1, 100, 1);
256 READ_INT("menu.separator.padding.width", theme
->menu_sep_paddingx
, 0, 100, 6);
257 READ_INT("menu.separator.padding.height", theme
->menu_sep_paddingy
, 0, 100, 3);
258 READ_INT("window.client.padding.width", theme
->cbwidthx
, 0, 100,
260 READ_INT("window.client.padding.height", theme
->cbwidthy
, 0, 100,
264 READ_COLOR_("window.active.border.color", "border.color",
265 theme
->frame_focused_border_color
, RrColorNew(inst
, 0, 0, 0));
267 /* title separator focused color inherits from focused border color */
268 READ_COLOR("window.active.title.separator.color",
269 theme
->title_separator_focused_color
,
270 RrColorCopy(theme
->frame_focused_border_color
));
272 /* unfocused border color inherits from frame focused border color */
273 READ_COLOR("window.inactive.border.color",
274 theme
->frame_unfocused_border_color
,
275 RrColorCopy(theme
->frame_focused_border_color
));
277 /* title separator unfocused color inherits from unfocused border color */
278 READ_COLOR("window.inactive.title.separator.color",
279 theme
->title_separator_unfocused_color
,
280 RrColorCopy(theme
->frame_unfocused_border_color
));
282 /* menu border color inherits from frame focused border color */
283 READ_COLOR("menu.border.color", theme
->menu_border_color
,
284 RrColorCopy(theme
->frame_focused_border_color
));
286 /* osd border color inherits from frame focused border color */
287 READ_COLOR("osd.border.color", theme
->osd_border_color
,
288 RrColorCopy(theme
->frame_focused_border_color
));
290 READ_COLOR("window.active.client.color", theme
->cb_focused_color
,
291 RrColorNew(inst
, 0xff, 0xff, 0xff));
293 READ_COLOR("window.inactive.client.color", theme
->cb_unfocused_color
,
294 RrColorNew(inst
, 0xff, 0xff, 0xff));
296 READ_COLOR("window.active.label.text.color", theme
->title_focused_color
,
297 RrColorNew(inst
, 0x0, 0x0, 0x0));
299 READ_COLOR_("osd.active.label.text.color",
300 "osd.label.text.color",
301 theme
->osd_color
, RrColorCopy(theme
->title_focused_color
));
303 READ_COLOR("window.inactive.label.text.color", theme
->title_unfocused_color
,
304 RrColorCopy(theme
->title_unfocused_color
));
306 READ_COLOR("osd.inactive.label.text.color", theme
->osd_text_inactive_color
,
307 RrColorNew(inst
, 0xff, 0xff, 0xff));
309 READ_COLOR("window.inactive.label.text.color",
310 theme
->title_unfocused_color
,
311 RrColorNew(inst
, 0xff, 0xff, 0xff));
313 READ_COLOR("window.active.button.unpressed.image.color",
314 theme
->titlebut_focused_unpressed_color
,
315 RrColorNew(inst
, 0, 0, 0));
317 READ_COLOR("window.inactive.button.unpressed.image.color",
318 theme
->titlebut_unfocused_unpressed_color
,
319 RrColorNew(inst
, 0xff, 0xff, 0xff));
321 READ_COLOR("window.active.button.pressed.image.color",
322 theme
->titlebut_focused_pressed_color
,
323 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
325 READ_COLOR("window.inactive.button.pressed.image.color",
326 theme
->titlebut_unfocused_pressed_color
,
327 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
329 READ_COLOR("window.active.button.disabled.image.color",
330 theme
->titlebut_disabled_focused_color
,
331 RrColorNew(inst
, 0xff, 0xff, 0xff));
333 READ_COLOR("window.inactive.button.disabled.image.color",
334 theme
->titlebut_disabled_unfocused_color
,
335 RrColorNew(inst
, 0, 0, 0));
337 READ_COLOR("window.active.button.hover.image.color",
338 theme
->titlebut_hover_focused_color
,
339 RrColorCopy(theme
->titlebut_focused_unpressed_color
));
341 READ_COLOR("window.inactive.button.hover.image.color",
342 theme
->titlebut_hover_unfocused_color
,
343 RrColorCopy(theme
->titlebut_unfocused_unpressed_color
));
345 READ_COLOR_("window.active.button.toggled.unpressed.image.color",
346 "window.active.button.toggled.image.color",
347 theme
->titlebut_toggled_focused_unpressed_color
,
348 RrColorCopy(theme
->titlebut_focused_pressed_color
));
350 READ_COLOR_("window.inactive.button.toggled.unpressed.image.color",
351 "window.inactive.button.toggled.image.color",
352 theme
->titlebut_toggled_unfocused_unpressed_color
,
353 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
355 READ_COLOR("window.active.button.toggled.hover.image.color",
356 theme
->titlebut_toggled_hover_focused_color
,
357 RrColorCopy(theme
->titlebut_toggled_focused_unpressed_color
));
359 READ_COLOR("window.inactive.button.toggled.hover.image.color",
360 theme
->titlebut_toggled_hover_unfocused_color
,
361 RrColorCopy(theme
->titlebut_toggled_unfocused_unpressed_color
));
363 READ_COLOR("window.active.button.toggled.pressed.image.color",
364 theme
->titlebut_toggled_focused_pressed_color
,
365 RrColorCopy(theme
->titlebut_focused_pressed_color
));
367 READ_COLOR("window.inactive.button.toggled.pressed.image.color",
368 theme
->titlebut_toggled_unfocused_pressed_color
,
369 RrColorCopy(theme
->titlebut_unfocused_pressed_color
));
371 READ_COLOR("menu.title.text.color", theme
->menu_title_color
,
372 RrColorNew(inst
, 0, 0, 0));
374 READ_COLOR("menu.items.text.color", theme
->menu_color
,
375 RrColorNew(inst
, 0xff, 0xff, 0xff));
377 READ_COLOR("menu.items.disabled.text.color", theme
->menu_disabled_color
,
378 RrColorNew(inst
, 0, 0, 0));
380 READ_COLOR("menu.items.active.disabled.text.color",
381 theme
->menu_disabled_selected_color
,
382 RrColorCopy(theme
->menu_disabled_color
));
384 READ_COLOR("menu.items.active.text.color", theme
->menu_selected_color
,
385 RrColorNew(inst
, 0, 0, 0));
387 READ_COLOR("menu.separator.color", theme
->menu_sep_color
,
388 RrColorCopy(theme
->menu_color
));
390 /* load the image masks */
392 /* maximize button masks */
394 if (!read_mask(inst
, path
, theme
, "max.xbm", &theme
->max_mask
)) {
395 guchar data
[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
396 theme
->max_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
399 if (!read_mask(inst
, path
, theme
, "max_toggled.xbm",
400 &theme
->max_toggled_mask
))
403 theme
->max_toggled_mask
= RrPixmapMaskCopy(theme
->max_mask
);
405 guchar data
[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
406 theme
->max_toggled_mask
= RrPixmapMaskNew(inst
, 6, 6,(gchar
*)data
);
409 READ_MASK_COPY("max_pressed.xbm", theme
->max_pressed_mask
,
411 READ_MASK_COPY("max_disabled.xbm", theme
->max_disabled_mask
,
413 READ_MASK_COPY("max_hover.xbm", theme
->max_hover_mask
, theme
->max_mask
);
414 READ_MASK_COPY("max_toggled_pressed.xbm", theme
->max_toggled_pressed_mask
,
415 theme
->max_toggled_mask
);
416 READ_MASK_COPY("max_toggled_hover.xbm", theme
->max_toggled_hover_mask
,
417 theme
->max_toggled_mask
);
419 /* iconify button masks */
420 if (!read_mask(inst
, path
, theme
, "iconify.xbm", &theme
->iconify_mask
)) {
421 guchar data
[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
422 theme
->iconify_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
424 READ_MASK_COPY("iconify_pressed.xbm", theme
->iconify_pressed_mask
,
425 theme
->iconify_mask
);
426 READ_MASK_COPY("iconify_disabled.xbm", theme
->iconify_disabled_mask
,
427 theme
->iconify_mask
);
428 READ_MASK_COPY("iconify_hover.xbm", theme
->iconify_hover_mask
,
429 theme
->iconify_mask
);
431 /* all desktops button masks */
433 if (!read_mask(inst
, path
, theme
, "desk.xbm", &theme
->desk_mask
)) {
434 guchar data
[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
435 theme
->desk_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
438 if (!read_mask(inst
, path
, theme
, "desk_toggled.xbm",
439 &theme
->desk_toggled_mask
)) {
441 theme
->desk_toggled_mask
= RrPixmapMaskCopy(theme
->desk_mask
);
443 guchar data
[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
444 theme
->desk_toggled_mask
=
445 RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
448 READ_MASK_COPY("desk_pressed.xbm", theme
->desk_pressed_mask
,
450 READ_MASK_COPY("desk_disabled.xbm", theme
->desk_disabled_mask
,
452 READ_MASK_COPY("desk_hover.xbm", theme
->desk_hover_mask
, theme
->desk_mask
);
453 READ_MASK_COPY("desk_toggled_pressed.xbm",
454 theme
->desk_toggled_pressed_mask
, theme
->desk_toggled_mask
);
455 READ_MASK_COPY("desk_toggled_hover.xbm", theme
->desk_toggled_hover_mask
,
456 theme
->desk_toggled_mask
);
458 /* shade button masks */
459 if (!read_mask(inst
, path
, theme
, "shade.xbm", &theme
->shade_mask
)) {
460 guchar data
[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
461 theme
->shade_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
463 READ_MASK_COPY("shade_toggled.xbm", theme
->shade_toggled_mask
,
465 READ_MASK_COPY("shade_pressed.xbm", theme
->shade_pressed_mask
,
467 READ_MASK_COPY("shade_disabled.xbm", theme
->shade_disabled_mask
,
469 READ_MASK_COPY("shade_hover.xbm", theme
->shade_hover_mask
,
471 READ_MASK_COPY("shade_toggled_pressed.xbm",
472 theme
->shade_toggled_pressed_mask
,
473 theme
->shade_toggled_mask
);
474 READ_MASK_COPY("shade_toggled_hover.xbm",
475 theme
->shade_toggled_hover_mask
, theme
->shade_toggled_mask
);
477 /* close button masks */
478 if (!read_mask(inst
, path
, theme
, "close.xbm", &theme
->close_mask
)) {
479 guchar data
[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
480 theme
->close_mask
= RrPixmapMaskNew(inst
, 6, 6, (gchar
*)data
);
482 READ_MASK_COPY("close_pressed.xbm", theme
->close_pressed_mask
,
484 READ_MASK_COPY("close_disabled.xbm", theme
->close_disabled_mask
,
486 READ_MASK_COPY("close_hover.xbm", theme
->close_hover_mask
,
489 /* submenu bullet mask */
490 if (!read_mask(inst
, path
, theme
, "bullet.xbm", &theme
->menu_bullet_mask
))
492 guchar data
[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
493 theme
->menu_bullet_mask
= RrPixmapMaskNew(inst
, 4, 7, (gchar
*)data
);
496 /* up and down arrows */
498 guchar data
[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
499 theme
->down_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
502 guchar data
[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
503 theme
->up_arrow_mask
= RrPixmapMaskNew(inst
, 9, 4, (gchar
*)data
);
506 /* setup the default window icon */
507 theme
->def_win_icon
= read_c_image(OB_DEFAULT_ICON_WIDTH
,
508 OB_DEFAULT_ICON_HEIGHT
,
509 OB_DEFAULT_ICON_pixel_data
);
510 theme
->def_win_icon_w
= OB_DEFAULT_ICON_WIDTH
;
511 theme
->def_win_icon_h
= OB_DEFAULT_ICON_HEIGHT
;
513 /* read the decoration textures */
514 READ_APPEARANCE("window.active.title.bg", theme
->a_focused_title
, FALSE
);
515 READ_APPEARANCE("window.inactive.title.bg", theme
->a_unfocused_title
,
517 READ_APPEARANCE("window.active.label.bg", theme
->a_focused_label
, TRUE
);
518 READ_APPEARANCE("window.inactive.label.bg", theme
->a_unfocused_label
,
520 READ_APPEARANCE("window.active.handle.bg", theme
->a_focused_handle
, FALSE
);
521 READ_APPEARANCE("window.inactive.handle.bg",theme
->a_unfocused_handle
,
523 READ_APPEARANCE("window.active.grip.bg", theme
->a_focused_grip
, TRUE
);
524 READ_APPEARANCE("window.inactive.grip.bg", theme
->a_unfocused_grip
, TRUE
);
525 READ_APPEARANCE("menu.items.bg", theme
->a_menu
, FALSE
);
526 READ_APPEARANCE("menu.title.bg", theme
->a_menu_title
, TRUE
);
527 READ_APPEARANCE("menu.items.active.bg", theme
->a_menu_selected
, TRUE
);
529 theme
->a_menu_disabled_selected
=
530 RrAppearanceCopy(theme
->a_menu_selected
);
532 /* read appearances for non-decorations (on-screen-display) */
533 if (!read_appearance(db
, inst
, "osd.bg", theme
->osd_bg
, FALSE
)) {
534 RrAppearanceFree(theme
->osd_bg
);
535 theme
->osd_bg
= RrAppearanceCopy(theme
->a_focused_title
);
537 if (!read_appearance(db
, inst
, "osd.active.label.bg",
538 theme
->osd_hilite_label
, TRUE
) &&
539 !read_appearance(db
, inst
, "osd.label.bg",
540 theme
->osd_hilite_label
, TRUE
)) {
541 RrAppearanceFree(theme
->osd_hilite_label
);
542 theme
->osd_hilite_label
= RrAppearanceCopy(theme
->a_focused_label
);
544 if (!read_appearance(db
, inst
, "osd.inactive.label.bg",
545 theme
->osd_unhilite_label
, TRUE
)) {
546 RrAppearanceFree(theme
->osd_unhilite_label
);
547 theme
->osd_unhilite_label
= RrAppearanceCopy(theme
->a_unfocused_label
);
549 /* osd_hilite_fg can't be parentrel */
550 if (!read_appearance(db
, inst
, "osd.hilight.bg",
551 theme
->osd_hilite_bg
, FALSE
)) {
552 RrAppearanceFree(theme
->osd_hilite_bg
);
553 if (theme
->a_focused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
554 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_label
);
556 theme
->osd_hilite_bg
= RrAppearanceCopy(theme
->a_focused_title
);
558 /* osd_unhilite_fg can't be parentrel either */
559 if (!read_appearance(db
, inst
, "osd.unhilight.bg",
560 theme
->osd_unhilite_bg
, FALSE
)) {
561 RrAppearanceFree(theme
->osd_unhilite_bg
);
562 if (theme
->a_unfocused_label
->surface
.grad
!= RR_SURFACE_PARENTREL
)
563 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_label
);
565 theme
->osd_unhilite_bg
=RrAppearanceCopy(theme
->a_unfocused_title
);
568 /* read buttons textures */
569 READ_APPEARANCE("window.active.button.disabled.bg",
570 theme
->a_disabled_focused_max
, TRUE
);
571 READ_APPEARANCE("window.inactive.button.disabled.bg",
572 theme
->a_disabled_unfocused_max
, TRUE
);
573 READ_APPEARANCE("window.active.button.pressed.bg",
574 theme
->a_focused_pressed_max
, TRUE
);
575 READ_APPEARANCE("window.inactive.button.pressed.bg",
576 theme
->a_unfocused_pressed_max
, TRUE
);
578 READ_APPEARANCE_("window.active.button.toggled.unpressed.bg",
579 "window.active.button.toggled.bg",
580 theme
->a_toggled_focused_unpressed_max
, TRUE
,
581 theme
->a_focused_pressed_max
);
582 READ_APPEARANCE_("window.inactive.button.toggled.unpressed.bg",
583 "window.inactive.button.toggled.bg",
584 theme
->a_toggled_unfocused_unpressed_max
, TRUE
,
585 theme
->a_unfocused_pressed_max
);
587 READ_APPEARANCE_COPY("window.active.button.toggled.hover.bg",
588 theme
->a_toggled_hover_focused_max
, TRUE
,
589 theme
->a_toggled_focused_unpressed_max
);
590 READ_APPEARANCE_COPY("window.inactive.button.toggled.hover.bg",
591 theme
->a_toggled_hover_unfocused_max
, TRUE
,
592 theme
->a_toggled_unfocused_unpressed_max
);
594 READ_APPEARANCE_COPY("window.active.button.toggled.pressed.bg",
595 theme
->a_toggled_focused_pressed_max
, TRUE
,
596 theme
->a_focused_pressed_max
);
597 READ_APPEARANCE_COPY("window.inactive.button.toggled.pressed.bg",
598 theme
->a_toggled_unfocused_pressed_max
, TRUE
,
599 theme
->a_unfocused_pressed_max
);
601 READ_APPEARANCE("window.active.button.unpressed.bg",
602 theme
->a_focused_unpressed_max
, TRUE
);
603 READ_APPEARANCE("window.inactive.button.unpressed.bg",
604 theme
->a_unfocused_unpressed_max
, TRUE
);
606 READ_APPEARANCE_COPY("window.active.button.hover.bg",
607 theme
->a_hover_focused_max
, TRUE
,
608 theme
->a_focused_unpressed_max
);
609 READ_APPEARANCE_COPY("window.inactive.button.hover.bg",
610 theme
->a_hover_unfocused_max
, TRUE
,
611 theme
->a_unfocused_unpressed_max
);
613 theme
->a_disabled_focused_close
=
614 RrAppearanceCopy(theme
->a_disabled_focused_max
);
615 theme
->a_disabled_unfocused_close
=
616 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
617 theme
->a_hover_focused_close
=
618 RrAppearanceCopy(theme
->a_hover_focused_max
);
619 theme
->a_hover_unfocused_close
=
620 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
621 theme
->a_unfocused_unpressed_close
=
622 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
623 theme
->a_unfocused_pressed_close
=
624 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
625 theme
->a_focused_unpressed_close
=
626 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
627 theme
->a_focused_pressed_close
=
628 RrAppearanceCopy(theme
->a_focused_pressed_max
);
629 theme
->a_disabled_focused_desk
=
630 RrAppearanceCopy(theme
->a_disabled_focused_max
);
631 theme
->a_disabled_unfocused_desk
=
632 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
633 theme
->a_hover_focused_desk
=
634 RrAppearanceCopy(theme
->a_hover_focused_max
);
635 theme
->a_hover_unfocused_desk
=
636 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
637 theme
->a_toggled_hover_focused_desk
=
638 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
639 theme
->a_toggled_hover_unfocused_desk
=
640 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
641 theme
->a_toggled_focused_unpressed_desk
=
642 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
643 theme
->a_toggled_unfocused_unpressed_desk
=
644 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
645 theme
->a_toggled_focused_pressed_desk
=
646 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
647 theme
->a_toggled_unfocused_pressed_desk
=
648 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
649 theme
->a_unfocused_unpressed_desk
=
650 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
651 theme
->a_unfocused_pressed_desk
=
652 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
653 theme
->a_focused_unpressed_desk
=
654 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
655 theme
->a_focused_pressed_desk
=
656 RrAppearanceCopy(theme
->a_focused_pressed_max
);
657 theme
->a_disabled_focused_shade
=
658 RrAppearanceCopy(theme
->a_disabled_focused_max
);
659 theme
->a_disabled_unfocused_shade
=
660 RrAppearanceCopy(theme
->a_disabled_unfocused_max
);
661 theme
->a_hover_focused_shade
=
662 RrAppearanceCopy(theme
->a_hover_focused_max
);
663 theme
->a_hover_unfocused_shade
=
664 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
665 theme
->a_toggled_hover_focused_shade
=
666 RrAppearanceCopy(theme
->a_toggled_hover_focused_max
);
667 theme
->a_toggled_hover_unfocused_shade
=
668 RrAppearanceCopy(theme
->a_toggled_hover_unfocused_max
);
669 theme
->a_toggled_focused_unpressed_shade
=
670 RrAppearanceCopy(theme
->a_toggled_focused_unpressed_max
);
671 theme
->a_toggled_unfocused_unpressed_shade
=
672 RrAppearanceCopy(theme
->a_toggled_unfocused_unpressed_max
);
673 theme
->a_toggled_focused_pressed_shade
=
674 RrAppearanceCopy(theme
->a_toggled_focused_pressed_max
);
675 theme
->a_toggled_unfocused_pressed_shade
=
676 RrAppearanceCopy(theme
->a_toggled_unfocused_pressed_max
);
677 theme
->a_unfocused_unpressed_shade
=
678 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
679 theme
->a_unfocused_pressed_shade
=
680 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
681 theme
->a_focused_unpressed_shade
=
682 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
683 theme
->a_focused_pressed_shade
=
684 RrAppearanceCopy(theme
->a_focused_pressed_max
);
685 theme
->a_disabled_focused_iconify
=
686 RrAppearanceCopy(theme
->a_disabled_focused_max
);
687 theme
->a_disabled_unfocused_iconify
=
688 RrAppearanceCopy(theme
->a_disabled_focused_max
);
689 theme
->a_hover_focused_iconify
=
690 RrAppearanceCopy(theme
->a_hover_focused_max
);
691 theme
->a_hover_unfocused_iconify
=
692 RrAppearanceCopy(theme
->a_hover_unfocused_max
);
693 theme
->a_unfocused_unpressed_iconify
=
694 RrAppearanceCopy(theme
->a_unfocused_unpressed_max
);
695 theme
->a_unfocused_pressed_iconify
=
696 RrAppearanceCopy(theme
->a_unfocused_pressed_max
);
697 theme
->a_focused_unpressed_iconify
=
698 RrAppearanceCopy(theme
->a_focused_unpressed_max
);
699 theme
->a_focused_pressed_iconify
=
700 RrAppearanceCopy(theme
->a_focused_pressed_max
);
702 theme
->a_icon
->surface
.grad
=
703 theme
->a_clear
->surface
.grad
=
704 theme
->a_clear_tex
->surface
.grad
=
705 theme
->a_menu_text_title
->surface
.grad
=
706 theme
->a_menu_normal
->surface
.grad
=
707 theme
->a_menu_disabled
->surface
.grad
=
708 theme
->a_menu_text_normal
->surface
.grad
=
709 theme
->a_menu_text_selected
->surface
.grad
=
710 theme
->a_menu_text_disabled
->surface
.grad
=
711 theme
->a_menu_text_disabled_selected
->surface
.grad
=
712 theme
->a_menu_bullet_normal
->surface
.grad
=
713 theme
->a_menu_bullet_selected
->surface
.grad
= RR_SURFACE_PARENTREL
;
715 /* set up the textures */
716 theme
->a_focused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
717 theme
->a_focused_label
->texture
[0].data
.text
.justify
= winjust
;
718 theme
->a_focused_label
->texture
[0].data
.text
.font
=theme
->win_font_focused
;
719 theme
->a_focused_label
->texture
[0].data
.text
.color
=
720 theme
->title_focused_color
;
722 if (read_string(db
, "window.active.label.text.font", &str
)) {
726 if (strstr(str
, "shadow=y")) {
727 if ((p
= strstr(str
, "shadowoffset=")))
728 i
= parse_inline_number(p
+ strlen("shadowoffset="));
731 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
732 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
734 if ((p
= strstr(str
, "shadowtint=")))
736 i
= parse_inline_number(p
+ strlen("shadowtint="));
737 j
= (i
> 0 ? 0 : 255);
740 theme
->title_focused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
741 theme
->title_focused_shadow_alpha
= i
;
743 theme
->title_focused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
744 theme
->title_focused_shadow_alpha
= 50;
748 theme
->a_focused_label
->texture
[0].data
.text
.shadow_color
=
749 theme
->title_focused_shadow_color
;
750 theme
->a_focused_label
->texture
[0].data
.text
.shadow_alpha
=
751 theme
->title_focused_shadow_alpha
;
753 theme
->osd_hilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
754 theme
->osd_hilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
755 theme
->osd_hilite_label
->texture
[0].data
.text
.font
=
756 theme
->osd_font_hilite
;
757 theme
->osd_hilite_label
->texture
[0].data
.text
.color
=
758 theme
->osd_text_active_color
;
760 if (read_string(db
, "osd.active.label.text.font", &str
) ||
761 read_string(db
, "osd.label.text.font", &str
))
766 if (strstr(str
, "shadow=y")) {
767 if ((p
= strstr(str
, "shadowoffset=")))
768 i
= parse_inline_number(p
+ strlen("shadowoffset="));
771 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
772 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
774 if ((p
= strstr(str
, "shadowtint=")))
776 i
= parse_inline_number(p
+ strlen("shadowtint="));
777 j
= (i
> 0 ? 0 : 255);
780 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, j
, j
, j
);
781 theme
->osd_text_active_shadow_alpha
= i
;
783 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
784 theme
->osd_text_active_shadow_alpha
= 50;
787 /* inherit the font settings from the focused label */
788 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_x
=
789 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_x
;
790 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_offset_y
=
791 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
;
792 if (theme
->title_focused_shadow_color
)
793 theme
->osd_text_active_shadow_color
=
795 theme
->title_focused_shadow_color
->r
,
796 theme
->title_focused_shadow_color
->g
,
797 theme
->title_focused_shadow_color
->b
);
799 theme
->osd_text_active_shadow_color
= RrColorNew(inst
, 0, 0, 0);
800 theme
->osd_text_active_shadow_alpha
=
801 theme
->title_focused_shadow_alpha
;
804 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_color
=
805 theme
->osd_text_active_shadow_color
;
806 theme
->osd_hilite_label
->texture
[0].data
.text
.shadow_alpha
=
807 theme
->osd_text_active_shadow_alpha
;
809 theme
->a_unfocused_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
810 theme
->a_unfocused_label
->texture
[0].data
.text
.justify
= winjust
;
811 theme
->a_unfocused_label
->texture
[0].data
.text
.font
=
812 theme
->win_font_unfocused
;
813 theme
->a_unfocused_label
->texture
[0].data
.text
.color
=
814 theme
->title_unfocused_color
;
816 if (read_string(db
, "window.inactive.label.text.font", &str
)) {
820 if (strstr(str
, "shadow=y")) {
821 if ((p
= strstr(str
, "shadowoffset=")))
822 i
= parse_inline_number(p
+ strlen("shadowoffset="));
825 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
= i
;
826 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
= i
;
828 if ((p
= strstr(str
, "shadowtint=")))
830 i
= parse_inline_number(p
+ strlen("shadowtint="));
831 j
= (i
> 0 ? 0 : 255);
834 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, j
, j
, j
);
835 theme
->title_unfocused_shadow_alpha
= i
;
837 theme
->title_unfocused_shadow_color
= RrColorNew(inst
, 0, 0, 0);
838 theme
->title_unfocused_shadow_alpha
= 50;
842 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_color
=
843 theme
->title_unfocused_shadow_color
;
844 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_alpha
=
845 theme
->title_unfocused_shadow_alpha
;
847 theme
->osd_unhilite_label
->texture
[0].type
= RR_TEXTURE_TEXT
;
848 theme
->osd_unhilite_label
->texture
[0].data
.text
.justify
= RR_JUSTIFY_LEFT
;
849 theme
->osd_unhilite_label
->texture
[0].data
.text
.font
=
850 theme
->osd_font_unhilite
;
851 theme
->osd_unhilite_label
->texture
[0].data
.text
.color
=
852 theme
->osd_text_inactive_color
;
854 if (read_string(db
, "osd.inactive.label.text.font", &str
))
859 if (strstr(str
, "shadow=y")) {
860 if ((p
= strstr(str
, "shadowoffset=")))
861 i
= parse_inline_number(p
+ strlen("shadowoffset="));
864 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=i
;
865 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=i
;
867 if ((p
= strstr(str
, "shadowtint=")))
869 i
= parse_inline_number(p
+ strlen("shadowtint="));
870 j
= (i
> 0 ? 0 : 255);
873 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, j
, j
, j
);
874 theme
->osd_text_inactive_shadow_alpha
= i
;
876 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
877 theme
->osd_text_inactive_shadow_alpha
= 50;
880 /* inherit the font settings from the unfocused label */
881 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_x
=
882 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_x
;
883 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_offset_y
=
884 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
;
885 if (theme
->title_unfocused_shadow_color
)
886 theme
->osd_text_inactive_shadow_color
=
888 theme
->title_unfocused_shadow_color
->r
,
889 theme
->title_unfocused_shadow_color
->g
,
890 theme
->title_unfocused_shadow_color
->b
);
892 theme
->osd_text_inactive_shadow_color
= RrColorNew(inst
, 0, 0, 0);
893 theme
->osd_text_inactive_shadow_alpha
=
894 theme
->title_unfocused_shadow_alpha
;
897 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_color
=
898 theme
->osd_text_inactive_shadow_color
;
899 theme
->osd_unhilite_label
->texture
[0].data
.text
.shadow_alpha
=
900 theme
->osd_text_inactive_shadow_alpha
;
902 theme
->a_menu_text_title
->texture
[0].type
= RR_TEXTURE_TEXT
;
903 theme
->a_menu_text_title
->texture
[0].data
.text
.justify
= mtitlejust
;
904 theme
->a_menu_text_title
->texture
[0].data
.text
.font
=
905 theme
->menu_title_font
;
906 theme
->a_menu_text_title
->texture
[0].data
.text
.color
=
907 theme
->menu_title_color
;
909 if (read_string(db
, "menu.title.text.font", &str
)) {
913 if (strstr(str
, "shadow=y")) {
914 if ((p
= strstr(str
, "shadowoffset=")))
915 i
= parse_inline_number(p
+ strlen("shadowoffset="));
918 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_x
= i
;
919 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
= i
;
921 if ((p
= strstr(str
, "shadowtint=")))
923 i
= parse_inline_number(p
+ strlen("shadowtint="));
924 j
= (i
> 0 ? 0 : 255);
927 theme
->menu_title_shadow_color
= RrColorNew(inst
, j
, j
, j
);
928 theme
->menu_title_shadow_alpha
= i
;
930 theme
->menu_title_shadow_color
= RrColorNew(inst
, 0, 0, 0);
931 theme
->menu_title_shadow_alpha
= 50;
935 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_color
=
936 theme
->menu_title_shadow_color
;
937 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_alpha
=
938 theme
->menu_title_shadow_alpha
;
940 theme
->a_menu_text_normal
->texture
[0].type
=
941 theme
->a_menu_text_selected
->texture
[0].type
=
942 theme
->a_menu_text_disabled
->texture
[0].type
=
943 theme
->a_menu_text_disabled_selected
->texture
[0].type
=
945 theme
->a_menu_text_normal
->texture
[0].data
.text
.justify
=
946 theme
->a_menu_text_selected
->texture
[0].data
.text
.justify
=
947 theme
->a_menu_text_disabled
->texture
[0].data
.text
.justify
=
948 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.justify
=
950 theme
->a_menu_text_normal
->texture
[0].data
.text
.font
=
951 theme
->a_menu_text_selected
->texture
[0].data
.text
.font
=
952 theme
->a_menu_text_disabled
->texture
[0].data
.text
.font
=
953 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.font
=
955 theme
->a_menu_text_normal
->texture
[0].data
.text
.color
= theme
->menu_color
;
956 theme
->a_menu_text_selected
->texture
[0].data
.text
.color
=
957 theme
->menu_selected_color
;
958 theme
->a_menu_text_disabled
->texture
[0].data
.text
.color
=
959 theme
->menu_disabled_color
;
960 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.color
=
961 theme
->menu_disabled_selected_color
;
963 if (read_string(db
, "menu.items.font", &str
)) {
967 if (strstr(str
, "shadow=y")) {
968 if ((p
= strstr(str
, "shadowoffset=")))
969 i
= parse_inline_number(p
+ strlen("shadowoffset="));
972 theme
->a_menu_text_normal
->
973 texture
[0].data
.text
.shadow_offset_x
= i
;
974 theme
->a_menu_text_normal
->
975 texture
[0].data
.text
.shadow_offset_y
= i
;
976 theme
->a_menu_text_selected
->
977 texture
[0].data
.text
.shadow_offset_x
= i
;
978 theme
->a_menu_text_selected
->
979 texture
[0].data
.text
.shadow_offset_y
= i
;
980 theme
->a_menu_text_disabled
->
981 texture
[0].data
.text
.shadow_offset_x
= i
;
982 theme
->a_menu_text_disabled
->
983 texture
[0].data
.text
.shadow_offset_y
= i
;
984 theme
->a_menu_text_disabled_selected
->
985 texture
[0].data
.text
.shadow_offset_x
= i
;
986 theme
->a_menu_text_disabled_selected
->
987 texture
[0].data
.text
.shadow_offset_y
= i
;
989 if ((p
= strstr(str
, "shadowtint=")))
991 i
= parse_inline_number(p
+ strlen("shadowtint="));
992 j
= (i
> 0 ? 0 : 255);
995 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, j
, j
, j
);
996 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, j
, j
, j
);
997 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, j
, j
, j
);
998 theme
->menu_text_normal_shadow_alpha
= i
;
999 theme
->menu_text_selected_shadow_alpha
= i
;
1000 theme
->menu_text_disabled_shadow_alpha
= i
;
1001 theme
->menu_text_disabled_selected_shadow_alpha
= i
;
1003 theme
->menu_text_normal_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1004 theme
->menu_text_selected_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1005 theme
->menu_text_disabled_shadow_color
= RrColorNew(inst
, 0, 0, 0);
1006 theme
->menu_text_normal_shadow_alpha
= 50;
1007 theme
->menu_text_selected_shadow_alpha
= 50;
1008 theme
->menu_text_disabled_selected_shadow_alpha
= 50;
1012 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_color
=
1013 theme
->menu_text_normal_shadow_color
;
1014 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_alpha
=
1015 theme
->menu_text_normal_shadow_alpha
;
1016 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_color
=
1017 theme
->menu_text_selected_shadow_color
;
1018 theme
->a_menu_text_selected
->texture
[0].data
.text
.shadow_alpha
=
1019 theme
->menu_text_selected_shadow_alpha
;
1020 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_color
=
1021 theme
->menu_text_disabled_shadow_color
;
1022 theme
->a_menu_text_disabled
->texture
[0].data
.text
.shadow_alpha
=
1023 theme
->menu_text_disabled_shadow_alpha
;
1024 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_color
=
1025 theme
->menu_text_disabled_shadow_color
;
1026 theme
->a_menu_text_disabled_selected
->texture
[0].data
.text
.shadow_alpha
=
1027 theme
->menu_text_disabled_shadow_alpha
;
1029 theme
->a_disabled_focused_max
->texture
[0].type
=
1030 theme
->a_disabled_unfocused_max
->texture
[0].type
=
1031 theme
->a_hover_focused_max
->texture
[0].type
=
1032 theme
->a_hover_unfocused_max
->texture
[0].type
=
1033 theme
->a_toggled_hover_focused_max
->texture
[0].type
=
1034 theme
->a_toggled_hover_unfocused_max
->texture
[0].type
=
1035 theme
->a_toggled_focused_unpressed_max
->texture
[0].type
=
1036 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].type
=
1037 theme
->a_toggled_focused_pressed_max
->texture
[0].type
=
1038 theme
->a_toggled_unfocused_pressed_max
->texture
[0].type
=
1039 theme
->a_focused_unpressed_max
->texture
[0].type
=
1040 theme
->a_focused_pressed_max
->texture
[0].type
=
1041 theme
->a_unfocused_unpressed_max
->texture
[0].type
=
1042 theme
->a_unfocused_pressed_max
->texture
[0].type
=
1043 theme
->a_disabled_focused_close
->texture
[0].type
=
1044 theme
->a_disabled_unfocused_close
->texture
[0].type
=
1045 theme
->a_hover_focused_close
->texture
[0].type
=
1046 theme
->a_hover_unfocused_close
->texture
[0].type
=
1047 theme
->a_focused_unpressed_close
->texture
[0].type
=
1048 theme
->a_focused_pressed_close
->texture
[0].type
=
1049 theme
->a_unfocused_unpressed_close
->texture
[0].type
=
1050 theme
->a_unfocused_pressed_close
->texture
[0].type
=
1051 theme
->a_disabled_focused_desk
->texture
[0].type
=
1052 theme
->a_disabled_unfocused_desk
->texture
[0].type
=
1053 theme
->a_hover_focused_desk
->texture
[0].type
=
1054 theme
->a_hover_unfocused_desk
->texture
[0].type
=
1055 theme
->a_toggled_hover_focused_desk
->texture
[0].type
=
1056 theme
->a_toggled_hover_unfocused_desk
->texture
[0].type
=
1057 theme
->a_toggled_focused_unpressed_desk
->texture
[0].type
=
1058 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].type
=
1059 theme
->a_toggled_focused_pressed_desk
->texture
[0].type
=
1060 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].type
=
1061 theme
->a_focused_unpressed_desk
->texture
[0].type
=
1062 theme
->a_focused_pressed_desk
->texture
[0].type
=
1063 theme
->a_unfocused_unpressed_desk
->texture
[0].type
=
1064 theme
->a_unfocused_pressed_desk
->texture
[0].type
=
1065 theme
->a_disabled_focused_shade
->texture
[0].type
=
1066 theme
->a_disabled_unfocused_shade
->texture
[0].type
=
1067 theme
->a_hover_focused_shade
->texture
[0].type
=
1068 theme
->a_hover_unfocused_shade
->texture
[0].type
=
1069 theme
->a_toggled_hover_focused_shade
->texture
[0].type
=
1070 theme
->a_toggled_hover_unfocused_shade
->texture
[0].type
=
1071 theme
->a_toggled_focused_unpressed_shade
->texture
[0].type
=
1072 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].type
=
1073 theme
->a_toggled_focused_pressed_shade
->texture
[0].type
=
1074 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].type
=
1075 theme
->a_focused_unpressed_shade
->texture
[0].type
=
1076 theme
->a_focused_pressed_shade
->texture
[0].type
=
1077 theme
->a_unfocused_unpressed_shade
->texture
[0].type
=
1078 theme
->a_unfocused_pressed_shade
->texture
[0].type
=
1079 theme
->a_disabled_focused_iconify
->texture
[0].type
=
1080 theme
->a_disabled_unfocused_iconify
->texture
[0].type
=
1081 theme
->a_hover_focused_iconify
->texture
[0].type
=
1082 theme
->a_hover_unfocused_iconify
->texture
[0].type
=
1083 theme
->a_focused_unpressed_iconify
->texture
[0].type
=
1084 theme
->a_focused_pressed_iconify
->texture
[0].type
=
1085 theme
->a_unfocused_unpressed_iconify
->texture
[0].type
=
1086 theme
->a_unfocused_pressed_iconify
->texture
[0].type
=
1087 theme
->a_menu_bullet_normal
->texture
[0].type
=
1088 theme
->a_menu_bullet_selected
->texture
[0].type
= RR_TEXTURE_MASK
;
1090 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.mask
=
1091 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.mask
=
1092 theme
->max_disabled_mask
;
1093 theme
->a_hover_focused_max
->texture
[0].data
.mask
.mask
=
1094 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1095 theme
->max_hover_mask
;
1096 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1097 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1098 theme
->max_pressed_mask
;
1099 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1100 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1102 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.mask
=
1103 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.mask
=
1104 theme
->max_toggled_hover_mask
;
1105 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.mask
=
1106 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.mask
=
1107 theme
->max_toggled_mask
;
1108 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.mask
=
1109 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.mask
=
1110 theme
->max_toggled_pressed_mask
;
1111 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.mask
=
1112 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.mask
=
1113 theme
->close_disabled_mask
;
1114 theme
->a_hover_focused_close
->texture
[0].data
.mask
.mask
=
1115 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.mask
=
1116 theme
->close_hover_mask
;
1117 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.mask
=
1118 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.mask
=
1119 theme
->close_pressed_mask
;
1120 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.mask
=
1121 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.mask
=
1123 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.mask
=
1124 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.mask
=
1125 theme
->desk_disabled_mask
;
1126 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1127 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1128 theme
->desk_hover_mask
;
1129 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1130 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1131 theme
->desk_pressed_mask
;
1132 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1133 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1135 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.mask
=
1136 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.mask
=
1137 theme
->desk_toggled_hover_mask
;
1138 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1139 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.mask
=
1140 theme
->desk_toggled_mask
;
1141 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.mask
=
1142 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.mask
=
1143 theme
->desk_toggled_pressed_mask
;
1144 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.mask
=
1145 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.mask
=
1146 theme
->shade_disabled_mask
;
1147 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1148 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1149 theme
->shade_hover_mask
;
1150 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1151 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1152 theme
->shade_pressed_mask
;
1153 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1154 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1156 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.mask
=
1157 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.mask
=
1158 theme
->shade_toggled_hover_mask
;
1159 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1160 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.mask
=
1161 theme
->shade_toggled_mask
;
1162 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.mask
=
1163 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.mask
=
1164 theme
->shade_toggled_pressed_mask
;
1165 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.mask
=
1166 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1167 theme
->iconify_disabled_mask
;
1168 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.mask
=
1169 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.mask
=
1170 theme
->iconify_hover_mask
;
1171 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1172 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.mask
=
1173 theme
->iconify_pressed_mask
;
1174 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1175 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.mask
=
1176 theme
->iconify_mask
;
1177 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.mask
=
1178 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.mask
=
1179 theme
->menu_bullet_mask
;
1180 theme
->a_disabled_focused_max
->texture
[0].data
.mask
.color
=
1181 theme
->a_disabled_focused_close
->texture
[0].data
.mask
.color
=
1182 theme
->a_disabled_focused_desk
->texture
[0].data
.mask
.color
=
1183 theme
->a_disabled_focused_shade
->texture
[0].data
.mask
.color
=
1184 theme
->a_disabled_focused_iconify
->texture
[0].data
.mask
.color
=
1185 theme
->titlebut_disabled_focused_color
;
1186 theme
->a_disabled_unfocused_max
->texture
[0].data
.mask
.color
=
1187 theme
->a_disabled_unfocused_close
->texture
[0].data
.mask
.color
=
1188 theme
->a_disabled_unfocused_desk
->texture
[0].data
.mask
.color
=
1189 theme
->a_disabled_unfocused_shade
->texture
[0].data
.mask
.color
=
1190 theme
->a_disabled_unfocused_iconify
->texture
[0].data
.mask
.color
=
1191 theme
->titlebut_disabled_unfocused_color
;
1192 theme
->a_hover_focused_max
->texture
[0].data
.mask
.color
=
1193 theme
->a_hover_focused_close
->texture
[0].data
.mask
.color
=
1194 theme
->a_hover_focused_desk
->texture
[0].data
.mask
.color
=
1195 theme
->a_hover_focused_shade
->texture
[0].data
.mask
.color
=
1196 theme
->a_hover_focused_iconify
->texture
[0].data
.mask
.color
=
1197 theme
->titlebut_hover_focused_color
;
1198 theme
->a_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1199 theme
->a_hover_unfocused_close
->texture
[0].data
.mask
.color
=
1200 theme
->a_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1201 theme
->a_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1202 theme
->a_hover_unfocused_iconify
->texture
[0].data
.mask
.color
=
1203 theme
->titlebut_hover_unfocused_color
;
1204 theme
->a_toggled_hover_focused_max
->texture
[0].data
.mask
.color
=
1205 theme
->a_toggled_hover_focused_desk
->texture
[0].data
.mask
.color
=
1206 theme
->a_toggled_hover_focused_shade
->texture
[0].data
.mask
.color
=
1207 theme
->titlebut_toggled_hover_focused_color
;
1208 theme
->a_toggled_hover_unfocused_max
->texture
[0].data
.mask
.color
=
1209 theme
->a_toggled_hover_unfocused_desk
->texture
[0].data
.mask
.color
=
1210 theme
->a_toggled_hover_unfocused_shade
->texture
[0].data
.mask
.color
=
1211 theme
->titlebut_toggled_hover_unfocused_color
;
1212 theme
->a_toggled_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1213 theme
->a_toggled_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1214 theme
->a_toggled_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1215 theme
->titlebut_toggled_focused_unpressed_color
;
1216 theme
->a_toggled_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1217 theme
->a_toggled_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1218 theme
->a_toggled_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1219 theme
->titlebut_toggled_unfocused_unpressed_color
;
1220 theme
->a_toggled_focused_pressed_max
->texture
[0].data
.mask
.color
=
1221 theme
->a_toggled_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1222 theme
->a_toggled_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1223 theme
->titlebut_toggled_focused_pressed_color
;
1224 theme
->a_toggled_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1225 theme
->a_toggled_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1226 theme
->a_toggled_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1227 theme
->titlebut_toggled_unfocused_pressed_color
;
1228 theme
->a_focused_unpressed_max
->texture
[0].data
.mask
.color
=
1229 theme
->a_focused_unpressed_close
->texture
[0].data
.mask
.color
=
1230 theme
->a_focused_unpressed_desk
->texture
[0].data
.mask
.color
=
1231 theme
->a_focused_unpressed_shade
->texture
[0].data
.mask
.color
=
1232 theme
->a_focused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1233 theme
->titlebut_focused_unpressed_color
;
1234 theme
->a_focused_pressed_max
->texture
[0].data
.mask
.color
=
1235 theme
->a_focused_pressed_close
->texture
[0].data
.mask
.color
=
1236 theme
->a_focused_pressed_desk
->texture
[0].data
.mask
.color
=
1237 theme
->a_focused_pressed_shade
->texture
[0].data
.mask
.color
=
1238 theme
->a_focused_pressed_iconify
->texture
[0].data
.mask
.color
=
1239 theme
->titlebut_focused_pressed_color
;
1240 theme
->a_unfocused_unpressed_max
->texture
[0].data
.mask
.color
=
1241 theme
->a_unfocused_unpressed_close
->texture
[0].data
.mask
.color
=
1242 theme
->a_unfocused_unpressed_desk
->texture
[0].data
.mask
.color
=
1243 theme
->a_unfocused_unpressed_shade
->texture
[0].data
.mask
.color
=
1244 theme
->a_unfocused_unpressed_iconify
->texture
[0].data
.mask
.color
=
1245 theme
->titlebut_unfocused_unpressed_color
;
1246 theme
->a_unfocused_pressed_max
->texture
[0].data
.mask
.color
=
1247 theme
->a_unfocused_pressed_close
->texture
[0].data
.mask
.color
=
1248 theme
->a_unfocused_pressed_desk
->texture
[0].data
.mask
.color
=
1249 theme
->a_unfocused_pressed_shade
->texture
[0].data
.mask
.color
=
1250 theme
->a_unfocused_pressed_iconify
->texture
[0].data
.mask
.color
=
1251 theme
->titlebut_unfocused_pressed_color
;
1252 theme
->a_menu_bullet_normal
->texture
[0].data
.mask
.color
=
1254 theme
->a_menu_bullet_selected
->texture
[0].data
.mask
.color
=
1255 theme
->menu_selected_color
;
1258 XrmDestroyDatabase(db
);
1260 /* set the font heights */
1261 theme
->win_font_height
= RrFontHeight
1262 (theme
->win_font_focused
,
1263 theme
->a_focused_label
->texture
[0].data
.text
.shadow_offset_y
);
1264 theme
->win_font_height
=
1265 MAX(theme
->win_font_height
,
1267 (theme
->win_font_focused
,
1268 theme
->a_unfocused_label
->texture
[0].data
.text
.shadow_offset_y
));
1269 theme
->menu_title_font_height
= RrFontHeight
1270 (theme
->menu_title_font
,
1271 theme
->a_menu_text_title
->texture
[0].data
.text
.shadow_offset_y
);
1272 theme
->menu_font_height
= RrFontHeight
1274 theme
->a_menu_text_normal
->texture
[0].data
.text
.shadow_offset_y
);
1276 /* calculate some last extents */
1278 gint ft
, fb
, fl
, fr
, ut
, ub
, ul
, ur
;
1280 RrMargins(theme
->a_focused_label
, &fl
, &ft
, &fr
, &fb
);
1281 RrMargins(theme
->a_unfocused_label
, &ul
, &ut
, &ur
, &ub
);
1282 theme
->label_height
= theme
->win_font_height
+ MAX(ft
+ fb
, ut
+ ub
);
1283 theme
->label_height
+= theme
->label_height
% 2;
1285 /* this would be nice I think, since padding.width can now be 0,
1286 but it breaks frame.c horribly and I don't feel like fixing that
1287 right now, so if anyone complains, here is how to keep text from
1288 going over the title's bevel/border with a padding.width of 0 and a
1289 bevelless/borderless label
1290 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1291 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1292 theme->title_height = theme->label_height +
1293 MAX(MAX(theme->padding * 2, ft + fb),
1294 MAX(theme->padding * 2, ut + ub));
1296 theme
->title_height
= theme
->label_height
+ theme
->paddingy
* 2;
1298 RrMargins(theme
->a_menu_title
, &ul
, &ut
, &ur
, &ub
);
1299 theme
->menu_title_label_height
= theme
->menu_title_font_height
+ut
+ub
;
1300 theme
->menu_title_height
= theme
->menu_title_label_height
+
1301 theme
->paddingy
* 2;
1303 theme
->button_size
= theme
->label_height
- 2;
1304 theme
->grip_width
= 25;
1306 RrAppearanceFree(a_disabled_focused_tmp
);
1307 RrAppearanceFree(a_disabled_unfocused_tmp
);
1308 RrAppearanceFree(a_hover_focused_tmp
);
1309 RrAppearanceFree(a_hover_unfocused_tmp
);
1310 RrAppearanceFree(a_focused_unpressed_tmp
);
1311 RrAppearanceFree(a_focused_pressed_tmp
);
1312 RrAppearanceFree(a_unfocused_unpressed_tmp
);
1313 RrAppearanceFree(a_unfocused_pressed_tmp
);
1314 RrAppearanceFree(a_toggled_hover_focused_tmp
);
1315 RrAppearanceFree(a_toggled_hover_unfocused_tmp
);
1316 RrAppearanceFree(a_toggled_focused_unpressed_tmp
);
1317 RrAppearanceFree(a_toggled_focused_pressed_tmp
);
1318 RrAppearanceFree(a_toggled_unfocused_unpressed_tmp
);
1319 RrAppearanceFree(a_toggled_unfocused_pressed_tmp
);
1324 void RrThemeFree(RrTheme
*theme
)
1327 g_free(theme
->name
);
1329 RrColorFree(theme
->menu_border_color
);
1330 RrColorFree(theme
->osd_border_color
);
1331 RrColorFree(theme
->frame_focused_border_color
);
1332 RrColorFree(theme
->frame_unfocused_border_color
);
1333 RrColorFree(theme
->title_separator_focused_color
);
1334 RrColorFree(theme
->title_separator_unfocused_color
);
1335 RrColorFree(theme
->cb_unfocused_color
);
1336 RrColorFree(theme
->cb_focused_color
);
1337 RrColorFree(theme
->title_focused_color
);
1338 RrColorFree(theme
->title_unfocused_color
);
1339 RrColorFree(theme
->titlebut_disabled_focused_color
);
1340 RrColorFree(theme
->titlebut_disabled_unfocused_color
);
1341 RrColorFree(theme
->titlebut_hover_focused_color
);
1342 RrColorFree(theme
->titlebut_hover_unfocused_color
);
1343 RrColorFree(theme
->titlebut_toggled_hover_focused_color
);
1344 RrColorFree(theme
->titlebut_toggled_hover_unfocused_color
);
1345 RrColorFree(theme
->titlebut_toggled_focused_pressed_color
);
1346 RrColorFree(theme
->titlebut_toggled_unfocused_pressed_color
);
1347 RrColorFree(theme
->titlebut_toggled_focused_unpressed_color
);
1348 RrColorFree(theme
->titlebut_toggled_unfocused_unpressed_color
);
1349 RrColorFree(theme
->titlebut_focused_pressed_color
);
1350 RrColorFree(theme
->titlebut_unfocused_pressed_color
);
1351 RrColorFree(theme
->titlebut_focused_unpressed_color
);
1352 RrColorFree(theme
->titlebut_unfocused_unpressed_color
);
1353 RrColorFree(theme
->menu_title_color
);
1354 RrColorFree(theme
->menu_sep_color
);
1355 RrColorFree(theme
->menu_color
);
1356 RrColorFree(theme
->menu_selected_color
);
1357 RrColorFree(theme
->menu_disabled_color
);
1358 RrColorFree(theme
->menu_disabled_selected_color
);
1359 RrColorFree(theme
->title_focused_shadow_color
);
1360 RrColorFree(theme
->title_unfocused_shadow_color
);
1361 RrColorFree(theme
->osd_text_active_color
);
1362 RrColorFree(theme
->osd_text_inactive_color
);
1363 RrColorFree(theme
->osd_text_active_shadow_color
);
1364 RrColorFree(theme
->osd_text_inactive_shadow_color
);
1365 RrColorFree(theme
->menu_title_shadow_color
);
1366 RrColorFree(theme
->menu_text_normal_shadow_color
);
1367 RrColorFree(theme
->menu_text_selected_shadow_color
);
1368 RrColorFree(theme
->menu_text_disabled_shadow_color
);
1369 RrColorFree(theme
->menu_text_disabled_selected_shadow_color
);
1371 g_free(theme
->def_win_icon
);
1373 RrPixmapMaskFree(theme
->max_mask
);
1374 RrPixmapMaskFree(theme
->max_toggled_mask
);
1375 RrPixmapMaskFree(theme
->max_toggled_hover_mask
);
1376 RrPixmapMaskFree(theme
->max_toggled_pressed_mask
);
1377 RrPixmapMaskFree(theme
->max_disabled_mask
);
1378 RrPixmapMaskFree(theme
->max_hover_mask
);
1379 RrPixmapMaskFree(theme
->max_pressed_mask
);
1380 RrPixmapMaskFree(theme
->desk_mask
);
1381 RrPixmapMaskFree(theme
->desk_toggled_mask
);
1382 RrPixmapMaskFree(theme
->desk_toggled_hover_mask
);
1383 RrPixmapMaskFree(theme
->desk_toggled_pressed_mask
);
1384 RrPixmapMaskFree(theme
->desk_disabled_mask
);
1385 RrPixmapMaskFree(theme
->desk_hover_mask
);
1386 RrPixmapMaskFree(theme
->desk_pressed_mask
);
1387 RrPixmapMaskFree(theme
->shade_mask
);
1388 RrPixmapMaskFree(theme
->shade_toggled_mask
);
1389 RrPixmapMaskFree(theme
->shade_toggled_hover_mask
);
1390 RrPixmapMaskFree(theme
->shade_toggled_pressed_mask
);
1391 RrPixmapMaskFree(theme
->shade_disabled_mask
);
1392 RrPixmapMaskFree(theme
->shade_hover_mask
);
1393 RrPixmapMaskFree(theme
->shade_pressed_mask
);
1394 RrPixmapMaskFree(theme
->iconify_mask
);
1395 RrPixmapMaskFree(theme
->iconify_disabled_mask
);
1396 RrPixmapMaskFree(theme
->iconify_hover_mask
);
1397 RrPixmapMaskFree(theme
->iconify_pressed_mask
);
1398 RrPixmapMaskFree(theme
->close_mask
);
1399 RrPixmapMaskFree(theme
->close_disabled_mask
);
1400 RrPixmapMaskFree(theme
->close_hover_mask
);
1401 RrPixmapMaskFree(theme
->close_pressed_mask
);
1402 RrPixmapMaskFree(theme
->menu_bullet_mask
);
1403 RrPixmapMaskFree(theme
->down_arrow_mask
);
1404 RrPixmapMaskFree(theme
->up_arrow_mask
);
1406 RrFontClose(theme
->win_font_focused
);
1407 RrFontClose(theme
->win_font_unfocused
);
1408 RrFontClose(theme
->menu_title_font
);
1409 RrFontClose(theme
->menu_font
);
1410 RrFontClose(theme
->osd_font_hilite
);
1411 RrFontClose(theme
->osd_font_unhilite
);
1413 RrAppearanceFree(theme
->a_disabled_focused_max
);
1414 RrAppearanceFree(theme
->a_disabled_unfocused_max
);
1415 RrAppearanceFree(theme
->a_hover_focused_max
);
1416 RrAppearanceFree(theme
->a_hover_unfocused_max
);
1417 RrAppearanceFree(theme
->a_toggled_hover_focused_max
);
1418 RrAppearanceFree(theme
->a_toggled_hover_unfocused_max
);
1419 RrAppearanceFree(theme
->a_toggled_focused_unpressed_max
);
1420 RrAppearanceFree(theme
->a_toggled_focused_pressed_max
);
1421 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_max
);
1422 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_max
);
1423 RrAppearanceFree(theme
->a_focused_unpressed_max
);
1424 RrAppearanceFree(theme
->a_focused_pressed_max
);
1425 RrAppearanceFree(theme
->a_unfocused_unpressed_max
);
1426 RrAppearanceFree(theme
->a_unfocused_pressed_max
);
1427 RrAppearanceFree(theme
->a_disabled_focused_close
);
1428 RrAppearanceFree(theme
->a_disabled_unfocused_close
);
1429 RrAppearanceFree(theme
->a_hover_focused_close
);
1430 RrAppearanceFree(theme
->a_hover_unfocused_close
);
1431 RrAppearanceFree(theme
->a_focused_unpressed_close
);
1432 RrAppearanceFree(theme
->a_focused_pressed_close
);
1433 RrAppearanceFree(theme
->a_unfocused_unpressed_close
);
1434 RrAppearanceFree(theme
->a_unfocused_pressed_close
);
1435 RrAppearanceFree(theme
->a_disabled_focused_desk
);
1436 RrAppearanceFree(theme
->a_disabled_unfocused_desk
);
1437 RrAppearanceFree(theme
->a_hover_focused_desk
);
1438 RrAppearanceFree(theme
->a_hover_unfocused_desk
);
1439 RrAppearanceFree(theme
->a_toggled_hover_focused_desk
);
1440 RrAppearanceFree(theme
->a_toggled_hover_unfocused_desk
);
1441 RrAppearanceFree(theme
->a_toggled_focused_unpressed_desk
);
1442 RrAppearanceFree(theme
->a_toggled_focused_pressed_desk
);
1443 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_desk
);
1444 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_desk
);
1445 RrAppearanceFree(theme
->a_focused_unpressed_desk
);
1446 RrAppearanceFree(theme
->a_focused_pressed_desk
);
1447 RrAppearanceFree(theme
->a_unfocused_unpressed_desk
);
1448 RrAppearanceFree(theme
->a_unfocused_pressed_desk
);
1449 RrAppearanceFree(theme
->a_disabled_focused_shade
);
1450 RrAppearanceFree(theme
->a_disabled_unfocused_shade
);
1451 RrAppearanceFree(theme
->a_hover_focused_shade
);
1452 RrAppearanceFree(theme
->a_hover_unfocused_shade
);
1453 RrAppearanceFree(theme
->a_toggled_hover_focused_shade
);
1454 RrAppearanceFree(theme
->a_toggled_hover_unfocused_shade
);
1455 RrAppearanceFree(theme
->a_toggled_focused_unpressed_shade
);
1456 RrAppearanceFree(theme
->a_toggled_focused_pressed_shade
);
1457 RrAppearanceFree(theme
->a_toggled_unfocused_unpressed_shade
);
1458 RrAppearanceFree(theme
->a_toggled_unfocused_pressed_shade
);
1459 RrAppearanceFree(theme
->a_focused_unpressed_shade
);
1460 RrAppearanceFree(theme
->a_focused_pressed_shade
);
1461 RrAppearanceFree(theme
->a_unfocused_unpressed_shade
);
1462 RrAppearanceFree(theme
->a_unfocused_pressed_shade
);
1463 RrAppearanceFree(theme
->a_disabled_focused_iconify
);
1464 RrAppearanceFree(theme
->a_disabled_unfocused_iconify
);
1465 RrAppearanceFree(theme
->a_hover_focused_iconify
);
1466 RrAppearanceFree(theme
->a_hover_unfocused_iconify
);
1467 RrAppearanceFree(theme
->a_focused_unpressed_iconify
);
1468 RrAppearanceFree(theme
->a_focused_pressed_iconify
);
1469 RrAppearanceFree(theme
->a_unfocused_unpressed_iconify
);
1470 RrAppearanceFree(theme
->a_unfocused_pressed_iconify
);
1471 RrAppearanceFree(theme
->a_focused_grip
);
1472 RrAppearanceFree(theme
->a_unfocused_grip
);
1473 RrAppearanceFree(theme
->a_focused_title
);
1474 RrAppearanceFree(theme
->a_unfocused_title
);
1475 RrAppearanceFree(theme
->a_focused_label
);
1476 RrAppearanceFree(theme
->a_unfocused_label
);
1477 RrAppearanceFree(theme
->a_icon
);
1478 RrAppearanceFree(theme
->a_focused_handle
);
1479 RrAppearanceFree(theme
->a_unfocused_handle
);
1480 RrAppearanceFree(theme
->a_menu
);
1481 RrAppearanceFree(theme
->a_menu_title
);
1482 RrAppearanceFree(theme
->a_menu_text_title
);
1483 RrAppearanceFree(theme
->a_menu_normal
);
1484 RrAppearanceFree(theme
->a_menu_selected
);
1485 RrAppearanceFree(theme
->a_menu_disabled
);
1486 RrAppearanceFree(theme
->a_menu_disabled_selected
);
1487 RrAppearanceFree(theme
->a_menu_text_normal
);
1488 RrAppearanceFree(theme
->a_menu_text_selected
);
1489 RrAppearanceFree(theme
->a_menu_text_disabled
);
1490 RrAppearanceFree(theme
->a_menu_text_disabled_selected
);
1491 RrAppearanceFree(theme
->a_menu_bullet_normal
);
1492 RrAppearanceFree(theme
->a_menu_bullet_selected
);
1493 RrAppearanceFree(theme
->a_clear
);
1494 RrAppearanceFree(theme
->a_clear_tex
);
1495 RrAppearanceFree(theme
->osd_bg
);
1496 RrAppearanceFree(theme
->osd_hilite_bg
);
1497 RrAppearanceFree(theme
->osd_hilite_label
);
1498 RrAppearanceFree(theme
->osd_unhilite_bg
);
1499 RrAppearanceFree(theme
->osd_unhilite_label
);
1501 g_slice_free(RrTheme
, theme
);
1505 static XrmDatabase
loaddb(const gchar
*name
, gchar
**path
)
1508 XrmDatabase db
= NULL
;
1511 if (name
[0] == '/') {
1512 s
= g_build_filename(name
, "openbox-3", "themerc", NULL
);
1513 if ((db
= XrmGetFileDatabase(s
)))
1514 *path
= g_path_get_dirname(s
);
1519 p
= obt_paths_new();
1521 /* XXX backwards compatibility, remove me sometime later */
1522 s
= g_build_filename(g_get_home_dir(), ".themes", name
,
1523 "openbox-3", "themerc", NULL
);
1524 if ((db
= XrmGetFileDatabase(s
)))
1525 *path
= g_path_get_dirname(s
);
1528 for (it
= obt_paths_data_dirs(p
); !db
&& it
; it
= g_slist_next(it
))
1530 s
= g_build_filename(it
->data
, "themes", name
,
1531 "openbox-3", "themerc", NULL
);
1532 if ((db
= XrmGetFileDatabase(s
)))
1533 *path
= g_path_get_dirname(s
);
1541 s
= g_build_filename(name
, "themerc", NULL
);
1542 if ((db
= XrmGetFileDatabase(s
)))
1543 *path
= g_path_get_dirname(s
);
1550 static gchar
*create_class_name(const gchar
*rname
)
1552 gchar
*rclass
= g_strdup(rname
);
1557 p
= strchr(p
+1, '.');
1558 if (p
== NULL
) break;
1560 if (*p
== '\0') break;
1565 static gboolean
read_int(XrmDatabase db
, const gchar
*rname
, gint
*value
)
1567 gboolean ret
= FALSE
;
1568 gchar
*rclass
= create_class_name(rname
);
1569 gchar
*rettype
, *end
;
1572 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1573 retvalue
.addr
!= NULL
) {
1574 *value
= (gint
)strtol(retvalue
.addr
, &end
, 10);
1575 if (end
!= retvalue
.addr
)
1583 static gboolean
read_string(XrmDatabase db
, const gchar
*rname
, gchar
**value
)
1585 gboolean ret
= FALSE
;
1586 gchar
*rclass
= create_class_name(rname
);
1590 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1591 retvalue
.addr
!= NULL
) {
1592 *value
= retvalue
.addr
;
1600 static gboolean
read_color(XrmDatabase db
, const RrInstance
*inst
,
1601 const gchar
*rname
, RrColor
**value
)
1603 gboolean ret
= FALSE
;
1604 gchar
*rclass
= create_class_name(rname
);
1608 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1609 retvalue
.addr
!= NULL
) {
1610 RrColor
*c
= RrColorParse(inst
, retvalue
.addr
);
1621 static gboolean
read_mask(const RrInstance
*inst
, const gchar
*path
,
1622 RrTheme
*theme
, const gchar
*maskname
,
1623 RrPixmapMask
**value
)
1625 gboolean ret
= FALSE
;
1627 gint hx
, hy
; /* ignored */
1631 s
= g_build_filename(path
, maskname
, NULL
);
1632 if (XReadBitmapFileData(s
, &w
, &h
, &b
, &hx
, &hy
) == BitmapSuccess
) {
1634 *value
= RrPixmapMaskNew(inst
, w
, h
, (gchar
*)b
);
1642 static void parse_appearance(gchar
*tex
, RrSurfaceColorType
*grad
,
1643 RrReliefType
*relief
, RrBevelType
*bevel
,
1644 gboolean
*interlaced
, gboolean
*border
,
1645 gboolean allow_trans
)
1649 /* convert to all lowercase */
1650 for (t
= tex
; *t
!= '\0'; ++t
)
1651 *t
= g_ascii_tolower(*t
);
1653 if (allow_trans
&& strstr(tex
, "parentrelative") != NULL
) {
1654 *grad
= RR_SURFACE_PARENTREL
;
1656 if (strstr(tex
, "gradient") != NULL
) {
1657 if (strstr(tex
, "crossdiagonal") != NULL
)
1658 *grad
= RR_SURFACE_CROSS_DIAGONAL
;
1659 else if (strstr(tex
, "pyramid") != NULL
)
1660 *grad
= RR_SURFACE_PYRAMID
;
1661 else if (strstr(tex
, "mirrorhorizontal") != NULL
)
1662 *grad
= RR_SURFACE_MIRROR_HORIZONTAL
;
1663 else if (strstr(tex
, "horizontal") != NULL
)
1664 *grad
= RR_SURFACE_HORIZONTAL
;
1665 else if (strstr(tex
, "splitvertical") != NULL
)
1666 *grad
= RR_SURFACE_SPLIT_VERTICAL
;
1667 else if (strstr(tex
, "vertical") != NULL
)
1668 *grad
= RR_SURFACE_VERTICAL
;
1670 *grad
= RR_SURFACE_DIAGONAL
;
1672 *grad
= RR_SURFACE_SOLID
;
1676 if (strstr(tex
, "sunken") != NULL
)
1677 *relief
= RR_RELIEF_SUNKEN
;
1678 else if (strstr(tex
, "flat") != NULL
)
1679 *relief
= RR_RELIEF_FLAT
;
1680 else if (strstr(tex
, "raised") != NULL
)
1681 *relief
= RR_RELIEF_RAISED
;
1683 *relief
= (*grad
== RR_SURFACE_PARENTREL
) ?
1684 RR_RELIEF_FLAT
: RR_RELIEF_RAISED
;
1687 if (*relief
== RR_RELIEF_FLAT
) {
1688 if (strstr(tex
, "border") != NULL
)
1691 if (strstr(tex
, "bevel2") != NULL
)
1692 *bevel
= RR_BEVEL_2
;
1694 *bevel
= RR_BEVEL_1
;
1697 if (strstr(tex
, "interlaced") != NULL
)
1700 *interlaced
= FALSE
;
1703 static gboolean
read_appearance(XrmDatabase db
, const RrInstance
*inst
,
1704 const gchar
*rname
, RrAppearance
*value
,
1705 gboolean allow_trans
)
1707 gboolean ret
= FALSE
;
1708 gchar
*rclass
= create_class_name(rname
);
1709 gchar
*cname
, *ctoname
, *bcname
, *icname
, *hname
, *sname
;
1710 gchar
*csplitname
, *ctosplitname
;
1715 cname
= g_strconcat(rname
, ".color", NULL
);
1716 ctoname
= g_strconcat(rname
, ".colorTo", NULL
);
1717 bcname
= g_strconcat(rname
, ".border.color", NULL
);
1718 icname
= g_strconcat(rname
, ".interlace.color", NULL
);
1719 hname
= g_strconcat(rname
, ".highlight", NULL
);
1720 sname
= g_strconcat(rname
, ".shadow", NULL
);
1721 csplitname
= g_strconcat(rname
, ".color.splitTo", NULL
);
1722 ctosplitname
= g_strconcat(rname
, ".colorTo.splitTo", NULL
);
1724 if (XrmGetResource(db
, rname
, rclass
, &rettype
, &retvalue
) &&
1725 retvalue
.addr
!= NULL
) {
1726 parse_appearance(retvalue
.addr
,
1727 &value
->surface
.grad
,
1728 &value
->surface
.relief
,
1729 &value
->surface
.bevel
,
1730 &value
->surface
.interlaced
,
1731 &value
->surface
.border
,
1733 if (!read_color(db
, inst
, cname
, &value
->surface
.primary
))
1734 value
->surface
.primary
= RrColorNew(inst
, 0, 0, 0);
1735 if (!read_color(db
, inst
, ctoname
, &value
->surface
.secondary
))
1736 value
->surface
.secondary
= RrColorNew(inst
, 0, 0, 0);
1737 if (value
->surface
.border
)
1738 if (!read_color(db
, inst
, bcname
,
1739 &value
->surface
.border_color
))
1740 value
->surface
.border_color
= RrColorNew(inst
, 0, 0, 0);
1741 if (value
->surface
.interlaced
)
1742 if (!read_color(db
, inst
, icname
,
1743 &value
->surface
.interlace_color
))
1744 value
->surface
.interlace_color
= RrColorNew(inst
, 0, 0, 0);
1745 if (read_int(db
, hname
, &i
) && i
>= 0)
1746 value
->surface
.bevel_light_adjust
= i
;
1747 if (read_int(db
, sname
, &i
) && i
>= 0 && i
<= 256)
1748 value
->surface
.bevel_dark_adjust
= i
;
1750 if (value
->surface
.grad
== RR_SURFACE_SPLIT_VERTICAL
) {
1753 if (!read_color(db
, inst
, csplitname
,
1754 &value
->surface
.split_primary
))
1756 r
= value
->surface
.primary
->r
;
1758 g
= value
->surface
.primary
->g
;
1760 b
= value
->surface
.primary
->b
;
1762 if (r
> 0xFF) r
= 0xFF;
1763 if (g
> 0xFF) g
= 0xFF;
1764 if (b
> 0xFF) b
= 0xFF;
1765 value
->surface
.split_primary
= RrColorNew(inst
, r
, g
, b
);
1768 if (!read_color(db
, inst
, ctosplitname
,
1769 &value
->surface
.split_secondary
))
1771 r
= value
->surface
.secondary
->r
;
1773 g
= value
->surface
.secondary
->g
;
1775 b
= value
->surface
.secondary
->b
;
1777 if (r
> 0xFF) r
= 0xFF;
1778 if (g
> 0xFF) g
= 0xFF;
1779 if (b
> 0xFF) b
= 0xFF;
1780 value
->surface
.split_secondary
= RrColorNew(inst
, r
, g
, b
);
1787 g_free(ctosplitname
);
1799 static int parse_inline_number(const char *p
)
1807 for (; isdigit(*p
); ++p
)
1808 res
= res
* 10 + *p
- '0';
1813 static void set_default_appearance(RrAppearance
*a
)
1815 a
->surface
.grad
= RR_SURFACE_SOLID
;
1816 a
->surface
.relief
= RR_RELIEF_FLAT
;
1817 a
->surface
.bevel
= RR_BEVEL_1
;
1818 a
->surface
.interlaced
= FALSE
;
1819 a
->surface
.border
= FALSE
;
1820 a
->surface
.primary
= RrColorNew(a
->inst
, 0, 0, 0);
1821 a
->surface
.secondary
= RrColorNew(a
->inst
, 0, 0, 0);
1824 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1825 an RrTextureRGBA. */
1826 static RrPixel32
* read_c_image(gint width
, gint height
, const guint8
*data
)
1831 p
= im
= g_memdup(data
, width
* height
* sizeof(RrPixel32
));
1833 for (i
= 0; i
< width
* height
; ++i
) {
1834 guchar a
= ((*p
>> 24) & 0xff);
1835 guchar b
= ((*p
>> 16) & 0xff);
1836 guchar g
= ((*p
>> 8) & 0xff);
1837 guchar r
= ((*p
>> 0) & 0xff);
1839 *p
= ((r
<< RrDefaultRedOffset
) +
1840 (g
<< RrDefaultGreenOffset
) +
1841 (b
<< RrDefaultBlueOffset
) +
1842 (a
<< RrDefaultAlphaOffset
));