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