]> Dogcows Code - chaz/openbox/blob - otk/renderstyle.cc
make button text white in the default style
[chaz/openbox] / otk / renderstyle.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #include "config.h"
4
5 #include "renderstyle.hh"
6 #include "display.hh"
7 #include "screeninfo.hh"
8
9 #include <cassert>
10
11 namespace otk {
12
13 RenderStyle **RenderStyle::_styles = 0;
14 std::list<StyleNotify*> *RenderStyle::_notifies = 0;
15
16 void RenderStyle::initialize()
17 {
18 int screens = ScreenCount(**display);
19 _styles = new RenderStyle*[screens];
20 for (int i = 0; i < screens; ++i) {
21 _styles[i] = new RenderStyle();
22 defaultStyle(_styles[i], i);
23 }
24 _notifies = new std::list<StyleNotify*>[screens];
25 }
26
27 void RenderStyle::destroy()
28 {
29 int screens = ScreenCount(**display);
30 for (int i = 0; i < screens; ++i)
31 delete _styles[i];
32 delete [] _styles;
33 delete [] _notifies;
34 }
35
36 void RenderStyle::registerNotify(int screen, StyleNotify *n)
37 {
38 assert(screen >= 0 && screen < ScreenCount(**display));
39 _notifies[screen].push_back(n);
40 }
41
42 void RenderStyle::unregisterNotify(int screen, StyleNotify *n)
43 {
44 assert(screen >= 0 && screen < ScreenCount(**display));
45 _notifies[screen].remove(n);
46 }
47
48 RenderStyle *RenderStyle::style(int screen)
49 {
50 assert(screen >= 0 && screen < ScreenCount(**display));
51 return _styles[screen];
52 }
53
54 bool RenderStyle::setStyle(int screen, const ustring &stylefile)
55 {
56 RenderStyle *s = new RenderStyle();
57 if (!loadStyle(s, screen, stylefile)) {
58 delete s;
59 return false;
60 }
61 delete _styles[screen];
62 _styles[screen] = s;
63
64 std::list<StyleNotify*>::iterator it, end = _notifies[screen].end();
65 for (it = _notifies[screen].begin(); it != end; ++it)
66 (*it)->styleChanged(*s);
67 return true;
68 }
69
70 bool RenderStyle::loadStyle(RenderStyle *s, int screen,
71 const ustring &stylefile)
72 {
73 s->_screen = screen;
74 s->_file = stylefile;
75 // pick one..
76 #define FIERON
77 //#define MERRY
78
79 #ifdef FIERON
80 s->_root_args = "#272a2f";
81
82 s->_text_color_focus = new RenderColor(screen, 0x272a2f);
83 s->_text_color_unfocus = new RenderColor(screen, 0x676869);
84
85 s->_button_color_focus = new RenderColor(screen, 0x96ba86);
86 s->_button_color_unfocus = new RenderColor(screen, 0x676869);
87
88 s->_frame_border_color = new RenderColor(screen, 0x181f24);
89 s->_frame_border_width = 1;
90
91 s->_client_border_color_focus = new RenderColor(screen, 0x858687);
92 s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
93 s->_client_border_width = 1;
94
95 s->_titlebar_focus = new RenderTexture(screen,
96 false,
97 RenderTexture::Flat,
98 RenderTexture::Bevel1,
99 false,
100 RenderTexture::Vertical,
101 false,
102 0x858687,
103 0x373a3f,
104 0x0,
105 0x0);
106 s->_titlebar_unfocus = new RenderTexture(screen,
107 false,
108 RenderTexture::Flat,
109 RenderTexture::Bevel1,
110 false,
111 RenderTexture::Vertical,
112 false,
113 0x555657,
114 0x171a1f,
115 0x0,
116 0x0);
117
118 s->_label_focus = new RenderTexture(screen,
119 false,
120 RenderTexture::Flat,
121 RenderTexture::Bevel1,
122 true,
123 RenderTexture::Vertical,
124 false,
125 0x96ba86,
126 0x5a724c,
127 0x181f24,
128 0x0);
129 s->_label_unfocus = new RenderTexture(screen,
130 false,
131 RenderTexture::Sunken,
132 RenderTexture::Bevel1,
133 false,
134 RenderTexture::CrossDiagonal,
135 false,
136 0x555657,
137 0x272a2f,
138 0x0,
139 0x0);
140
141 s->_handle_focus = new RenderTexture(screen,
142 false,
143 RenderTexture::Flat,
144 RenderTexture::Bevel1,
145 false,
146 RenderTexture::Vertical,
147 false,
148 0x858687,
149 0x373a3f,
150 0x0,
151 0x0);
152 s->_handle_unfocus = new RenderTexture(screen,
153 false,
154 RenderTexture::Flat,
155 RenderTexture::Bevel1,
156 false,
157 RenderTexture::Vertical,
158 false,
159 0x555657,
160 0x171a1f,
161 0x0,
162 0x0);
163
164 s->_button_unpress_focus = new RenderTexture(screen,
165 false,
166 RenderTexture::Raised,
167 RenderTexture::Bevel2,
168 false,
169 RenderTexture::CrossDiagonal,
170 false,
171 0x858687,
172 0x272a2f,
173 0x0,
174 0x0);
175 s->_button_unpress_unfocus = new RenderTexture(screen,
176 false,
177 RenderTexture::Raised,
178 RenderTexture::Bevel2,
179 false,
180 RenderTexture::CrossDiagonal,
181 false,
182 0x555657,
183 0x171a1f,
184 0x0,
185 0x0);
186
187 s->_button_press_focus = new RenderTexture(screen,
188 false,
189 RenderTexture::Sunken,
190 RenderTexture::Bevel2,
191 false,
192 RenderTexture::CrossDiagonal,
193 false,
194 0x96ba86,
195 0x5a724c,
196 0x0,
197 0x0);
198 s->_button_press_unfocus = new RenderTexture(screen,
199 false,
200 RenderTexture::Sunken,
201 RenderTexture::Bevel2,
202 false,
203 RenderTexture::CrossDiagonal,
204 false,
205 0x555657,
206 0x171a1f,
207 0x0,
208 0x0);
209
210 s->_grip_focus = new RenderTexture(screen,
211 false,
212 RenderTexture::Flat,
213 RenderTexture::Bevel1,
214 false,
215 RenderTexture::Vertical,
216 false,
217 0x96ba86,
218 0x5a724c,
219 0x0,
220 0x0);
221 s->_grip_unfocus = new RenderTexture(screen,
222 false,
223 RenderTexture::Flat,
224 RenderTexture::Bevel1,
225 false,
226 RenderTexture::Vertical,
227 false,
228 0x555657,
229 0x171a1f,
230 0x0,
231 0x0);
232
233 s->_label_font = new Font(screen, "Arial,Sans-9:bold", true, 1, 0x40);
234 s->_label_justify = RightBottomJustify;
235
236 s->_max_mask = new PixmapMask();
237 s->_max_mask->w = s->_max_mask->h = 8;
238 {
239 //char data[] = { 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0x7e };
240 char data [] = {0x00, 0x00, 0x18, 0x3c, 0x66, 0x42, 0x00, 0x00 };
241 s->_max_mask->mask =
242 XCreateBitmapFromData(**display,
243 display->screenInfo(screen)->rootWindow(),
244 data, 8, 8);
245 }
246
247 s->_icon_mask = new PixmapMask();
248 s->_icon_mask->w = s->_icon_mask->h = 8;
249 {
250 //char data[] = { 0x00, 0x00, 0xc3, 0xe7, 0x7e, 0x3c, 0x18, 0x00 };
251 char data[] = { 0x00, 0x00, 0x42, 0x66, 0x3c, 0x18, 0x00, 0x00 };
252 s->_icon_mask->mask =
253 XCreateBitmapFromData(**display,
254 display->screenInfo(screen)->rootWindow(),
255 data, 8, 8);
256 }
257
258 s->_alldesk_mask = new PixmapMask();
259 s->_alldesk_mask->w = s->_alldesk_mask->h = 8;
260 {
261 //char data[] = { 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00 };
262 char data[] = { 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00 };
263 s->_alldesk_mask->mask =
264 XCreateBitmapFromData(**display,
265 display->screenInfo(screen)->rootWindow(),
266 data, 8, 8);
267 }
268
269 s->_close_mask = new PixmapMask();
270 s->_close_mask->w = s->_close_mask->h = 8;
271 {
272 //char data[] = { 0xc3, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0xc3 };
273 char data[] = { 0x00, 0xc3, 0x66, 0x3c, 0x3c, 0x66, 0xc3, 0x00 };
274 s->_close_mask->mask =
275 XCreateBitmapFromData(**display,
276 display->screenInfo(screen)->rootWindow(),
277 data, 8, 8);
278 }
279
280 s->_bevel_width = 1;
281 s->_handle_width = 4;
282 #else
283 # ifdef MERRY
284 s->_root_args = "#7b756a";
285
286 s->_text_color_focus = new RenderColor(screen, 0xffffff);
287 s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
288
289 s->_button_color_focus = new RenderColor(screen, 0x222222);
290 s->_button_color_unfocus = new RenderColor(screen, 0x333333);
291
292 s->_frame_border_color = new RenderColor(screen, 0x222222);
293 s->_frame_border_width = 1;
294
295 s->_client_border_color_focus = new RenderColor(screen, 0x858687);
296 s->_client_border_color_unfocus = new RenderColor(screen, 0x555657);
297 s->_client_border_width = 0;
298
299 s->_titlebar_focus = new RenderTexture(screen,
300 false,
301 RenderTexture::Flat,
302 RenderTexture::Bevel1,
303 false,
304 RenderTexture::Solid,
305 false,
306 0xe6e6e6,
307 0xe6e6e6,
308 0x0,
309 0x0);
310 s->_titlebar_unfocus = new RenderTexture(screen,
311 false,
312 RenderTexture::Flat,
313 RenderTexture::Bevel1,
314 false,
315 RenderTexture::Solid,
316 false,
317 0xe6e6e6,
318 0xd9d9d9,
319 0x0,
320 0x0);
321
322 s->_label_focus = new RenderTexture(screen,
323 false,
324 RenderTexture::Flat,
325 RenderTexture::Bevel1,
326 true,
327 RenderTexture::Vertical,
328 false,
329 //0x6a6973,
330 //0x6a6973,
331 0x4c59a6,
332 0x5a6dbd,
333 0x222222,
334 0x0);
335 //urg this ain't so hot
336 s->_label_unfocus = new RenderTexture(screen,
337 false,
338 RenderTexture::Flat,
339 RenderTexture::Bevel1,
340 true,
341 RenderTexture::Vertical,
342 false,
343 0xb4b2ad,
344 0xc3c1bc,
345 0x6a696a,
346 0x0);
347
348
349 s->_handle_focus = new RenderTexture(screen,
350 false,
351 RenderTexture::Flat,
352 RenderTexture::Bevel1,
353 false,
354 RenderTexture::Vertical,
355 false,
356 0xe6e6e6,
357 0xd9d9d9,
358 0x0,
359 0x0);
360 s->_handle_unfocus = new RenderTexture(screen,
361 false,
362 RenderTexture::Flat,
363 RenderTexture::Bevel1,
364 false,
365 RenderTexture::Solid,
366 false,
367 0xe6e6e6,
368 0xe6e6e6,
369 0x0,
370 0x0);
371
372
373 s->_button_unpress_focus = new RenderTexture(screen,
374 false,
375 RenderTexture::Flat,
376 RenderTexture::Bevel1,
377 false,
378 RenderTexture::Solid,
379 false,
380 0xe6e6e6,
381 0xe6e6e6,
382 0x0,
383 0x0);
384 s->_button_unpress_unfocus = new RenderTexture(screen,
385 false,
386 RenderTexture::Flat,
387 RenderTexture::Bevel1,
388 false,
389 RenderTexture::Solid,
390 false,
391 0xe6e6e6,
392 0xe6e6e6,
393 0x0,
394 0x0);
395
396 s->_button_press_focus = new RenderTexture(screen,
397 false,
398 RenderTexture::Sunken,
399 RenderTexture::Bevel2,
400 false,
401 RenderTexture::Vertical,
402 false,
403 0xe6e6e6,
404 0xe6e6e6,
405 0x0,
406 0x0);
407 s->_button_press_unfocus = new RenderTexture(screen,
408 false,
409 RenderTexture::Sunken,
410 RenderTexture::Bevel2,
411 false,
412 RenderTexture::Vertical,
413 false,
414 0xe6e6e6,
415 0xe6e6e6,
416 0x0,
417 0x0);
418
419 s->_grip_focus = new RenderTexture(screen,
420 false,
421 RenderTexture::Flat,
422 RenderTexture::Bevel1,
423 false,
424 RenderTexture::Vertical,
425 false,
426 0xe6e6e6,
427 0xd9d9d9,
428 0x0,
429 0x0);
430 s->_grip_unfocus = new RenderTexture(screen,
431 false,
432 RenderTexture::Flat,
433 RenderTexture::Bevel1,
434 false,
435 RenderTexture::Solid,
436 false,
437 0xe6e6e6,
438 0xe6e6e6,
439 0x0,
440 0x0);
441
442 s->_label_font = new Font(screen, "Arial,Sans-8", true, 1, 0x3e);
443 s->_label_justify = CenterJustify;
444
445 s->_max_mask = new PixmapMask();
446 s->_max_mask->w = s->_max_mask->h = 7;
447 {
448 char data [] = {0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
449 s->_max_mask->mask =
450 XCreateBitmapFromData(**display,
451 display->screenInfo(screen)->rootWindow(),
452 data, 7, 7);
453 }
454
455 s->_icon_mask = new PixmapMask();
456 s->_icon_mask->w = s->_icon_mask->h = 7;
457 {
458 char data[] = {0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e };
459 s->_icon_mask->mask =
460 XCreateBitmapFromData(**display,
461 display->screenInfo(screen)->rootWindow(),
462 data, 7, 7);
463 }
464
465 s->_alldesk_mask = new PixmapMask();
466 s->_alldesk_mask->w = s->_alldesk_mask->h = 7;
467 {
468 char data[] = {0x00, 0x36, 0x36, 0x00, 0x36, 0x36, 0x00 };
469 s->_alldesk_mask->mask =
470 XCreateBitmapFromData(**display,
471 display->screenInfo(screen)->rootWindow(),
472 data, 7, 7);
473 }
474
475 s->_close_mask = new PixmapMask();
476 s->_close_mask->w = s->_close_mask->h = 7;
477 {
478 char data[] = { 0x22, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x22 };
479 s->_close_mask->mask =
480 XCreateBitmapFromData(**display,
481 display->screenInfo(screen)->rootWindow(),
482 data, 7, 7);
483 }
484
485 s->_bevel_width = 1;
486 s->_handle_width = 3;
487 # else
488 # error 1
489 # endif
490 #endif
491
492 return true;
493 }
494
495 void RenderStyle::defaultStyle(RenderStyle *s, int screen)
496 {
497 s->_screen = screen;
498 s->_file = "";
499
500 s->_root_args = "#000000";
501 s->_text_color_focus = new RenderColor(screen, 0xffffff);
502 s->_text_color_unfocus = new RenderColor(screen, 0xffffff);
503 s->_button_color_focus = new RenderColor(screen, 0xffffff);
504 s->_button_color_unfocus = new RenderColor(screen, 0xffffff);
505 s->_frame_border_color = new RenderColor(screen, 0);
506 s->_frame_border_width = 1;
507 s->_client_border_color_focus = new RenderColor(screen, 0);
508 s->_client_border_color_unfocus = new RenderColor(screen, 0);
509 s->_client_border_width = 1;
510 s->_titlebar_focus = new RenderTexture(screen,
511 false,
512 RenderTexture::Flat,
513 RenderTexture::Bevel1,
514 false,
515 RenderTexture::Solid,
516 false,
517 0, 0, 0, 0);
518 s->_titlebar_unfocus = new RenderTexture(screen,
519 false,
520 RenderTexture::Flat,
521 RenderTexture::Bevel1,
522 false,
523 RenderTexture::Solid,
524 false,
525 0, 0, 0, 0);
526
527 s->_label_focus = new RenderTexture(screen,
528 false,
529 RenderTexture::Flat,
530 RenderTexture::Bevel1,
531 true,
532 RenderTexture::Solid,
533 false,
534 0, 0, 0, 0);
535 s->_label_unfocus = new RenderTexture(screen,
536 false,
537 RenderTexture::Flat,
538 RenderTexture::Bevel1,
539 false,
540 RenderTexture::Solid,
541 false,
542 0, 0, 0, 0);
543
544 s->_handle_focus = new RenderTexture(screen,
545 false,
546 RenderTexture::Flat,
547 RenderTexture::Bevel1,
548 false,
549 RenderTexture::Solid,
550 false,
551 0, 0, 0, 0);
552 s->_handle_unfocus = new RenderTexture(screen,
553 false,
554 RenderTexture::Flat,
555 RenderTexture::Bevel1,
556 false,
557 RenderTexture::Solid,
558 false,
559 0, 0, 0, 0);
560
561 s->_button_unpress_focus = new RenderTexture(screen,
562 false,
563 RenderTexture::Flat,
564 RenderTexture::Bevel1,
565 false,
566 RenderTexture::Solid,
567 false,
568 0, 0, 0, 0);
569 s->_button_unpress_unfocus = new RenderTexture(screen,
570 false,
571 RenderTexture::Flat,
572 RenderTexture::Bevel1,
573 false,
574 RenderTexture::Solid,
575 false,
576 0, 0, 0, 0);
577
578 s->_button_press_focus = new RenderTexture(screen,
579 false,
580 RenderTexture::Flat,
581 RenderTexture::Bevel1,
582 false,
583 RenderTexture::Solid,
584 false,
585 0, 0, 0, 0);
586 s->_button_press_unfocus = new RenderTexture(screen,
587 false,
588 RenderTexture::Flat,
589 RenderTexture::Bevel1,
590 false,
591 RenderTexture::Solid,
592 false,
593 0, 0, 0, 0);
594
595 s->_grip_focus = new RenderTexture(screen,
596 false,
597 RenderTexture::Flat,
598 RenderTexture::Bevel1,
599 false,
600 RenderTexture::Solid,
601 false,
602 0, 0, 0, 0);
603 s->_grip_unfocus = new RenderTexture(screen,
604 false,
605 RenderTexture::Flat,
606 RenderTexture::Bevel1,
607 false,
608 RenderTexture::Solid,
609 false,
610 0, 0, 0, 0);
611
612 s->_label_font = new Font(screen, "Sans-9", false, 0, 0);
613 s->_label_justify = LeftTopJustify;
614
615 s->_max_mask = new PixmapMask();
616 s->_max_mask->w = s->_max_mask->h = 0;
617 s->_max_mask->mask = None;
618
619 s->_icon_mask = new PixmapMask();
620 s->_icon_mask->w = s->_icon_mask->h = 0;
621 s->_icon_mask->mask = None;
622
623 s->_alldesk_mask = new PixmapMask();
624 s->_alldesk_mask->w = s->_alldesk_mask->h = 0;
625 s->_alldesk_mask->mask = 0;
626
627 s->_close_mask = new PixmapMask();
628 s->_close_mask->w = s->_close_mask->h = 8;
629 s->_close_mask->mask = 0;
630
631 s->_bevel_width = 1;
632 s->_handle_width = 4;
633 }
634
635 RenderStyle::~RenderStyle()
636 {
637 assert(_text_color_focus);
638 delete _text_color_focus;
639 assert(_text_color_unfocus);
640 delete _text_color_unfocus;
641
642 assert(_button_color_focus);
643 delete _button_color_focus;
644 assert(_button_color_unfocus);
645 delete _button_color_unfocus;
646
647 assert(_frame_border_color);
648 delete _frame_border_color;
649
650 assert(_client_border_color_focus);
651 delete _client_border_color_focus;
652 assert(_client_border_color_unfocus);
653 delete _client_border_color_unfocus;
654
655 assert(_titlebar_focus);
656 delete _titlebar_focus;
657 assert(_titlebar_unfocus);
658 delete _titlebar_unfocus;
659
660 assert(_label_focus);
661 delete _label_focus;
662 assert(_label_unfocus);
663 delete _label_unfocus;
664
665 assert(_handle_focus);
666 delete _handle_focus;
667 assert(_handle_unfocus);
668 delete _handle_unfocus;
669
670 assert(_button_unpress_focus);
671 delete _button_unpress_focus;
672 assert(_button_unpress_unfocus);
673 delete _button_unpress_unfocus;
674 assert(_button_press_focus);
675 delete _button_press_focus;
676 assert(_button_press_unfocus);
677 delete _button_press_unfocus;
678
679 assert(_grip_focus);
680 delete _grip_focus;
681 assert(_grip_unfocus);
682 delete _grip_unfocus;
683
684 assert(_label_font);
685 delete _label_font;
686
687 assert(_max_mask);
688 delete _max_mask;
689 assert(_icon_mask);
690 delete _icon_mask;
691 assert(_alldesk_mask);
692 delete _alldesk_mask;
693 assert(_close_mask);
694 delete _close_mask;
695 }
696
697 }
This page took 0.069985 seconds and 5 git commands to generate.