]> Dogcows Code - chaz/openbox/blob - render/theme.c
Merge branch 'backport' into work
[chaz/openbox] / render / theme.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3 theme.c for the Openbox window manager
4 Copyright (c) 2006 Mikael Magnusson
5 Copyright (c) 2003-2007 Dana Jansens
6
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.
11
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.
16
17 See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "render.h"
21 #include "color.h"
22 #include "font.h"
23 #include "mask.h"
24 #include "theme.h"
25 #include "icon.h"
26 #include "obt/paths.h"
27
28 #include <X11/Xlib.h>
29 #include <X11/Xresource.h>
30 #include <ctype.h>
31 #include <stdlib.h>
32 #include <string.h>
33
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);
48
49 static RrFont *get_font(RrFont *target, RrFont **default_font,
50 const RrInstance *inst)
51 {
52 if (target) {
53 RrFontRef(target);
54 return target;
55 } else {
56 /* Only load the default font once */
57 if (*default_font) {
58 RrFontRef(*default_font);
59 } else {
60 *default_font = RrFontOpenDefault(inst);
61 }
62 return *default_font;
63 }
64 }
65
66 RrTheme* RrThemeNew(const RrInstance *inst, const gchar *name,
67 gboolean allow_fallback,
68 RrFont *active_window_font, RrFont *inactive_window_font,
69 RrFont *menu_title_font, RrFont *menu_item_font,
70 RrFont *osd_font)
71 {
72 XrmDatabase db = NULL;
73 RrJustify winjust, mtitlejust;
74 gchar *str;
75 RrTheme *theme;
76 RrFont *default_font = NULL;
77 gchar *path;
78 gboolean userdef;
79
80 if (name) {
81 db = loaddb(name, &path);
82 if (db == NULL) {
83 g_message("Unable to load the theme '%s'", name);
84 if (allow_fallback)
85 g_message("Falling back to the default theme '%s'",
86 DEFAULT_THEME);
87 /* fallback to the default theme */
88 name = NULL;
89 }
90 }
91 if (name == NULL) {
92 if (allow_fallback) {
93 db = loaddb(DEFAULT_THEME, &path);
94 if (db == NULL) {
95 g_message("Unable to load the theme '%s'", DEFAULT_THEME);
96 return NULL;
97 }
98 } else
99 return NULL;
100 }
101
102 theme = g_new0(RrTheme, 1);
103
104 theme->inst = inst;
105 theme->name = g_strdup(name ? name : DEFAULT_THEME);
106
107 theme->a_disabled_focused_max = RrAppearanceNew(inst, 1);
108 theme->a_disabled_unfocused_max = RrAppearanceNew(inst, 1);
109 theme->a_hover_focused_max = RrAppearanceNew(inst, 1);
110 theme->a_hover_unfocused_max = RrAppearanceNew(inst, 1);
111 theme->a_toggled_focused_unpressed_max = RrAppearanceNew(inst, 1);
112 theme->a_toggled_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
113 theme->a_toggled_hover_focused_max = RrAppearanceNew(inst, 1);
114 theme->a_toggled_hover_unfocused_max = RrAppearanceNew(inst, 1);
115 theme->a_toggled_focused_pressed_max = RrAppearanceNew(inst, 1);
116 theme->a_toggled_unfocused_pressed_max = RrAppearanceNew(inst, 1);
117 theme->a_focused_unpressed_max = RrAppearanceNew(inst, 1);
118 theme->a_focused_pressed_max = RrAppearanceNew(inst, 1);
119 theme->a_unfocused_unpressed_max = RrAppearanceNew(inst, 1);
120 theme->a_unfocused_pressed_max = RrAppearanceNew(inst, 1);
121 theme->a_focused_grip = RrAppearanceNew(inst, 0);
122 theme->a_unfocused_grip = RrAppearanceNew(inst, 0);
123 theme->a_focused_title = RrAppearanceNew(inst, 0);
124 theme->a_unfocused_title = RrAppearanceNew(inst, 0);
125 theme->a_focused_label = RrAppearanceNew(inst, 1);
126 theme->a_unfocused_label = RrAppearanceNew(inst, 1);
127 theme->a_icon = RrAppearanceNew(inst, 1);
128 theme->a_focused_handle = RrAppearanceNew(inst, 0);
129 theme->a_unfocused_handle = RrAppearanceNew(inst, 0);
130 theme->a_menu = RrAppearanceNew(inst, 0);
131 theme->a_menu_title = RrAppearanceNew(inst, 0);
132 theme->a_menu_text_title = RrAppearanceNew(inst, 1);
133 theme->a_menu_normal = RrAppearanceNew(inst, 0);
134 theme->a_menu_selected = RrAppearanceNew(inst, 0);
135 theme->a_menu_disabled = RrAppearanceNew(inst, 0);
136 /* a_menu_disabled_selected is copied from a_menu_selected */
137 theme->a_menu_text_normal = RrAppearanceNew(inst, 1);
138 theme->a_menu_text_selected = RrAppearanceNew(inst, 1);
139 theme->a_menu_text_disabled = RrAppearanceNew(inst, 1);
140 theme->a_menu_text_disabled_selected = RrAppearanceNew(inst, 1);
141 theme->a_menu_bullet_normal = RrAppearanceNew(inst, 1);
142 theme->a_menu_bullet_selected = RrAppearanceNew(inst, 1);
143 theme->a_clear = RrAppearanceNew(inst, 0);
144 theme->a_clear_tex = RrAppearanceNew(inst, 1);
145 theme->osd_hilite_bg = RrAppearanceNew(inst, 0);
146 theme->osd_hilite_label = RrAppearanceNew(inst, 1);
147 theme->osd_hilite_fg = RrAppearanceNew(inst, 0);
148 theme->osd_unhilite_fg = RrAppearanceNew(inst, 0);
149
150 /* load the font stuff */
151 theme->win_font_focused = get_font(active_window_font,
152 &default_font, inst);
153 theme->win_font_unfocused = get_font(inactive_window_font,
154 &default_font, inst);
155
156 winjust = RR_JUSTIFY_LEFT;
157 if (read_string(db, "window.label.text.justify", &str)) {
158 if (!g_ascii_strcasecmp(str, "right"))
159 winjust = RR_JUSTIFY_RIGHT;
160 else if (!g_ascii_strcasecmp(str, "center"))
161 winjust = RR_JUSTIFY_CENTER;
162 }
163
164 theme->menu_title_font = get_font(menu_title_font, &default_font, inst);
165
166 mtitlejust = RR_JUSTIFY_LEFT;
167 if (read_string(db, "menu.title.text.justify", &str)) {
168 if (!g_ascii_strcasecmp(str, "right"))
169 mtitlejust = RR_JUSTIFY_RIGHT;
170 else if (!g_ascii_strcasecmp(str, "center"))
171 mtitlejust = RR_JUSTIFY_CENTER;
172 }
173
174 theme->menu_font = get_font(menu_item_font, &default_font, inst);
175
176 theme->osd_font = get_font(osd_font, &default_font, inst);
177
178 /* load direct dimensions */
179 if ((!read_int(db, "menu.overlap.x", &theme->menu_overlap_x) &&
180 !read_int(db, "menu.overlap", &theme->menu_overlap_x)) ||
181 theme->menu_overlap_x < -100 || theme->menu_overlap_x > 100)
182 theme->menu_overlap_x = 0;
183 if ((!read_int(db, "menu.overlap.y", &theme->menu_overlap_y) &&
184 !read_int(db, "menu.overlap", &theme->menu_overlap_y)) ||
185 theme->menu_overlap_y < -100 || theme->menu_overlap_y > 100)
186 theme->menu_overlap_y = 0;
187 if (!read_int(db, "window.handle.width", &theme->handle_height) ||
188 theme->handle_height < 0 || theme->handle_height > 100)
189 theme->handle_height = 6;
190 if (!read_int(db, "padding.width", &theme->paddingx) ||
191 theme->paddingx < 0 || theme->paddingx > 100)
192 theme->paddingx = 3;
193 if (!read_int(db, "padding.height", &theme->paddingy) ||
194 theme->paddingy < 0 || theme->paddingy > 100)
195 theme->paddingy = theme->paddingx;
196 if (!read_int(db, "border.width", &theme->fbwidth) ||
197 theme->fbwidth < 0 || theme->fbwidth > 100)
198 theme->fbwidth = 1;
199 /* menu border width inherits from the frame border width */
200 if (!read_int(db, "menu.border.width", &theme->mbwidth) ||
201 theme->mbwidth < 0 || theme->mbwidth > 100)
202 theme->mbwidth = theme->fbwidth;
203 /* osd border width inherits from the frame border width */
204 if (!read_int(db, "osd.border.width", &theme->obwidth) ||
205 theme->obwidth < 0 || theme->obwidth > 100)
206 theme->obwidth = theme->fbwidth;
207 if (!read_int(db, "window.client.padding.width", &theme->cbwidthx) ||
208 theme->cbwidthx < 0 || theme->cbwidthx > 100)
209 theme->cbwidthx = theme->paddingx;
210 if (!read_int(db, "window.client.padding.height", &theme->cbwidthy) ||
211 theme->cbwidthy < 0 || theme->cbwidthy > 100)
212 theme->cbwidthy = theme->cbwidthx;
213 if (!read_int(db, "menu.separator.width", &theme->menu_sep_width) ||
214 theme->menu_sep_width < 1 || theme->menu_sep_width > 100)
215 theme->menu_sep_width = 1;
216 if (!read_int(db, "menu.separator.padding.width",
217 &theme->menu_sep_paddingx) ||
218 theme->menu_sep_paddingx < 0 || theme->menu_sep_paddingx > 100)
219 theme->menu_sep_paddingx = 6;
220 if (!read_int(db, "menu.separator.padding.height",
221 &theme->menu_sep_paddingy) ||
222 theme->menu_sep_paddingy < 0 || theme->menu_sep_paddingy > 100)
223 theme->menu_sep_paddingy = 3;
224
225 /* load colors */
226 if (!read_color(db, inst,
227 "window.active.border.color",
228 &theme->frame_focused_border_color) &&
229 !read_color(db, inst,
230 "border.color",
231 &theme->frame_focused_border_color))
232 theme->frame_focused_border_color = RrColorNew(inst, 0, 0, 0);
233 /* title separator focused color inherits from focused border color */
234 if (!read_color(db, inst,
235 "window.active.title.separator.color",
236 &theme->title_separator_focused_color))
237 theme->title_separator_focused_color =
238 RrColorNew(inst,
239 theme->frame_focused_border_color->r,
240 theme->frame_focused_border_color->g,
241 theme->frame_focused_border_color->b);
242 /* unfocused border color inherits from frame focused border color */
243 if (!read_color(db, inst,
244 "window.inactive.border.color",
245 &theme->frame_unfocused_border_color))
246 theme->frame_unfocused_border_color =
247 RrColorNew(inst, theme->frame_focused_border_color->r,
248 theme->frame_focused_border_color->g,
249 theme->frame_focused_border_color->b);
250 /* title separator unfocused color inherits from unfocused border color */
251 if (!read_color(db, inst,
252 "window.inactive.title.separator.color",
253 &theme->title_separator_unfocused_color))
254 theme->title_separator_unfocused_color =
255 RrColorNew(inst,
256 theme->frame_unfocused_border_color->r,
257 theme->frame_unfocused_border_color->g,
258 theme->frame_unfocused_border_color->b);
259
260 /* menu border color inherits from frame focused border color */
261 if (!read_color(db, inst, "menu.border.color", &theme->menu_border_color))
262 theme->menu_border_color =
263 RrColorNew(inst,
264 theme->frame_focused_border_color->r,
265 theme->frame_focused_border_color->g,
266 theme->frame_focused_border_color->b);
267 /* osd border color inherits from frame focused border color */
268 if (!read_color(db, inst, "osd.border.color", &theme->osd_border_color))
269 theme->osd_border_color =
270 RrColorNew(inst,
271 theme->frame_focused_border_color->r,
272 theme->frame_focused_border_color->g,
273 theme->frame_focused_border_color->b);
274 if (!read_color(db, inst,
275 "window.active.client.color",
276 &theme->cb_focused_color))
277 theme->cb_focused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
278 if (!read_color(db, inst,
279 "window.inactive.client.color",
280 &theme->cb_unfocused_color))
281 theme->cb_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
282 if (!read_color(db, inst,
283 "window.active.label.text.color",
284 &theme->title_focused_color))
285 theme->title_focused_color = RrColorNew(inst, 0x0, 0x0, 0x0);
286 if (!read_color(db, inst, "osd.label.text.color", &theme->osd_color))
287 theme->osd_color = RrColorNew(inst,
288 theme->title_focused_color->r,
289 theme->title_focused_color->g,
290 theme->title_focused_color->b);
291 if (!read_color(db, inst,
292 "window.inactive.label.text.color",
293 &theme->title_unfocused_color))
294 theme->title_unfocused_color = RrColorNew(inst, 0xff, 0xff, 0xff);
295 if (!read_color(db, inst,
296 "window.active.button.unpressed.image.color",
297 &theme->titlebut_focused_unpressed_color))
298 theme->titlebut_focused_unpressed_color = RrColorNew(inst, 0, 0, 0);
299 if (!read_color(db, inst,
300 "window.inactive.button.unpressed.image.color",
301 &theme->titlebut_unfocused_unpressed_color))
302 theme->titlebut_unfocused_unpressed_color =
303 RrColorNew(inst, 0xff, 0xff, 0xff);
304 if (!read_color(db, inst,
305 "window.active.button.pressed.image.color",
306 &theme->titlebut_focused_pressed_color))
307 theme->titlebut_focused_pressed_color =
308 RrColorNew(inst,
309 theme->titlebut_focused_unpressed_color->r,
310 theme->titlebut_focused_unpressed_color->g,
311 theme->titlebut_focused_unpressed_color->b);
312 if (!read_color(db, inst,
313 "window.inactive.button.pressed.image.color",
314 &theme->titlebut_unfocused_pressed_color))
315 theme->titlebut_unfocused_pressed_color =
316 RrColorNew(inst,
317 theme->titlebut_unfocused_unpressed_color->r,
318 theme->titlebut_unfocused_unpressed_color->g,
319 theme->titlebut_unfocused_unpressed_color->b);
320 if (!read_color(db, inst,
321 "window.active.button.disabled.image.color",
322 &theme->titlebut_disabled_focused_color))
323 theme->titlebut_disabled_focused_color =
324 RrColorNew(inst, 0xff, 0xff, 0xff);
325 if (!read_color(db, inst,
326 "window.inactive.button.disabled.image.color",
327 &theme->titlebut_disabled_unfocused_color))
328 theme->titlebut_disabled_unfocused_color = RrColorNew(inst, 0, 0, 0);
329 if (!read_color(db, inst,
330 "window.active.button.hover.image.color",
331 &theme->titlebut_hover_focused_color))
332 theme->titlebut_hover_focused_color =
333 RrColorNew(inst,
334 theme->titlebut_focused_unpressed_color->r,
335 theme->titlebut_focused_unpressed_color->g,
336 theme->titlebut_focused_unpressed_color->b);
337 if (!read_color(db, inst,
338 "window.inactive.button.hover.image.color",
339 &theme->titlebut_hover_unfocused_color))
340 theme->titlebut_hover_unfocused_color =
341 RrColorNew(inst,
342 theme->titlebut_unfocused_unpressed_color->r,
343 theme->titlebut_unfocused_unpressed_color->g,
344 theme->titlebut_unfocused_unpressed_color->b);
345 if (!read_color(db, inst,
346 "window.active.button.toggled.unpressed.image.color",
347 &theme->titlebut_toggled_focused_unpressed_color) &&
348 !read_color(db, inst,
349 "window.active.button.toggled.image.color",
350 &theme->titlebut_toggled_focused_unpressed_color))
351 theme->titlebut_toggled_focused_unpressed_color =
352 RrColorNew(inst,
353 theme->titlebut_focused_pressed_color->r,
354 theme->titlebut_focused_pressed_color->g,
355 theme->titlebut_focused_pressed_color->b);
356 if (!read_color(db, inst,
357 "window.inactive.button.toggled.unpressed.image.color",
358 &theme->titlebut_toggled_unfocused_unpressed_color) &&
359 !read_color(db, inst,
360 "window.inactive.button.toggled.image.color",
361 &theme->titlebut_toggled_unfocused_unpressed_color))
362 theme->titlebut_toggled_unfocused_unpressed_color =
363 RrColorNew(inst,
364 theme->titlebut_unfocused_pressed_color->r,
365 theme->titlebut_unfocused_pressed_color->g,
366 theme->titlebut_unfocused_pressed_color->b);
367 if (!read_color(db, inst,
368 "window.active.button.toggled.hover.image.color",
369 &theme->titlebut_toggled_hover_focused_color))
370 theme->titlebut_toggled_hover_focused_color =
371 RrColorNew(inst,
372 theme->titlebut_toggled_focused_unpressed_color->r,
373 theme->titlebut_toggled_focused_unpressed_color->g,
374 theme->titlebut_toggled_focused_unpressed_color->b);
375 if (!read_color(db, inst,
376 "window.inactive.button.toggled.hover.image.color",
377 &theme->titlebut_toggled_hover_unfocused_color))
378 theme->titlebut_toggled_hover_unfocused_color =
379 RrColorNew(inst,
380 theme->titlebut_toggled_unfocused_unpressed_color->r,
381 theme->titlebut_toggled_unfocused_unpressed_color->g,
382 theme->titlebut_toggled_unfocused_unpressed_color->b);
383 if (!read_color(db, inst,
384 "window.active.button.toggled.pressed.image.color",
385 &theme->titlebut_toggled_focused_pressed_color))
386 theme->titlebut_toggled_focused_pressed_color =
387 RrColorNew(inst,
388 theme->titlebut_focused_pressed_color->r,
389 theme->titlebut_focused_pressed_color->g,
390 theme->titlebut_focused_pressed_color->b);
391 if (!read_color(db, inst,
392 "window.inactive.button.toggled.pressed.image.color",
393 &theme->titlebut_toggled_unfocused_pressed_color))
394 theme->titlebut_toggled_unfocused_pressed_color =
395 RrColorNew(inst,
396 theme->titlebut_unfocused_pressed_color->r,
397 theme->titlebut_unfocused_pressed_color->g,
398 theme->titlebut_unfocused_pressed_color->b);
399 if (!read_color(db, inst,
400 "menu.title.text.color", &theme->menu_title_color))
401 theme->menu_title_color = RrColorNew(inst, 0, 0, 0);
402 if (!read_color(db, inst,
403 "menu.items.text.color", &theme->menu_color))
404 theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
405 if (!read_color(db, inst,
406 "menu.items.disabled.text.color",
407 &theme->menu_disabled_color))
408 theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
409 if (!read_color(db, inst,
410 "menu.items.active.disabled.text.color",
411 &theme->menu_disabled_selected_color))
412 theme->menu_disabled_selected_color =
413 RrColorNew(inst,
414 theme->menu_disabled_color->r,
415 theme->menu_disabled_color->g,
416 theme->menu_disabled_color->b);
417 if (!read_color(db, inst,
418 "menu.items.active.text.color",
419 &theme->menu_selected_color))
420 theme->menu_selected_color = RrColorNew(inst, 0, 0, 0);
421 if (!read_color(db, inst,
422 "menu.separator.color", &theme->menu_sep_color))
423 theme->menu_sep_color = RrColorNew(inst,
424 theme->menu_color->r,
425 theme->menu_color->g,
426 theme->menu_color->b);
427
428 /* load the image masks */
429
430 /* maximize button masks */
431 userdef = TRUE;
432 if (!read_mask(inst, path, theme, "max.xbm", &theme->max_mask)) {
433 guchar data[] = { 0x3f, 0x3f, 0x21, 0x21, 0x21, 0x3f };
434 theme->max_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
435 userdef = FALSE;
436 }
437 if (!read_mask(inst, path, theme, "max_toggled.xbm",
438 &theme->max_toggled_mask))
439 {
440 if (userdef)
441 theme->max_toggled_mask = RrPixmapMaskCopy(theme->max_mask);
442 else {
443 guchar data[] = { 0x3e, 0x22, 0x2f, 0x29, 0x39, 0x0f };
444 theme->max_toggled_mask = RrPixmapMaskNew(inst, 6, 6,(gchar*)data);
445 }
446 }
447 if (!read_mask(inst, path, theme, "max_pressed.xbm",
448 &theme->max_pressed_mask))
449 theme->max_pressed_mask = RrPixmapMaskCopy(theme->max_mask);
450 if (!read_mask(inst,path,theme,"max_disabled.xbm",
451 &theme->max_disabled_mask))
452 theme->max_disabled_mask = RrPixmapMaskCopy(theme->max_mask);
453 if (!read_mask(inst, path, theme, "max_hover.xbm", &theme->max_hover_mask))
454 theme->max_hover_mask = RrPixmapMaskCopy(theme->max_mask);
455 if (!read_mask(inst, path, theme, "max_toggled_pressed.xbm",
456 &theme->max_toggled_pressed_mask))
457 theme->max_toggled_pressed_mask =
458 RrPixmapMaskCopy(theme->max_toggled_mask);
459 if (!read_mask(inst, path, theme, "max_toggled_hover.xbm",
460 &theme->max_toggled_hover_mask))
461 theme->max_toggled_hover_mask =
462 RrPixmapMaskCopy(theme->max_toggled_mask);
463
464 /* iconify button masks */
465 if (!read_mask(inst, path, theme, "iconify.xbm", &theme->iconify_mask)) {
466 guchar data[] = { 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f };
467 theme->iconify_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
468 }
469 if (!read_mask(inst, path, theme, "iconify_pressed.xbm",
470 &theme->iconify_pressed_mask))
471 theme->iconify_pressed_mask = RrPixmapMaskCopy(theme->iconify_mask);
472 if (!read_mask(inst, path, theme, "iconify_disabled.xbm",
473 &theme->iconify_disabled_mask))
474 theme->iconify_disabled_mask = RrPixmapMaskCopy(theme->iconify_mask);
475 if (!read_mask(inst, path, theme, "iconify_hover.xbm",
476 &theme->iconify_hover_mask))
477 theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
478
479 /* all desktops button masks */
480 userdef = TRUE;
481 if (!read_mask(inst, path, theme, "desk.xbm", &theme->desk_mask)) {
482 guchar data[] = { 0x33, 0x33, 0x00, 0x00, 0x33, 0x33 };
483 theme->desk_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
484 userdef = FALSE;
485 }
486 if (!read_mask(inst, path, theme, "desk_toggled.xbm",
487 &theme->desk_toggled_mask)) {
488 if (userdef)
489 theme->desk_toggled_mask = RrPixmapMaskCopy(theme->desk_mask);
490 else {
491 guchar data[] = { 0x00, 0x1e, 0x1a, 0x16, 0x1e, 0x00 };
492 theme->desk_toggled_mask =
493 RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
494 }
495 }
496 if (!read_mask(inst, path, theme, "desk_pressed.xbm",
497 &theme->desk_pressed_mask))
498 theme->desk_pressed_mask = RrPixmapMaskCopy(theme->desk_mask);
499 if (!read_mask(inst, path, theme, "desk_disabled.xbm",
500 &theme->desk_disabled_mask))
501 theme->desk_disabled_mask = RrPixmapMaskCopy(theme->desk_mask);
502 if (!read_mask(inst, path, theme, "desk_hover.xbm",
503 &theme->desk_hover_mask))
504 theme->desk_hover_mask = RrPixmapMaskCopy(theme->desk_mask);
505 if (!read_mask(inst, path, theme, "desk_toggled_pressed.xbm",
506 &theme->desk_toggled_pressed_mask))
507 theme->desk_toggled_pressed_mask =
508 RrPixmapMaskCopy(theme->desk_toggled_mask);
509 if (!read_mask(inst, path, theme, "desk_toggled_hover.xbm",
510 &theme->desk_toggled_hover_mask))
511 theme->desk_toggled_hover_mask =
512 RrPixmapMaskCopy(theme->desk_toggled_mask);
513
514 /* shade button masks */
515 if (!read_mask(inst, path, theme, "shade.xbm", &theme->shade_mask)) {
516 guchar data[] = { 0x3f, 0x3f, 0x00, 0x00, 0x00, 0x00 };
517 theme->shade_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
518 }
519 if (!read_mask(inst, path, theme, "shade_toggled.xbm",
520 &theme->shade_toggled_mask))
521 theme->shade_toggled_mask = RrPixmapMaskCopy(theme->shade_mask);
522 if (!read_mask(inst, path, theme, "shade_pressed.xbm",
523 &theme->shade_pressed_mask))
524 theme->shade_pressed_mask = RrPixmapMaskCopy(theme->shade_mask);
525 if (!read_mask(inst, path, theme, "shade_disabled.xbm",
526 &theme->shade_disabled_mask))
527 theme->shade_disabled_mask = RrPixmapMaskCopy(theme->shade_mask);
528 if (!read_mask(inst, path, theme, "shade_hover.xbm",
529 &theme->shade_hover_mask))
530 theme->shade_hover_mask = RrPixmapMaskCopy(theme->shade_mask);
531 if (!read_mask(inst, path, theme, "shade_toggled_pressed.xbm",
532 &theme->shade_toggled_pressed_mask))
533 theme->shade_toggled_pressed_mask =
534 RrPixmapMaskCopy(theme->shade_toggled_mask);
535 if (!read_mask(inst, path, theme, "shade_toggled_hover.xbm",
536 &theme->shade_toggled_hover_mask))
537 theme->shade_toggled_hover_mask =
538 RrPixmapMaskCopy(theme->shade_toggled_mask);
539
540 /* close button masks */
541 if (!read_mask(inst, path, theme, "close.xbm", &theme->close_mask)) {
542 guchar data[] = { 0x33, 0x3f, 0x1e, 0x1e, 0x3f, 0x33 };
543 theme->close_mask = RrPixmapMaskNew(inst, 6, 6, (gchar*)data);
544 }
545 if (!read_mask(inst, path, theme, "close_pressed.xbm",
546 &theme->close_pressed_mask))
547 theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
548 if (!read_mask(inst, path, theme, "close_disabled.xbm",
549 &theme->close_disabled_mask))
550 theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
551 if (!read_mask(inst, path, theme, "close_hover.xbm",
552 &theme->close_hover_mask))
553 theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
554
555 /* submenu bullet mask */
556 if (!read_mask(inst, path, theme, "bullet.xbm", &theme->menu_bullet_mask))
557 {
558 guchar data[] = { 0x01, 0x03, 0x07, 0x0f, 0x07, 0x03, 0x01 };
559 theme->menu_bullet_mask = RrPixmapMaskNew(inst, 4, 7, (gchar*)data);
560 }
561
562 /* up and down arrows */
563 {
564 guchar data[] = { 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, 0x10, 0x00 };
565 theme->down_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
566 }
567 {
568 guchar data[] = { 0x10, 0x00, 0x38, 0x00, 0x7c, 0x00, 0xfe, 0x00 };
569 theme->up_arrow_mask = RrPixmapMaskNew(inst, 9, 4, (gchar*)data);
570 }
571
572 /* setup the default window icon */
573 theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
574 OB_DEFAULT_ICON_HEIGHT,
575 OB_DEFAULT_ICON_pixel_data);
576 theme->def_win_icon_w = OB_DEFAULT_ICON_WIDTH;
577 theme->def_win_icon_h = OB_DEFAULT_ICON_HEIGHT;
578
579 /* read the decoration textures */
580 if (!read_appearance(db, inst,
581 "window.active.title.bg", theme->a_focused_title,
582 FALSE))
583 set_default_appearance(theme->a_focused_title);
584 if (!read_appearance(db, inst,
585 "window.inactive.title.bg", theme->a_unfocused_title,
586 FALSE))
587 set_default_appearance(theme->a_unfocused_title);
588 if (!read_appearance(db, inst,
589 "window.active.label.bg", theme->a_focused_label,
590 TRUE))
591 set_default_appearance(theme->a_focused_label);
592 if (!read_appearance(db, inst,
593 "window.inactive.label.bg", theme->a_unfocused_label,
594 TRUE))
595 set_default_appearance(theme->a_unfocused_label);
596 if (!read_appearance(db, inst,
597 "window.active.handle.bg", theme->a_focused_handle,
598 FALSE))
599 set_default_appearance(theme->a_focused_handle);
600 if (!read_appearance(db, inst,
601 "window.inactive.handle.bg",theme->a_unfocused_handle,
602 FALSE))
603 set_default_appearance(theme->a_unfocused_handle);
604 if (!read_appearance(db, inst,
605 "window.active.grip.bg", theme->a_focused_grip,
606 TRUE))
607 set_default_appearance(theme->a_focused_grip);
608 if (!read_appearance(db, inst,
609 "window.inactive.grip.bg", theme->a_unfocused_grip,
610 TRUE))
611 set_default_appearance(theme->a_unfocused_grip);
612 if (!read_appearance(db, inst,
613 "menu.items.bg", theme->a_menu,
614 FALSE))
615 set_default_appearance(theme->a_menu);
616 if (!read_appearance(db, inst,
617 "menu.title.bg", theme->a_menu_title,
618 TRUE))
619 set_default_appearance(theme->a_menu_title);
620 if (!read_appearance(db, inst,
621 "menu.items.active.bg", theme->a_menu_selected,
622 TRUE))
623 set_default_appearance(theme->a_menu_selected);
624 theme->a_menu_disabled_selected =
625 RrAppearanceCopy(theme->a_menu_selected);
626
627 /* read appearances for non-decorations (on-screen-display) */
628 if (!read_appearance(db, inst, "osd.bg", theme->osd_hilite_bg, FALSE)) {
629 RrAppearanceFree(theme->osd_hilite_bg);
630 theme->osd_hilite_bg = RrAppearanceCopy(theme->a_focused_title);
631 }
632 if (!read_appearance(db, inst, "osd.label.bg",
633 theme->osd_hilite_label, TRUE)) {
634 RrAppearanceFree(theme->osd_hilite_label);
635 theme->osd_hilite_label = RrAppearanceCopy(theme->a_focused_label);
636 }
637 /* osd_hilite_fg can't be parentrel */
638 if (!read_appearance(db, inst, "osd.hilight.bg",
639 theme->osd_hilite_fg, FALSE)) {
640 RrAppearanceFree(theme->osd_hilite_fg);
641 if (theme->a_focused_label->surface.grad != RR_SURFACE_PARENTREL)
642 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_label);
643 else
644 theme->osd_hilite_fg = RrAppearanceCopy(theme->a_focused_title);
645 }
646 /* osd_unhilite_fg can't be parentrel either */
647 if (!read_appearance(db, inst, "osd.unhilight.bg",
648 theme->osd_unhilite_fg, FALSE)) {
649 RrAppearanceFree(theme->osd_unhilite_fg);
650 if (theme->a_unfocused_label->surface.grad != RR_SURFACE_PARENTREL)
651 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_label);
652 else
653 theme->osd_unhilite_fg=RrAppearanceCopy(theme->a_unfocused_title);
654 }
655
656 /* read buttons textures */
657 if (!read_appearance(db, inst,
658 "window.active.button.disabled.bg",
659 theme->a_disabled_focused_max,
660 TRUE))
661 set_default_appearance(theme->a_disabled_focused_max);
662 if (!read_appearance(db, inst,
663 "window.inactive.button.disabled.bg",
664 theme->a_disabled_unfocused_max,
665 TRUE))
666 set_default_appearance(theme->a_disabled_unfocused_max);
667 if (!read_appearance(db, inst,
668 "window.active.button.pressed.bg",
669 theme->a_focused_pressed_max,
670 TRUE))
671 set_default_appearance(theme->a_focused_pressed_max);
672 if (!read_appearance(db, inst,
673 "window.inactive.button.pressed.bg",
674 theme->a_unfocused_pressed_max,
675 TRUE))
676 set_default_appearance(theme->a_unfocused_pressed_max);
677 if (!read_appearance(db, inst,
678 "window.active.button.toggled.unpressed.bg",
679 theme->a_toggled_focused_unpressed_max,
680 TRUE) &&
681 !read_appearance(db, inst,
682 "window.active.button.toggled.bg",
683 theme->a_toggled_focused_unpressed_max,
684 TRUE))
685 {
686 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
687 theme->a_toggled_focused_unpressed_max =
688 RrAppearanceCopy(theme->a_focused_pressed_max);
689 }
690 if (!read_appearance(db, inst,
691 "window.inactive.button.toggled.unpressed.bg",
692 theme->a_toggled_unfocused_unpressed_max,
693 TRUE) &&
694 !read_appearance(db, inst,
695 "window.inactive.button.toggled.bg",
696 theme->a_toggled_unfocused_unpressed_max,
697 TRUE))
698 {
699 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
700 theme->a_toggled_unfocused_unpressed_max =
701 RrAppearanceCopy(theme->a_unfocused_pressed_max);
702 }
703 if (!read_appearance(db, inst,
704 "window.active.button.toggled.hover.bg",
705 theme->a_toggled_hover_focused_max,
706 TRUE))
707 {
708 RrAppearanceFree(theme->a_toggled_hover_focused_max);
709 theme->a_toggled_hover_focused_max =
710 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
711 }
712 if (!read_appearance(db, inst,
713 "window.inactive.button.toggled.hover.bg",
714 theme->a_toggled_hover_unfocused_max,
715 TRUE))
716 {
717 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
718 theme->a_toggled_hover_unfocused_max =
719 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
720 }
721 if (!read_appearance(db, inst,
722 "window.active.button.toggled.pressed.bg",
723 theme->a_toggled_focused_pressed_max,
724 TRUE))
725 {
726 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
727 theme->a_toggled_focused_pressed_max =
728 RrAppearanceCopy(theme->a_focused_pressed_max);
729 }
730 if (!read_appearance(db, inst,
731 "window.inactive.button.toggled.pressed.bg",
732 theme->a_toggled_unfocused_pressed_max,
733 TRUE))
734 {
735 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
736 theme->a_toggled_unfocused_pressed_max =
737 RrAppearanceCopy(theme->a_unfocused_pressed_max);
738 }
739 if (!read_appearance(db, inst,
740 "window.active.button.unpressed.bg",
741 theme->a_focused_unpressed_max,
742 TRUE))
743 set_default_appearance(theme->a_focused_unpressed_max);
744 if (!read_appearance(db, inst,
745 "window.inactive.button.unpressed.bg",
746 theme->a_unfocused_unpressed_max,
747 TRUE))
748 set_default_appearance(theme->a_unfocused_unpressed_max);
749 if (!read_appearance(db, inst,
750 "window.active.button.hover.bg",
751 theme->a_hover_focused_max,
752 TRUE))
753 {
754 RrAppearanceFree(theme->a_hover_focused_max);
755 theme->a_hover_focused_max =
756 RrAppearanceCopy(theme->a_focused_unpressed_max);
757 }
758 if (!read_appearance(db, inst,
759 "window.inactive.button.hover.bg",
760 theme->a_hover_unfocused_max,
761 TRUE))
762 {
763 RrAppearanceFree(theme->a_hover_unfocused_max);
764 theme->a_hover_unfocused_max =
765 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
766 }
767
768 theme->a_disabled_focused_close =
769 RrAppearanceCopy(theme->a_disabled_focused_max);
770 theme->a_disabled_unfocused_close =
771 RrAppearanceCopy(theme->a_disabled_unfocused_max);
772 theme->a_hover_focused_close =
773 RrAppearanceCopy(theme->a_hover_focused_max);
774 theme->a_hover_unfocused_close =
775 RrAppearanceCopy(theme->a_hover_unfocused_max);
776 theme->a_unfocused_unpressed_close =
777 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
778 theme->a_unfocused_pressed_close =
779 RrAppearanceCopy(theme->a_unfocused_pressed_max);
780 theme->a_focused_unpressed_close =
781 RrAppearanceCopy(theme->a_focused_unpressed_max);
782 theme->a_focused_pressed_close =
783 RrAppearanceCopy(theme->a_focused_pressed_max);
784 theme->a_disabled_focused_desk =
785 RrAppearanceCopy(theme->a_disabled_focused_max);
786 theme->a_disabled_unfocused_desk =
787 RrAppearanceCopy(theme->a_disabled_unfocused_max);
788 theme->a_hover_focused_desk =
789 RrAppearanceCopy(theme->a_hover_focused_max);
790 theme->a_hover_unfocused_desk =
791 RrAppearanceCopy(theme->a_hover_unfocused_max);
792 theme->a_toggled_hover_focused_desk =
793 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
794 theme->a_toggled_hover_unfocused_desk =
795 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
796 theme->a_toggled_focused_unpressed_desk =
797 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
798 theme->a_toggled_unfocused_unpressed_desk =
799 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
800 theme->a_toggled_focused_pressed_desk =
801 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
802 theme->a_toggled_unfocused_pressed_desk =
803 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
804 theme->a_unfocused_unpressed_desk =
805 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
806 theme->a_unfocused_pressed_desk =
807 RrAppearanceCopy(theme->a_unfocused_pressed_max);
808 theme->a_focused_unpressed_desk =
809 RrAppearanceCopy(theme->a_focused_unpressed_max);
810 theme->a_focused_pressed_desk =
811 RrAppearanceCopy(theme->a_focused_pressed_max);
812 theme->a_disabled_focused_shade =
813 RrAppearanceCopy(theme->a_disabled_focused_max);
814 theme->a_disabled_unfocused_shade =
815 RrAppearanceCopy(theme->a_disabled_unfocused_max);
816 theme->a_hover_focused_shade =
817 RrAppearanceCopy(theme->a_hover_focused_max);
818 theme->a_hover_unfocused_shade =
819 RrAppearanceCopy(theme->a_hover_unfocused_max);
820 theme->a_toggled_hover_focused_shade =
821 RrAppearanceCopy(theme->a_toggled_hover_focused_max);
822 theme->a_toggled_hover_unfocused_shade =
823 RrAppearanceCopy(theme->a_toggled_hover_unfocused_max);
824 theme->a_toggled_focused_unpressed_shade =
825 RrAppearanceCopy(theme->a_toggled_focused_unpressed_max);
826 theme->a_toggled_unfocused_unpressed_shade =
827 RrAppearanceCopy(theme->a_toggled_unfocused_unpressed_max);
828 theme->a_toggled_focused_pressed_shade =
829 RrAppearanceCopy(theme->a_toggled_focused_pressed_max);
830 theme->a_toggled_unfocused_pressed_shade =
831 RrAppearanceCopy(theme->a_toggled_unfocused_pressed_max);
832 theme->a_unfocused_unpressed_shade =
833 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
834 theme->a_unfocused_pressed_shade =
835 RrAppearanceCopy(theme->a_unfocused_pressed_max);
836 theme->a_focused_unpressed_shade =
837 RrAppearanceCopy(theme->a_focused_unpressed_max);
838 theme->a_focused_pressed_shade =
839 RrAppearanceCopy(theme->a_focused_pressed_max);
840 theme->a_disabled_focused_iconify =
841 RrAppearanceCopy(theme->a_disabled_focused_max);
842 theme->a_disabled_unfocused_iconify =
843 RrAppearanceCopy(theme->a_disabled_focused_max);
844 theme->a_hover_focused_iconify =
845 RrAppearanceCopy(theme->a_hover_focused_max);
846 theme->a_hover_unfocused_iconify =
847 RrAppearanceCopy(theme->a_hover_unfocused_max);
848 theme->a_unfocused_unpressed_iconify =
849 RrAppearanceCopy(theme->a_unfocused_unpressed_max);
850 theme->a_unfocused_pressed_iconify =
851 RrAppearanceCopy(theme->a_unfocused_pressed_max);
852 theme->a_focused_unpressed_iconify =
853 RrAppearanceCopy(theme->a_focused_unpressed_max);
854 theme->a_focused_pressed_iconify =
855 RrAppearanceCopy(theme->a_focused_pressed_max);
856
857 theme->a_icon->surface.grad =
858 theme->a_clear->surface.grad =
859 theme->a_clear_tex->surface.grad =
860 theme->a_menu_text_title->surface.grad =
861 theme->a_menu_normal->surface.grad =
862 theme->a_menu_disabled->surface.grad =
863 theme->a_menu_text_normal->surface.grad =
864 theme->a_menu_text_selected->surface.grad =
865 theme->a_menu_text_disabled->surface.grad =
866 theme->a_menu_text_disabled_selected->surface.grad =
867 theme->a_menu_bullet_normal->surface.grad =
868 theme->a_menu_bullet_selected->surface.grad = RR_SURFACE_PARENTREL;
869
870 /* set up the textures */
871 theme->a_focused_label->texture[0].type = RR_TEXTURE_TEXT;
872 theme->a_focused_label->texture[0].data.text.justify = winjust;
873 theme->a_focused_label->texture[0].data.text.font=theme->win_font_focused;
874 theme->a_focused_label->texture[0].data.text.color =
875 theme->title_focused_color;
876
877 if (read_string(db, "window.active.label.text.font", &str)) {
878 char *p;
879 gint i = 0;
880 gint j;
881 if (strstr(str, "shadow=y")) {
882 if ((p = strstr(str, "shadowoffset=")))
883 i = parse_inline_number(p + strlen("shadowoffset="));
884 else
885 i = 1;
886 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
887 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
888 }
889 if ((p = strstr(str, "shadowtint=")))
890 {
891 i = parse_inline_number(p + strlen("shadowtint="));
892 j = (i > 0 ? 0 : 255);
893 i = ABS(i*255/100);
894
895 theme->title_focused_shadow_color = RrColorNew(inst, j, j, j);
896 theme->title_focused_shadow_alpha = i;
897 } else {
898 theme->title_focused_shadow_color = RrColorNew(inst, 0, 0, 0);
899 theme->title_focused_shadow_alpha = 50;
900 }
901 }
902
903 theme->a_focused_label->texture[0].data.text.shadow_color =
904 theme->title_focused_shadow_color;
905 theme->a_focused_label->texture[0].data.text.shadow_alpha =
906 theme->title_focused_shadow_alpha;
907
908 theme->osd_hilite_label->texture[0].type = RR_TEXTURE_TEXT;
909 theme->osd_hilite_label->texture[0].data.text.justify = RR_JUSTIFY_LEFT;
910 theme->osd_hilite_label->texture[0].data.text.font = theme->osd_font;
911 theme->osd_hilite_label->texture[0].data.text.color = theme->osd_color;
912
913 if (read_string(db, "osd.label.text.font", &str)) {
914 char *p;
915 gint i = 0;
916 gint j;
917 if (strstr(str, "shadow=y")) {
918 if ((p = strstr(str, "shadowoffset=")))
919 i = parse_inline_number(p + strlen("shadowoffset="));
920 else
921 i = 1;
922 theme->a_focused_label->texture[0].data.text.shadow_offset_x = i;
923 theme->a_focused_label->texture[0].data.text.shadow_offset_y = i;
924 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x = i;
925 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y = i;
926 }
927 if ((p = strstr(str, "shadowtint=")))
928 {
929 i = parse_inline_number(p + strlen("shadowtint="));
930 j = (i > 0 ? 0 : 255);
931 i = ABS(i*255/100);
932
933 theme->osd_shadow_color = RrColorNew(inst, j, j, j);
934 theme->osd_shadow_alpha = i;
935 } else {
936 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
937 theme->osd_shadow_alpha = 50;
938 }
939 } else {
940 /* inherit the font settings from the focused label */
941 theme->osd_hilite_label->texture[0].data.text.shadow_offset_x =
942 theme->a_focused_label->texture[0].data.text.shadow_offset_x;
943 theme->osd_hilite_label->texture[0].data.text.shadow_offset_y =
944 theme->a_focused_label->texture[0].data.text.shadow_offset_y;
945 if (theme->title_focused_shadow_color)
946 theme->osd_shadow_color =
947 RrColorNew(inst,
948 theme->title_focused_shadow_color->r,
949 theme->title_focused_shadow_color->g,
950 theme->title_focused_shadow_color->b);
951 else
952 theme->osd_shadow_color = RrColorNew(inst, 0, 0, 0);
953 theme->osd_shadow_alpha = theme->title_focused_shadow_alpha;
954 }
955
956 theme->osd_hilite_label->texture[0].data.text.shadow_color =
957 theme->osd_shadow_color;
958 theme->osd_hilite_label->texture[0].data.text.shadow_alpha =
959 theme->osd_shadow_alpha;
960
961 theme->a_unfocused_label->texture[0].type = RR_TEXTURE_TEXT;
962 theme->a_unfocused_label->texture[0].data.text.justify = winjust;
963 theme->a_unfocused_label->texture[0].data.text.font =
964 theme->win_font_unfocused;
965 theme->a_unfocused_label->texture[0].data.text.color =
966 theme->title_unfocused_color;
967
968 if (read_string(db, "window.inactive.label.text.font", &str)) {
969 char *p;
970 gint i = 0;
971 gint j;
972 if (strstr(str, "shadow=y")) {
973 if ((p = strstr(str, "shadowoffset=")))
974 i = parse_inline_number(p + strlen("shadowoffset="));
975 else
976 i = 1;
977 theme->a_unfocused_label->texture[0].data.text.shadow_offset_x = i;
978 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y = i;
979 }
980 if ((p = strstr(str, "shadowtint=")))
981 {
982 i = parse_inline_number(p + strlen("shadowtint="));
983 j = (i > 0 ? 0 : 255);
984 i = ABS(i*255/100);
985
986 theme->title_unfocused_shadow_color = RrColorNew(inst, j, j, j);
987 theme->title_unfocused_shadow_alpha = i;
988 } else {
989 theme->title_unfocused_shadow_color = RrColorNew(inst, 0, 0, 0);
990 theme->title_unfocused_shadow_alpha = 50;
991 }
992 }
993
994 theme->a_unfocused_label->texture[0].data.text.shadow_color =
995 theme->title_unfocused_shadow_color;
996 theme->a_unfocused_label->texture[0].data.text.shadow_alpha =
997 theme->title_unfocused_shadow_alpha;
998
999 theme->a_menu_text_title->texture[0].type = RR_TEXTURE_TEXT;
1000 theme->a_menu_text_title->texture[0].data.text.justify = mtitlejust;
1001 theme->a_menu_text_title->texture[0].data.text.font =
1002 theme->menu_title_font;
1003 theme->a_menu_text_title->texture[0].data.text.color =
1004 theme->menu_title_color;
1005
1006 if (read_string(db, "menu.title.text.font", &str)) {
1007 char *p;
1008 gint i = 0;
1009 gint j;
1010 if (strstr(str, "shadow=y")) {
1011 if ((p = strstr(str, "shadowoffset=")))
1012 i = parse_inline_number(p + strlen("shadowoffset="));
1013 else
1014 i = 1;
1015 theme->a_menu_text_title->texture[0].data.text.shadow_offset_x = i;
1016 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y = i;
1017 }
1018 if ((p = strstr(str, "shadowtint=")))
1019 {
1020 i = parse_inline_number(p + strlen("shadowtint="));
1021 j = (i > 0 ? 0 : 255);
1022 i = ABS(i*255/100);
1023
1024 theme->menu_title_shadow_color = RrColorNew(inst, j, j, j);
1025 theme->menu_title_shadow_alpha = i;
1026 } else {
1027 theme->menu_title_shadow_color = RrColorNew(inst, 0, 0, 0);
1028 theme->menu_title_shadow_alpha = 50;
1029 }
1030 }
1031
1032 theme->a_menu_text_title->texture[0].data.text.shadow_color =
1033 theme->menu_title_shadow_color;
1034 theme->a_menu_text_title->texture[0].data.text.shadow_alpha =
1035 theme->menu_title_shadow_alpha;
1036
1037 theme->a_menu_text_normal->texture[0].type =
1038 theme->a_menu_text_selected->texture[0].type =
1039 theme->a_menu_text_disabled->texture[0].type =
1040 theme->a_menu_text_disabled_selected->texture[0].type =
1041 RR_TEXTURE_TEXT;
1042 theme->a_menu_text_normal->texture[0].data.text.justify =
1043 theme->a_menu_text_selected->texture[0].data.text.justify =
1044 theme->a_menu_text_disabled->texture[0].data.text.justify =
1045 theme->a_menu_text_disabled_selected->texture[0].data.text.justify =
1046 RR_JUSTIFY_LEFT;
1047 theme->a_menu_text_normal->texture[0].data.text.font =
1048 theme->a_menu_text_selected->texture[0].data.text.font =
1049 theme->a_menu_text_disabled->texture[0].data.text.font =
1050 theme->a_menu_text_disabled_selected->texture[0].data.text.font =
1051 theme->menu_font;
1052 theme->a_menu_text_normal->texture[0].data.text.color = theme->menu_color;
1053 theme->a_menu_text_selected->texture[0].data.text.color =
1054 theme->menu_selected_color;
1055 theme->a_menu_text_disabled->texture[0].data.text.color =
1056 theme->menu_disabled_color;
1057 theme->a_menu_text_disabled_selected->texture[0].data.text.color =
1058 theme->menu_disabled_selected_color;
1059
1060 if (read_string(db, "menu.items.font", &str)) {
1061 char *p;
1062 gint i = 0;
1063 gint j;
1064 if (strstr(str, "shadow=y")) {
1065 if ((p = strstr(str, "shadowoffset=")))
1066 i = parse_inline_number(p + strlen("shadowoffset="));
1067 else
1068 i = 1;
1069 theme->a_menu_text_normal->
1070 texture[0].data.text.shadow_offset_x = i;
1071 theme->a_menu_text_normal->
1072 texture[0].data.text.shadow_offset_y = i;
1073 theme->a_menu_text_selected->
1074 texture[0].data.text.shadow_offset_x = i;
1075 theme->a_menu_text_selected->
1076 texture[0].data.text.shadow_offset_y = i;
1077 theme->a_menu_text_disabled->
1078 texture[0].data.text.shadow_offset_x = i;
1079 theme->a_menu_text_disabled->
1080 texture[0].data.text.shadow_offset_y = i;
1081 theme->a_menu_text_disabled_selected->
1082 texture[0].data.text.shadow_offset_x = i;
1083 theme->a_menu_text_disabled_selected->
1084 texture[0].data.text.shadow_offset_y = i;
1085 }
1086 if ((p = strstr(str, "shadowtint=")))
1087 {
1088 i = parse_inline_number(p + strlen("shadowtint="));
1089 j = (i > 0 ? 0 : 255);
1090 i = ABS(i*255/100);
1091
1092 theme->menu_text_normal_shadow_color = RrColorNew(inst, j, j, j);
1093 theme->menu_text_selected_shadow_color = RrColorNew(inst, j, j, j);
1094 theme->menu_text_disabled_shadow_color = RrColorNew(inst, j, j, j);
1095 theme->menu_text_normal_shadow_alpha = i;
1096 theme->menu_text_selected_shadow_alpha = i;
1097 theme->menu_text_disabled_shadow_alpha = i;
1098 theme->menu_text_disabled_selected_shadow_alpha = i;
1099 } else {
1100 theme->menu_text_normal_shadow_color = RrColorNew(inst, 0, 0, 0);
1101 theme->menu_text_selected_shadow_color = RrColorNew(inst, 0, 0, 0);
1102 theme->menu_text_disabled_shadow_color = RrColorNew(inst, 0, 0, 0);
1103 theme->menu_text_normal_shadow_alpha = 50;
1104 theme->menu_text_selected_shadow_alpha = 50;
1105 theme->menu_text_disabled_selected_shadow_alpha = 50;
1106 }
1107 }
1108
1109 theme->a_menu_text_normal->texture[0].data.text.shadow_color =
1110 theme->menu_text_normal_shadow_color;
1111 theme->a_menu_text_normal->texture[0].data.text.shadow_alpha =
1112 theme->menu_text_normal_shadow_alpha;
1113 theme->a_menu_text_selected->texture[0].data.text.shadow_color =
1114 theme->menu_text_selected_shadow_color;
1115 theme->a_menu_text_selected->texture[0].data.text.shadow_alpha =
1116 theme->menu_text_selected_shadow_alpha;
1117 theme->a_menu_text_disabled->texture[0].data.text.shadow_color =
1118 theme->menu_text_disabled_shadow_color;
1119 theme->a_menu_text_disabled->texture[0].data.text.shadow_alpha =
1120 theme->menu_text_disabled_shadow_alpha;
1121 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_color =
1122 theme->menu_text_disabled_shadow_color;
1123 theme->a_menu_text_disabled_selected->texture[0].data.text.shadow_alpha =
1124 theme->menu_text_disabled_shadow_alpha;
1125
1126 theme->a_disabled_focused_max->texture[0].type =
1127 theme->a_disabled_unfocused_max->texture[0].type =
1128 theme->a_hover_focused_max->texture[0].type =
1129 theme->a_hover_unfocused_max->texture[0].type =
1130 theme->a_toggled_hover_focused_max->texture[0].type =
1131 theme->a_toggled_hover_unfocused_max->texture[0].type =
1132 theme->a_toggled_focused_unpressed_max->texture[0].type =
1133 theme->a_toggled_unfocused_unpressed_max->texture[0].type =
1134 theme->a_toggled_focused_pressed_max->texture[0].type =
1135 theme->a_toggled_unfocused_pressed_max->texture[0].type =
1136 theme->a_focused_unpressed_max->texture[0].type =
1137 theme->a_focused_pressed_max->texture[0].type =
1138 theme->a_unfocused_unpressed_max->texture[0].type =
1139 theme->a_unfocused_pressed_max->texture[0].type =
1140 theme->a_disabled_focused_close->texture[0].type =
1141 theme->a_disabled_unfocused_close->texture[0].type =
1142 theme->a_hover_focused_close->texture[0].type =
1143 theme->a_hover_unfocused_close->texture[0].type =
1144 theme->a_focused_unpressed_close->texture[0].type =
1145 theme->a_focused_pressed_close->texture[0].type =
1146 theme->a_unfocused_unpressed_close->texture[0].type =
1147 theme->a_unfocused_pressed_close->texture[0].type =
1148 theme->a_disabled_focused_desk->texture[0].type =
1149 theme->a_disabled_unfocused_desk->texture[0].type =
1150 theme->a_hover_focused_desk->texture[0].type =
1151 theme->a_hover_unfocused_desk->texture[0].type =
1152 theme->a_toggled_hover_focused_desk->texture[0].type =
1153 theme->a_toggled_hover_unfocused_desk->texture[0].type =
1154 theme->a_toggled_focused_unpressed_desk->texture[0].type =
1155 theme->a_toggled_unfocused_unpressed_desk->texture[0].type =
1156 theme->a_toggled_focused_pressed_desk->texture[0].type =
1157 theme->a_toggled_unfocused_pressed_desk->texture[0].type =
1158 theme->a_focused_unpressed_desk->texture[0].type =
1159 theme->a_focused_pressed_desk->texture[0].type =
1160 theme->a_unfocused_unpressed_desk->texture[0].type =
1161 theme->a_unfocused_pressed_desk->texture[0].type =
1162 theme->a_disabled_focused_shade->texture[0].type =
1163 theme->a_disabled_unfocused_shade->texture[0].type =
1164 theme->a_hover_focused_shade->texture[0].type =
1165 theme->a_hover_unfocused_shade->texture[0].type =
1166 theme->a_toggled_hover_focused_shade->texture[0].type =
1167 theme->a_toggled_hover_unfocused_shade->texture[0].type =
1168 theme->a_toggled_focused_unpressed_shade->texture[0].type =
1169 theme->a_toggled_unfocused_unpressed_shade->texture[0].type =
1170 theme->a_toggled_focused_pressed_shade->texture[0].type =
1171 theme->a_toggled_unfocused_pressed_shade->texture[0].type =
1172 theme->a_focused_unpressed_shade->texture[0].type =
1173 theme->a_focused_pressed_shade->texture[0].type =
1174 theme->a_unfocused_unpressed_shade->texture[0].type =
1175 theme->a_unfocused_pressed_shade->texture[0].type =
1176 theme->a_disabled_focused_iconify->texture[0].type =
1177 theme->a_disabled_unfocused_iconify->texture[0].type =
1178 theme->a_hover_focused_iconify->texture[0].type =
1179 theme->a_hover_unfocused_iconify->texture[0].type =
1180 theme->a_focused_unpressed_iconify->texture[0].type =
1181 theme->a_focused_pressed_iconify->texture[0].type =
1182 theme->a_unfocused_unpressed_iconify->texture[0].type =
1183 theme->a_unfocused_pressed_iconify->texture[0].type =
1184 theme->a_menu_bullet_normal->texture[0].type =
1185 theme->a_menu_bullet_selected->texture[0].type = RR_TEXTURE_MASK;
1186
1187 theme->a_disabled_focused_max->texture[0].data.mask.mask =
1188 theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
1189 theme->max_disabled_mask;
1190 theme->a_hover_focused_max->texture[0].data.mask.mask =
1191 theme->a_hover_unfocused_max->texture[0].data.mask.mask =
1192 theme->max_hover_mask;
1193 theme->a_focused_pressed_max->texture[0].data.mask.mask =
1194 theme->a_unfocused_pressed_max->texture[0].data.mask.mask =
1195 theme->max_pressed_mask;
1196 theme->a_focused_unpressed_max->texture[0].data.mask.mask =
1197 theme->a_unfocused_unpressed_max->texture[0].data.mask.mask =
1198 theme->max_mask;
1199 theme->a_toggled_hover_focused_max->texture[0].data.mask.mask =
1200 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.mask =
1201 theme->max_toggled_hover_mask;
1202 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.mask =
1203 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.mask =
1204 theme->max_toggled_mask;
1205 theme->a_toggled_focused_pressed_max->texture[0].data.mask.mask =
1206 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.mask =
1207 theme->max_toggled_pressed_mask;
1208 theme->a_disabled_focused_close->texture[0].data.mask.mask =
1209 theme->a_disabled_unfocused_close->texture[0].data.mask.mask =
1210 theme->close_disabled_mask;
1211 theme->a_hover_focused_close->texture[0].data.mask.mask =
1212 theme->a_hover_unfocused_close->texture[0].data.mask.mask =
1213 theme->close_hover_mask;
1214 theme->a_focused_pressed_close->texture[0].data.mask.mask =
1215 theme->a_unfocused_pressed_close->texture[0].data.mask.mask =
1216 theme->close_pressed_mask;
1217 theme->a_focused_unpressed_close->texture[0].data.mask.mask =
1218 theme->a_unfocused_unpressed_close->texture[0].data.mask.mask =
1219 theme->close_mask;
1220 theme->a_disabled_focused_desk->texture[0].data.mask.mask =
1221 theme->a_disabled_unfocused_desk->texture[0].data.mask.mask =
1222 theme->desk_disabled_mask;
1223 theme->a_hover_focused_desk->texture[0].data.mask.mask =
1224 theme->a_hover_unfocused_desk->texture[0].data.mask.mask =
1225 theme->desk_hover_mask;
1226 theme->a_focused_pressed_desk->texture[0].data.mask.mask =
1227 theme->a_unfocused_pressed_desk->texture[0].data.mask.mask =
1228 theme->desk_pressed_mask;
1229 theme->a_focused_unpressed_desk->texture[0].data.mask.mask =
1230 theme->a_unfocused_unpressed_desk->texture[0].data.mask.mask =
1231 theme->desk_mask;
1232 theme->a_toggled_hover_focused_desk->texture[0].data.mask.mask =
1233 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.mask =
1234 theme->desk_toggled_hover_mask;
1235 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.mask =
1236 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.mask =
1237 theme->desk_toggled_mask;
1238 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.mask =
1239 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.mask =
1240 theme->desk_toggled_pressed_mask;
1241 theme->a_disabled_focused_shade->texture[0].data.mask.mask =
1242 theme->a_disabled_unfocused_shade->texture[0].data.mask.mask =
1243 theme->shade_disabled_mask;
1244 theme->a_hover_focused_shade->texture[0].data.mask.mask =
1245 theme->a_hover_unfocused_shade->texture[0].data.mask.mask =
1246 theme->shade_hover_mask;
1247 theme->a_focused_pressed_shade->texture[0].data.mask.mask =
1248 theme->a_unfocused_pressed_shade->texture[0].data.mask.mask =
1249 theme->shade_pressed_mask;
1250 theme->a_focused_unpressed_shade->texture[0].data.mask.mask =
1251 theme->a_unfocused_unpressed_shade->texture[0].data.mask.mask =
1252 theme->shade_mask;
1253 theme->a_toggled_hover_focused_shade->texture[0].data.mask.mask =
1254 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.mask =
1255 theme->shade_toggled_hover_mask;
1256 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.mask =
1257 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.mask =
1258 theme->shade_toggled_mask;
1259 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.mask =
1260 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.mask =
1261 theme->shade_toggled_pressed_mask;
1262 theme->a_disabled_focused_iconify->texture[0].data.mask.mask =
1263 theme->a_disabled_unfocused_iconify->texture[0].data.mask.mask =
1264 theme->iconify_disabled_mask;
1265 theme->a_hover_focused_iconify->texture[0].data.mask.mask =
1266 theme->a_hover_unfocused_iconify->texture[0].data.mask.mask =
1267 theme->iconify_hover_mask;
1268 theme->a_focused_pressed_iconify->texture[0].data.mask.mask =
1269 theme->a_unfocused_pressed_iconify->texture[0].data.mask.mask =
1270 theme->iconify_pressed_mask;
1271 theme->a_focused_unpressed_iconify->texture[0].data.mask.mask =
1272 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.mask =
1273 theme->iconify_mask;
1274 theme->a_menu_bullet_normal->texture[0].data.mask.mask =
1275 theme->a_menu_bullet_selected->texture[0].data.mask.mask =
1276 theme->menu_bullet_mask;
1277 theme->a_disabled_focused_max->texture[0].data.mask.color =
1278 theme->a_disabled_focused_close->texture[0].data.mask.color =
1279 theme->a_disabled_focused_desk->texture[0].data.mask.color =
1280 theme->a_disabled_focused_shade->texture[0].data.mask.color =
1281 theme->a_disabled_focused_iconify->texture[0].data.mask.color =
1282 theme->titlebut_disabled_focused_color;
1283 theme->a_disabled_unfocused_max->texture[0].data.mask.color =
1284 theme->a_disabled_unfocused_close->texture[0].data.mask.color =
1285 theme->a_disabled_unfocused_desk->texture[0].data.mask.color =
1286 theme->a_disabled_unfocused_shade->texture[0].data.mask.color =
1287 theme->a_disabled_unfocused_iconify->texture[0].data.mask.color =
1288 theme->titlebut_disabled_unfocused_color;
1289 theme->a_hover_focused_max->texture[0].data.mask.color =
1290 theme->a_hover_focused_close->texture[0].data.mask.color =
1291 theme->a_hover_focused_desk->texture[0].data.mask.color =
1292 theme->a_hover_focused_shade->texture[0].data.mask.color =
1293 theme->a_hover_focused_iconify->texture[0].data.mask.color =
1294 theme->titlebut_hover_focused_color;
1295 theme->a_hover_unfocused_max->texture[0].data.mask.color =
1296 theme->a_hover_unfocused_close->texture[0].data.mask.color =
1297 theme->a_hover_unfocused_desk->texture[0].data.mask.color =
1298 theme->a_hover_unfocused_shade->texture[0].data.mask.color =
1299 theme->a_hover_unfocused_iconify->texture[0].data.mask.color =
1300 theme->titlebut_hover_unfocused_color;
1301 theme->a_toggled_hover_focused_max->texture[0].data.mask.color =
1302 theme->a_toggled_hover_focused_desk->texture[0].data.mask.color =
1303 theme->a_toggled_hover_focused_shade->texture[0].data.mask.color =
1304 theme->titlebut_toggled_hover_focused_color;
1305 theme->a_toggled_hover_unfocused_max->texture[0].data.mask.color =
1306 theme->a_toggled_hover_unfocused_desk->texture[0].data.mask.color =
1307 theme->a_toggled_hover_unfocused_shade->texture[0].data.mask.color =
1308 theme->titlebut_toggled_hover_unfocused_color;
1309 theme->a_toggled_focused_unpressed_max->texture[0].data.mask.color =
1310 theme->a_toggled_focused_unpressed_desk->texture[0].data.mask.color =
1311 theme->a_toggled_focused_unpressed_shade->texture[0].data.mask.color =
1312 theme->titlebut_toggled_focused_unpressed_color;
1313 theme->a_toggled_unfocused_unpressed_max->texture[0].data.mask.color =
1314 theme->a_toggled_unfocused_unpressed_desk->texture[0].data.mask.color =
1315 theme->a_toggled_unfocused_unpressed_shade->texture[0].data.mask.color=
1316 theme->titlebut_toggled_unfocused_unpressed_color;
1317 theme->a_toggled_focused_pressed_max->texture[0].data.mask.color =
1318 theme->a_toggled_focused_pressed_desk->texture[0].data.mask.color =
1319 theme->a_toggled_focused_pressed_shade->texture[0].data.mask.color =
1320 theme->titlebut_toggled_focused_pressed_color;
1321 theme->a_toggled_unfocused_pressed_max->texture[0].data.mask.color =
1322 theme->a_toggled_unfocused_pressed_desk->texture[0].data.mask.color =
1323 theme->a_toggled_unfocused_pressed_shade->texture[0].data.mask.color =
1324 theme->titlebut_toggled_unfocused_pressed_color;
1325 theme->a_focused_unpressed_max->texture[0].data.mask.color =
1326 theme->a_focused_unpressed_close->texture[0].data.mask.color =
1327 theme->a_focused_unpressed_desk->texture[0].data.mask.color =
1328 theme->a_focused_unpressed_shade->texture[0].data.mask.color =
1329 theme->a_focused_unpressed_iconify->texture[0].data.mask.color =
1330 theme->titlebut_focused_unpressed_color;
1331 theme->a_focused_pressed_max->texture[0].data.mask.color =
1332 theme->a_focused_pressed_close->texture[0].data.mask.color =
1333 theme->a_focused_pressed_desk->texture[0].data.mask.color =
1334 theme->a_focused_pressed_shade->texture[0].data.mask.color =
1335 theme->a_focused_pressed_iconify->texture[0].data.mask.color =
1336 theme->titlebut_focused_pressed_color;
1337 theme->a_unfocused_unpressed_max->texture[0].data.mask.color =
1338 theme->a_unfocused_unpressed_close->texture[0].data.mask.color =
1339 theme->a_unfocused_unpressed_desk->texture[0].data.mask.color =
1340 theme->a_unfocused_unpressed_shade->texture[0].data.mask.color =
1341 theme->a_unfocused_unpressed_iconify->texture[0].data.mask.color =
1342 theme->titlebut_unfocused_unpressed_color;
1343 theme->a_unfocused_pressed_max->texture[0].data.mask.color =
1344 theme->a_unfocused_pressed_close->texture[0].data.mask.color =
1345 theme->a_unfocused_pressed_desk->texture[0].data.mask.color =
1346 theme->a_unfocused_pressed_shade->texture[0].data.mask.color =
1347 theme->a_unfocused_pressed_iconify->texture[0].data.mask.color =
1348 theme->titlebut_unfocused_pressed_color;
1349 theme->a_menu_bullet_normal->texture[0].data.mask.color =
1350 theme->menu_color;
1351 theme->a_menu_bullet_selected->texture[0].data.mask.color =
1352 theme->menu_selected_color;
1353
1354 g_free(path);
1355 XrmDestroyDatabase(db);
1356
1357 /* set the font heights */
1358 theme->win_font_height = RrFontHeight
1359 (theme->win_font_focused,
1360 theme->a_focused_label->texture[0].data.text.shadow_offset_y);
1361 theme->win_font_height =
1362 MAX(theme->win_font_height,
1363 RrFontHeight
1364 (theme->win_font_focused,
1365 theme->a_unfocused_label->texture[0].data.text.shadow_offset_y));
1366 theme->menu_title_font_height = RrFontHeight
1367 (theme->menu_title_font,
1368 theme->a_menu_text_title->texture[0].data.text.shadow_offset_y);
1369 theme->menu_font_height = RrFontHeight
1370 (theme->menu_font,
1371 theme->a_menu_text_normal->texture[0].data.text.shadow_offset_y);
1372
1373 /* calculate some last extents */
1374 {
1375 gint ft, fb, fl, fr, ut, ub, ul, ur;
1376
1377 RrMargins(theme->a_focused_label, &fl, &ft, &fr, &fb);
1378 RrMargins(theme->a_unfocused_label, &ul, &ut, &ur, &ub);
1379 theme->label_height = theme->win_font_height + MAX(ft + fb, ut + ub);
1380 theme->label_height += theme->label_height % 2;
1381
1382 /* this would be nice I think, since padding.width can now be 0,
1383 but it breaks frame.c horribly and I don't feel like fixing that
1384 right now, so if anyone complains, here is how to keep text from
1385 going over the title's bevel/border with a padding.width of 0 and a
1386 bevelless/borderless label
1387 RrMargins(theme->a_focused_title, &fl, &ft, &fr, &fb);
1388 RrMargins(theme->a_unfocused_title, &ul, &ut, &ur, &ub);
1389 theme->title_height = theme->label_height +
1390 MAX(MAX(theme->padding * 2, ft + fb),
1391 MAX(theme->padding * 2, ut + ub));
1392 */
1393 theme->title_height = theme->label_height + theme->paddingy * 2;
1394
1395 RrMargins(theme->a_menu_title, &ul, &ut, &ur, &ub);
1396 theme->menu_title_label_height = theme->menu_title_font_height+ut+ub;
1397 theme->menu_title_height = theme->menu_title_label_height +
1398 theme->paddingy * 2;
1399 }
1400 theme->button_size = theme->label_height - 2;
1401 theme->grip_width = 25;
1402
1403 return theme;
1404 }
1405
1406 void RrThemeFree(RrTheme *theme)
1407 {
1408 if (theme) {
1409 g_free(theme->name);
1410
1411 RrColorFree(theme->menu_border_color);
1412 RrColorFree(theme->osd_border_color);
1413 RrColorFree(theme->frame_focused_border_color);
1414 RrColorFree(theme->frame_unfocused_border_color);
1415 RrColorFree(theme->title_separator_focused_color);
1416 RrColorFree(theme->title_separator_unfocused_color);
1417 RrColorFree(theme->cb_unfocused_color);
1418 RrColorFree(theme->cb_focused_color);
1419 RrColorFree(theme->title_focused_color);
1420 RrColorFree(theme->title_unfocused_color);
1421 RrColorFree(theme->titlebut_disabled_focused_color);
1422 RrColorFree(theme->titlebut_disabled_unfocused_color);
1423 RrColorFree(theme->titlebut_hover_focused_color);
1424 RrColorFree(theme->titlebut_hover_unfocused_color);
1425 RrColorFree(theme->titlebut_toggled_hover_focused_color);
1426 RrColorFree(theme->titlebut_toggled_hover_unfocused_color);
1427 RrColorFree(theme->titlebut_toggled_focused_pressed_color);
1428 RrColorFree(theme->titlebut_toggled_unfocused_pressed_color);
1429 RrColorFree(theme->titlebut_toggled_focused_unpressed_color);
1430 RrColorFree(theme->titlebut_toggled_unfocused_unpressed_color);
1431 RrColorFree(theme->titlebut_focused_pressed_color);
1432 RrColorFree(theme->titlebut_unfocused_pressed_color);
1433 RrColorFree(theme->titlebut_focused_unpressed_color);
1434 RrColorFree(theme->titlebut_unfocused_unpressed_color);
1435 RrColorFree(theme->menu_title_color);
1436 RrColorFree(theme->menu_sep_color);
1437 RrColorFree(theme->menu_color);
1438 RrColorFree(theme->menu_selected_color);
1439 RrColorFree(theme->menu_disabled_color);
1440 RrColorFree(theme->menu_disabled_selected_color);
1441 RrColorFree(theme->title_focused_shadow_color);
1442 RrColorFree(theme->title_unfocused_shadow_color);
1443 RrColorFree(theme->osd_color);
1444 RrColorFree(theme->osd_shadow_color);
1445 RrColorFree(theme->menu_title_shadow_color);
1446 RrColorFree(theme->menu_text_normal_shadow_color);
1447 RrColorFree(theme->menu_text_selected_shadow_color);
1448 RrColorFree(theme->menu_text_disabled_shadow_color);
1449 RrColorFree(theme->menu_text_disabled_selected_shadow_color);
1450
1451 g_free(theme->def_win_icon);
1452
1453 RrPixmapMaskFree(theme->max_mask);
1454 RrPixmapMaskFree(theme->max_toggled_mask);
1455 RrPixmapMaskFree(theme->max_toggled_hover_mask);
1456 RrPixmapMaskFree(theme->max_toggled_pressed_mask);
1457 RrPixmapMaskFree(theme->max_disabled_mask);
1458 RrPixmapMaskFree(theme->max_hover_mask);
1459 RrPixmapMaskFree(theme->max_pressed_mask);
1460 RrPixmapMaskFree(theme->desk_mask);
1461 RrPixmapMaskFree(theme->desk_toggled_mask);
1462 RrPixmapMaskFree(theme->desk_toggled_hover_mask);
1463 RrPixmapMaskFree(theme->desk_toggled_pressed_mask);
1464 RrPixmapMaskFree(theme->desk_disabled_mask);
1465 RrPixmapMaskFree(theme->desk_hover_mask);
1466 RrPixmapMaskFree(theme->desk_pressed_mask);
1467 RrPixmapMaskFree(theme->shade_mask);
1468 RrPixmapMaskFree(theme->shade_toggled_mask);
1469 RrPixmapMaskFree(theme->shade_toggled_hover_mask);
1470 RrPixmapMaskFree(theme->shade_toggled_pressed_mask);
1471 RrPixmapMaskFree(theme->shade_disabled_mask);
1472 RrPixmapMaskFree(theme->shade_hover_mask);
1473 RrPixmapMaskFree(theme->shade_pressed_mask);
1474 RrPixmapMaskFree(theme->iconify_mask);
1475 RrPixmapMaskFree(theme->iconify_disabled_mask);
1476 RrPixmapMaskFree(theme->iconify_hover_mask);
1477 RrPixmapMaskFree(theme->iconify_pressed_mask);
1478 RrPixmapMaskFree(theme->close_mask);
1479 RrPixmapMaskFree(theme->close_disabled_mask);
1480 RrPixmapMaskFree(theme->close_hover_mask);
1481 RrPixmapMaskFree(theme->close_pressed_mask);
1482 RrPixmapMaskFree(theme->menu_bullet_mask);
1483 RrPixmapMaskFree(theme->down_arrow_mask);
1484 RrPixmapMaskFree(theme->up_arrow_mask);
1485
1486 RrFontClose(theme->win_font_focused);
1487 RrFontClose(theme->win_font_unfocused);
1488 RrFontClose(theme->menu_title_font);
1489 RrFontClose(theme->menu_font);
1490 RrFontClose(theme->osd_font);
1491
1492 RrAppearanceFree(theme->a_disabled_focused_max);
1493 RrAppearanceFree(theme->a_disabled_unfocused_max);
1494 RrAppearanceFree(theme->a_hover_focused_max);
1495 RrAppearanceFree(theme->a_hover_unfocused_max);
1496 RrAppearanceFree(theme->a_toggled_hover_focused_max);
1497 RrAppearanceFree(theme->a_toggled_hover_unfocused_max);
1498 RrAppearanceFree(theme->a_toggled_focused_unpressed_max);
1499 RrAppearanceFree(theme->a_toggled_focused_pressed_max);
1500 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_max);
1501 RrAppearanceFree(theme->a_toggled_unfocused_pressed_max);
1502 RrAppearanceFree(theme->a_focused_unpressed_max);
1503 RrAppearanceFree(theme->a_focused_pressed_max);
1504 RrAppearanceFree(theme->a_unfocused_unpressed_max);
1505 RrAppearanceFree(theme->a_unfocused_pressed_max);
1506 RrAppearanceFree(theme->a_disabled_focused_close);
1507 RrAppearanceFree(theme->a_disabled_unfocused_close);
1508 RrAppearanceFree(theme->a_hover_focused_close);
1509 RrAppearanceFree(theme->a_hover_unfocused_close);
1510 RrAppearanceFree(theme->a_focused_unpressed_close);
1511 RrAppearanceFree(theme->a_focused_pressed_close);
1512 RrAppearanceFree(theme->a_unfocused_unpressed_close);
1513 RrAppearanceFree(theme->a_unfocused_pressed_close);
1514 RrAppearanceFree(theme->a_disabled_focused_desk);
1515 RrAppearanceFree(theme->a_disabled_unfocused_desk);
1516 RrAppearanceFree(theme->a_hover_focused_desk);
1517 RrAppearanceFree(theme->a_hover_unfocused_desk);
1518 RrAppearanceFree(theme->a_toggled_hover_focused_desk);
1519 RrAppearanceFree(theme->a_toggled_hover_unfocused_desk);
1520 RrAppearanceFree(theme->a_toggled_focused_unpressed_desk);
1521 RrAppearanceFree(theme->a_toggled_focused_pressed_desk);
1522 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_desk);
1523 RrAppearanceFree(theme->a_toggled_unfocused_pressed_desk);
1524 RrAppearanceFree(theme->a_focused_unpressed_desk);
1525 RrAppearanceFree(theme->a_focused_pressed_desk);
1526 RrAppearanceFree(theme->a_unfocused_unpressed_desk);
1527 RrAppearanceFree(theme->a_unfocused_pressed_desk);
1528 RrAppearanceFree(theme->a_disabled_focused_shade);
1529 RrAppearanceFree(theme->a_disabled_unfocused_shade);
1530 RrAppearanceFree(theme->a_hover_focused_shade);
1531 RrAppearanceFree(theme->a_hover_unfocused_shade);
1532 RrAppearanceFree(theme->a_toggled_hover_focused_shade);
1533 RrAppearanceFree(theme->a_toggled_hover_unfocused_shade);
1534 RrAppearanceFree(theme->a_toggled_focused_unpressed_shade);
1535 RrAppearanceFree(theme->a_toggled_focused_pressed_shade);
1536 RrAppearanceFree(theme->a_toggled_unfocused_unpressed_shade);
1537 RrAppearanceFree(theme->a_toggled_unfocused_pressed_shade);
1538 RrAppearanceFree(theme->a_focused_unpressed_shade);
1539 RrAppearanceFree(theme->a_focused_pressed_shade);
1540 RrAppearanceFree(theme->a_unfocused_unpressed_shade);
1541 RrAppearanceFree(theme->a_unfocused_pressed_shade);
1542 RrAppearanceFree(theme->a_disabled_focused_iconify);
1543 RrAppearanceFree(theme->a_disabled_unfocused_iconify);
1544 RrAppearanceFree(theme->a_hover_focused_iconify);
1545 RrAppearanceFree(theme->a_hover_unfocused_iconify);
1546 RrAppearanceFree(theme->a_focused_unpressed_iconify);
1547 RrAppearanceFree(theme->a_focused_pressed_iconify);
1548 RrAppearanceFree(theme->a_unfocused_unpressed_iconify);
1549 RrAppearanceFree(theme->a_unfocused_pressed_iconify);
1550 RrAppearanceFree(theme->a_focused_grip);
1551 RrAppearanceFree(theme->a_unfocused_grip);
1552 RrAppearanceFree(theme->a_focused_title);
1553 RrAppearanceFree(theme->a_unfocused_title);
1554 RrAppearanceFree(theme->a_focused_label);
1555 RrAppearanceFree(theme->a_unfocused_label);
1556 RrAppearanceFree(theme->a_icon);
1557 RrAppearanceFree(theme->a_focused_handle);
1558 RrAppearanceFree(theme->a_unfocused_handle);
1559 RrAppearanceFree(theme->a_menu);
1560 RrAppearanceFree(theme->a_menu_title);
1561 RrAppearanceFree(theme->a_menu_text_title);
1562 RrAppearanceFree(theme->a_menu_normal);
1563 RrAppearanceFree(theme->a_menu_selected);
1564 RrAppearanceFree(theme->a_menu_disabled);
1565 RrAppearanceFree(theme->a_menu_disabled_selected);
1566 RrAppearanceFree(theme->a_menu_text_normal);
1567 RrAppearanceFree(theme->a_menu_text_selected);
1568 RrAppearanceFree(theme->a_menu_text_disabled);
1569 RrAppearanceFree(theme->a_menu_text_disabled_selected);
1570 RrAppearanceFree(theme->a_menu_bullet_normal);
1571 RrAppearanceFree(theme->a_menu_bullet_selected);
1572 RrAppearanceFree(theme->a_clear);
1573 RrAppearanceFree(theme->a_clear_tex);
1574 RrAppearanceFree(theme->osd_hilite_bg);
1575 RrAppearanceFree(theme->osd_hilite_fg);
1576 RrAppearanceFree(theme->osd_hilite_label);
1577 RrAppearanceFree(theme->osd_unhilite_fg);
1578
1579 g_free(theme);
1580 }
1581 }
1582
1583 static XrmDatabase loaddb(const gchar *name, gchar **path)
1584 {
1585 GSList *it;
1586 XrmDatabase db = NULL;
1587 gchar *s;
1588
1589 if (name[0] == '/') {
1590 s = g_build_filename(name, "openbox-3", "themerc", NULL);
1591 if ((db = XrmGetFileDatabase(s)))
1592 *path = g_path_get_dirname(s);
1593 g_free(s);
1594 } else {
1595 ObtPaths *p;
1596
1597 p = obt_paths_new();
1598
1599 /* XXX backwards compatibility, remove me sometime later */
1600 s = g_build_filename(g_get_home_dir(), ".themes", name,
1601 "openbox-3", "themerc", NULL);
1602 if ((db = XrmGetFileDatabase(s)))
1603 *path = g_path_get_dirname(s);
1604 g_free(s);
1605
1606 for (it = obt_paths_data_dirs(p); !db && it; it = g_slist_next(it))
1607 {
1608 s = g_build_filename(it->data, "themes", name,
1609 "openbox-3", "themerc", NULL);
1610 if ((db = XrmGetFileDatabase(s)))
1611 *path = g_path_get_dirname(s);
1612 g_free(s);
1613 }
1614
1615 obt_paths_unref(p);
1616 }
1617
1618 if (db == NULL) {
1619 s = g_build_filename(name, "themerc", NULL);
1620 if ((db = XrmGetFileDatabase(s)))
1621 *path = g_path_get_dirname(s);
1622 g_free(s);
1623 }
1624
1625 return db;
1626 }
1627
1628 static gchar *create_class_name(const gchar *rname)
1629 {
1630 gchar *rclass = g_strdup(rname);
1631 gchar *p = rclass;
1632
1633 while (TRUE) {
1634 *p = toupper(*p);
1635 p = strchr(p+1, '.');
1636 if (p == NULL) break;
1637 ++p;
1638 if (*p == '\0') break;
1639 }
1640 return rclass;
1641 }
1642
1643 static gboolean read_int(XrmDatabase db, const gchar *rname, gint *value)
1644 {
1645 gboolean ret = FALSE;
1646 gchar *rclass = create_class_name(rname);
1647 gchar *rettype, *end;
1648 XrmValue retvalue;
1649
1650 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1651 retvalue.addr != NULL) {
1652 *value = (gint)strtol(retvalue.addr, &end, 10);
1653 if (end != retvalue.addr)
1654 ret = TRUE;
1655 }
1656
1657 g_free(rclass);
1658 return ret;
1659 }
1660
1661 static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
1662 {
1663 gboolean ret = FALSE;
1664 gchar *rclass = create_class_name(rname);
1665 gchar *rettype;
1666 XrmValue retvalue;
1667
1668 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1669 retvalue.addr != NULL) {
1670 *value = retvalue.addr;
1671 ret = TRUE;
1672 }
1673
1674 g_free(rclass);
1675 return ret;
1676 }
1677
1678 static gboolean read_color(XrmDatabase db, const RrInstance *inst,
1679 const gchar *rname, RrColor **value)
1680 {
1681 gboolean ret = FALSE;
1682 gchar *rclass = create_class_name(rname);
1683 gchar *rettype;
1684 XrmValue retvalue;
1685
1686 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1687 retvalue.addr != NULL) {
1688 RrColor *c = RrColorParse(inst, retvalue.addr);
1689 if (c != NULL) {
1690 *value = c;
1691 ret = TRUE;
1692 }
1693 }
1694
1695 g_free(rclass);
1696 return ret;
1697 }
1698
1699 static gboolean read_mask(const RrInstance *inst, const gchar *path,
1700 RrTheme *theme, const gchar *maskname,
1701 RrPixmapMask **value)
1702 {
1703 gboolean ret = FALSE;
1704 gchar *s;
1705 gint hx, hy; /* ignored */
1706 guint w, h;
1707 guchar *b;
1708
1709 s = g_build_filename(path, maskname, NULL);
1710 if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) {
1711 ret = TRUE;
1712 *value = RrPixmapMaskNew(inst, w, h, (gchar*)b);
1713 XFree(b);
1714 }
1715 g_free(s);
1716
1717 return ret;
1718 }
1719
1720 static void parse_appearance(gchar *tex, RrSurfaceColorType *grad,
1721 RrReliefType *relief, RrBevelType *bevel,
1722 gboolean *interlaced, gboolean *border,
1723 gboolean allow_trans)
1724 {
1725 gchar *t;
1726
1727 /* convert to all lowercase */
1728 for (t = tex; *t != '\0'; ++t)
1729 *t = g_ascii_tolower(*t);
1730
1731 if (allow_trans && strstr(tex, "parentrelative") != NULL) {
1732 *grad = RR_SURFACE_PARENTREL;
1733 } else {
1734 if (strstr(tex, "gradient") != NULL) {
1735 if (strstr(tex, "crossdiagonal") != NULL)
1736 *grad = RR_SURFACE_CROSS_DIAGONAL;
1737 else if (strstr(tex, "pyramid") != NULL)
1738 *grad = RR_SURFACE_PYRAMID;
1739 else if (strstr(tex, "mirrorhorizontal") != NULL)
1740 *grad = RR_SURFACE_MIRROR_HORIZONTAL;
1741 else if (strstr(tex, "horizontal") != NULL)
1742 *grad = RR_SURFACE_HORIZONTAL;
1743 else if (strstr(tex, "splitvertical") != NULL)
1744 *grad = RR_SURFACE_SPLIT_VERTICAL;
1745 else if (strstr(tex, "vertical") != NULL)
1746 *grad = RR_SURFACE_VERTICAL;
1747 else
1748 *grad = RR_SURFACE_DIAGONAL;
1749 } else {
1750 *grad = RR_SURFACE_SOLID;
1751 }
1752 }
1753
1754 if (strstr(tex, "sunken") != NULL)
1755 *relief = RR_RELIEF_SUNKEN;
1756 else if (strstr(tex, "flat") != NULL)
1757 *relief = RR_RELIEF_FLAT;
1758 else if (strstr(tex, "raised") != NULL)
1759 *relief = RR_RELIEF_RAISED;
1760 else
1761 *relief = (*grad == RR_SURFACE_PARENTREL) ?
1762 RR_RELIEF_FLAT : RR_RELIEF_RAISED;
1763
1764 *border = FALSE;
1765 if (*relief == RR_RELIEF_FLAT) {
1766 if (strstr(tex, "border") != NULL)
1767 *border = TRUE;
1768 } else {
1769 if (strstr(tex, "bevel2") != NULL)
1770 *bevel = RR_BEVEL_2;
1771 else
1772 *bevel = RR_BEVEL_1;
1773 }
1774
1775 if (strstr(tex, "interlaced") != NULL)
1776 *interlaced = TRUE;
1777 else
1778 *interlaced = FALSE;
1779 }
1780
1781 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
1782 const gchar *rname, RrAppearance *value,
1783 gboolean allow_trans)
1784 {
1785 gboolean ret = FALSE;
1786 gchar *rclass = create_class_name(rname);
1787 gchar *cname, *ctoname, *bcname, *icname, *hname, *sname;
1788 gchar *csplitname, *ctosplitname;
1789 gchar *rettype;
1790 XrmValue retvalue;
1791 gint i;
1792
1793 cname = g_strconcat(rname, ".color", NULL);
1794 ctoname = g_strconcat(rname, ".colorTo", NULL);
1795 bcname = g_strconcat(rname, ".border.color", NULL);
1796 icname = g_strconcat(rname, ".interlace.color", NULL);
1797 hname = g_strconcat(rname, ".highlight", NULL);
1798 sname = g_strconcat(rname, ".shadow", NULL);
1799 csplitname = g_strconcat(rname, ".color.splitTo", NULL);
1800 ctosplitname = g_strconcat(rname, ".colorTo.splitTo", NULL);
1801
1802 if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
1803 retvalue.addr != NULL) {
1804 parse_appearance(retvalue.addr,
1805 &value->surface.grad,
1806 &value->surface.relief,
1807 &value->surface.bevel,
1808 &value->surface.interlaced,
1809 &value->surface.border,
1810 allow_trans);
1811 if (!read_color(db, inst, cname, &value->surface.primary))
1812 value->surface.primary = RrColorNew(inst, 0, 0, 0);
1813 if (!read_color(db, inst, ctoname, &value->surface.secondary))
1814 value->surface.secondary = RrColorNew(inst, 0, 0, 0);
1815 if (value->surface.border)
1816 if (!read_color(db, inst, bcname,
1817 &value->surface.border_color))
1818 value->surface.border_color = RrColorNew(inst, 0, 0, 0);
1819 if (value->surface.interlaced)
1820 if (!read_color(db, inst, icname,
1821 &value->surface.interlace_color))
1822 value->surface.interlace_color = RrColorNew(inst, 0, 0, 0);
1823 if (read_int(db, hname, &i) && i >= 0)
1824 value->surface.bevel_light_adjust = i;
1825 if (read_int(db, sname, &i) && i >= 0 && i <= 256)
1826 value->surface.bevel_dark_adjust = i;
1827
1828 if (value->surface.grad == RR_SURFACE_SPLIT_VERTICAL) {
1829 gint r, g, b;
1830
1831 if (!read_color(db, inst, csplitname,
1832 &value->surface.split_primary))
1833 {
1834 r = value->surface.primary->r;
1835 r += r >> 2;
1836 g = value->surface.primary->g;
1837 g += g >> 2;
1838 b = value->surface.primary->b;
1839 b += b >> 2;
1840 if (r > 0xFF) r = 0xFF;
1841 if (g > 0xFF) g = 0xFF;
1842 if (b > 0xFF) b = 0xFF;
1843 value->surface.split_primary = RrColorNew(inst, r, g, b);
1844 }
1845
1846 if (!read_color(db, inst, ctosplitname,
1847 &value->surface.split_secondary))
1848 {
1849 r = value->surface.secondary->r;
1850 r += r >> 4;
1851 g = value->surface.secondary->g;
1852 g += g >> 4;
1853 b = value->surface.secondary->b;
1854 b += b >> 4;
1855 if (r > 0xFF) r = 0xFF;
1856 if (g > 0xFF) g = 0xFF;
1857 if (b > 0xFF) b = 0xFF;
1858 value->surface.split_secondary = RrColorNew(inst, r, g, b);
1859 }
1860 }
1861
1862 ret = TRUE;
1863 }
1864
1865 g_free(ctosplitname);
1866 g_free(csplitname);
1867 g_free(sname);
1868 g_free(hname);
1869 g_free(icname);
1870 g_free(bcname);
1871 g_free(ctoname);
1872 g_free(cname);
1873 g_free(rclass);
1874 return ret;
1875 }
1876
1877 static int parse_inline_number(const char *p)
1878 {
1879 int neg = 1;
1880 int res = 0;
1881 if (*p == '-') {
1882 neg = -1;
1883 ++p;
1884 }
1885 for (; isdigit(*p); ++p)
1886 res = res * 10 + *p - '0';
1887 res *= neg;
1888 return res;
1889 }
1890
1891 static void set_default_appearance(RrAppearance *a)
1892 {
1893 a->surface.grad = RR_SURFACE_SOLID;
1894 a->surface.relief = RR_RELIEF_FLAT;
1895 a->surface.bevel = RR_BEVEL_1;
1896 a->surface.interlaced = FALSE;
1897 a->surface.border = FALSE;
1898 a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
1899 a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
1900 }
1901
1902 /* Reads the output from gimp's C-Source file format into valid RGBA data for
1903 an RrTextureRGBA. */
1904 static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
1905 {
1906 RrPixel32 *im, *p;
1907 gint i;
1908
1909 p = im = g_memdup(data, width * height * sizeof(RrPixel32));
1910
1911 for (i = 0; i < width * height; ++i) {
1912 guchar a = ((*p >> 24) & 0xff);
1913 guchar b = ((*p >> 16) & 0xff);
1914 guchar g = ((*p >> 8) & 0xff);
1915 guchar r = ((*p >> 0) & 0xff);
1916
1917 *p = ((r << RrDefaultRedOffset) +
1918 (g << RrDefaultGreenOffset) +
1919 (b << RrDefaultBlueOffset) +
1920 (a << RrDefaultAlphaOffset));
1921 p++;
1922 }
1923
1924 return im;
1925 }
This page took 0.139544 seconds and 4 git commands to generate.