Update to clearlooks from gtk-engines-2.16.0
[ardour.git] / libs / clearlooks / clearlooks_draw.c
1 /* Clearlooks theme engine
2  * Copyright (C) 2006 Richard Stellingwerff
3  * Copyright (C) 2006 Daniel Borgman
4  * Copyright (C) 2007 Benjamin Berg
5  * Copyright (C) 2007 Andrea Cimitan
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Library General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library 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 GNU
15  * Library General Public License for more details.
16  *
17  * You should have received a copy of the GNU Library General Public
18  * License along with this library; if not, write to the
19  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  *
22  */
23
24 #include "clearlooks_draw.h"
25 #include "clearlooks_style.h"
26 #include "clearlooks_types.h"
27
28 #include "support.h"
29 #include <ge-support.h>
30 #include <math.h>
31
32 #include <cairo.h>
33
34 /* Normal shadings */
35 #define SHADE_TOP 1.055
36 #define SHADE_CENTER_TOP 1.01
37 #define SHADE_CENTER_BOTTOM 0.98
38 #define SHADE_BOTTOM 0.90
39
40 typedef void (*menubar_draw_proto) (cairo_t *cr,
41                                     const ClearlooksColors *colors,
42                                     const WidgetParameters *params,
43                                     const MenuBarParameters *menubar,
44                                     int x, int y, int width, int height);
45
46 static void
47 clearlooks_draw_inset (cairo_t          *cr,
48                        const CairoColor *bg_color,
49                        double x, double y, double width, double height,
50                        double radius, uint8 corners)
51 {
52         CairoColor shadow;
53         CairoColor highlight;
54         double line_width;
55         double min = MIN (width, height);
56
57         line_width = cairo_get_line_width (cr);
58
59         /* not really sure of shading ratios... we will think */
60         ge_shade_color (bg_color, 0.94, &shadow);
61         ge_shade_color (bg_color, 1.06, &highlight);
62
63         /* highlight */
64         cairo_save (cr);
65
66         cairo_move_to (cr, x, y + height);
67         cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
68         cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
69         cairo_line_to (cr, x + width, y);
70         cairo_line_to (cr, x, y);
71         cairo_close_path (cr);
72         
73         cairo_clip (cr);
74
75         ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
76                                     width - line_width, height - line_width,
77                                     radius, corners);
78
79         ge_cairo_set_color (cr, &shadow);
80         cairo_stroke (cr);
81         
82         cairo_restore (cr);
83
84         /* shadow */
85         cairo_save (cr);
86
87         cairo_move_to (cr, x, y + height);
88         cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
89         cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
90         cairo_line_to (cr, x + width, y);
91         cairo_line_to (cr, x + width, y + height);
92         cairo_close_path (cr);
93         
94         cairo_clip (cr);
95
96         ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
97                                     width - line_width, height - line_width,
98                                     radius, corners);
99
100         ge_cairo_set_color (cr, &highlight);
101         cairo_stroke (cr);
102
103         cairo_restore (cr);
104 }
105
106 static void
107 clearlooks_draw_shadow (cairo_t *cr, const ClearlooksColors *colors, gfloat radius, int width, int height)
108 {
109         CairoColor shadow;
110         cairo_save (cr);
111
112         ge_shade_color (&colors->shade[6], 0.92, &shadow);
113
114         cairo_set_line_width (cr, 1.0);
115         cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
116
117         cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
118
119         cairo_move_to (cr, width - 0.5, radius);
120         ge_cairo_rounded_corner (cr, width - 0.5, height - 0.5, radius, CR_CORNER_BOTTOMRIGHT);
121         cairo_line_to (cr, radius, height - 0.5);
122
123         cairo_stroke (cr);
124         cairo_restore (cr);
125 }
126
127 /* This is copied at least in clearlooks_draw_gummy.c.
128  * KEEP IN SYNC IF POSSIBLE! */
129 static void
130 clearlooks_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
131                                     const WidgetParameters *params,
132                                     int x, int y, int width, int height,
133                                     gdouble radius, CairoCorners corners)
134 {
135         CairoColor hilight;
136
137         double line_width = cairo_get_line_width (cr);
138         double offset = line_width / 2.0;
139         double light_top, light_bottom, light_left, light_right;
140
141         cairo_save (cr);
142
143         cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
144
145         light_top = y + offset;
146         light_bottom = y + height;
147         light_left = x + offset;
148         light_right = x + width;
149         
150         if (corners & CR_CORNER_BOTTOMLEFT)
151                 light_bottom -= radius;
152         if (corners & CR_CORNER_TOPRIGHT)
153                 light_right -= radius;
154
155         ge_shade_color (color, params->style_constants->topleft_highlight_shade, &hilight);
156         cairo_move_to         (cr, light_left, light_bottom);
157
158         ge_cairo_rounded_corner (cr, light_left, light_top, radius, corners & CR_CORNER_TOPLEFT);
159
160         cairo_line_to         (cr, light_right, light_top);
161         cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, params->style_constants->topleft_highlight_alpha);
162         cairo_stroke          (cr);
163
164         cairo_restore (cr);
165 }
166
167 #ifdef DEVELOPMENT
168 #warning seems to be very slow in scrollbar_stepper
169 #endif
170
171 static void
172 clearlooks_draw_highlight_and_shade (cairo_t *cr, const ClearlooksColors *colors,
173                                      const ShadowParameters *params,
174                                      int width, int height, gdouble radius)
175 {
176         CairoColor hilight;
177         CairoColor shadow;
178         uint8 corners = params->corners;
179         double x = 1.0;
180         double y = 1.0;
181
182         ge_shade_color (&colors->bg[0], 1.06, &hilight);
183         ge_shade_color (&colors->bg[0], 0.94, &shadow);
184
185         width  -= 2;
186         height -= 2;
187
188         cairo_save (cr);
189
190         /* Top/Left highlight */
191         if (corners & CR_CORNER_BOTTOMLEFT)
192                 cairo_move_to (cr, x + 0.5, y+height-radius);
193         else
194                 cairo_move_to (cr, x + 0.5, y+height);
195
196         ge_cairo_rounded_corner (cr, x + 0.5, y + 0.5, radius, corners & CR_CORNER_TOPLEFT);
197
198         if (corners & CR_CORNER_TOPRIGHT)
199                 cairo_line_to (cr, x+width-radius, y + 0.5);
200         else
201                 cairo_line_to (cr, x+width, y + 0.5);
202
203         if (params->shadow & CL_SHADOW_OUT)
204                 ge_cairo_set_color (cr, &hilight);
205         else
206                 ge_cairo_set_color (cr, &shadow);
207
208         cairo_stroke (cr);
209
210         /* Bottom/Right highlight -- this includes the corners */
211         cairo_arc (cr, x + width - 0.5 - radius, y + radius, radius, G_PI * (3/2.0+1/4.0), G_PI * 2);
212         ge_cairo_rounded_corner (cr, x+width - 0.5, y+height - 0.5, radius, corners & CR_CORNER_BOTTOMRIGHT);
213         cairo_arc (cr, x + radius, y + height - 0.5 - radius, radius, G_PI * 1/2, G_PI * 3/4);
214
215         if (params->shadow & CL_SHADOW_OUT)
216                 ge_cairo_set_color (cr, &shadow);
217         else
218                 ge_cairo_set_color (cr, &hilight);
219
220         cairo_stroke (cr);
221
222         cairo_restore (cr);
223 }
224
225 static void
226 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
227 {
228         cairo_pattern_t *pattern;
229
230         CairoColor bottom_shade;
231         ge_shade_color (color, hilight, &bottom_shade);
232
233         pattern = cairo_pattern_create_linear (0, 0, width, height);
234         cairo_pattern_add_color_stop_rgb (pattern, 0, color->r, color->g, color->b);
235         cairo_pattern_add_color_stop_rgb (pattern, 1, bottom_shade.r, bottom_shade.g, bottom_shade.b);
236
237         cairo_set_source (cr, pattern);
238         cairo_pattern_destroy (pattern);
239 }
240
241 static void
242 clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, int y,
243                           int width, int height, int xr, int yr,
244                           float contrast)
245 {
246         const CairoColor *dark = &colors->shade[4];
247         CairoColor hilight;
248         int i, j;
249         int xoff, yoff;
250         int x_start, y_start;
251
252         ge_shade_color (dark, 1.5, &hilight);
253         
254         /* The "- 1" is because there is no space in front of the first dot. */
255         x_start = x + width / 2 - ((xr * 3 - 1) / 2);
256         y_start = y + height / 2 - ((yr * 3 - 1) / 2);
257         
258         for ( i = 0; i < xr; i++ )
259         {
260                 for ( j = 0; j < yr; j++ )
261                 {
262                         xoff = 3 * i;
263                         yoff = 3 * j;
264
265                         cairo_rectangle (cr, x_start + xoff, y_start + yoff, 2, 2);
266                         cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.8+contrast);
267                         cairo_fill (cr);
268                         cairo_rectangle (cr, x_start + xoff, y_start + yoff, 1, 1);
269                         cairo_set_source_rgba (cr, dark->r, dark->g, dark->b, 0.8+contrast);
270                         cairo_fill (cr);
271                 }
272         }
273 }
274
275 static void
276 clearlooks_draw_button (cairo_t *cr,
277                         const ClearlooksColors *colors,
278                         const WidgetParameters *params,
279                         int x, int y, int width, int height)
280 {
281         double xoffset = 0, yoffset = 0;
282         double radius = params->radius;
283         const CairoColor *fill = &colors->bg[params->state_type];
284         CairoColor border_normal = colors->shade[6];
285         CairoColor border_disabled = colors->shade[4];
286
287         CairoColor shadow;
288         ge_shade_color (&border_normal, 1.04, &border_normal);
289         ge_shade_color (&border_normal, 0.94, &shadow);
290         ge_shade_color (&border_disabled, 1.08, &border_disabled);
291
292         cairo_save (cr);
293
294         cairo_translate (cr, x, y);
295         cairo_set_line_width (cr, 1.0);
296
297         if (params->xthickness == 3 || params->ythickness == 3)
298         {
299                 if (params->xthickness == 3)
300                         xoffset = 1;
301                 if (params->ythickness == 3)
302                         yoffset = 1;
303         }
304
305         radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
306
307         if (params->xthickness == 3 || params->ythickness == 3)
308         {
309                 params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
310         }
311
312         ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
313                                              width-(xoffset*2)-2,
314                                              height-(yoffset*2)-2,
315                                              radius, params->corners);
316
317         if (!params->active)
318         {
319                 cairo_pattern_t *pattern;
320                 CairoColor top_shade, topmiddle_shade, bottom_shade, middle_shade;
321
322                 ge_shade_color (fill, SHADE_TOP, &top_shade);
323                 ge_shade_color (fill, SHADE_CENTER_TOP, &topmiddle_shade);
324                 ge_shade_color (fill, SHADE_CENTER_BOTTOM, &middle_shade);
325                 ge_shade_color (fill, SHADE_BOTTOM, &bottom_shade);
326
327                 cairo_save (cr);
328                 cairo_clip_preserve (cr);
329
330                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
331                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top_shade.r, top_shade.g, top_shade.b);
332                 cairo_pattern_add_color_stop_rgb (pattern, 0.3, topmiddle_shade.r, topmiddle_shade.g, topmiddle_shade.b);
333                 cairo_pattern_add_color_stop_rgb (pattern, 0.7, middle_shade.r, middle_shade.g, middle_shade.b);
334                 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bottom_shade.r, bottom_shade.g, bottom_shade.b);
335                 cairo_set_source (cr, pattern);
336                 cairo_fill (cr);
337                 cairo_pattern_destroy (pattern);
338
339                 cairo_move_to (cr, width-(xoffset*2)-0.5, 0);
340                 cairo_line_to (cr, width-(xoffset*2)-0.5, height);
341                 ge_cairo_set_color (cr, &bottom_shade);
342                 cairo_stroke (cr);
343
344                 /* Draw topleft shadow */
345                 params->style_functions->draw_top_left_highlight (cr, fill, params, xoffset + 1, yoffset + 1,
346                                                                   width - 2*(xoffset + 1), height - 2*(yoffset + 1),
347                                                                   MAX(radius-1, 0), params->corners);
348
349                 cairo_restore (cr);
350         }
351         else
352         {
353                 cairo_pattern_t *pattern;
354
355                 ge_cairo_set_color (cr, fill);
356                 cairo_fill_preserve (cr);
357
358                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
359                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.0);
360                 cairo_pattern_add_color_stop_rgba (pattern, 0.4, shadow.r, shadow.g, shadow.b, 0.0);
361                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.2);
362                 cairo_set_source (cr, pattern);
363                 cairo_fill_preserve (cr);
364                 cairo_pattern_destroy (pattern);
365
366                 pattern = cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
367                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
368                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
369                 cairo_set_source (cr, pattern);
370                 cairo_fill_preserve (cr);
371                 cairo_pattern_destroy (pattern);
372
373                 pattern = cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
374                 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
375                 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
376                 cairo_set_source (cr, pattern);
377                 cairo_fill (cr);
378                 cairo_pattern_destroy (pattern);
379         }
380
381         /* Drawing the border */
382         if (!params->active && params->is_default)
383         {
384                 ge_shade_color (&border_normal, 0.74, &border_normal);
385         }
386
387         ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, params->corners);
388
389         if (params->disabled)
390         {
391                 ge_cairo_set_color (cr, &border_disabled);
392         }
393         else
394         {
395                 if (!params->active)
396                         clearlooks_set_border_gradient (cr, &border_normal,
397                                                         params->is_default ? 1.1 : 1.3, 0, height);
398                 else
399                 {
400                         ge_shade_color (&border_normal, 1.08, &border_normal);
401                         ge_cairo_set_color (cr, &border_normal);
402                 }
403         }
404
405         cairo_stroke (cr);
406
407         cairo_restore (cr);
408 }
409
410 static void
411 clearlooks_draw_entry (cairo_t *cr,
412                        const ClearlooksColors *colors,
413                        const WidgetParameters *params,
414                        int x, int y, int width, int height)
415 {
416         const CairoColor *base = &colors->base[params->state_type];
417         CairoColor border = colors->shade[params->disabled ? 3 : 6];
418         double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
419
420         if (params->focus)
421                 border = colors->spot[2];
422
423         cairo_save (cr);
424
425         cairo_translate (cr, x, y);
426         cairo_set_line_width (cr, 1.0);
427
428         /* Now fill the area we want to be base[NORMAL]. */
429         ge_cairo_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
430         ge_cairo_set_color (cr, base);
431         cairo_fill (cr);
432
433         params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, width, height, radius+1, params->corners);
434
435         /* Draw the inner shadow */
436         if (params->focus)
437         {
438                 ge_cairo_set_color (cr, &colors->spot[0]);
439                 ge_cairo_inner_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
440                 cairo_stroke (cr);
441         }
442         else
443         {
444                 CairoColor shadow;
445                 ge_shade_color (&border, 0.925, &shadow);
446
447                 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.05 : 0.1);
448
449                 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
450                 cairo_move_to (cr, 2.5, height-radius);
451                 cairo_arc (cr, 2.5+MAX(0, radius-1), 2.5+MAX(0, radius-1), MAX(0, radius-1), G_PI, 270*(G_PI/180));
452                 cairo_line_to (cr, width-radius, 2.5);
453                 cairo_stroke (cr);
454         }
455
456         ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, params->corners);
457         if (params->focus || params->disabled)
458                 ge_cairo_set_color (cr, &border);
459         else
460                 clearlooks_set_border_gradient (cr, &border, 1.32, 0, height);
461         cairo_stroke (cr);
462
463         cairo_restore (cr);
464 }
465
466 static void
467 clearlooks_draw_spinbutton (cairo_t *cr,
468                             const ClearlooksColors *colors,
469                             const WidgetParameters *params,
470                             int x, int y, int width, int height)
471 {
472         const CairoColor *border = &colors->shade[!params->disabled ? 5 : 3];
473         CairoColor hilight;
474
475         params->style_functions->draw_button (cr, colors, params, x, y, width, height);
476
477         ge_shade_color (&colors->bg[0], params->style_constants->topleft_highlight_shade, &hilight);
478         hilight.a = params->style_constants->topleft_highlight_alpha;
479
480         cairo_translate (cr, x, y);
481
482         cairo_move_to (cr, params->xthickness + 0.5,       (height/2) + 0.5);
483         cairo_line_to (cr, width-params->xthickness - 0.5, (height/2) + 0.5);
484         ge_cairo_set_color (cr, border);
485         cairo_stroke (cr);
486
487         cairo_move_to (cr, params->xthickness + 0.5,       (height/2)+1.5);
488         cairo_line_to (cr, width-params->xthickness - 0.5, (height/2)+1.5);
489         ge_cairo_set_color (cr, &hilight);
490         cairo_stroke (cr);
491 }
492
493 static void
494 clearlooks_draw_spinbutton_down (cairo_t *cr,
495                                  const ClearlooksColors *colors,
496                                  const WidgetParameters *params,
497                                  int x, int y, int width, int height)
498 {
499         cairo_pattern_t *pattern;
500         double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
501         CairoColor shadow;
502         ge_shade_color (&colors->bg[0], 0.8, &shadow);
503
504         cairo_translate (cr, x+1, y+1);
505
506         ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, params->corners);
507
508         ge_cairo_set_color (cr, &colors->bg[params->state_type]);
509
510         cairo_fill_preserve (cr);
511
512         pattern = cairo_pattern_create_linear (0, 0, 0, height);
513         cairo_pattern_add_color_stop_rgb (pattern, 0.0, shadow.r, shadow.g, shadow.b);
514         cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
515
516         cairo_set_source (cr, pattern);
517         cairo_fill (cr);
518
519         cairo_pattern_destroy (pattern);
520 }
521
522 static void
523 clearlooks_scale_draw_gradient (cairo_t *cr,
524                                 const CairoColor *c1,
525                                 const CairoColor *c2,
526                                 const CairoColor *c3,
527                                 int x, int y, int width, int height,
528                                 boolean horizontal)
529 {
530         cairo_pattern_t *pattern;
531
532         pattern = cairo_pattern_create_linear (0.5, 0.5, horizontal ? 0.5 :  width + 1, horizontal ? height + 1: 0.5);
533         cairo_pattern_add_color_stop_rgb (pattern, 0.0, c1->r, c1->g, c1->b);
534         cairo_pattern_add_color_stop_rgb (pattern, 1.0, c2->r, c2->g, c2->b);
535
536         cairo_rectangle (cr, x, y, width, height);
537         cairo_set_source (cr, pattern);
538         cairo_fill (cr);
539         cairo_pattern_destroy (pattern);
540
541         ge_cairo_set_color (cr, c3);
542         ge_cairo_inner_rectangle (cr, x, y, width, height);
543         cairo_stroke (cr);
544 }
545
546 #define TROUGH_SIZE 7
547 static void
548 clearlooks_draw_scale_trough (cairo_t *cr,
549                               const ClearlooksColors *colors,
550                               const WidgetParameters *params,
551                               const SliderParameters *slider,
552                               int x, int y, int width, int height)
553 {
554         int     trough_width, trough_height;
555         double  translate_x, translate_y;
556
557         cairo_save (cr);
558
559         if (slider->horizontal)
560         {
561                 trough_width  = width;
562                 trough_height = TROUGH_SIZE;
563                 
564                 translate_x   = x;
565                 translate_y   = y + (height/2) - (TROUGH_SIZE/2);
566         }
567         else
568         {
569                 trough_width  = TROUGH_SIZE;
570                 trough_height = height;
571                 
572                 translate_x   = x + (width/2) - (TROUGH_SIZE/2);
573                 translate_y  = y;
574         }
575
576         cairo_set_line_width (cr, 1.0);
577         cairo_translate (cr, translate_x, translate_y);
578
579         if (!slider->fill_level)
580                 params->style_functions->draw_inset (cr, &params->parentbg, 0, 0, trough_width, trough_height, 0, 0);
581         
582         if (!slider->lower && !slider->fill_level)
583         {
584                 CairoColor shadow;
585                 ge_shade_color (&colors->shade[2], 0.96, &shadow);
586
587                 clearlooks_scale_draw_gradient (cr, &shadow, /* top */
588                                                 &colors->shade[2], /* bottom */
589                                                 &colors->shade[4], /* border */
590                                                 1.0, 1.0, trough_width - 2, trough_height - 2,
591                                                 slider->horizontal);
592         }
593         else
594         {
595                 CairoColor border = colors->spot[2];
596                 border.a = 0.64;
597
598                 clearlooks_scale_draw_gradient (cr, &colors->spot[1], /* top */
599                                                 &colors->spot[0], /* bottom */
600                                                 &border, /* border */
601                                                 1.0, 1.0, trough_width - 2, trough_height - 2,
602                                                 slider->horizontal);
603         }
604         cairo_restore (cr);
605 }
606
607 static void
608 clearlooks_draw_slider (cairo_t *cr,
609                         const ClearlooksColors *colors,
610                         const WidgetParameters *params,
611                         int x, int y, int width, int height)
612 {
613         const CairoColor *spot   = &colors->spot[1];
614         const CairoColor *fill   = &colors->shade[2];
615         CairoColor border = colors->shade[params->disabled ? 4 : 6];
616         double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
617
618         cairo_pattern_t *pattern;
619
620         cairo_set_line_width (cr, 1.0);
621         cairo_translate      (cr, x, y);
622
623         if (params->prelight)
624                 border = colors->spot[2];
625
626         /* fill the widget */
627         ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, params->corners);
628
629         /* Fake light */
630         if (!params->disabled)
631         {
632                 const CairoColor *top = &colors->shade[0];
633                 const CairoColor *bot = &colors->shade[2];
634
635                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
636                 cairo_pattern_add_color_stop_rgb (pattern, 0.0,  top->r, top->g, top->b);
637                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,  bot->r, bot->g, bot->b);
638                 cairo_set_source (cr, pattern);
639                 cairo_fill (cr);
640                 cairo_pattern_destroy (pattern);
641         }
642         else
643         {
644                 ge_cairo_set_color (cr, fill);
645                 cairo_fill         (cr);
646         }
647
648         /* Set the clip */
649         cairo_save (cr);
650         cairo_rectangle (cr, 1.0, 1.0, 6, height-2);
651         cairo_rectangle (cr, width-7.0, 1.0, 6, height-2);
652         cairo_clip_preserve (cr);
653
654         cairo_new_path (cr);
655
656         /* Draw the handles */
657         ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners);
658         pattern = cairo_pattern_create_linear (1.0, 1.0, 1.0, 1.0+height);
659
660         if (params->prelight)
661         {
662                 CairoColor highlight;
663                 ge_shade_color (spot, 1.3, &highlight);
664                 cairo_pattern_add_color_stop_rgb (pattern, 0.0, highlight.r, highlight.g, highlight.b);
665                 cairo_pattern_add_color_stop_rgb (pattern, 1.0, spot->r, spot->g, spot->b);
666                 cairo_set_source (cr, pattern);
667         }
668         else
669         {
670                 CairoColor hilight;
671                 ge_shade_color (fill, 1.3, &hilight);
672                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
673         }
674
675         cairo_fill (cr);
676         cairo_pattern_destroy (pattern);
677
678         cairo_restore (cr);
679
680         /* Draw the border */
681         ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
682
683         if (params->prelight || params->disabled)
684                 ge_cairo_set_color (cr, &border);
685         else
686                 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
687         cairo_stroke (cr);
688
689         /* Draw handle lines */
690         if (width > 14)
691         {
692                 cairo_move_to (cr, 6.5, 1.0);
693                 cairo_line_to (cr, 6.5, height-1);
694
695                 cairo_move_to (cr, width-6.5, 1.0);
696                 cairo_line_to (cr, width-6.5, height-1);
697
698                 cairo_set_line_width (cr, 1.0);
699                 border.a = params->disabled ? 0.6 : 0.3;
700                 ge_cairo_set_color (cr, &border);
701                 cairo_stroke (cr);
702         }
703 }
704
705 static void
706 clearlooks_draw_slider_button (cairo_t *cr,
707                                const ClearlooksColors *colors,
708                                const WidgetParameters *params,
709                                const SliderParameters *slider,
710                                int x, int y, int width, int height)
711 {
712         double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
713
714         cairo_save (cr);
715         cairo_set_line_width (cr, 1.0);
716
717         if (!slider->horizontal)
718                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
719         cairo_translate (cr, x, y);
720
721         params->style_functions->draw_shadow (cr, colors, radius, width, height);
722         params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
723
724         if (width > 24)
725                 params->style_functions->draw_gripdots (cr, colors, 1, 1, width-2, height-2, 3, 3, 0);
726
727         cairo_restore (cr);
728 }
729
730 static void
731 clearlooks_draw_progressbar_trough (cairo_t *cr,
732                                     const ClearlooksColors *colors,
733                                     const WidgetParameters *params,
734                                     int x, int y, int width, int height)
735 {
736         const CairoColor *border = &colors->shade[4];
737         CairoColor        shadow;
738         cairo_pattern_t  *pattern;
739         double            radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
740
741         cairo_save (cr);
742
743         cairo_set_line_width (cr, 1.0);
744
745         /* Create trough box */
746         ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
747         ge_cairo_set_color (cr, &colors->shade[2]);
748         cairo_fill (cr);
749
750         /* Draw border */
751         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
752         ge_cairo_set_color (cr, border);
753         cairo_stroke (cr);
754
755         /* clip the corners of the shadows */
756         ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
757         cairo_clip (cr);
758
759         ge_shade_color (border, 0.925, &shadow);
760
761         /* Top shadow */
762         cairo_rectangle (cr, x+1, y+1, width-2, 4);
763         pattern = cairo_pattern_create_linear (x, y, x, y+4);
764         cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.2);
765         cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0);
766         cairo_set_source (cr, pattern);
767         cairo_fill (cr);
768         cairo_pattern_destroy (pattern);
769
770         /* Left shadow */
771         cairo_rectangle (cr, x+1, y+1, 4, height-2);
772         pattern = cairo_pattern_create_linear (x, y, x+4, y);
773         cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.2);
774         cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0);
775         cairo_set_source (cr, pattern);
776         cairo_fill (cr);
777         cairo_pattern_destroy (pattern);
778
779         cairo_restore (cr);
780 }
781
782 static void
783 clearlooks_draw_progressbar_fill (cairo_t *cr,
784                                   const ClearlooksColors *colors,
785                                   const WidgetParameters *params,
786                                   const ProgressBarParameters *progressbar,
787                                   int x, int y, int width, int height,
788                                   gint offset)
789 {
790         boolean      is_horizontal = progressbar->orientation < 2;
791         double       tile_pos = 0;
792         double       stroke_width;
793         double       radius;
794         int          x_step;
795
796         cairo_pattern_t *pattern;
797         CairoColor       bg_shade;
798         CairoColor       border;
799         CairoColor       shadow;
800
801         radius = MAX (0, params->radius - params->xthickness);
802
803         cairo_save (cr);
804
805         if (!is_horizontal)
806                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
807
808         if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
809                 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
810
811         /* Clamp the radius so that the _height_ fits ...  */
812         radius = MIN (radius, height / 2.0);
813
814         stroke_width = height;
815         x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
816
817         cairo_translate (cr, x, y);
818
819         cairo_save (cr);
820         /* This is kind of nasty ... Clip twice from each side in case the length
821          * of the fill is smaller than twice the radius. */
822         ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
823         cairo_clip (cr);
824         ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
825         cairo_clip (cr);
826
827         /* Draw the background gradient */
828         ge_shade_color (&colors->spot[1], 1.1, &bg_shade);
829
830         /* Just leave this disabled, maybe we could use the same gradient
831          * as the buttons in the future, not flat fill */
832 /*      pattern = cairo_pattern_create_linear (0, 0, 0, height);*/
833 /*      cairo_pattern_add_color_stop_rgb (pattern, 0.0, bg_shade.r, bg_shade.g, bg_shade.b);*/
834 /*      cairo_pattern_add_color_stop_rgb (pattern, 0.6, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);*/
835 /*      cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg_shade.r, bg_shade.g, bg_shade.b);*/
836 /*      cairo_set_source (cr, pattern);*/
837 /*      cairo_paint (cr);*/
838 /*      cairo_pattern_destroy (pattern);*/
839
840         ge_cairo_set_color (cr, &bg_shade);
841         cairo_paint (cr);
842
843         /* Draw the Strokes */
844         while (tile_pos <= width+x_step)
845         {
846                 cairo_move_to (cr, stroke_width/2-x_step, 0);
847                 cairo_line_to (cr, stroke_width-x_step,   0);
848                 cairo_line_to (cr, stroke_width/2-x_step, height);
849                 cairo_line_to (cr, -x_step, height);
850
851                 cairo_translate (cr, stroke_width, 0);
852                 tile_pos += stroke_width;
853         }
854
855         pattern = cairo_pattern_create_linear (0, 0, 0, height);
856         cairo_pattern_add_color_stop_rgba (pattern, 0.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0);
857         cairo_pattern_add_color_stop_rgba (pattern, 1.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0.24);
858         cairo_set_source (cr, pattern);
859         cairo_fill (cr);
860         cairo_pattern_destroy (pattern);
861
862         cairo_restore (cr); /* rounded clip region */
863
864         /* Draw the dark lines and the shadow */
865         cairo_save (cr);
866         /* Again, this weird clip area. */
867         ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
868         cairo_clip (cr);
869         ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
870         cairo_clip (cr);
871
872         shadow.r = 0.0;
873         shadow.g = 0.0;
874         shadow.b = 0.0;
875         shadow.a = 0.1;
876
877         if (progressbar->pulsing)
878         {
879                 /* At the beginning of the bar. */
880                 cairo_move_to (cr, -0.5 + radius, height + 0.5);
881                 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
882                 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
883                 ge_cairo_set_color (cr, &shadow);
884                 cairo_stroke (cr);
885         }
886         if (progressbar->value < 1.0 || progressbar->pulsing)
887         {
888                 /* At the end of the bar. */
889                 cairo_move_to (cr, width + 0.5 - radius, -0.5);
890                 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
891                 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
892                 ge_cairo_set_color (cr, &shadow);
893                 cairo_stroke (cr);
894         }
895
896 /*      ge_cairo_rounded_rectangle (cr, 1.5,1.5, width-2, height-2, radius, CR_CORNER_ALL);*/
897 /*      cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 1);*/
898 /*      cairo_stroke (cr);*/
899
900         params->style_functions->draw_top_left_highlight (cr, &colors->spot[1], params, 1.5, 1.5,
901                                                           width - 1, height - 1,
902                                                           radius, params->corners);
903
904         border = colors->spot[2];
905         border.a = 0.6;
906         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, CR_CORNER_ALL);
907         ge_cairo_set_color (cr, &border);
908         cairo_stroke (cr);
909
910         cairo_restore (cr);
911
912         cairo_restore (cr); /* rotation, mirroring */
913 }
914
915 static void
916 clearlooks_draw_optionmenu (cairo_t *cr,
917                             const ClearlooksColors *colors,
918                             const WidgetParameters *params,
919                             const OptionMenuParameters *optionmenu,
920                             int x, int y, int width, int height)
921 {
922         SeparatorParameters separator;
923         int offset = params->ythickness + 2;
924
925         params->style_functions->draw_button (cr, colors, params, x, y, width, height);
926
927         separator.horizontal = FALSE;
928         params->style_functions->draw_separator (cr, colors, params, &separator, x+optionmenu->linepos, y + offset, 2, height - offset*2);
929 }
930
931 static void
932 clearlooks_draw_menu_item_separator (cairo_t                   *cr,
933                                      const ClearlooksColors    *colors,
934                                      const WidgetParameters    *widget,
935                                      const SeparatorParameters *separator,
936                                      int x, int y, int width, int height)
937 {
938         cairo_save (cr);
939         cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
940         ge_cairo_set_color (cr, &colors->shade[5]);
941
942         if (separator->horizontal)
943                 cairo_rectangle (cr, x, y, width, 1);
944         else
945                 cairo_rectangle (cr, x, y, 1, height);
946
947         cairo_fill      (cr);
948
949         cairo_restore (cr);
950 }
951
952 static void
953 clearlooks_draw_menubar0 (cairo_t *cr,
954                           const ClearlooksColors *colors,
955                           const WidgetParameters *params,
956                           const MenuBarParameters *menubar,
957                           int x, int y, int width, int height)
958 {
959         const CairoColor *dark = &colors->shade[3];
960
961         cairo_save (cr);
962
963         cairo_set_line_width (cr, 1);
964         cairo_translate (cr, x, y);
965
966         cairo_move_to (cr, 0, height-0.5);
967         cairo_line_to (cr, width, height-0.5);
968         ge_cairo_set_color (cr, dark);
969         cairo_stroke (cr);
970
971         cairo_restore (cr);
972 }
973
974 static void
975 clearlooks_draw_menubar2 (cairo_t *cr,
976                           const ClearlooksColors *colors,
977                           const WidgetParameters *params,
978                           const MenuBarParameters *menubar,
979                           int x, int y, int width, int height)
980 {
981         CairoColor lower;
982         cairo_pattern_t *pattern;
983
984         cairo_save (cr);
985
986         ge_shade_color (&colors->bg[0], 0.96, &lower);
987
988         cairo_translate (cr, x, y);
989         cairo_rectangle (cr, 0, 0, width, height);
990
991         /* Draw the gradient */
992         pattern = cairo_pattern_create_linear (0, 0, 0, height);
993         cairo_pattern_add_color_stop_rgb (pattern, 0.0, colors->bg[0].r,
994                                                         colors->bg[0].g,
995                                                         colors->bg[0].b);
996         cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r,
997                                                         lower.g,
998                                                         lower.b);
999         cairo_set_source      (cr, pattern);
1000         cairo_fill            (cr);
1001         cairo_pattern_destroy (pattern);
1002
1003         /* Draw bottom line */
1004         cairo_set_line_width (cr, 1.0);
1005         cairo_move_to        (cr, 0, height-0.5);
1006         cairo_line_to        (cr, width, height-0.5);
1007         ge_cairo_set_color   (cr, &colors->shade[3]);
1008         cairo_stroke         (cr);
1009
1010         cairo_restore (cr);
1011 }
1012
1013 static void
1014 clearlooks_draw_menubar1 (cairo_t *cr,
1015                           const ClearlooksColors *colors,
1016                           const WidgetParameters *params,
1017                           const MenuBarParameters *menubar,
1018                           int x, int y, int width, int height)
1019 {
1020         const CairoColor *border = &colors->shade[3];
1021
1022         clearlooks_draw_menubar2 (cr, colors, params, menubar,
1023                                   x, y, width, height);
1024
1025         ge_cairo_set_color (cr, border);
1026         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1027 }
1028
1029
1030 static menubar_draw_proto clearlooks_menubar_draw[3] =
1031 {
1032         clearlooks_draw_menubar0,
1033         clearlooks_draw_menubar1,
1034         clearlooks_draw_menubar2
1035 };
1036
1037 static void
1038 clearlooks_draw_menubar (cairo_t *cr,
1039                          const ClearlooksColors *colors,
1040                          const WidgetParameters *params,
1041                          const MenuBarParameters *menubar,
1042                          int x, int y, int width, int height)
1043 {
1044         if (menubar->style < 0 || menubar->style >= G_N_ELEMENTS (clearlooks_menubar_draw))
1045                 return;
1046
1047         clearlooks_menubar_draw[menubar->style](cr, colors, params, menubar,
1048                                      x, y, width, height);
1049 }
1050
1051 static void
1052 clearlooks_get_frame_gap_clip (int x, int y, int width, int height,
1053                                const FrameParameters     *frame,
1054                                ClearlooksRectangle *bevel,
1055                                ClearlooksRectangle *border)
1056 {
1057         if (frame->gap_side == CL_GAP_TOP)
1058         {
1059                 CLEARLOOKS_RECTANGLE_SET (*bevel,  2.0 + frame->gap_x,  0.0,
1060                                           frame->gap_width - 3, 2.0);
1061                 CLEARLOOKS_RECTANGLE_SET (*border, 1.0 + frame->gap_x,  0.0,
1062                                          frame->gap_width - 2, 2.0);
1063         }
1064         else if (frame->gap_side == CL_GAP_BOTTOM)
1065         {
1066                 CLEARLOOKS_RECTANGLE_SET (*bevel,  2.0 + frame->gap_x,  height - 2.0,
1067                                           frame->gap_width - 3, 2.0);
1068                 CLEARLOOKS_RECTANGLE_SET (*border, 1.0 + frame->gap_x,  height - 1.0,
1069                                           frame->gap_width - 2, 2.0);
1070         }
1071         else if (frame->gap_side == CL_GAP_LEFT)
1072         {
1073                 CLEARLOOKS_RECTANGLE_SET (*bevel,  0.0, 2.0 + frame->gap_x,
1074                                           2.0, frame->gap_width - 3);
1075                 CLEARLOOKS_RECTANGLE_SET (*border, 0.0, 1.0 + frame->gap_x,
1076                                           1.0, frame->gap_width - 2);
1077         }
1078         else if (frame->gap_side == CL_GAP_RIGHT)
1079         {
1080                 CLEARLOOKS_RECTANGLE_SET (*bevel,  width - 2.0, 2.0 + frame->gap_x,
1081                                           2.0, frame->gap_width - 3);
1082                 CLEARLOOKS_RECTANGLE_SET (*border, width - 1.0, 1.0 + frame->gap_x,
1083                                           1.0, frame->gap_width - 2);
1084         }
1085 }
1086
1087 static void
1088 clearlooks_draw_frame            (cairo_t *cr,
1089                                   const ClearlooksColors     *colors,
1090                                   const WidgetParameters     *params,
1091                                   const FrameParameters      *frame,
1092                                   int x, int y, int width, int height)
1093 {
1094         const CairoColor *border = frame->border;
1095         const CairoColor *dark   = (CairoColor*)&colors->shade[4];
1096         ClearlooksRectangle bevel_clip = {0, 0, 0, 0};
1097         ClearlooksRectangle frame_clip = {0, 0, 0, 0};
1098         double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1099         CairoColor hilight;
1100
1101         ge_shade_color (&colors->bg[0], 1.05, &hilight);
1102
1103         if (frame->shadow == CL_SHADOW_NONE)
1104                 return;
1105
1106         if (frame->gap_x != -1)
1107                 clearlooks_get_frame_gap_clip (x, y, width, height,
1108                                                frame, &bevel_clip, &frame_clip);
1109
1110         cairo_set_line_width (cr, 1.0);
1111         cairo_translate      (cr, x, y);
1112
1113         /* save everything */
1114         cairo_save (cr);
1115         /* Set clip for the bevel */
1116         if (frame->gap_x != -1)
1117         {
1118                 /* Set clip for gap */
1119                 cairo_set_fill_rule  (cr, CAIRO_FILL_RULE_EVEN_ODD);
1120                 cairo_rectangle      (cr, 0, 0, width, height);
1121                 cairo_rectangle      (cr, bevel_clip.x, bevel_clip.y, bevel_clip.width, bevel_clip.height);
1122                 cairo_clip           (cr);
1123         }
1124
1125         /* Draw the bevel */
1126         if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
1127         {
1128                 ge_cairo_set_color (cr, &hilight);
1129                 if (frame->shadow == CL_SHADOW_ETCHED_IN)
1130                         ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
1131                 else
1132                         ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1133                 cairo_stroke (cr);
1134         }
1135         else if (frame->shadow != CL_SHADOW_NONE)
1136         {
1137                 ShadowParameters shadow;
1138                 shadow.corners = params->corners;
1139                 shadow.shadow  = frame->shadow;
1140                 clearlooks_draw_highlight_and_shade (cr, colors, &shadow, width, height, radius);
1141         }
1142
1143         /* restore the previous clip region */
1144         cairo_restore    (cr);
1145         cairo_save       (cr);
1146         if (frame->gap_x != -1)
1147         {
1148                 /* Set clip for gap */
1149                 cairo_set_fill_rule  (cr, CAIRO_FILL_RULE_EVEN_ODD);
1150                 cairo_rectangle      (cr, 0, 0, width, height);
1151                 cairo_rectangle      (cr, frame_clip.x, frame_clip.y, frame_clip.width, frame_clip.height);
1152                 cairo_clip           (cr);
1153         }
1154
1155         /* Draw frame */
1156         if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
1157         {
1158                 ge_cairo_set_color (cr, dark);
1159                 if (frame->shadow == CL_SHADOW_ETCHED_IN)
1160                         ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1161                 else
1162                         ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
1163         }
1164         else
1165         {
1166                 ge_cairo_set_color (cr, border);
1167                 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
1168         }
1169         cairo_stroke (cr);
1170
1171         cairo_restore (cr);
1172 }
1173
1174 static void
1175 clearlooks_draw_tab (cairo_t *cr,
1176                      const ClearlooksColors *colors,
1177                      const WidgetParameters *params,
1178                      const TabParameters    *tab,
1179                      int x, int y, int width, int height)
1180 {
1181         const CairoColor *border1       = &colors->shade[6];
1182         const CairoColor *border2       = &colors->shade[5];
1183         const CairoColor *stripe_fill   = &colors->spot[1];
1184         const CairoColor *stripe_border = &colors->spot[2];
1185         const CairoColor *fill;
1186         CairoColor        hilight;
1187
1188         cairo_pattern_t  *pattern;
1189
1190         double            radius;
1191         double            stripe_size = 2.0;
1192         double            stripe_fill_size;
1193         double            length;
1194
1195         radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1196
1197         cairo_save (cr);
1198
1199         /* Set clip */
1200         cairo_rectangle      (cr, x, y, width, height);
1201         cairo_clip           (cr);
1202         cairo_new_path       (cr);
1203
1204         /* Translate and set line width */
1205         cairo_set_line_width (cr, 1.0);
1206         cairo_translate      (cr, x, y);
1207
1208
1209         /* Make the tabs slightly bigger than they should be, to create a gap */
1210         /* And calculate the strip size too, while you're at it */
1211         if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
1212         {
1213                 height += 3.0;
1214                 length = height;
1215                 stripe_fill_size = (tab->gap_side == CL_GAP_TOP ? stripe_size/height : stripe_size/(height-2));
1216
1217                 if (tab->gap_side == CL_GAP_TOP)
1218                         cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
1219         }
1220         else
1221         {
1222                 width += 3.0;
1223                 length = width;
1224                 stripe_fill_size = (tab->gap_side == CL_GAP_LEFT ? stripe_size/width : stripe_size/(width-2));
1225
1226                 if (tab->gap_side == CL_GAP_LEFT)
1227                         cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
1228         }
1229
1230         /* Set the fill color */
1231         fill = &colors->bg[params->state_type];
1232
1233         /* Set tab shape */
1234         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
1235                                     radius, params->corners);
1236
1237         /* Draw fill */
1238         ge_cairo_set_color (cr, fill);
1239         cairo_fill   (cr);
1240
1241
1242         ge_shade_color (fill, 1.3, &hilight);
1243
1244         /* Draw highlight */
1245         if (!params->active)
1246         {
1247                 ShadowParameters shadow;
1248
1249                 shadow.shadow  = CL_SHADOW_OUT;
1250                 shadow.corners = params->corners;
1251
1252                 clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
1253                                                      width,
1254                                                      height, radius);
1255         }
1256
1257
1258         if (params->active)
1259         {
1260                 CairoColor shadow;
1261                 switch (tab->gap_side)
1262                 {
1263                         case CL_GAP_TOP:
1264                                 pattern = cairo_pattern_create_linear (0.5, height-1.5, 0.5, 0.5);
1265                                 break;
1266                         case CL_GAP_BOTTOM:
1267                                 pattern = cairo_pattern_create_linear (0.5, 1.5, 0.5, height+0.5);
1268                                 break;
1269                         case CL_GAP_LEFT:
1270                                 pattern = cairo_pattern_create_linear (width-1.5, 0.5, 1.5, 0.5);
1271                                 break;
1272                         case CL_GAP_RIGHT:
1273                                 pattern = cairo_pattern_create_linear (1.5, 0.5, width-1.5, 0.5);
1274                                 break;
1275                         default:
1276                                 pattern = NULL;
1277                 }
1278
1279                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
1280
1281                 ge_shade_color (fill, 0.92, &shadow);
1282
1283                 cairo_pattern_add_color_stop_rgba  (pattern, 0.0,        hilight.r, hilight.g, hilight.b, 0.4);
1284                 cairo_pattern_add_color_stop_rgba  (pattern, 1.0/length, hilight.r, hilight.g, hilight.b, 0.4);
1285                 cairo_pattern_add_color_stop_rgb   (pattern, 1.0/length, fill->r,fill->g,fill->b);
1286                 cairo_pattern_add_color_stop_rgb   (pattern, 1.0,        shadow.r,shadow.g,shadow.b);
1287                 cairo_set_source (cr, pattern);
1288                 cairo_fill (cr);
1289                 cairo_pattern_destroy (pattern);
1290         }
1291         else
1292         {
1293                 /* Draw shade */
1294                 switch (tab->gap_side)
1295                 {
1296                         case CL_GAP_TOP:
1297                                 pattern = cairo_pattern_create_linear (0.5, height-1.5, 0.5, 0.5);
1298                                 break;
1299                         case CL_GAP_BOTTOM:
1300                                 pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, height+0.5);
1301                                 break;
1302                         case CL_GAP_LEFT:
1303                                 pattern = cairo_pattern_create_linear (width-1.5, 0.5, 0.5, 0.5);
1304                                 break;
1305                         case CL_GAP_RIGHT:
1306                                 pattern = cairo_pattern_create_linear (0.5, 0.5, width+0.5, 0.5);
1307                                 break;
1308                         default:
1309                                 pattern = NULL;
1310                 }
1311
1312                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
1313
1314                 cairo_pattern_add_color_stop_rgb  (pattern, 0.0,        stripe_fill->r, stripe_fill->g, stripe_fill->b);
1315                 cairo_pattern_add_color_stop_rgb  (pattern, stripe_fill_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
1316                 cairo_pattern_add_color_stop_rgba (pattern, stripe_fill_size, hilight.r, hilight.g, hilight.b, 0.5);
1317                 cairo_pattern_add_color_stop_rgba (pattern, 0.8,        hilight.r, hilight.g, hilight.b, 0.0);
1318                 cairo_set_source (cr, pattern);
1319                 cairo_fill (cr);
1320                 cairo_pattern_destroy (pattern);
1321         }
1322
1323         ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
1324
1325         if (params->active)
1326         {
1327                 ge_cairo_set_color (cr, border2);
1328                 cairo_stroke (cr);
1329         }
1330         else
1331         {
1332                 switch (tab->gap_side)
1333                 {
1334                         case CL_GAP_TOP:
1335                                 pattern = cairo_pattern_create_linear (2.5, height-1.5, 2.5, 2.5);
1336                                 break;
1337                         case CL_GAP_BOTTOM:
1338                                 pattern = cairo_pattern_create_linear (2.5, 2.5, 2.5, height+0.5);
1339                                 break;
1340                         case CL_GAP_LEFT:
1341                                 pattern = cairo_pattern_create_linear (width-1.5, 2.5, 2.5, 2.5);
1342                                 break;
1343                         case CL_GAP_RIGHT:
1344                                 pattern = cairo_pattern_create_linear (2.5, 2.5, width+0.5, 2.5);
1345                                 break;
1346                         default:
1347                                 pattern = NULL;
1348                 }
1349
1350                 cairo_pattern_add_color_stop_rgb (pattern, 0.0,        stripe_border->r, stripe_border->g, stripe_border->b);
1351                 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_border->r, stripe_border->g, stripe_border->b);
1352                 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, border1->r,       border1->g,       border1->b);
1353                 cairo_pattern_add_color_stop_rgb (pattern, 1.0,        border2->r,       border2->g,       border2->b);
1354                 cairo_set_source (cr, pattern);
1355                 cairo_stroke (cr);
1356                 cairo_pattern_destroy (pattern);
1357         }
1358
1359         cairo_restore (cr);
1360 }
1361
1362 static void
1363 clearlooks_draw_separator (cairo_t *cr,
1364                            const ClearlooksColors     *colors,
1365                            const WidgetParameters     *widget,
1366                            const SeparatorParameters  *separator,
1367                            int x, int y, int width, int height)
1368 {
1369         CairoColor color = colors->shade[2];
1370         CairoColor hilight;
1371         ge_shade_color (&colors->bg[0], 1.065, &hilight);
1372
1373         cairo_save (cr);
1374         cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
1375
1376         if (separator->horizontal)
1377         {
1378                 cairo_set_line_width  (cr, 1.0);
1379                 cairo_translate       (cr, x, y+0.5);
1380
1381                 cairo_move_to         (cr, 0.0,   0.0);
1382                 cairo_line_to         (cr, width, 0.0);
1383                 ge_cairo_set_color    (cr, &color);
1384                 cairo_stroke          (cr);
1385
1386                 cairo_move_to         (cr, 0.0,   1.0);
1387                 cairo_line_to         (cr, width, 1.0);
1388                 ge_cairo_set_color    (cr, &hilight);
1389                 cairo_stroke          (cr);
1390         }
1391         else
1392         {
1393                 cairo_set_line_width  (cr, 1.0);
1394                 cairo_translate       (cr, x+0.5, y);
1395
1396                 cairo_move_to         (cr, 0.0, 0.0);
1397                 cairo_line_to         (cr, 0.0, height);
1398                 ge_cairo_set_color    (cr, &color);
1399                 cairo_stroke          (cr);
1400
1401                 cairo_move_to         (cr, 1.0, 0.0);
1402                 cairo_line_to         (cr, 1.0, height);
1403                 ge_cairo_set_color    (cr, &hilight);
1404                 cairo_stroke          (cr);
1405         }
1406
1407         cairo_restore (cr);
1408 }
1409
1410 static void
1411 clearlooks_draw_list_view_header (cairo_t *cr,
1412                                   const ClearlooksColors          *colors,
1413                                   const WidgetParameters          *params,
1414                                   const ListViewHeaderParameters  *header,
1415                                   int x, int y, int width, int height)
1416 {
1417         const CairoColor *border = &colors->shade[4];
1418         CairoColor hilight;
1419
1420         ge_shade_color (&colors->bg[params->state_type],
1421                         params->style_constants->topleft_highlight_shade, &hilight);
1422         hilight.a = params->style_constants->topleft_highlight_alpha;
1423
1424         cairo_translate (cr, x, y);
1425         cairo_set_line_width (cr, 1.0);
1426
1427         /* Draw highlight */
1428         if (header->order & CL_ORDER_FIRST)
1429         {
1430                 cairo_move_to (cr, 0.5, height-1);
1431                 cairo_line_to (cr, 0.5, 0.5);
1432         }
1433         else
1434                 cairo_move_to (cr, 0.0, 0.5);
1435
1436         cairo_line_to (cr, width, 0.5);
1437
1438         ge_cairo_set_color (cr, &hilight);
1439         cairo_stroke (cr);
1440
1441         /* Draw bottom border */
1442         cairo_move_to (cr, 0.0, height-0.5);
1443         cairo_line_to (cr, width, height-0.5);
1444         ge_cairo_set_color (cr, border);
1445         cairo_stroke (cr);
1446
1447         /* Draw resize grip */
1448         if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
1449             (!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
1450         {
1451                 SeparatorParameters separator;
1452                 separator.horizontal = FALSE;
1453
1454                 if (params->ltr)
1455                         params->style_functions->draw_separator (cr, colors, params, &separator,
1456                                                                  width-1.5, 4.0, 2, height-8.0);
1457                 else
1458                         params->style_functions->draw_separator (cr, colors, params, &separator,
1459                                                                  1.5, 4.0, 2, height-8.0);
1460         }
1461 }
1462
1463 /* We can't draw transparent things here, since it will be called on the same
1464  * surface multiple times, when placed on a handlebox_bin or dockitem_bin */
1465 static void
1466 clearlooks_draw_toolbar (cairo_t *cr,
1467                          const ClearlooksColors          *colors,
1468                          const WidgetParameters          *widget,
1469                          const ToolbarParameters         *toolbar,
1470                          int x, int y, int width, int height)
1471 {
1472         const CairoColor *fill  = &colors->bg[0];
1473         const CairoColor *dark  = &colors->shade[3];
1474         CairoColor light;
1475         ge_shade_color (fill, 1.065, &light);
1476
1477         cairo_set_line_width (cr, 1.0);
1478         cairo_translate (cr, x, y);
1479
1480         ge_cairo_set_color (cr, fill);
1481         cairo_paint (cr);
1482
1483         if (!toolbar->topmost)
1484         {
1485                 /* Draw highlight */
1486                 cairo_move_to       (cr, 0, 0.5);
1487                 cairo_line_to       (cr, width-1, 0.5);
1488                 ge_cairo_set_color  (cr, &light);
1489                 cairo_stroke        (cr);
1490         }
1491
1492         /* Draw shadow */
1493         cairo_move_to       (cr, 0, height-0.5);
1494         cairo_line_to       (cr, width-1, height-0.5);
1495         ge_cairo_set_color  (cr, dark);
1496         cairo_stroke        (cr);
1497 }
1498
1499 static void
1500 clearlooks_draw_menuitem (cairo_t *cr,
1501                           const ClearlooksColors          *colors,
1502                           const WidgetParameters          *widget,
1503                           int x, int y, int width, int height)
1504 {
1505         const CairoColor *fill = &colors->spot[1];
1506         CairoColor fill_shade;
1507         CairoColor border = colors->spot[2];
1508         cairo_pattern_t *pattern;
1509
1510         ge_shade_color (&border, 1.05, &border);
1511         ge_shade_color (fill, 0.85, &fill_shade);
1512         cairo_set_line_width (cr, 1.0);
1513
1514         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
1515
1516         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1517         cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
1518         cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1519
1520         cairo_set_source (cr, pattern);
1521         cairo_fill_preserve  (cr);
1522         cairo_pattern_destroy (pattern);
1523
1524         ge_cairo_set_color (cr, &border);
1525         cairo_stroke (cr);
1526 }
1527
1528 static void
1529 clearlooks_draw_menubaritem (cairo_t *cr,
1530                           const ClearlooksColors          *colors,
1531                           const WidgetParameters          *widget,
1532                           int x, int y, int width, int height)
1533 {
1534         const CairoColor *fill = &colors->spot[1];
1535         CairoColor fill_shade;
1536         CairoColor border = colors->spot[2];
1537         cairo_pattern_t *pattern;
1538
1539         ge_shade_color (&border, 1.05, &border);
1540         ge_shade_color (fill, 0.85, &fill_shade);
1541
1542         cairo_set_line_width (cr, 1.0);
1543         ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
1544
1545         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1546         cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
1547         cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1548
1549         cairo_set_source (cr, pattern);
1550         cairo_fill_preserve  (cr);
1551         cairo_pattern_destroy (pattern);
1552
1553         ge_cairo_set_color (cr, &border);
1554         cairo_stroke_preserve (cr);
1555 }
1556
1557 static void
1558 clearlooks_draw_selected_cell (cairo_t                  *cr,
1559                                const ClearlooksColors   *colors,
1560                                const WidgetParameters   *params,
1561                                int x, int y, int width, int height)
1562 {
1563         CairoColor upper_color;
1564         CairoColor lower_color;
1565         cairo_pattern_t *pattern;
1566         cairo_save (cr);
1567
1568         cairo_translate (cr, x, y);
1569
1570         if (params->focus)
1571                 upper_color = colors->base[params->state_type];
1572         else
1573                 upper_color = colors->base[GTK_STATE_ACTIVE];
1574
1575         ge_shade_color(&upper_color, 0.92, &lower_color);
1576
1577         pattern = cairo_pattern_create_linear (0, 0, 0, height);
1578         cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
1579                                                         upper_color.g,
1580                                                         upper_color.b);
1581         cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
1582                                                         lower_color.g,
1583                                                         lower_color.b);
1584
1585         cairo_set_source (cr, pattern);
1586         cairo_rectangle  (cr, 0, 0, width, height);
1587         cairo_fill       (cr);
1588
1589         cairo_pattern_destroy (pattern);
1590
1591         cairo_restore (cr);
1592 }
1593
1594
1595 static void
1596 clearlooks_draw_scrollbar_trough (cairo_t *cr,
1597                                   const ClearlooksColors           *colors,
1598                                   const WidgetParameters           *widget,
1599                                   const ScrollBarParameters        *scrollbar,
1600                                   int x, int y, int width, int height)
1601 {
1602         const CairoColor *bg     = &colors->shade[2];
1603         const CairoColor *border = &colors->shade[5];
1604         CairoColor        bg_shade;
1605         cairo_pattern_t *pattern;
1606         double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1607
1608         ge_shade_color (bg, 0.95, &bg_shade);
1609
1610         cairo_set_line_width (cr, 1);
1611         /* cairo_translate (cr, x, y); */
1612
1613         if (scrollbar->horizontal)
1614                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1615
1616         cairo_translate (cr, x, y);
1617
1618         /* Draw fill */
1619         if (radius > 3.0)
1620                 ge_cairo_rounded_rectangle (cr, 1, 0, width-2, height,
1621                                             radius, widget->corners);
1622         else
1623                 cairo_rectangle (cr, 1, 0, width-2, height);
1624         ge_cairo_set_color (cr, bg);
1625         cairo_fill (cr);
1626
1627         /* Draw shadow */
1628         pattern = cairo_pattern_create_linear (1, 0, 3, 0);
1629         cairo_pattern_add_color_stop_rgb (pattern, 0,   bg_shade.r, bg_shade.g, bg_shade.b);
1630         cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg->r,      bg->g,      bg->b);
1631         cairo_rectangle (cr, 1, 0, 4, height);
1632         cairo_set_source (cr, pattern);
1633         cairo_fill (cr);
1634         cairo_pattern_destroy (pattern);
1635
1636         /* Draw border */
1637         if (radius > 3.0)
1638                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
1639                                             radius, widget->corners);
1640         else
1641                 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
1642         ge_cairo_set_color (cr, border);
1643         cairo_stroke (cr);
1644 }
1645
1646 static void
1647 clearlooks_draw_scrollbar_stepper (cairo_t *cr,
1648                                    const ClearlooksColors           *colors,
1649                                    const WidgetParameters           *widget,
1650                                    const ScrollBarParameters        *scrollbar,
1651                                    const ScrollBarStepperParameters *stepper,
1652                                    int x, int y, int width, int height)
1653 {
1654         CairoCorners corners = CR_CORNER_NONE;
1655         CairoColor   border;
1656         CairoColor   s1, s2, s3, s4;
1657         cairo_pattern_t *pattern;
1658         double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1659
1660         ge_shade_color(&colors->shade[6], 1.08, &border);
1661
1662         if (scrollbar->horizontal)
1663         {
1664                 if (stepper->stepper == CL_STEPPER_A)
1665                         corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
1666                 else if (stepper->stepper == CL_STEPPER_D)
1667                         corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
1668         }
1669         else
1670         {
1671                 if (stepper->stepper == CL_STEPPER_A)
1672                         corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
1673                 else if (stepper->stepper == CL_STEPPER_D)
1674                         corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
1675         }
1676
1677         cairo_translate (cr, x, y);
1678         cairo_set_line_width (cr, 1);
1679
1680         ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
1681
1682         if (scrollbar->horizontal)
1683                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1684         else
1685                 pattern = cairo_pattern_create_linear (0, 0, width, 0);
1686
1687         ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
1688         ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
1689         ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
1690         ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
1691
1692         cairo_pattern_add_color_stop_rgb(pattern, 0,   s1.r, s1.g, s1.b);
1693         cairo_pattern_add_color_stop_rgb(pattern, 0.3, s2.r, s2.g, s2.b);
1694         cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
1695         cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
1696         cairo_set_source (cr, pattern);
1697         cairo_fill (cr);
1698         cairo_pattern_destroy (pattern);
1699
1700         widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width - 2, height - 2, MAX(radius - 1, 0), corners);
1701
1702         ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
1703         clearlooks_set_border_gradient (cr, &border, 1.1, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
1704         cairo_stroke (cr);
1705 }
1706
1707 static void
1708 clearlooks_draw_scrollbar_slider (cairo_t *cr,
1709                                    const ClearlooksColors          *colors,
1710                                    const WidgetParameters          *widget,
1711                                    const ScrollBarParameters       *scrollbar,
1712                                    int x, int y, int width, int height)
1713 {
1714         cairo_save (cr);
1715
1716         if (scrollbar->junction & CL_JUNCTION_BEGIN)
1717         {
1718                 if (scrollbar->horizontal)
1719                 {
1720                         x -= 1;
1721                         width += 1;
1722                 }
1723                 else
1724                 {
1725                         y -= 1;
1726                         height += 1;
1727                 }
1728         }
1729         if (scrollbar->junction & CL_JUNCTION_END)
1730         {
1731                 if (scrollbar->horizontal)
1732                         width += 1;
1733                 else
1734                         height += 1;
1735         }
1736
1737         if (!scrollbar->horizontal)
1738                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1739
1740         cairo_translate (cr, x, y);
1741
1742         if (scrollbar->has_color)
1743         {
1744                 const CairoColor *border  = &colors->shade[7];
1745                 CairoColor  fill    = scrollbar->color;
1746                 CairoColor  hilight;
1747                 CairoColor  shade1, shade2, shade3;
1748                 cairo_pattern_t *pattern;
1749
1750                 if (widget->prelight)
1751                         ge_shade_color (&fill, 1.1, &fill);
1752
1753                 cairo_set_line_width (cr, 1);
1754
1755                 ge_shade_color (&fill, 1.3, &hilight);
1756                 ge_shade_color (&fill, 1.1, &shade1);
1757                 ge_shade_color (&fill, 1.05, &shade2);
1758                 ge_shade_color (&fill, 0.98, &shade3);
1759
1760                 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1761                 cairo_pattern_add_color_stop_rgb (pattern, 0,   shade1.r, shade1.g, shade1.b);
1762                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1763                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
1764                 cairo_pattern_add_color_stop_rgb (pattern, 1,   fill.r,  fill.g,  fill.b);
1765                 cairo_rectangle (cr, 1, 1, width-2, height-2);
1766                 cairo_set_source (cr, pattern);
1767                 cairo_fill (cr);
1768                 cairo_pattern_destroy (pattern);
1769
1770                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1771                 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1772
1773                 ge_cairo_set_color (cr, border);
1774                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1775         }
1776         else
1777         {
1778                 const CairoColor *dark  = &colors->shade[4];
1779                 const CairoColor *light = &colors->shade[0];
1780                 CairoColor border;
1781                 CairoColor s1, s2, s3, s4, s5;
1782                 cairo_pattern_t *pattern;
1783                 int bar_x, i;
1784
1785                 ge_shade_color (&colors->shade[6], 1.08, &border);
1786                 ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
1787                 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
1788                 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
1789                 ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
1790
1791                 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
1792                 cairo_pattern_add_color_stop_rgb(pattern, 0,   s1.r, s1.g, s1.b);
1793                 cairo_pattern_add_color_stop_rgb(pattern, 0.3, s2.r, s2.g, s2.b);
1794                 cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
1795                 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
1796
1797                 cairo_rectangle (cr, 1, 1, width-2, height-2);
1798                 cairo_set_source(cr, pattern);
1799                 cairo_fill(cr);
1800                 cairo_pattern_destroy(pattern);
1801
1802                 clearlooks_set_border_gradient (cr, &border, 1.1, 0, height);
1803                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1804
1805                 cairo_move_to (cr, 1.5, height-1.5);
1806                 cairo_line_to (cr, 1.5, 1.5);
1807                 cairo_line_to (cr, width-1.5, 1.5);
1808                 ge_shade_color (&s2, widget->style_constants->topleft_highlight_shade, &s5);
1809                 s5.a = widget->style_constants->topleft_highlight_alpha;
1810                 ge_cairo_set_color (cr, &s5);
1811                 cairo_stroke(cr);
1812
1813                 /* draw handles */
1814                 cairo_set_line_width (cr, 1);
1815                 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
1816
1817                 bar_x = width/2 - 4;
1818
1819                 for (i=0; i<3; i++)
1820                 {
1821                         cairo_move_to (cr, bar_x + 0.5, 4);
1822                         cairo_line_to (cr, bar_x + 0.5, height-4);
1823                         ge_cairo_set_color (cr, dark);
1824                         cairo_stroke (cr);
1825
1826                         cairo_move_to (cr, bar_x+1.5, 4);
1827                         cairo_line_to (cr, bar_x+1.5, height-4);
1828                         ge_cairo_set_color (cr, light);
1829                         cairo_stroke (cr);
1830
1831                         bar_x += 3;
1832                 }
1833         }
1834
1835         cairo_restore (cr);
1836 }
1837
1838 static void
1839 clearlooks_draw_statusbar (cairo_t *cr,
1840                            const ClearlooksColors          *colors,
1841                            const WidgetParameters          *widget,
1842                            int x, int y, int width, int height)
1843 {
1844         const CairoColor *dark = &colors->shade[3];
1845         CairoColor hilight;
1846
1847         ge_shade_color (dark, 1.4, &hilight);
1848
1849         cairo_set_line_width  (cr, 1);
1850         cairo_translate       (cr, x, y+0.5);
1851         cairo_move_to         (cr, 0, 0);
1852         cairo_line_to         (cr, width, 0);
1853         ge_cairo_set_color    (cr, dark);
1854         cairo_stroke          (cr);
1855
1856         cairo_translate       (cr, 0, 1);
1857         cairo_move_to         (cr, 0, 0);
1858         cairo_line_to         (cr, width, 0);
1859         ge_cairo_set_color    (cr, &hilight);
1860         cairo_stroke          (cr);
1861 }
1862
1863 static void
1864 clearlooks_draw_menu_frame (cairo_t *cr,
1865                             const ClearlooksColors          *colors,
1866                             const WidgetParameters          *widget,
1867                             int x, int y, int width, int height)
1868 {
1869         const CairoColor *border = &colors->shade[5];
1870         cairo_translate      (cr, x, y);
1871         cairo_set_line_width (cr, 1);
1872
1873         ge_cairo_set_color (cr, border);
1874         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1875 }
1876
1877 static void
1878 clearlooks_draw_tooltip (cairo_t *cr,
1879                          const ClearlooksColors          *colors,
1880                          const WidgetParameters          *widget,
1881                          int x, int y, int width, int height)
1882 {
1883         CairoColor border;
1884
1885         ge_shade_color (&colors->bg[widget->state_type], 0.6, &border);
1886
1887         cairo_save (cr);
1888
1889         cairo_translate      (cr, x, y);
1890         cairo_set_line_width (cr, 1);
1891
1892         ge_cairo_set_color (cr, &colors->bg[widget->state_type]);
1893         cairo_rectangle (cr, 0, 0, width, height);
1894         cairo_fill (cr);
1895
1896         ge_cairo_set_color (cr, &border);
1897         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1898
1899         cairo_restore (cr);
1900 }
1901
1902 static void
1903 clearlooks_draw_handle (cairo_t *cr,
1904                         const ClearlooksColors          *colors,
1905                         const WidgetParameters          *params,
1906                         const HandleParameters          *handle,
1907                         int x, int y, int width, int height)
1908 {
1909         const CairoColor *fill  = &colors->bg[params->state_type];
1910         int num_bars = 6; /* shut up gcc warnings */
1911
1912         cairo_save (cr);
1913
1914         switch (handle->type)
1915         {
1916                 case CL_HANDLE_TOOLBAR:
1917                         num_bars    = 6;
1918                 break;
1919                 case CL_HANDLE_SPLITTER:
1920                         num_bars    = 16;
1921                 break;
1922         }
1923
1924         if (params->prelight)
1925         {
1926                 cairo_rectangle (cr, x, y, width, height);
1927                 ge_cairo_set_color (cr, fill);
1928                 cairo_fill (cr);
1929         }
1930
1931         cairo_translate (cr, x, y);
1932
1933         cairo_set_line_width (cr, 1);
1934
1935         if (handle->horizontal)
1936         {
1937                 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, num_bars, 2, 0.1);
1938         }
1939         else
1940         {
1941                 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, 2, num_bars, 0.1);
1942         }
1943
1944         cairo_restore (cr);
1945 }
1946
1947 static void
1948 clearlooks_draw_resize_grip (cairo_t *cr,
1949                              const ClearlooksColors          *colors,
1950                              const WidgetParameters          *widget,
1951                              const ResizeGripParameters      *grip,
1952                              int x, int y, int width, int height)
1953 {
1954         const CairoColor *dark   = &colors->shade[4];
1955         CairoColor hilight;
1956         int lx, ly;
1957         int x_down;
1958         int y_down;
1959         int dots;
1960
1961         ge_shade_color (dark, 1.5, &hilight);
1962
1963         /* The number of dots fitting into the area. Just hardcoded to 4 right now. */
1964         /* dots = MIN (width - 2, height - 2) / 3; */
1965         dots = 4;
1966
1967         cairo_save (cr);
1968
1969         switch (grip->edge)
1970         {
1971                 case CL_WINDOW_EDGE_NORTH_EAST:
1972                         x_down = 0;
1973                         y_down = 0;
1974                         cairo_translate (cr, x + width - 3*dots + 2, y + 1);
1975                 break;
1976                 case CL_WINDOW_EDGE_SOUTH_EAST:
1977                         x_down = 0;
1978                         y_down = 1;
1979                         cairo_translate (cr, x + width - 3*dots + 2, y + height - 3*dots + 2);
1980                 break;
1981                 case CL_WINDOW_EDGE_SOUTH_WEST:
1982                         x_down = 1;
1983                         y_down = 1;
1984                         cairo_translate (cr, x + 1, y + height - 3*dots + 2);
1985                 break;
1986                 case CL_WINDOW_EDGE_NORTH_WEST:
1987                         x_down = 1;
1988                         y_down = 0;
1989                         cairo_translate (cr, x + 1, y + 1);
1990                 break;
1991                 default:
1992                         /* Not implemented. */
1993                         return;
1994         }
1995
1996         for (lx = 0; lx < dots; lx++) /* horizontally */
1997         {
1998                 for (ly = 0; ly <= lx; ly++) /* vertically */
1999                 {
2000                         int mx, my;
2001                         mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
2002                         my = y_down * dots + (1 - y_down * 2) * ly - y_down;
2003
2004                         ge_cairo_set_color (cr, &hilight);
2005                         cairo_rectangle (cr, mx*3-1, my*3-1, 2, 2);
2006                         cairo_fill (cr);
2007
2008                         ge_cairo_set_color (cr, dark);
2009                         cairo_rectangle (cr, mx*3-1, my*3-1, 1, 1);
2010                         cairo_fill (cr);
2011                 }
2012         }
2013
2014         cairo_restore (cr);
2015 }
2016
2017 static void
2018 clearlooks_draw_radiobutton (cairo_t *cr,
2019                              const ClearlooksColors  *colors,
2020                              const WidgetParameters  *widget,
2021                              const CheckboxParameters *checkbox,
2022                              int x, int y, int width, int height)
2023 {
2024         const CairoColor *border;
2025         const CairoColor *dot;
2026         CairoColor shadow;
2027         CairoColor highlight;
2028         cairo_pattern_t *pt;
2029         gboolean inconsistent;
2030         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2031         gdouble w, h, cx, cy, radius;
2032
2033         w = (gdouble) width;
2034         h = (gdouble) height;
2035         cx = width / 2.0;
2036         cy = height / 2.0;
2037         radius = MIN (width, height) / 2.0;
2038
2039         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2040         draw_bullet |= inconsistent;
2041
2042         if (widget->disabled)
2043         {
2044                 border = &colors->shade[5];
2045                 dot    = &colors->shade[6];
2046         }
2047         else
2048         {
2049                 border = &colors->shade[6];
2050                 dot    = &colors->text[0];
2051         }
2052
2053         ge_shade_color (&widget->parentbg, 0.9, &shadow);
2054         ge_shade_color (&widget->parentbg, 1.1, &highlight);
2055
2056         pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
2057         cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
2058         cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
2059         cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
2060         cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
2061
2062         cairo_translate (cr, x, y);
2063
2064         cairo_set_line_width (cr, MAX (1.0, floor (radius/3)));
2065         cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2);
2066         cairo_set_source (cr, pt);
2067         cairo_stroke (cr);
2068         cairo_pattern_destroy (pt);
2069
2070         cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
2071
2072         cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
2073
2074         if (!widget->disabled)
2075         {
2076                 ge_cairo_set_color (cr, &colors->base[0]);
2077                 cairo_fill_preserve (cr);
2078         }
2079
2080         ge_cairo_set_color (cr, border);
2081         cairo_stroke (cr);
2082
2083         if (draw_bullet)
2084         {
2085                 if (inconsistent)
2086                 {
2087                         cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
2088                         cairo_set_line_width (cr, ceil (radius * 2 / 3));
2089
2090                         cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy));
2091                         cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy));
2092
2093                         ge_cairo_set_color (cr, dot);
2094                         cairo_stroke (cr);
2095                 }
2096                 else
2097                 {
2098                         cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
2099                         ge_cairo_set_color (cr, dot);
2100                         cairo_fill (cr);
2101
2102                         cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
2103                         cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
2104                         cairo_fill (cr);
2105                 }
2106         }
2107 }
2108
2109 static void
2110 clearlooks_draw_checkbox (cairo_t *cr,
2111                           const ClearlooksColors  *colors,
2112                           const WidgetParameters  *widget,
2113                           const CheckboxParameters *checkbox,
2114                           int x, int y, int width, int height)
2115 {
2116         const CairoColor *border;
2117         const CairoColor *dot;
2118         gboolean inconsistent = FALSE;
2119         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2120
2121         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2122         draw_bullet |= inconsistent;
2123
2124         if (widget->disabled)
2125         {
2126                 border = &colors->shade[5];
2127                 dot    = &colors->shade[6];
2128         }
2129         else
2130         {
2131                 border = &colors->shade[6];
2132                 dot    = &colors->text[GTK_STATE_NORMAL];
2133         }
2134
2135         cairo_translate (cr, x, y);
2136         cairo_set_line_width (cr, 1);
2137
2138         if (widget->xthickness > 2 && widget->ythickness > 2)
2139         {
2140                 widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0, width, height, 1, CR_CORNER_ALL);
2141
2142                 /* Draw the rectangle for the checkbox itself */
2143                 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2144         }
2145         else
2146         {
2147                 /* Draw the rectangle for the checkbox itself */
2148                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2149         }
2150
2151         if (!widget->disabled)
2152         {
2153                 ge_cairo_set_color (cr, &colors->base[0]);
2154                 cairo_fill_preserve (cr);
2155         }
2156
2157         ge_cairo_set_color (cr, border);
2158         cairo_stroke (cr);
2159
2160         if (draw_bullet)
2161         {
2162                 if (inconsistent) /* Inconsistent */
2163                 {
2164                         cairo_set_line_width (cr, 2.0);
2165                         cairo_move_to (cr, 3, height*0.5);
2166                         cairo_line_to (cr, width-3, height*0.5);
2167                 }
2168                 else
2169                 {
2170                         cairo_set_line_width (cr, 1.7);
2171                         cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
2172                         cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
2173
2174                         cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
2175                                             0.5 + (width*0.5), (height*0.4),
2176                                             0.5 + (width*0.70), (height*0.25));
2177
2178                 }
2179
2180                 ge_cairo_set_color (cr, dot);
2181                 cairo_stroke (cr);
2182         }
2183 }
2184
2185 static void
2186 clearlooks_draw_normal_arrow (cairo_t *cr, const CairoColor *color,
2187                               double x, double y, double width, double height)
2188 {
2189         double arrow_width;
2190         double arrow_height;
2191         double line_width_2;
2192
2193         cairo_save (cr);
2194
2195         arrow_width = MIN (height * 2.0 + MAX (1.0, ceil (height * 2.0 / 6.0 * 2.0) / 2.0) / 2.0, width);
2196         line_width_2 = MAX (1.0, ceil (arrow_width / 6.0 * 2.0) / 2.0) / 2.0;
2197         arrow_height = arrow_width / 2.0 + line_width_2;
2198
2199         cairo_translate (cr, x, y - arrow_height / 2.0);
2200
2201         cairo_move_to (cr, -arrow_width / 2.0, line_width_2);
2202         cairo_line_to (cr, -arrow_width / 2.0 + line_width_2, 0);
2203         /* cairo_line_to (cr, 0, arrow_height - line_width_2); */
2204         cairo_arc_negative (cr, 0, arrow_height - 2*line_width_2 - 2*line_width_2 * sqrt(2), 2*line_width_2, G_PI_2 + G_PI_4, G_PI_4);
2205         cairo_line_to (cr, arrow_width / 2.0 - line_width_2, 0);
2206         cairo_line_to (cr, arrow_width / 2.0, line_width_2);
2207         cairo_line_to (cr, 0, arrow_height);
2208         cairo_close_path (cr);
2209
2210         ge_cairo_set_color (cr, color);
2211         cairo_fill (cr);
2212
2213         cairo_restore (cr);
2214 }
2215
2216 static void
2217 clearlooks_draw_combo_arrow (cairo_t *cr, const CairoColor *color,
2218                              double x, double y, double width, double height)
2219 {
2220         double arrow_width = MIN (height * 2 / 3.0, width);
2221         double arrow_height = arrow_width / 2.0;
2222         double gap_size = 1.0 * arrow_height;
2223
2224         cairo_save (cr);
2225         cairo_translate (cr, x, y - (arrow_height + gap_size) / 2.0);
2226         cairo_rotate (cr, G_PI);
2227         clearlooks_draw_normal_arrow (cr, color, 0, 0, arrow_width, arrow_height);
2228         cairo_restore (cr);
2229
2230         clearlooks_draw_normal_arrow (cr, color, x, y + (arrow_height + gap_size) / 2.0, arrow_width, arrow_height);
2231 }
2232
2233 static void
2234 _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
2235                         ClearlooksDirection dir, ClearlooksArrowType type,
2236                         double x, double y, double width, double height)
2237 {
2238         double rotate;
2239
2240         if (dir == CL_DIRECTION_LEFT)
2241                 rotate = G_PI*1.5;
2242         else if (dir == CL_DIRECTION_RIGHT)
2243                 rotate = G_PI*0.5;
2244         else if (dir == CL_DIRECTION_UP)
2245                 rotate = G_PI;
2246         else if (dir == CL_DIRECTION_DOWN)
2247                 rotate = 0;
2248         else
2249                 return;
2250
2251         if (type == CL_ARROW_NORMAL)
2252         {
2253                 cairo_translate (cr, x, y);
2254                 cairo_rotate (cr, -rotate);
2255                 clearlooks_draw_normal_arrow (cr, color, 0, 0, width, height);
2256         }
2257         else if (type == CL_ARROW_COMBO)
2258         {
2259                 cairo_translate (cr, x, y);
2260                 clearlooks_draw_combo_arrow (cr, color, 0, 0, width, height);
2261         }
2262 }
2263
2264 static void
2265 clearlooks_draw_arrow (cairo_t *cr,
2266                        const ClearlooksColors *colors,
2267                        const WidgetParameters *widget,
2268                        const ArrowParameters  *arrow,
2269                        int x, int y, int width, int height)
2270 {
2271         const CairoColor *color = &colors->fg[widget->state_type];
2272         gdouble tx, ty;
2273
2274         tx = x + width/2.0;
2275         ty = y + height/2.0;
2276
2277         if (widget->disabled)
2278         {
2279                 _clearlooks_draw_arrow (cr, &colors->shade[0],
2280                                         arrow->direction, arrow->type,
2281                                         tx+0.5, ty+0.5, width, height);
2282         }
2283
2284         cairo_identity_matrix (cr);
2285
2286         _clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
2287                                 tx, ty, width, height);
2288 }
2289
2290 void
2291 clearlooks_draw_focus (cairo_t *cr,
2292                        const ClearlooksColors *colors,
2293                        const WidgetParameters *widget,
2294                        const FocusParameters  *focus,
2295                        int x, int y, int width, int height)
2296 {
2297         if (focus->has_color)
2298                 ge_cairo_set_color (cr, &focus->color);
2299         else if (focus->type == CL_FOCUS_COLOR_WHEEL_LIGHT)
2300                 cairo_set_source_rgb (cr, 0., 0., 0.);
2301         else if (focus->type == CL_FOCUS_COLOR_WHEEL_DARK)
2302                 cairo_set_source_rgb (cr, 1., 1., 1.);
2303         else
2304                 cairo_set_source_rgba (cr,
2305                                        colors->fg[widget->state_type].r,
2306                                        colors->fg[widget->state_type].g,
2307                                        colors->fg[widget->state_type].b,
2308                                        0.7);
2309
2310         cairo_set_line_width (cr, focus->line_width);
2311
2312         if (focus->dash_list[0])
2313         {
2314                 gint n_dashes = strlen ((gchar *)focus->dash_list);
2315                 gdouble *dashes = g_new (gdouble, n_dashes);
2316                 gdouble total_length = 0;
2317                 gdouble dash_offset;
2318                 gint i;
2319
2320                 for (i = 0; i < n_dashes; i++)
2321                 {
2322                         dashes[i] = focus->dash_list[i];
2323                         total_length += focus->dash_list[i];
2324                 }
2325
2326                 dash_offset = -focus->line_width / 2.0;
2327                 while (dash_offset < 0)
2328                         dash_offset += total_length;
2329
2330                 cairo_set_dash (cr, dashes, n_dashes, dash_offset);
2331                 g_free (dashes);
2332         }
2333
2334         cairo_rectangle (cr,
2335                          x + focus->line_width / 2.0,
2336                          y + focus->line_width / 2.0,
2337                          width - focus->line_width, height - focus->line_width);
2338         cairo_stroke (cr);
2339 }
2340
2341 void
2342 clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
2343 {
2344         g_assert (functions);
2345
2346         functions->draw_top_left_highlight  = clearlooks_draw_top_left_highlight;
2347         functions->draw_button              = clearlooks_draw_button;
2348         functions->draw_scale_trough        = clearlooks_draw_scale_trough;
2349         functions->draw_progressbar_trough  = clearlooks_draw_progressbar_trough;
2350         functions->draw_progressbar_fill    = clearlooks_draw_progressbar_fill;
2351         functions->draw_slider_button       = clearlooks_draw_slider_button;
2352         functions->draw_entry               = clearlooks_draw_entry;
2353         functions->draw_spinbutton          = clearlooks_draw_spinbutton;
2354         functions->draw_spinbutton_down     = clearlooks_draw_spinbutton_down;
2355         functions->draw_optionmenu          = clearlooks_draw_optionmenu;
2356         functions->draw_inset               = clearlooks_draw_inset;
2357         functions->draw_menubar             = clearlooks_draw_menubar;
2358         functions->draw_tab                 = clearlooks_draw_tab;
2359         functions->draw_frame               = clearlooks_draw_frame;
2360         functions->draw_separator           = clearlooks_draw_separator;
2361         functions->draw_menu_item_separator = clearlooks_draw_menu_item_separator;
2362         functions->draw_list_view_header    = clearlooks_draw_list_view_header;
2363         functions->draw_toolbar             = clearlooks_draw_toolbar;
2364         functions->draw_menuitem            = clearlooks_draw_menuitem;
2365         functions->draw_menubaritem         = clearlooks_draw_menubaritem;
2366         functions->draw_selected_cell       = clearlooks_draw_selected_cell;
2367         functions->draw_scrollbar_stepper   = clearlooks_draw_scrollbar_stepper;
2368         functions->draw_scrollbar_slider    = clearlooks_draw_scrollbar_slider;
2369         functions->draw_scrollbar_trough    = clearlooks_draw_scrollbar_trough;
2370         functions->draw_statusbar           = clearlooks_draw_statusbar;
2371         functions->draw_menu_frame          = clearlooks_draw_menu_frame;
2372         functions->draw_tooltip             = clearlooks_draw_tooltip;
2373         functions->draw_handle              = clearlooks_draw_handle;
2374         functions->draw_resize_grip         = clearlooks_draw_resize_grip;
2375         functions->draw_arrow               = clearlooks_draw_arrow;
2376         functions->draw_focus                = clearlooks_draw_focus;
2377         functions->draw_checkbox            = clearlooks_draw_checkbox;
2378         functions->draw_radiobutton         = clearlooks_draw_radiobutton;
2379         functions->draw_shadow              = clearlooks_draw_shadow;
2380         functions->draw_slider              = clearlooks_draw_slider;
2381         functions->draw_gripdots            = clearlooks_draw_gripdots;
2382
2383         constants->topleft_highlight_shade  = 1.3;
2384         constants->topleft_highlight_alpha  = 0.6;
2385 }