maximizing!
[dana/openbox.git] / otk / renderstyle.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef    HAVE_CONFIG_H
4 #  include "../config.h"
5 #endif // HAVE_CONFIG_H
6
7 #include "renderstyle.hh"
8 #include "display.hh"
9 #include "screeninfo.hh"
10
11 namespace otk {
12
13 RenderStyle::RenderStyle(int screen, const std::string &stylefile)
14   : _screen(screen),
15     _file(stylefile)
16 {
17 // pick one..
18 //#define FIERON
19 #define MERRY
20
21 #ifdef FIERON
22   _root_color = new RenderColor(_screen, 0x272a2f);
23   
24   _text_color_focus = new RenderColor(_screen, 0x272a2f);
25   _text_color_unfocus = new RenderColor(_screen, 0x676869);
26
27   _button_color_focus = new RenderColor(_screen, 0x96ba86);
28   _button_color_unfocus = new RenderColor(_screen, 0x676869);
29
30   _frame_border_color = new RenderColor(_screen, 0x181f24);
31   _frame_border_width = 1;
32
33   _client_border_color_focus = new RenderColor(_screen, 0x858687);
34   _client_border_color_unfocus = new RenderColor(_screen, 0x555657);
35   _client_border_width = 1;
36
37   _titlebar_focus = new RenderTexture(_screen,
38                                       false,
39                                       RenderTexture::Flat,
40                                       RenderTexture::Bevel1,
41                                       false,
42                                       RenderTexture::Vertical,
43                                       false,
44                                       0x858687,
45                                       0x373a3f,
46                                       0x0,
47                                       0x0);
48   _titlebar_unfocus = new RenderTexture(_screen,
49                                         false,
50                                         RenderTexture::Flat,
51                                         RenderTexture::Bevel1,
52                                         false,
53                                         RenderTexture::Vertical,
54                                         false,
55                                         0x555657,
56                                         0x171a1f,
57                                         0x0,
58                                         0x0);
59
60   _label_focus = new RenderTexture(_screen,
61                                    false,
62                                    RenderTexture::Flat,
63                                    RenderTexture::Bevel1,
64                                    true,
65                                    RenderTexture::Vertical,
66                                    false,
67                                    0x96ba86,
68                                    0x5a724c,
69                                    0x181f24,
70                                    0x0);
71   _label_unfocus = new RenderTexture(_screen,
72                                      false,
73                                      RenderTexture::Sunken,
74                                      RenderTexture::Bevel1,
75                                      false,
76                                      RenderTexture::CrossDiagonal,
77                                      false,
78                                      0x555657,
79                                      0x272a2f,
80                                      0x0,
81                                      0x0);
82
83
84   _handle_focus = new RenderTexture(_screen,
85                                     false,
86                                     RenderTexture::Flat,
87                                     RenderTexture::Bevel1,
88                                     false,
89                                     RenderTexture::Vertical,
90                                     false,
91                                     0x858687,
92                                     0x373a3f,
93                                     0x0,
94                                     0x0);
95   _handle_unfocus = new RenderTexture(_screen,
96                                       false,
97                                       RenderTexture::Flat,
98                                       RenderTexture::Bevel1,
99                                       false,
100                                       RenderTexture::Vertical,
101                                       false,
102                                       0x555657,
103                                       0x171a1f,
104                                       0x0,
105                                       0x0);
106
107   
108   _button_unpress_focus = new RenderTexture(_screen,
109                                             false,
110                                             RenderTexture::Raised,
111                                             RenderTexture::Bevel2,
112                                             false,
113                                             RenderTexture::CrossDiagonal,
114                                             false,
115                                             0x858687,
116                                             0x272a2f,
117                                             0x0,
118                                             0x0);
119   _button_unpress_unfocus = new RenderTexture(_screen,
120                                               false,
121                                               RenderTexture::Raised,
122                                               RenderTexture::Bevel2,
123                                               false,
124                                               RenderTexture::CrossDiagonal,
125                                               false,
126                                               0x555657,
127                                               0x171a1f,
128                                               0x0,
129                                               0x0);
130
131   _button_press_focus = new RenderTexture(_screen,
132                                           false,
133                                           RenderTexture::Sunken,
134                                           RenderTexture::Bevel2,
135                                           false,
136                                           RenderTexture::CrossDiagonal,
137                                           false,
138                                           0x96ba86,
139                                           0x5a724c,
140                                           0x0,
141                                           0x0);
142   _button_press_unfocus = new RenderTexture(_screen,
143                                             false,
144                                             RenderTexture::Sunken,
145                                             RenderTexture::Bevel2,
146                                             false,
147                                             RenderTexture::CrossDiagonal,
148                                             false,
149                                             0x555657,
150                                             0x171a1f,
151                                             0x0,
152                                             0x0);
153
154   _grip_focus = new RenderTexture(_screen,
155                                   false,
156                                   RenderTexture::Flat,
157                                   RenderTexture::Bevel1,
158                                   false,
159                                   RenderTexture::Vertical,
160                                   false,
161                                   0x96ba86,
162                                   0x5a724c,
163                                   0x0,
164                                   0x0);
165   _grip_unfocus = new RenderTexture(_screen,
166                                     false,
167                                     RenderTexture::Flat,
168                                     RenderTexture::Bevel1,
169                                     false,
170                                     RenderTexture::Vertical,
171                                     false,
172                                     0x555657,
173                                     0x171a1f,
174                                     0x0,
175                                     0x0);
176
177   _label_font = new Font(_screen, "Arial,Sans-9:bold", true, 1, 0x40);
178   _label_justify = RightJustify;
179
180   _max_mask = new PixmapMask();
181   _max_mask->w = _max_mask->h = 8;
182   {
183     //char data[] = { 0x7e, 0xff, 0xc3, 0xc3, 0xc3, 0xc3, 0xff, 0x7e };
184     char data []  = {0x00, 0x00, 0x18, 0x3c, 0x66, 0x42, 0x00, 0x00 };
185     _max_mask->mask =
186       XCreateBitmapFromData(**display,
187                             display->screenInfo(_screen)->rootWindow(),
188                             data, 8, 8);
189   }
190
191   _icon_mask = new PixmapMask();
192   _icon_mask->w = _icon_mask->h = 8;
193   {
194     //char data[] = { 0x00, 0x00, 0xc3, 0xe7, 0x7e, 0x3c, 0x18, 0x00 };
195     char data[] = { 0x00, 0x00, 0x42, 0x66, 0x3c, 0x18, 0x00, 0x00 };
196     _icon_mask->mask =
197       XCreateBitmapFromData(**display,
198                             display->screenInfo(_screen)->rootWindow(),
199                             data, 8, 8);
200   }
201   
202   _alldesk_mask = new PixmapMask();
203   _alldesk_mask->w = _alldesk_mask->h = 8;
204   {
205     //char data[] = { 0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00 };
206     char data[] = { 0x00, 0x66, 0x66, 0x00, 0x00, 0x66, 0x66, 0x00 };
207     _alldesk_mask->mask =
208       XCreateBitmapFromData(**display,
209                             display->screenInfo(_screen)->rootWindow(),
210                             data, 8, 8);
211   }
212   
213   _close_mask = new PixmapMask();
214   _close_mask->w = _close_mask->h = 8;
215   {
216     //char data[] = { 0xc3, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0xc3 };
217     char data[] = { 0x00, 0xc3, 0x66, 0x3c, 0x3c, 0x66, 0xc3, 0x00 };
218     _close_mask->mask =
219       XCreateBitmapFromData(**display,
220                             display->screenInfo(_screen)->rootWindow(),
221                             data, 8, 8);
222   }
223
224   _bevel_width = 1;
225   _handle_width = 4;
226 #else
227 #  ifdef MERRY
228   _root_color = new RenderColor(_screen, 0x7b756a);
229   
230   _text_color_focus = new RenderColor(_screen, 0xffffff);
231   _text_color_unfocus = new RenderColor(_screen, 0xffffff);
232
233   _button_color_focus = new RenderColor(_screen, 0x222222);
234   _button_color_unfocus = new RenderColor(_screen, 0x333333);
235
236   _frame_border_color = new RenderColor(_screen, 0x222222);
237   _frame_border_width = 1;
238
239   _client_border_color_focus = new RenderColor(_screen, 0x858687);
240   _client_border_color_unfocus = new RenderColor(_screen, 0x555657);
241   _client_border_width = 0;
242
243   _titlebar_focus = new RenderTexture(_screen,
244                                       false,
245                                       RenderTexture::Flat,
246                                       RenderTexture::Bevel1,
247                                       false,
248                                       RenderTexture::Solid,
249                                       false,
250                                       0xe6e6e6,
251                                       0xe6e6e6,  
252                                       0x0,
253                                       0x0);
254   _titlebar_unfocus = new RenderTexture(_screen,
255                                         false,
256                                         RenderTexture::Flat,
257                                         RenderTexture::Bevel1,
258                                         false,
259                                         RenderTexture::Solid,
260                                         false,
261                                         0xe6e6e6,
262                                         0xe6e6e6,
263                                         0x0,
264                                         0x0);
265
266   _label_focus = new RenderTexture(_screen,
267                                    false,
268                                    RenderTexture::Flat,
269                                    RenderTexture::Bevel1,
270                                    true,
271                                    RenderTexture::Solid,
272                                    false,
273                                    //0x6a6973,
274                                    //0x6a6973,
275                                    0x4c59a6,
276                                    0x4c59a6,
277                                    0x222222,
278                                    0x0);
279   _label_unfocus = new RenderTexture(_screen,
280                                         false,
281                                    RenderTexture::Flat,
282                                    RenderTexture::Bevel1,
283                                    true,
284                                    RenderTexture::Solid,
285                                    false,
286                                    0xcdcac7,
287                                    0xcdcac7,
288                                 0xb0ada9,
289                                    0x0);
290
291
292   _handle_focus = new RenderTexture(_screen,
293                                     false,
294                                     RenderTexture::Flat,
295                                     RenderTexture::Bevel1,
296                                     false,
297                                     RenderTexture::Solid,
298                                     false,
299                                     0xe6e6e6,
300                                         0xe6e6e6,
301                                     0x0,
302                                     0x0);
303   _handle_unfocus = new RenderTexture(_screen,
304                                       false,
305                                       RenderTexture::Flat,
306                                       RenderTexture::Bevel1,
307                                       false,
308                                       RenderTexture::Solid,
309                                       false,
310                                      0xe6e6e6,
311                                         0xe6e6e6,
312                                       0x0,
313                                       0x0);
314
315   
316   _button_unpress_focus = new RenderTexture(_screen,
317                                             false,
318                                             RenderTexture::Flat,
319                                             RenderTexture::Bevel1,
320                                             false,
321                                             RenderTexture::Solid,
322                                             false,
323                                             0xe6e6e6,
324                                         0xe6e6e6,
325                                             0x0,
326                                             0x0);
327   _button_unpress_unfocus = new RenderTexture(_screen,
328                                               false,
329                                               RenderTexture::Flat,
330                                               RenderTexture::Bevel1,
331                                               false,
332                                               RenderTexture::Solid,
333                                               false,
334                                              0xe6e6e6,
335                                         0xe6e6e6,
336                                               0x0,
337                                               0x0);
338
339   _button_press_focus = new RenderTexture(_screen,
340                                           false,
341                                             RenderTexture::Sunken,
342                                             RenderTexture::Bevel1,
343                                           false,
344                                           RenderTexture::Solid,
345                                           false,
346                                           0xe6e6e6,
347                                           0xe6e6e6,
348                                           0x0,
349                                           0x0);
350   _button_press_unfocus = new RenderTexture(_screen,
351                                             false,
352                                               RenderTexture::Sunken,
353                                             RenderTexture::Bevel1,
354                                             false,
355                                             RenderTexture::Solid,
356                                             false,
357                                               0xe6e6e6,
358                                         0xe6e6e6,
359                                             0x0,
360                                             0x0);
361
362   _grip_focus = new RenderTexture(_screen,
363                                   false,
364                                   RenderTexture::Flat,
365                                   RenderTexture::Bevel1,
366                                   false,
367                                   RenderTexture::Solid,
368                                   false,
369                                     0xe6e6e6,
370                                         0xe6e6e6,
371                                   0x0,
372                                   0x0);
373   _grip_unfocus = 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
385   _label_font = new Font(_screen, "Arial,Sans-8", true, 1, 0x3e);
386   _label_justify = CenterJustify;
387
388   _max_mask = new PixmapMask();
389   _max_mask->w = _max_mask->h = 7;
390   {
391     char data []  = {0x7c, 0x44, 0x47, 0x47, 0x7f, 0x1f, 0x1f  };
392     _max_mask->mask =
393       XCreateBitmapFromData(**display,
394                             display->screenInfo(_screen)->rootWindow(),
395                             data, 7, 7);
396   }
397
398   _icon_mask = new PixmapMask();
399   _icon_mask->w = _icon_mask->h = 7;
400   {
401     char data[] = {0x00, 0x00, 0x00, 0x00, 0x3e, 0x3e, 0x3e };
402     _icon_mask->mask =
403       XCreateBitmapFromData(**display,
404                             display->screenInfo(_screen)->rootWindow(),
405                             data, 7, 7);
406   }
407   
408   _alldesk_mask = new PixmapMask();
409   _alldesk_mask->w = _alldesk_mask->h = 7;
410   {
411     char data[] = {0x00, 0x36, 0x36, 0x00, 0x36, 0x36, 0x00 };
412     _alldesk_mask->mask =
413       XCreateBitmapFromData(**display,
414                             display->screenInfo(_screen)->rootWindow(),
415                             data, 7, 7);
416   }
417   
418   _close_mask = new PixmapMask();
419   _close_mask->w = _close_mask->h = 7;
420   {
421     char data[] = {  0x22, 0x77, 0x3e, 0x1c, 0x3e, 0x77, 0x22 };
422     _close_mask->mask =
423       XCreateBitmapFromData(**display,
424                             display->screenInfo(_screen)->rootWindow(),
425                             data, 7, 7);
426   }
427
428   _bevel_width = 1;
429   _handle_width = 3;
430 #  else
431 #    error 1
432 #  endif
433 #endif
434 }
435
436 RenderStyle::~RenderStyle()
437 {
438   delete _root_color;
439   
440   delete _text_color_focus;
441   delete _text_color_unfocus;
442
443   delete _button_color_focus;
444   delete _button_color_unfocus;
445
446   delete _frame_border_color;
447
448   delete _client_border_color_focus; 
449   delete _client_border_color_unfocus;
450  
451   delete _titlebar_focus;
452   delete _titlebar_unfocus;
453
454   delete _label_focus;
455   delete _label_unfocus;
456
457   delete _handle_focus;
458   delete _handle_unfocus;
459
460   delete _button_unpress_focus;
461   delete _button_unpress_unfocus;
462   delete _button_press_focus;
463   delete _button_press_unfocus;
464
465   delete _grip_focus;
466   delete _grip_unfocus;
467
468   delete _label_font;
469
470   delete _max_mask;
471   delete _icon_mask;
472   delete _alldesk_mask;
473   delete _close_mask;
474 }
475
476 }