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