1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
5 #include "renderstyle.hh"
7 #include "screeninfo.hh"
13 RenderStyle
**RenderStyle::_styles
= 0;
14 std::list
<StyleNotify
*> *RenderStyle::_notifies
= 0;
16 void RenderStyle::initialize()
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
);
24 _notifies
= new std::list
<StyleNotify
*>[screens
];
27 void RenderStyle::destroy()
29 int screens
= ScreenCount(**display
);
30 for (int i
= 0; i
< screens
; ++i
)
36 void RenderStyle::registerNotify(int screen
, StyleNotify
*n
)
38 assert(screen
>= 0 && screen
< ScreenCount(**display
));
39 _notifies
[screen
].push_back(n
);
42 void RenderStyle::unregisterNotify(int screen
, StyleNotify
*n
)
44 assert(screen
>= 0 && screen
< ScreenCount(**display
));
45 _notifies
[screen
].remove(n
);
48 RenderStyle
*RenderStyle::style(int screen
)
50 assert(screen
>= 0 && screen
< ScreenCount(**display
));
51 return _styles
[screen
];
54 bool RenderStyle::setStyle(int screen
, const ustring
&stylefile
)
56 RenderStyle
*s
= new RenderStyle();
57 if (!loadStyle(s
, screen
, stylefile
)) {
61 delete _styles
[screen
];
64 std::list
<StyleNotify
*>::iterator it
, end
= _notifies
[screen
].end();
65 for (it
= _notifies
[screen
].begin(); it
!= end
; ++it
)
66 (*it
)->styleChanged(*s
);
70 bool RenderStyle::loadStyle(RenderStyle
*s
, int screen
,
71 const ustring
&stylefile
)
80 s
->_root_args
= "#272a2f";
82 s
->_text_color_focus
= new RenderColor(screen
, 0x272a2f);
83 s
->_text_color_unfocus
= new RenderColor(screen
, 0x676869);
85 s
->_button_color_focus
= new RenderColor(screen
, 0x96ba86);
86 s
->_button_color_unfocus
= new RenderColor(screen
, 0x676869);
88 s
->_frame_border_color
= new RenderColor(screen
, 0x181f24);
89 s
->_frame_border_width
= 1;
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;
95 s
->_titlebar_focus
= new RenderTexture(screen
,
98 RenderTexture::Bevel1
,
100 RenderTexture::Vertical
,
106 s
->_titlebar_unfocus
= new RenderTexture(screen
,
109 RenderTexture::Bevel1
,
111 RenderTexture::Vertical
,
118 s
->_label_focus
= new RenderTexture(screen
,
121 RenderTexture::Bevel1
,
123 RenderTexture::Vertical
,
129 s
->_label_unfocus
= new RenderTexture(screen
,
131 RenderTexture::Sunken
,
132 RenderTexture::Bevel1
,
134 RenderTexture::CrossDiagonal
,
141 s
->_handle_focus
= new RenderTexture(screen
,
144 RenderTexture::Bevel1
,
146 RenderTexture::Vertical
,
152 s
->_handle_unfocus
= new RenderTexture(screen
,
155 RenderTexture::Bevel1
,
157 RenderTexture::Vertical
,
164 s
->_button_unpress_focus
= new RenderTexture(screen
,
166 RenderTexture::Raised
,
167 RenderTexture::Bevel2
,
169 RenderTexture::CrossDiagonal
,
175 s
->_button_unpress_unfocus
= new RenderTexture(screen
,
177 RenderTexture::Raised
,
178 RenderTexture::Bevel2
,
180 RenderTexture::CrossDiagonal
,
187 s
->_button_press_focus
= new RenderTexture(screen
,
189 RenderTexture::Sunken
,
190 RenderTexture::Bevel2
,
192 RenderTexture::CrossDiagonal
,
198 s
->_button_press_unfocus
= new RenderTexture(screen
,
200 RenderTexture::Sunken
,
201 RenderTexture::Bevel2
,
203 RenderTexture::CrossDiagonal
,
210 s
->_grip_focus
= new RenderTexture(screen
,
213 RenderTexture::Bevel1
,
215 RenderTexture::Vertical
,
221 s
->_grip_unfocus
= new RenderTexture(screen
,
224 RenderTexture::Bevel1
,
226 RenderTexture::Vertical
,
233 s
->_label_font
= new Font(screen
, "Arial,Sans-9:bold", true, 1, 0x40);
234 s
->_label_justify
= RightBottomJustify
;
236 s
->_max_mask
= new PixmapMask();
237 s
->_max_mask
->w
= s
->_max_mask
->h
= 8;
239 //char data[] = { 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0x7e };
240 char data
[] = {0x00, 0x00, 0x18, 0x3c, 0x66, 0x42, 0x00, 0x00 };
242 XCreateBitmapFromData(**display
,
243 display
->screenInfo(screen
)->rootWindow(),
247 s
->_icon_mask
= new PixmapMask();
248 s
->_icon_mask
->w
= s
->_icon_mask
->h
= 8;
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(),
258 s
->_alldesk_mask
= new PixmapMask();
259 s
->_alldesk_mask
->w
= s
->_alldesk_mask
->h
= 8;
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(),
269 s
->_close_mask
= new PixmapMask();
270 s
->_close_mask
->w
= s
->_close_mask
->h
= 8;
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(),
281 s
->_handle_width
= 4;
284 s
->_root_args
= "#7b756a";
286 s
->_text_color_focus
= new RenderColor(screen
, 0xffffff);
287 s
->_text_color_unfocus
= new RenderColor(screen
, 0xffffff);
289 s
->_button_color_focus
= new RenderColor(screen
, 0x222222);
290 s
->_button_color_unfocus
= new RenderColor(screen
, 0x333333);
292 s
->_frame_border_color
= new RenderColor(screen
, 0x222222);
293 s
->_frame_border_width
= 1;
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;
299 s
->_titlebar_focus
= new RenderTexture(screen
,
302 RenderTexture::Bevel1
,
304 RenderTexture::Solid
,
310 s
->_titlebar_unfocus
= new RenderTexture(screen
,
313 RenderTexture::Bevel1
,
315 RenderTexture::Solid
,
322 s
->_label_focus
= new RenderTexture(screen
,
325 RenderTexture::Bevel1
,
327 RenderTexture::Vertical
,
335 //urg this ain't so hot
336 s
->_label_unfocus
= new RenderTexture(screen
,
339 RenderTexture::Bevel1
,
341 RenderTexture::Vertical
,
349 s
->_handle_focus
= new RenderTexture(screen
,
352 RenderTexture::Bevel1
,
354 RenderTexture::Vertical
,
360 s
->_handle_unfocus
= new RenderTexture(screen
,
363 RenderTexture::Bevel1
,
365 RenderTexture::Solid
,
373 s
->_button_unpress_focus
= new RenderTexture(screen
,
376 RenderTexture::Bevel1
,
378 RenderTexture::Solid
,
384 s
->_button_unpress_unfocus
= new RenderTexture(screen
,
387 RenderTexture::Bevel1
,
389 RenderTexture::Solid
,
396 s
->_button_press_focus
= new RenderTexture(screen
,
398 RenderTexture::Sunken
,
399 RenderTexture::Bevel2
,
401 RenderTexture::Vertical
,
407 s
->_button_press_unfocus
= new RenderTexture(screen
,
409 RenderTexture::Sunken
,
410 RenderTexture::Bevel2
,
412 RenderTexture::Vertical
,
419 s
->_grip_focus
= new RenderTexture(screen
,
422 RenderTexture::Bevel1
,
424 RenderTexture::Vertical
,
430 s
->_grip_unfocus
= new RenderTexture(screen
,
433 RenderTexture::Bevel1
,
435 RenderTexture::Solid
,
442 s
->_label_font
= new Font(screen
, "Arial,Sans-8", true, 1, 0x3e);
443 s
->_label_justify
= CenterJustify
;
445 s
->_max_mask
= new PixmapMask();
446 s
->_max_mask
->w
= s
->_max_mask
->h
= 7;
448 char data
[] = {0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f };
450 XCreateBitmapFromData(**display
,
451 display
->screenInfo(screen
)->rootWindow(),
455 s
->_icon_mask
= new PixmapMask();
456 s
->_icon_mask
->w
= s
->_icon_mask
->h
= 7;
458 char data
[] = {0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e };
459 s
->_icon_mask
->mask
=
460 XCreateBitmapFromData(**display
,
461 display
->screenInfo(screen
)->rootWindow(),
465 s
->_alldesk_mask
= new PixmapMask();
466 s
->_alldesk_mask
->w
= s
->_alldesk_mask
->h
= 7;
468 char data
[] = {0x00, 0x36, 0x36, 0x00, 0x36, 0x36, 0x00 };
469 s
->_alldesk_mask
->mask
=
470 XCreateBitmapFromData(**display
,
471 display
->screenInfo(screen
)->rootWindow(),
475 s
->_close_mask
= new PixmapMask();
476 s
->_close_mask
->w
= s
->_close_mask
->h
= 7;
478 char data
[] = { 0x22, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x22 };
479 s
->_close_mask
->mask
=
480 XCreateBitmapFromData(**display
,
481 display
->screenInfo(screen
)->rootWindow(),
486 s
->_handle_width
= 3;
495 void RenderStyle::defaultStyle(RenderStyle
*s
, int screen
)
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
, 0);
504 s
->_button_color_unfocus
= new RenderColor(screen
, 0);
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
,
513 RenderTexture::Bevel1
,
515 RenderTexture::Solid
,
518 s
->_titlebar_unfocus
= new RenderTexture(screen
,
521 RenderTexture::Bevel1
,
523 RenderTexture::Solid
,
527 s
->_label_focus
= new RenderTexture(screen
,
530 RenderTexture::Bevel1
,
532 RenderTexture::Solid
,
535 s
->_label_unfocus
= new RenderTexture(screen
,
538 RenderTexture::Bevel1
,
540 RenderTexture::Solid
,
544 s
->_handle_focus
= new RenderTexture(screen
,
547 RenderTexture::Bevel1
,
549 RenderTexture::Solid
,
552 s
->_handle_unfocus
= new RenderTexture(screen
,
555 RenderTexture::Bevel1
,
557 RenderTexture::Solid
,
561 s
->_button_unpress_focus
= new RenderTexture(screen
,
564 RenderTexture::Bevel1
,
566 RenderTexture::Solid
,
569 s
->_button_unpress_unfocus
= new RenderTexture(screen
,
572 RenderTexture::Bevel1
,
574 RenderTexture::Solid
,
578 s
->_button_press_focus
= new RenderTexture(screen
,
581 RenderTexture::Bevel1
,
583 RenderTexture::Solid
,
586 s
->_button_press_unfocus
= new RenderTexture(screen
,
589 RenderTexture::Bevel1
,
591 RenderTexture::Solid
,
595 s
->_grip_focus
= new RenderTexture(screen
,
598 RenderTexture::Bevel1
,
600 RenderTexture::Solid
,
603 s
->_grip_unfocus
= new RenderTexture(screen
,
606 RenderTexture::Bevel1
,
608 RenderTexture::Solid
,
612 s
->_label_font
= new Font(screen
, "Sans-9", false, 0, 0);
613 s
->_label_justify
= LeftTopJustify
;
615 s
->_max_mask
= new PixmapMask();
616 s
->_max_mask
->w
= s
->_max_mask
->h
= 0;
617 s
->_max_mask
->mask
= None
;
619 s
->_icon_mask
= new PixmapMask();
620 s
->_icon_mask
->w
= s
->_icon_mask
->h
= 0;
621 s
->_icon_mask
->mask
= None
;
623 s
->_alldesk_mask
= new PixmapMask();
624 s
->_alldesk_mask
->w
= s
->_alldesk_mask
->h
= 0;
625 s
->_alldesk_mask
->mask
= 0;
627 s
->_close_mask
= new PixmapMask();
628 s
->_close_mask
->w
= s
->_close_mask
->h
= 8;
629 s
->_close_mask
->mask
= 0;
632 s
->_handle_width
= 4;
635 RenderStyle::~RenderStyle()
637 assert(_text_color_focus
);
638 delete _text_color_focus
;
639 assert(_text_color_unfocus
);
640 delete _text_color_unfocus
;
642 assert(_button_color_focus
);
643 delete _button_color_focus
;
644 assert(_button_color_unfocus
);
645 delete _button_color_unfocus
;
647 assert(_frame_border_color
);
648 delete _frame_border_color
;
650 assert(_client_border_color_focus
);
651 delete _client_border_color_focus
;
652 assert(_client_border_color_unfocus
);
653 delete _client_border_color_unfocus
;
655 assert(_titlebar_focus
);
656 delete _titlebar_focus
;
657 assert(_titlebar_unfocus
);
658 delete _titlebar_unfocus
;
660 assert(_label_focus
);
662 assert(_label_unfocus
);
663 delete _label_unfocus
;
665 assert(_handle_focus
);
666 delete _handle_focus
;
667 assert(_handle_unfocus
);
668 delete _handle_unfocus
;
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
;
681 assert(_grip_unfocus
);
682 delete _grip_unfocus
;
691 assert(_alldesk_mask
);
692 delete _alldesk_mask
;