1 /* Murrine theme engine
2  * Copyright (C) 2006-2007-2008-2009 Andrea Cimitan
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  *
19  */
20 
21 #ifndef MURRINE_TYPES_H
22 #define MURRINE_TYPES_H
23 
24 typedef unsigned char boolean;
25 typedef unsigned char uint8;
26 typedef struct _MurrineStyleFunctions MurrineStyleFunctions;
27 
28 typedef enum
29 {
30 	MRN_STYLE_MURRINE = 0,
31 	MRN_STYLE_RGBA = 1,
32 	MRN_NUM_DRAW_STYLES = 2
33 } MurrineStyles;
34 
35 typedef enum
36 {
37 	MRN_STATE_NORMAL,
38 	MRN_STATE_ACTIVE,
39 	MRN_STATE_SELECTED,
40 	MRN_STATE_INSENSITIVE
41 } MurrineStateType;
42 
43 typedef enum
44 {
45 	MRN_CORNER_NONE        = 0,
46 	MRN_CORNER_TOPLEFT     = 1,
47 	MRN_CORNER_TOPRIGHT    = 2,
48 	MRN_CORNER_BOTTOMLEFT  = 4,
49 	MRN_CORNER_BOTTOMRIGHT = 8,
50 	MRN_CORNER_ALL         = 15
51 } MurrineCorners;
52 
53 typedef enum
54 {
55 	MRN_JUNCTION_NONE      = 0,
56 	MRN_JUNCTION_BEGIN     = 1,
57 	MRN_JUNCTION_END       = 2
58 } MurrineJunction;
59 
60 typedef enum
61 {
62 	MRN_CONT_NONE          = 0,
63 	MRN_CONT_LEFT          = 1 << 0,
64 	MRN_CONT_RIGHT         = 1 << 1
65 } MurrineContinue;
66 
67 typedef enum
68 {
69 	MRN_STEPPER_UNKNOWN    = 0,
70 	MRN_STEPPER_A          = 1,
71 	MRN_STEPPER_B          = 2,
72 	MRN_STEPPER_C          = 4,
73 	MRN_STEPPER_D          = 8
74 } MurrineStepper;
75 
76 typedef enum
77 {
78 	MRN_ORDER_FIRST = 1 << 0,
79 	MRN_ORDER_LAST = 1 << 1
80 } MurrineOrder;
81 
82 typedef enum
83 {
84 	MRN_ORIENTATION_LEFT_TO_RIGHT,
85 	MRN_ORIENTATION_RIGHT_TO_LEFT,
86 	MRN_ORIENTATION_BOTTOM_TO_TOP,
87 	MRN_ORIENTATION_TOP_TO_BOTTOM
88 } MurrineOrientation;
89 
90 typedef enum
91 {
92 	MRN_GAP_LEFT,
93 	MRN_GAP_RIGHT,
94 	MRN_GAP_TOP,
95 	MRN_GAP_BOTTOM
96 } MurrineGapSide;
97 
98 typedef enum
99 {
100 	MRN_SHADOW_NONE,
101 	MRN_SHADOW_IN,
102 	MRN_SHADOW_OUT,
103 	MRN_SHADOW_ETCHED_IN,
104 	MRN_SHADOW_ETCHED_OUT,
105 	MRN_SHADOW_FLAT
106 } MurrineShadowType;
107 
108 typedef enum
109 {
110 	MRN_HANDLE_TOOLBAR,
111 	MRN_HANDLE_SPLITTER
112 } MurrineHandleType;
113 
114 typedef enum
115 {
116 	MRN_ARROW_NORMAL,
117 	MRN_ARROW_COMBO
118 } MurrineArrowType;
119 
120 typedef enum
121 {
122 	MRN_FOCUS_BUTTON,
123 	MRN_FOCUS_BUTTON_DEFAULT,
124 	MRN_FOCUS_BUTTON_FLAT,
125 	MRN_FOCUS_LABEL,
126 	MRN_FOCUS_TREEVIEW,
127 	MRN_FOCUS_TREEVIEW_HEADER,
128 	MRN_FOCUS_TREEVIEW_ROW,
129 	MRN_FOCUS_TREEVIEW_DND,
130 	MRN_FOCUS_SCALE,
131 	MRN_FOCUS_TAB,
132 	MRN_FOCUS_COLOR_WHEEL_DARK,
133 	MRN_FOCUS_COLOR_WHEEL_LIGHT,
134 	MRN_FOCUS_ICONVIEW,
135 	MRN_FOCUS_UNKNOWN
136 } MurrineFocusType;
137 
138 typedef enum
139 {
140 	MRN_DIRECTION_UP,
141 	MRN_DIRECTION_DOWN,
142 	MRN_DIRECTION_LEFT,
143 	MRN_DIRECTION_RIGHT
144 } MurrineDirection;
145 
146 typedef enum
147 {
148 	MRN_WINDOW_EDGE_NORTH_WEST,
149 	MRN_WINDOW_EDGE_NORTH,
150 	MRN_WINDOW_EDGE_NORTH_EAST,
151 	MRN_WINDOW_EDGE_WEST,
152 	MRN_WINDOW_EDGE_EAST,
153 	MRN_WINDOW_EDGE_SOUTH_WEST,
154 	MRN_WINDOW_EDGE_SOUTH,
155 	MRN_WINDOW_EDGE_SOUTH_EAST
156 } MurrineWindowEdge;
157 
158 typedef struct
159 {
160 	double r;
161 	double g;
162 	double b;
163 } MurrineRGB;
164 
165 typedef struct
166 {
167 	double x;
168 	double y;
169 	double width;
170 	double height;
171 } MurrineRectangle;
172 
173 typedef struct
174 {
175 	MurrineRGB bg[5];
176 	MurrineRGB base[5];
177 	MurrineRGB text[5];
178 	MurrineRGB fg[5];
179 
180 	MurrineRGB shade[9];
181 	MurrineRGB spot[3];
182 } MurrineColors;
183 
184 typedef struct
185 {
186 	double  border_shades[2];
187 	double  gradient_shades[4];
188 	double  shadow_shades[2];
189 	double  trough_border_shades[2];
190 	double  trough_shades[2];
191 	double  rgba_opacity;
192 
193 	MurrineRGB border_colors[2];
194 	MurrineRGB gradient_colors[4];
195 
196 	boolean has_border_colors;
197 	boolean gradients;
198 	boolean has_gradient_colors;
199 	boolean use_rgba;
200 } MurrineGradients;
201 
202 typedef struct
203 {
204 	MurrineArrowType type;
205 	MurrineDirection direction;
206 	int style;
207 } ArrowParameters;
208 
209 typedef struct
210 {
211 	MurrineRGB default_button_color;
212 	boolean    has_default_button_color;
213 } ButtonParameters;
214 
215 typedef struct
216 {
217 	int style;
218 } CellParameters;
219 
220 typedef struct
221 {
222 	MurrineShadowType shadow_type;
223 	boolean           in_cell;
224 	boolean           in_menu;
225 } CheckboxParameters;
226 
227 typedef struct
228 {
229 	boolean as_list;
230 	int     box_w;
231 	int     style;
232 	double  prelight_shade;
233 } ComboBoxParameters;
234 
235 typedef struct
236 {
237 	/* The maximum size of the fill. Calcualted from the entries allocation,
238 	 * and other information. Relative to the drawn position.
239 	 */
240 	GdkRectangle max_size;
241 	gboolean max_size_known;
242 	/* The border around the bar. This can be used for radius calculations.
243 	 */
244 	GtkBorder border;
245 } EntryProgressParameters;
246 
247 typedef struct
248 {
249 	boolean in_treeview;
250 	int arrowstyle;
251 	int size;
252 	int style;
253 	GtkExpanderStyle expander_style;
254 	GtkTextDirection text_direction;
255 } ExpanderParameters;
256 
257 typedef struct
258 {
259 	MurrineFocusType    type;
260 	MurrineContinue     continue_side;
261 	MurrineRGB          color;
262 	boolean             has_color;
263 	gint                line_width;
264 	gint                padding;
265 	guint8*             dash_list;
266 	boolean             interior;
267 	int                 style;
268 } FocusParameters;
269 
270 typedef struct
271 {
272 	MurrineShadowType shadow;
273 	MurrineGapSide    gap_side;
274 	int               gap_x;
275 	int               gap_width;
276 	MurrineRGB       *border;
277 } FrameParameters;
278 
279 typedef struct
280 {
281 	MurrineHandleType type;
282 	boolean           horizontal;
283 	int               style;
284 } HandleParameters;
285 
286 typedef struct
287 {
288 	MurrineOrder   order;
289 	boolean        resizable;
290 	int            style;
291 } ListViewHeaderParameters;
292 
293 typedef struct
294 {
295 	int linepos;
296 } OptionMenuParameters;
297 
298 typedef struct
299 {
300 	MurrineOrientation orientation;
301 	int style;
302 } ProgressBarParameters;
303 
304 typedef struct
305 {
306 	MurrineWindowEdge edge;
307 } ResizeGripParameters;
308 
309 typedef struct
310 {
311 	MurrineRGB      color;
312 	MurrineJunction junction; /* On which sides the slider junctions */
313 	MurrineStepper  steppers; /* The visible steppers */
314 	boolean         horizontal;
315 	boolean         has_color;
316 	boolean         within_bevel;
317 	int             handlestyle;
318 	int             style;
319 	int             steppersize;
320 	int             stepperstyle;
321 	double          prelight_shade;
322 } ScrollBarParameters;
323 
324 typedef struct
325 {
326 	MurrineStepper stepper; /* Which stepper to draw */
327 } ScrollBarStepperParameters;
328 
329 typedef struct
330 {
331 	boolean horizontal;
332 	boolean use_rgba;
333 	int     style;
334 } SeparatorParameters;
335 
336 typedef struct
337 {
338 	MurrineCorners    corners;
339 	MurrineShadowType shadow;
340 } ShadowParameters;
341 
342 typedef struct
343 {
344 	boolean lower;
345 	boolean horizontal;
346 	boolean fill_level;
347 } SliderParameters;
348 
349 typedef struct
350 {
351 	int style;
352 } SpinbuttonParameters;
353 
354 typedef struct
355 {
356 	MurrineGapSide gap_side;
357 } TabParameters;
358 
359 typedef struct
360 {
361 	boolean topmost;
362 	int     style;
363 } ToolbarParameters;
364 
365 typedef struct
366 {
367 	boolean active;
368 	boolean prelight;
369 	boolean disabled;
370 	boolean ltr;
371 	boolean focus;
372 	boolean is_default;
373 	MurrineStateType state_type;
374 	uint8 corners;
375 	uint8 xthickness;
376 	uint8 ythickness;
377 	MurrineRGB parentbg;
378 
379 	/* Style */
380 	int glazestyle;
381 	int glowstyle;
382 	int lightborderstyle;
383 	int reliefstyle;
384 	int roundness;
385 	double contrast;
386 	double glow_shade;
387 	double highlight_shade;
388 	double lightborder_shade;
389 	MurrineGradients mrn_gradient;
390 
391 	MurrineStyles style;
392 	MurrineStyleFunctions *style_functions;
393 } WidgetParameters;
394 
395 struct _MurrineStyleFunctions
396 {
397 	void (*draw_button) (cairo_t *cr,
398 	                     const MurrineColors    *colors,
399 	                     const WidgetParameters *widget,
400 	                     const ButtonParameters *button,
401 	                     int x, int y, int width, int height,
402 	                     boolean vertical);
403 
404 	void (*draw_combobox) (cairo_t *cr,
405 	                       MurrineColors    colors,
406 	                       WidgetParameters widget,
407 	                       const ComboBoxParameters *combobox,
408 	                       int x, int y, int width, int height,
409 	                       boolean vertical);
410 
411 	void (*draw_scale_trough) (cairo_t *cr,
412 	                           const MurrineColors    *colors,
413 	                           const WidgetParameters *widget,
414 	                           const SliderParameters *slider,
415 	                           int x, int y, int width, int height);
416 
417 	void (*draw_slider) (cairo_t *cr,
418 	                     const MurrineColors    *colors,
419 	                     const WidgetParameters *widget,
420 	                     const SliderParameters *slider,
421 	                     int x, int y, int width, int height);
422 
423 	void (*draw_slider_handle) (cairo_t *cr,
424 	                            const MurrineColors    *colors,
425 	                            const WidgetParameters *widget,
426 	                            const HandleParameters *handle,
427 	                            int x, int y, int width, int height,
428 	                            boolean horizontal);
429 
430 	void (*draw_progressbar_trough) (cairo_t *cr,
431 	                                 const MurrineColors    *colors,
432 	                                 const WidgetParameters *widget,
433 	                                 const ProgressBarParameters *progressbar,
434 	                                 int x, int y, int width, int height);
435 
436 	void (*draw_progressbar_fill) (cairo_t *cr,
437 	                               const MurrineColors         *colors,
438 	                               const WidgetParameters      *widget,
439 	                               const ProgressBarParameters *progressbar,
440 	                               int x, int y, int width, int height,
441 	                               gint offset);
442 
443 	void (*draw_entry) (cairo_t *cr,
444 	                    const MurrineColors    *colors,
445 	                    const WidgetParameters *widget,
446 	                    const FocusParameters  *focus,
447 	                    int x, int y, int width, int height);
448 
449 	void (*draw_entry_progress)   (cairo_t *cr,
450 	                               const MurrineColors    *colors,
451 	                               const WidgetParameters *widget,
452 	                               const EntryProgressParameters *progress,
453 	                               int x, int y, int width, int height);
454 
455 	void (*draw_expander) (cairo_t *cr,
456 	                       const MurrineColors    *colors,
457 	                       const WidgetParameters *widget,
458 	                       const ExpanderParameters *expander,
459 	                       int x, int y);
460 
461 	void (*draw_spinbutton) (cairo_t *cr,
462 	                         const MurrineColors    *colors,
463 	                         const WidgetParameters *widget,
464 	                         const SpinbuttonParameters *spinbutton,
465 	                         int x, int y, int width, int height,
466 	                         boolean horizontal);
467 
468 	void (*draw_spinbutton_down) (cairo_t *cr,
469 	                              const MurrineColors    *colors,
470 	                              const WidgetParameters *widget,
471 	                              int x, int y, int width, int height);
472 
473 	void (*draw_optionmenu) (cairo_t *cr,
474 	                         const MurrineColors        *colors,
475 	                         const WidgetParameters     *widget,
476 	                         const OptionMenuParameters *optionmenu,
477 	                         int x, int y, int width, int height);
478 
479 	void (*draw_menubar) (cairo_t *cr,
480 	                      const MurrineColors    *colors,
481 	                      const WidgetParameters *widget,
482 	                      int x, int y, int width, int height,
483 	                      int menubarstyle);
484 
485 	void (*draw_tab) (cairo_t *cr,
486 	                  const MurrineColors    *colors,
487 	                  const WidgetParameters *widget,
488 	                  const TabParameters    *tab,
489 	                  int x, int y, int width, int height);
490 
491 	void (*draw_frame) (cairo_t *cr,
492 	                    const MurrineColors    *colors,
493 	                    const WidgetParameters *widget,
494 	                    const FrameParameters  *frame,
495 	                    int x, int y, int width, int height);
496 
497 	void (*draw_separator) (cairo_t *cr,
498 	                        const MurrineColors       *colors,
499 	                        const WidgetParameters    *widget,
500 	                        const SeparatorParameters *separator,
501 	                        int x, int y, int width, int height);
502 
503 	void (*draw_combo_separator) (cairo_t *cr,
504 	                              const MurrineColors    *colors,
505 	                              const WidgetParameters *widget,
506 	                              int x, int y, int width, int height);
507 
508 	void (*draw_list_view_header) (cairo_t *cr,
509 	                               const MurrineColors            *colors,
510 	                               const WidgetParameters         *widget,
511 	                               const ListViewHeaderParameters *header,
512 	                               int x, int y, int width, int height);
513 
514 	void (*draw_toolbar) (cairo_t *cr,
515 	                      const MurrineColors    *colors,
516 	                      const WidgetParameters *widget,
517 	                      const ToolbarParameters *toolbar,
518 	                      int x, int y, int width, int height);
519 
520 	void (*draw_menuitem) (cairo_t *cr,
521 	                       const MurrineColors    *colors,
522 	                       const WidgetParameters *widget,
523 	                       int x, int y, int width, int height,
524 	                       int menuitemstyle);
525 
526 	void (*draw_scrollbar_stepper) (cairo_t *cr,
527 	                                const MurrineColors              *colors,
528 	                                const WidgetParameters           *widget,
529 	                                const ScrollBarParameters        *scrollbar,
530 	                                //const ScrollBarStepperParameters *stepper,
531 	                                int x, int y, int width, int height);
532 
533 	void (*draw_scrollbar_slider) (cairo_t *cr,
534 	                               const MurrineColors       *colors,
535 	                               const WidgetParameters    *widget,
536 	                               const ScrollBarParameters *scrollbar,
537 	                               int x, int y, int width, int height);
538 
539 	void (*draw_scrollbar_trough) (cairo_t *cr,
540 	                               const MurrineColors       *colors,
541 	                               const WidgetParameters    *widget,
542 	                               const ScrollBarParameters *scrollbar,
543 	                               int x, int y, int width, int height);
544 
545 	void (*draw_selected_cell) (cairo_t *cr,
546 	                            const MurrineColors    *colors,
547 	                            const WidgetParameters *widget,
548 	                            const CellParameters   *cell,
549 	                            int x, int y, int width, int height);
550 
551 	void (*draw_statusbar) (cairo_t *cr,
552 	                        const MurrineColors    *colors,
553 	                        const WidgetParameters *widget,
554 	                        int x, int y, int width, int height);
555 
556 	void (*draw_menu_frame) (cairo_t *cr,
557 	                         const MurrineColors    *colors,
558 	                         const WidgetParameters *widget,
559 	                         int x, int y, int width, int height,
560 	                         int menustyle);
561 
562 	void (*draw_tooltip) (cairo_t *cr,
563 	                      const MurrineColors    *colors,
564 	                      const WidgetParameters *widget,
565 	                      int x, int y, int width, int height);
566 
567 	void (*draw_iconview) (cairo_t *cr,
568 	                       const MurrineColors    *colors,
569 	                       const WidgetParameters *widget,
570 	                       int x, int y, int width, int height);
571 
572 	void (*draw_handle) (cairo_t *cr,
573 	                     const MurrineColors    *colors,
574 	                     const WidgetParameters *widget,
575 	                     const HandleParameters *handle,
576 	                     int x, int y, int width, int height);
577 
578 	void (*draw_arrow) (cairo_t *cr,
579 	                    const MurrineColors    *colors,
580 	                    const WidgetParameters *widget,
581 	                    const ArrowParameters  *arrow,
582 	                    int x, int y, int width, int height);
583 
584 	void (*draw_checkbox) (cairo_t *cr,
585 	                       const MurrineColors      *colors,
586 	                       const WidgetParameters   *widget,
587 	                       const CheckboxParameters *checkbox,
588 	                       int x, int y, int width, int height,
589 	                       double trans);
590 
591 	void (*draw_radiobutton) (cairo_t *cr,
592 	                          const MurrineColors      *colors,
593 	                          const WidgetParameters   *widget,
594 	                          const CheckboxParameters *checkbox,
595 	                          int x, int y, int width, int height,
596 	                          double trans);
597 
598 	void (*draw_resize_grip) (cairo_t *cr,
599 	                          const MurrineColors        *colors,
600 	                          const WidgetParameters     *widget,
601 	                          const ResizeGripParameters *grip,
602 	                          int x, int y, int width, int height);
603 
604 	void (*draw_focus) (cairo_t *cr,
605 	                    const MurrineColors    *colors,
606 	                    const WidgetParameters *widget,
607 	                    const FocusParameters  *focus,
608 	                    int x, int y, int width, int height);
609 };
610 
611 #define MURRINE_RECTANGLE_SET(rect, _x, _y, _w, _h) rect.x      = _x; \
612                                                     rect.y      = _y; \
613                                                     rect.width  = _w; \
614                                                     rect.height = _h;
615 
616 #endif /* MURRINE_TYPES_H */
617