Merge branch 'nsm' of https://github.com/royvegard/ardour
[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         (void) params;
949         (void) menubar;
950         
951 /*      const CairoColor *light = &colors->shade[0]; */
952         const CairoColor *dark = &colors->shade[3];
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         (void) params;
976         (void) menubar;
977         
978         CairoColor lower;
979         cairo_pattern_t *pattern;
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         (void) widget;
1320         
1321         CairoColor color = colors->shade[3];
1322         CairoColor hilight; 
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         (void) widget;
1436
1437         const CairoColor *fill  = &colors->bg[GTK_STATE_NORMAL];
1438         const CairoColor *dark  = &colors->shade[3];
1439         CairoColor light;
1440         ge_shade_color (fill, 1.1, &light);
1441         
1442         cairo_set_line_width (cr, 1.0);
1443         cairo_translate (cr, x, y);
1444
1445         ge_cairo_set_color (cr, fill);
1446         cairo_paint (cr);
1447
1448         if (!toolbar->topmost) 
1449         {
1450                 /* Draw highlight */
1451                 cairo_move_to       (cr, 0, 0.5);
1452                 cairo_line_to       (cr, width-1, 0.5);
1453                 ge_cairo_set_color  (cr, &light);
1454                 cairo_stroke        (cr);
1455         }
1456
1457         /* Draw shadow */
1458         cairo_move_to       (cr, 0, height-0.5);
1459         cairo_line_to       (cr, width-1, height-0.5);
1460         ge_cairo_set_color  (cr, dark);
1461         cairo_stroke        (cr);
1462 }
1463
1464 static void
1465 clearlooks_draw_menuitem (cairo_t *cr,
1466                           const ClearlooksColors          *colors,
1467                           const WidgetParameters          *widget,
1468                           int x, int y, int width, int height)
1469 {
1470         const CairoColor *fill = &colors->spot[1];
1471         CairoColor fill_shade;
1472         CairoColor border = colors->spot[2];
1473         cairo_pattern_t *pattern;
1474
1475         ge_shade_color (&border, 1.05, &border);
1476         ge_shade_color (fill, 0.85, &fill_shade);
1477         cairo_set_line_width (cr, 1.0);
1478
1479         ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
1480
1481         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1482         cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
1483         cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1484
1485         cairo_set_source (cr, pattern);
1486         cairo_fill_preserve  (cr);
1487         cairo_pattern_destroy (pattern);
1488
1489         ge_cairo_set_color (cr, &border);
1490         cairo_stroke (cr);
1491 }
1492
1493 static void
1494 clearlooks_draw_menubaritem (cairo_t *cr,
1495                           const ClearlooksColors          *colors,
1496                           const WidgetParameters          *widget,
1497                           int x, int y, int width, int height)
1498 {
1499         const CairoColor *fill = &colors->spot[1];
1500         CairoColor fill_shade;
1501         CairoColor border = colors->spot[2];
1502         cairo_pattern_t *pattern;
1503         
1504         ge_shade_color (&border, 1.05, &border);
1505         ge_shade_color (fill, 0.85, &fill_shade);
1506         
1507         cairo_set_line_width (cr, 1.0);
1508         ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
1509
1510         pattern = cairo_pattern_create_linear (x, y, x, y + height);
1511         cairo_pattern_add_color_stop_rgb (pattern, 0,   fill->r, fill->g, fill->b);
1512         cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1513
1514         cairo_set_source (cr, pattern);
1515         cairo_fill_preserve  (cr);
1516         cairo_pattern_destroy (pattern);
1517
1518         ge_cairo_set_color (cr, &border);
1519         cairo_stroke_preserve (cr);
1520 }
1521
1522 static void
1523 clearlooks_draw_selected_cell (cairo_t                  *cr,
1524                                const ClearlooksColors   *colors,
1525                                const WidgetParameters   *params,
1526                                int x, int y, int width, int height)
1527 {
1528         CairoColor upper_color;
1529         CairoColor lower_color;
1530         CairoColor border;
1531         cairo_pattern_t *pattern;
1532         cairo_save (cr);
1533         
1534         cairo_translate (cr, x, y);
1535
1536         if (params->focus)
1537                 upper_color = colors->base[params->state_type];
1538         else
1539                 upper_color = colors->base[GTK_STATE_ACTIVE];
1540
1541         ge_shade_color(&upper_color, 0.92, &lower_color);
1542
1543         pattern = cairo_pattern_create_linear (0, 0, 0, height);
1544         cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
1545                                                         upper_color.g,
1546                                                         upper_color.b);
1547         cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
1548                                                         lower_color.g,
1549                                                         lower_color.b);
1550
1551         cairo_set_source (cr, pattern);
1552         cairo_rectangle  (cr, 0, 0, width, height);
1553         cairo_fill       (cr);
1554
1555         cairo_pattern_destroy (pattern);
1556         
1557         ge_shade_color(&upper_color, 0.8, &border);     
1558
1559         cairo_move_to  (cr, 0, 0.5);
1560         cairo_rel_line_to (cr, width, 0);
1561         cairo_move_to  (cr, 0, height-0.5);
1562         cairo_rel_line_to (cr, width, 0);
1563
1564         ge_cairo_set_color (cr, &border);
1565         cairo_stroke (cr);
1566
1567         cairo_restore (cr);
1568 }
1569
1570
1571 static void
1572 clearlooks_draw_scrollbar_trough (cairo_t *cr,
1573                                   const ClearlooksColors           *colors,
1574                                   const WidgetParameters           *widget,
1575                                   const ScrollBarParameters        *scrollbar,
1576                                   int x, int y, int width, int height)
1577 {
1578         (void) widget;
1579
1580         const CairoColor *bg     = &colors->shade[2];
1581         const CairoColor *border = &colors->shade[5];
1582         CairoColor        bg_shade;
1583         cairo_pattern_t *pattern;
1584         
1585         ge_shade_color (bg, 0.95, &bg_shade);
1586         
1587         cairo_set_line_width (cr, 1);
1588         /* cairo_translate (cr, x, y); */
1589         
1590         if (scrollbar->horizontal)
1591                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1592
1593         cairo_translate (cr, x, y);     
1594
1595         /* Draw fill */
1596         cairo_rectangle (cr, 1, 0, width-2, height);
1597         ge_cairo_set_color (cr, bg);
1598         cairo_fill (cr);
1599
1600         /* Draw shadow */
1601         pattern = cairo_pattern_create_linear (1, 0, 3, 0);
1602         cairo_pattern_add_color_stop_rgb (pattern, 0,   bg_shade.r, bg_shade.g, bg_shade.b);
1603         cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg->r,      bg->g,      bg->b); 
1604         cairo_rectangle (cr, 1, 0, 4, height);
1605         cairo_set_source (cr, pattern);
1606         cairo_fill (cr);
1607         cairo_pattern_destroy (pattern);
1608         
1609         /* Draw border */
1610         ge_cairo_set_color (cr, border);
1611         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1612 }
1613
1614 static void
1615 clearlooks_draw_scrollbar_stepper (cairo_t *cr,
1616                                    const ClearlooksColors           *colors,
1617                                    const WidgetParameters           *widget,
1618                                    const ScrollBarParameters        *scrollbar,
1619                                    const ScrollBarStepperParameters *stepper,
1620                                    int x, int y, int width, int height)
1621 {
1622         CairoCorners corners = CR_CORNER_NONE;
1623         CairoColor   border;
1624         CairoColor   s1, s2, s3, s4;
1625         cairo_pattern_t *pattern;
1626         double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1627
1628         ge_shade_color(&colors->shade[6], 1.05, &border);
1629         
1630         if (scrollbar->horizontal)
1631         {
1632                 if (stepper->stepper == CL_STEPPER_A)
1633                         corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
1634                 else if (stepper->stepper == CL_STEPPER_D)
1635                         corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
1636         }
1637         else
1638         {
1639                 if (stepper->stepper == CL_STEPPER_A)
1640                         corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
1641                 else if (stepper->stepper == CL_STEPPER_D)
1642                         corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
1643         }
1644         
1645         cairo_translate (cr, x, y);
1646         cairo_set_line_width (cr, 1);
1647         
1648         ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
1649         
1650         if (scrollbar->horizontal)
1651                 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1652         else
1653                 pattern = cairo_pattern_create_linear (0, 0, width, 0);
1654                                 
1655         s2 = colors->bg[widget->state_type];
1656         ge_shade_color(&s2, 1.06, &s1);
1657         ge_shade_color(&s2, 0.98, &s3); 
1658         ge_shade_color(&s2, 0.94, &s4); 
1659         
1660         cairo_pattern_add_color_stop_rgb(pattern, 0,    s1.r, s1.g, s1.b);
1661         cairo_pattern_add_color_stop_rgb(pattern, 0.5,  s2.r, s2.g, s2.b);
1662         cairo_pattern_add_color_stop_rgb(pattern, 0.7,  s3.r, s3.g, s3.b);
1663         cairo_pattern_add_color_stop_rgb(pattern, 1.0,  s4.r, s4.g, s4.b);
1664         cairo_set_source (cr, pattern);
1665         cairo_fill (cr);
1666         cairo_pattern_destroy (pattern);
1667         
1668         cairo_translate (cr, 0.5, 0.5);
1669         clearlooks_draw_top_left_highlight (cr, &s2, widget, width, height, (stepper->stepper == CL_STEPPER_A) ? radius : 0);
1670         cairo_translate (cr, -0.5, -0.5);
1671         
1672         ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
1673         clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0)); 
1674         cairo_stroke (cr);
1675         
1676         cairo_translate (cr, 0.5, 0.5);
1677 }
1678
1679 static void
1680 clearlooks_draw_scrollbar_slider (cairo_t *cr,
1681                                    const ClearlooksColors          *colors,
1682                                    const WidgetParameters          *widget,
1683                                    const ScrollBarParameters       *scrollbar,
1684                                    int x, int y, int width, int height)
1685 {
1686         if (scrollbar->junction & CL_JUNCTION_BEGIN)
1687         {
1688                 if (scrollbar->horizontal)
1689                 {
1690                         x -= 1;
1691                         width += 1;
1692                 }
1693                 else
1694                 {
1695                         y -= 1;
1696                         height += 1;
1697                 }
1698         }
1699         if (scrollbar->junction & CL_JUNCTION_END)
1700         {
1701                 if (scrollbar->horizontal)
1702                         width += 1;
1703                 else
1704                         height += 1;
1705         }
1706         
1707         if (!scrollbar->horizontal)
1708                 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1709
1710         cairo_translate (cr, x, y);     
1711
1712         if (scrollbar->has_color)
1713         {
1714                 const CairoColor *border  = &colors->shade[7];
1715                 CairoColor  fill    = scrollbar->color;
1716                 CairoColor  hilight;
1717                 CairoColor  shade1, shade2, shade3;
1718                 cairo_pattern_t *pattern;
1719
1720                 if (widget->prelight)
1721                         ge_shade_color (&fill, 1.1, &fill);
1722                         
1723                 cairo_set_line_width (cr, 1);
1724                 
1725                 ge_shade_color (&fill, 1.3, &hilight);
1726                 ge_shade_color (&fill, 1.1, &shade1);
1727                 ge_shade_color (&fill, 1.05, &shade2);
1728                 ge_shade_color (&fill, 0.98, &shade3);
1729                 
1730                 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1731                 cairo_pattern_add_color_stop_rgb (pattern, 0,   shade1.r, shade1.g, shade1.b);
1732                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1733                 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);  
1734                 cairo_pattern_add_color_stop_rgb (pattern, 1,   fill.r,  fill.g,  fill.b);
1735                 cairo_rectangle (cr, 1, 1, width-2, height-2);
1736                 cairo_set_source (cr, pattern);
1737                 cairo_fill (cr);
1738                 cairo_pattern_destroy (pattern);
1739                 
1740                 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1741                 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1742         
1743                 ge_cairo_set_color (cr, border);
1744                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1745         }
1746         else
1747         {
1748                 const CairoColor *dark  = &colors->shade[4];
1749                 const CairoColor *light = &colors->shade[0];
1750                 CairoColor border;
1751                 CairoColor s1, s2, s3, s4, s5;
1752                 cairo_pattern_t *pattern;
1753                 int bar_x, i;
1754
1755                 ge_shade_color(&colors->shade[6], 1.05, &border);
1756                 
1757                 s2 = colors->bg[widget->state_type];
1758                 ge_shade_color(&s2, 1.06, &s1);
1759                 ge_shade_color(&s2, 0.98, &s3); 
1760                 ge_shade_color(&s2, 0.94, &s4); 
1761         
1762                 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
1763                 cairo_pattern_add_color_stop_rgb(pattern, 0,   s1.r, s1.g, s1.b);
1764                 cairo_pattern_add_color_stop_rgb(pattern, 0.5, s2.r, s2.g, s2.b);
1765                 cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
1766                 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
1767
1768                 cairo_rectangle (cr, 1, 1, width-2, height-2);
1769                 cairo_set_source(cr, pattern);
1770                 cairo_fill(cr);
1771                 cairo_pattern_destroy(pattern);
1772                 
1773                 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height); 
1774                 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1775                 
1776                 cairo_move_to (cr, 1.5, height-1.5);
1777                 cairo_line_to (cr, 1.5, 1.5);
1778                 cairo_line_to (cr, width-1.5, 1.5);
1779                 ge_shade_color (&s2, 1.3, &s5);
1780                 cairo_set_source_rgba (cr, s5.r, s5.g, s5.b, 0.5);
1781                 cairo_stroke(cr);
1782                 
1783                 /* draw handles */
1784                 cairo_set_line_width (cr, 1);
1785                 
1786                 bar_x = width/2 - 4;
1787                 cairo_translate(cr, 0.5, 0.5);
1788                 for (i=0; i<3; i++)
1789                 {
1790                         cairo_move_to (cr, bar_x, 4);
1791                         cairo_line_to (cr, bar_x, height-5);
1792                         ge_cairo_set_color (cr, dark);
1793                         cairo_stroke (cr);
1794                         
1795                         cairo_move_to (cr, bar_x+1, 4);
1796                         cairo_line_to (cr, bar_x+1, height-5);
1797                         ge_cairo_set_color (cr, light);
1798                         cairo_stroke (cr);
1799                         
1800                         bar_x += 3;
1801                 }
1802         }
1803         
1804 }
1805
1806 static void
1807 clearlooks_draw_statusbar (cairo_t *cr,
1808                            const ClearlooksColors          *colors,
1809                            const WidgetParameters          *widget,
1810                            int x, int y, int width, int height)
1811 {
1812         (void) widget;
1813         (void) height;
1814         
1815         const CairoColor *dark = &colors->shade[3];
1816         CairoColor hilight;
1817
1818         ge_shade_color (dark, 1.4, &hilight);
1819
1820         cairo_set_line_width  (cr, 1);
1821         cairo_translate       (cr, x, y+0.5);
1822         cairo_move_to         (cr, 0, 0);
1823         cairo_line_to         (cr, width, 0);
1824         ge_cairo_set_color  (cr, dark);
1825         cairo_stroke          (cr);
1826
1827         cairo_translate       (cr, 0, 1);
1828         cairo_move_to         (cr, 0, 0);
1829         cairo_line_to         (cr, width, 0);
1830         ge_cairo_set_color    (cr, &hilight);
1831         cairo_stroke          (cr);
1832 }
1833
1834 static void
1835 clearlooks_draw_menu_frame (cairo_t *cr,
1836                             const ClearlooksColors          *colors,
1837                             const WidgetParameters          *widget,
1838                             int x, int y, int width, int height)
1839 {
1840         (void) widget;
1841
1842         const CairoColor *border = &colors->shade[5];
1843         cairo_translate      (cr, x, y);
1844         cairo_set_line_width (cr, 1);
1845 /*
1846         cairo_set_source_rgba (cr, colors->bg[0].r, colors->bg[0].g, colors->bg[0].b, 0.9);
1847         cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
1848         cairo_paint          (cr);
1849 */
1850         ge_cairo_set_color (cr, border);
1851         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1852 }
1853
1854 static void
1855 clearlooks_draw_tooltip (cairo_t *cr,
1856                          const ClearlooksColors          *colors,
1857                          const WidgetParameters          *widget,
1858                          int x, int y, int width, int height)
1859 {
1860         CairoColor border;
1861
1862         ge_shade_color (&colors->bg[widget->state_type], 0.6, &border);
1863
1864         cairo_save (cr);
1865
1866         cairo_translate      (cr, x, y);
1867         cairo_set_line_width (cr, 1);
1868
1869         ge_cairo_set_color (cr, &colors->bg[widget->state_type]);
1870         cairo_rectangle (cr, 0, 0, width, height);
1871         cairo_fill (cr);
1872
1873         ge_cairo_set_color (cr, &border);
1874         ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1875
1876         cairo_restore (cr);
1877 }
1878
1879 static void
1880 clearlooks_draw_handle (cairo_t *cr,
1881                         const ClearlooksColors          *colors,
1882                         const WidgetParameters          *params,
1883                         const HandleParameters          *handle,
1884                         int x, int y, int width, int height)
1885 {
1886         const CairoColor *fill  = &colors->bg[params->state_type];
1887         int num_bars = 6; /* shut up gcc warnings */
1888         
1889         switch (handle->type)
1890         {
1891                 case CL_HANDLE_TOOLBAR:
1892                         num_bars    = 6;
1893                 break;
1894                 case CL_HANDLE_SPLITTER:
1895                         num_bars    = 16;
1896                 break;
1897         }
1898
1899         if (params->prelight)
1900         {
1901                 cairo_rectangle (cr, x, y, width, height);
1902                 ge_cairo_set_color (cr, fill);
1903                 cairo_fill (cr);
1904         }
1905         
1906         cairo_translate (cr, x+0.5, y+0.5);
1907         
1908         cairo_set_line_width (cr, 1);
1909         
1910         if (handle->horizontal)
1911         {
1912                 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, num_bars, 2, 0.1);
1913         }
1914         else
1915         {
1916                 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, 2, num_bars, 0.1);
1917         }
1918 }
1919
1920 static void
1921 clearlooks_draw_resize_grip (cairo_t *cr,
1922                              const ClearlooksColors          *colors,
1923                              const WidgetParameters          *widget,
1924                              const ResizeGripParameters      *grip,
1925                              int x, int y, int width, int height)
1926 {
1927         (void) widget;
1928         
1929         const CairoColor *dark   = &colors->shade[4];
1930         CairoColor hilight;
1931         int lx, ly;
1932         int x_down;
1933         int y_down;
1934         int dots;
1935         
1936         ge_shade_color (dark, 1.5, &hilight);
1937
1938         /* The number of dots fitting into the area. Just hardcoded to 4 right now. */
1939         /* dots = MIN (width - 2, height - 2) / 3; */
1940         dots = 4;
1941
1942         cairo_save (cr);
1943
1944         switch (grip->edge)
1945         {
1946                 case CL_WINDOW_EDGE_NORTH_EAST:
1947                         x_down = 0;
1948                         y_down = 0;
1949                         cairo_translate (cr, x + width - 3*dots + 2, y + 1);
1950                 break;
1951                 case CL_WINDOW_EDGE_SOUTH_EAST:
1952                         x_down = 0;
1953                         y_down = 1;
1954                         cairo_translate (cr, x + width - 3*dots + 2, y + height - 3*dots + 2);
1955                 break;
1956                 case CL_WINDOW_EDGE_SOUTH_WEST:
1957                         x_down = 1;
1958                         y_down = 1;
1959                         cairo_translate (cr, x + 1, y + height - 3*dots + 2);
1960                 break;
1961                 case CL_WINDOW_EDGE_NORTH_WEST:
1962                         x_down = 1;
1963                         y_down = 0;
1964                         cairo_translate (cr, x + 1, y + 1);
1965                 break;
1966                 default:
1967                         /* Not implemented. */
1968                         return;
1969         }
1970
1971         for (lx = 0; lx < dots; lx++) /* horizontally */
1972         {
1973                 for (ly = 0; ly <= lx; ly++) /* vertically */
1974                 {
1975                         int mx, my;
1976                         mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
1977                         my = y_down * dots + (1 - y_down * 2) * ly - y_down;
1978
1979                         ge_cairo_set_color (cr, &hilight);
1980                         cairo_rectangle (cr, mx*3-1, my*3-1, 2, 2);
1981                         cairo_fill (cr);
1982
1983                         ge_cairo_set_color (cr, dark);
1984                         cairo_rectangle (cr, mx*3-1, my*3-1, 1, 1);
1985                         cairo_fill (cr);
1986                 }
1987         }
1988
1989         cairo_restore (cr);
1990 }
1991
1992 static void
1993 clearlooks_draw_radiobutton (cairo_t *cr,
1994                              const ClearlooksColors  *colors,
1995                              const WidgetParameters  *widget,
1996                              const CheckboxParameters *checkbox,
1997                              int x, int y, int width, int height)
1998 {
1999         (void) width;
2000         (void) height;
2001         
2002         const CairoColor *border;
2003         const CairoColor *dot;
2004         CairoColor shadow;
2005         CairoColor highlight;
2006         cairo_pattern_t *pt;
2007         gboolean inconsistent;
2008         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2009
2010         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2011         draw_bullet |= inconsistent;
2012
2013         if (widget->disabled)
2014         {
2015                 border = &colors->shade[5];
2016                 dot    = &colors->shade[6];
2017         }
2018         else
2019         {
2020                 border = &colors->shade[6];
2021                 dot    = &colors->text[0];
2022         }
2023
2024         ge_shade_color (&widget->parentbg, 0.9, &shadow);
2025         ge_shade_color (&widget->parentbg, 1.1, &highlight);
2026
2027         pt = cairo_pattern_create_linear (0, 0, 13, 13);
2028         cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
2029         cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
2030         cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
2031         cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
2032         
2033         cairo_translate (cr, x, y);
2034         
2035         cairo_set_line_width (cr, 2);
2036         cairo_arc       (cr, 7, 7, 6, 0, G_PI*2);       
2037         cairo_set_source (cr, pt);
2038         cairo_stroke (cr);
2039         cairo_pattern_destroy (pt);
2040
2041         cairo_set_line_width (cr, 1);
2042
2043         cairo_arc       (cr, 7, 7, 5.5, 0, G_PI*2);     
2044         
2045         if (!widget->disabled)
2046         {
2047                 ge_cairo_set_color (cr, &colors->base[0]);
2048                 cairo_fill_preserve (cr);
2049         }
2050         
2051         ge_cairo_set_color (cr, border);
2052         cairo_stroke (cr);
2053         
2054         if (draw_bullet)
2055         {
2056                 if (inconsistent)
2057                 {
2058                         cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
2059                         cairo_set_line_width (cr, 4);
2060
2061                         cairo_move_to(cr, 5, 7);
2062                         cairo_line_to(cr, 9, 7);
2063
2064                         ge_cairo_set_color (cr, dot);
2065                         cairo_stroke (cr);
2066                 }
2067                 else
2068                 {
2069                         cairo_arc (cr, 7, 7, 3, 0, G_PI*2);
2070                         ge_cairo_set_color (cr, dot);
2071                         cairo_fill (cr);
2072                 
2073                         cairo_arc (cr, 6, 6, 1, 0, G_PI*2);
2074                         cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
2075                         cairo_fill (cr);
2076                 }
2077         }
2078 }
2079
2080 static void
2081 clearlooks_draw_checkbox (cairo_t *cr,
2082                           const ClearlooksColors  *colors,
2083                           const WidgetParameters  *widget,
2084                           const CheckboxParameters *checkbox,
2085                           int x, int y, int width, int height)
2086 {
2087         const CairoColor *border;
2088         const CairoColor *dot;
2089         gboolean inconsistent = FALSE;
2090         gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2091
2092         inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2093         draw_bullet |= inconsistent;
2094         
2095         if (widget->disabled)
2096         {
2097                 border = &colors->shade[5];
2098                 dot    = &colors->shade[6];
2099         }
2100         else
2101         {
2102                 border = &colors->shade[6];
2103                 dot    = &colors->text[GTK_STATE_NORMAL];
2104         }
2105
2106         cairo_translate (cr, x, y);
2107         cairo_set_line_width (cr, 1);
2108         
2109         if (widget->xthickness > 2 && widget->ythickness > 2)
2110         {
2111                 widget->style_functions->draw_inset (cr, &widget->parentbg, 0.5, 0.5, width-1, height-1, 1, CR_CORNER_ALL);
2112                 
2113                 /* Draw the rectangle for the checkbox itself */
2114                 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2115         }
2116         else
2117         {
2118                 /* Draw the rectangle for the checkbox itself */
2119                 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2120         }
2121         
2122         if (!widget->disabled)
2123         {
2124                 ge_cairo_set_color (cr, &colors->base[0]);
2125                 cairo_fill_preserve (cr);
2126         }
2127         
2128         ge_cairo_set_color (cr, border);
2129         cairo_stroke (cr);
2130
2131         if (draw_bullet)
2132         {
2133                 if (inconsistent) /* Inconsistent */
2134                 {
2135                         cairo_set_line_width (cr, 2.0);
2136                         cairo_move_to (cr, 3, height*0.5);
2137                         cairo_line_to (cr, width-3, height*0.5);
2138                 }
2139                 else
2140                 {
2141                         cairo_set_line_width (cr, 1.7);
2142                         cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
2143                         cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
2144                 
2145                         cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
2146                                             0.5 + (width*0.5), (height*0.4),
2147                                             0.5 + (width*0.70), (height*0.25));
2148
2149                 }
2150                 
2151                 ge_cairo_set_color (cr, dot);
2152                 cairo_stroke (cr);
2153         }
2154 }
2155
2156 static void
2157 clearlooks_draw_normal_arrow (cairo_t *cr, const CairoColor *color,
2158                               double x, double y, double width, double height)
2159 {
2160         double arrow_width;
2161         double arrow_height;
2162         double line_width_2;
2163
2164         cairo_save (cr);
2165
2166         arrow_width = MIN (height * 2.0 + MAX (1.0, ceil (height * 2.0 / 6.0 * 2.0) / 2.0) / 2.0, width);
2167         line_width_2 = MAX (1.0, ceil (arrow_width / 6.0 * 2.0) / 2.0) / 2.0;
2168         arrow_height = arrow_width / 2.0 + line_width_2;
2169         
2170         cairo_translate (cr, x, y - arrow_height / 2.0);
2171
2172         cairo_move_to (cr, -arrow_width / 2.0, line_width_2);
2173         cairo_line_to (cr, -arrow_width / 2.0 + line_width_2, 0);
2174         /* cairo_line_to (cr, 0, arrow_height - line_width_2); */
2175         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);
2176         cairo_line_to (cr, arrow_width / 2.0 - line_width_2, 0);
2177         cairo_line_to (cr, arrow_width / 2.0, line_width_2);
2178         cairo_line_to (cr, 0, arrow_height);
2179         cairo_close_path (cr);
2180         
2181         ge_cairo_set_color (cr, color);
2182         cairo_fill (cr);
2183         
2184         cairo_restore (cr);
2185 }
2186
2187 static void
2188 clearlooks_draw_combo_arrow (cairo_t *cr, const CairoColor *color,
2189                              double x, double y, double width, double height)
2190 {
2191         double arrow_width = MIN (height * 2 / 3.0, width);
2192         double arrow_height = arrow_width / 2.0;
2193         double gap_size = 1.0 * arrow_height;
2194         
2195         cairo_save (cr);
2196         cairo_translate (cr, x, y - (arrow_height + gap_size) / 2.0);
2197         cairo_rotate (cr, G_PI);
2198         clearlooks_draw_normal_arrow (cr, color, 0, 0, arrow_width, arrow_height);
2199         cairo_restore (cr);
2200         
2201         clearlooks_draw_normal_arrow (cr, color, x, y + (arrow_height + gap_size) / 2.0, arrow_width, arrow_height);
2202 }
2203
2204 static void
2205 _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
2206                         ClearlooksDirection dir, ClearlooksArrowType type,
2207                         double x, double y, double width, double height)
2208 {
2209         double rotate;
2210         
2211         if (dir == CL_DIRECTION_LEFT)
2212                 rotate = G_PI*1.5;
2213         else if (dir == CL_DIRECTION_RIGHT)
2214                 rotate = G_PI*0.5;
2215         else if (dir == CL_DIRECTION_UP)
2216                 rotate = G_PI;
2217         else if (dir == CL_DIRECTION_DOWN)
2218                 rotate = 0;
2219         else
2220                 return;
2221         
2222         if (type == CL_ARROW_NORMAL)
2223         {
2224                 cairo_translate (cr, x, y);
2225                 cairo_rotate (cr, -rotate);             
2226                 clearlooks_draw_normal_arrow (cr, color, 0, 0, width, height);
2227         }
2228         else if (type == CL_ARROW_COMBO)
2229         {
2230                 cairo_translate (cr, x, y);
2231                 clearlooks_draw_combo_arrow (cr, color, 0, 0, width, height);
2232         }
2233 }
2234
2235 static void
2236 clearlooks_draw_arrow (cairo_t *cr,
2237                        const ClearlooksColors          *colors,
2238                        const WidgetParameters          *widget,
2239                        const ArrowParameters           *arrow,
2240                        int x, int y, int width, int height)
2241 {
2242         const CairoColor *color = &colors->fg[widget->state_type];
2243         gdouble tx, ty;
2244         
2245         tx = x + width/2.0;
2246         ty = y + height/2.0;
2247         
2248         if (widget->disabled)
2249         {
2250                 _clearlooks_draw_arrow (cr, &colors->shade[0],
2251                                         arrow->direction, arrow->type,
2252                                         tx+0.5, ty+0.5, width, height);
2253         }
2254
2255         cairo_identity_matrix (cr);
2256         
2257         _clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
2258                                 tx, ty, width, height);
2259 }
2260
2261 void
2262 clearlooks_register_style_classic (ClearlooksStyleFunctions *functions)
2263 {
2264         g_assert (functions);
2265
2266         functions->draw_button             = clearlooks_draw_button;
2267         functions->draw_scale_trough       = clearlooks_draw_scale_trough;
2268         functions->draw_progressbar_trough = clearlooks_draw_progressbar_trough;
2269         functions->draw_progressbar_fill   = clearlooks_draw_progressbar_fill;
2270         functions->draw_slider_button      = clearlooks_draw_slider_button;
2271         functions->draw_entry              = clearlooks_draw_entry;
2272         functions->draw_spinbutton         = clearlooks_draw_spinbutton;
2273         functions->draw_spinbutton_down    = clearlooks_draw_spinbutton_down;
2274         functions->draw_optionmenu         = clearlooks_draw_optionmenu;
2275         functions->draw_inset              = clearlooks_draw_inset;
2276         functions->draw_menubar            = clearlooks_draw_menubar;
2277         functions->draw_tab                = clearlooks_draw_tab;
2278         functions->draw_frame              = clearlooks_draw_frame;
2279         functions->draw_separator          = clearlooks_draw_separator;
2280         functions->draw_menu_item_separator = clearlooks_draw_menu_item_separator;
2281         functions->draw_list_view_header   = clearlooks_draw_list_view_header;
2282         functions->draw_toolbar            = clearlooks_draw_toolbar;
2283         functions->draw_menuitem           = clearlooks_draw_menuitem;
2284         functions->draw_menubaritem        = clearlooks_draw_menubaritem;
2285         functions->draw_selected_cell      = clearlooks_draw_selected_cell;
2286         functions->draw_scrollbar_stepper  = clearlooks_draw_scrollbar_stepper;
2287         functions->draw_scrollbar_slider   = clearlooks_draw_scrollbar_slider;
2288         functions->draw_scrollbar_trough   = clearlooks_draw_scrollbar_trough;
2289         functions->draw_statusbar          = clearlooks_draw_statusbar;
2290         functions->draw_menu_frame         = clearlooks_draw_menu_frame;
2291         functions->draw_tooltip            = clearlooks_draw_tooltip;
2292         functions->draw_handle             = clearlooks_draw_handle;
2293         functions->draw_resize_grip        = clearlooks_draw_resize_grip;
2294         functions->draw_arrow              = clearlooks_draw_arrow;
2295         functions->draw_checkbox           = clearlooks_draw_checkbox;
2296         functions->draw_radiobutton        = clearlooks_draw_radiobutton;
2297         functions->draw_shadow             = clearlooks_draw_shadow;
2298         functions->draw_slider             = clearlooks_draw_slider;
2299         functions->draw_gripdots           = clearlooks_draw_gripdots;
2300 }