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
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.
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.
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.
24 #include "clearlooks_draw.h"
25 #include "clearlooks_style.h"
26 #include "clearlooks_types.h"
29 #include <ge-support.h>
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);
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)
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);
54 cairo_move_to (cr, x + w + (radius * -0.2928932188), y - (radius * -0.2928932188)); /* 0.2928932... 1-sqrt(2)/2 gives middle of curve */
56 if (corners & CR_CORNER_TOPRIGHT)
57 cairo_arc (cr, x + w - radius, y + radius, radius, G_PI * 1.75, G_PI * 2);
59 cairo_line_to (cr, x + w, y);
61 if (corners & CR_CORNER_BOTTOMRIGHT)
62 cairo_arc (cr, x + w - radius, y + h - radius, radius, 0, G_PI * 0.5);
64 cairo_line_to (cr, x + w, y + h);
66 if (corners & CR_CORNER_BOTTOMLEFT)
67 cairo_arc (cr, x + radius, y + h - radius, radius, G_PI * 0.5, G_PI * 0.75);
69 cairo_line_to (cr, x, y + h);
71 ge_cairo_set_color (cr, &highlight);
75 cairo_move_to (cr, x + (radius * 0.2928932188), y + h + (radius * -0.2928932188));
77 if (corners & CR_CORNER_BOTTOMLEFT)
78 cairo_arc (cr, x + radius, y + h - radius, radius, M_PI * 0.75, M_PI);
80 cairo_line_to (cr, x, y + h);
82 if (corners & CR_CORNER_TOPLEFT)
83 cairo_arc (cr, x + radius, y + radius, radius, M_PI, M_PI * 1.5);
85 cairo_line_to (cr, x, y);
87 if (corners & CR_CORNER_TOPRIGHT)
88 cairo_arc (cr, x + w - radius, y + radius, radius, M_PI * 1.5, M_PI * 1.75);
90 cairo_line_to (cr, x + w, y);
92 ge_cairo_set_color (cr, &shadow);
97 clearlooks_draw_shadow (cairo_t *cr, const ClearlooksColors *colors, gfloat radius, int width, int height)
100 ge_shade_color (&colors->shade[6], 0.92, &shadow);
102 cairo_set_line_width (cr, 1.0);
104 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
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);
114 clearlooks_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
115 const WidgetParameters *params,
116 int width, int height, gdouble radius)
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;
125 ge_shade_color (color, 1.3, &hilight);
126 cairo_move_to (cr, light_left, light_bottom - (int)radius/2);
128 ge_cairo_rounded_corner (cr, light_left, light_top, radius, params->corners & CR_CORNER_TOPLEFT);
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);
136 #warning seems to be very slow in scrollbar_stepper
140 clearlooks_draw_highlight_and_shade (cairo_t *cr, const ClearlooksColors *colors,
141 const ShadowParameters *params,
142 int width, int height, gdouble radius)
146 uint8 corners = params->corners;
150 ge_shade_color (&colors->bg[GTK_STATE_NORMAL], 1.06, &hilight);
151 ge_shade_color (&colors->bg[GTK_STATE_NORMAL], 0.94, &shadow);
158 /* Top/Left highlight */
159 if (corners & CR_CORNER_BOTTOMLEFT)
160 cairo_move_to (cr, x, y+height-radius);
162 cairo_move_to (cr, x, y+height);
164 ge_cairo_rounded_corner (cr, x, y, radius, corners & CR_CORNER_TOPLEFT);
166 if (corners & CR_CORNER_TOPRIGHT)
167 cairo_line_to (cr, x+width-radius, y);
169 cairo_line_to (cr, x+width, y);
171 if (params->shadow & CL_SHADOW_OUT)
172 ge_cairo_set_color (cr, &hilight);
174 ge_cairo_set_color (cr, &shadow);
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);
184 if (params->shadow & CL_SHADOW_OUT)
185 ge_cairo_set_color (cr, &shadow);
187 ge_cairo_set_color (cr, &hilight);
195 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
197 cairo_pattern_t *pattern;
199 CairoColor bottom_shade;
200 ge_shade_color (color, hilight, &bottom_shade);
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);
206 cairo_set_source (cr, pattern);
207 cairo_pattern_destroy (pattern);
211 clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, int y,
212 int width, int height, int xr, int yr,
215 const CairoColor *dark = &colors->shade[4];
220 ge_shade_color (dark, 1.5, &hilight);
222 for ( i = 0; i < xr; i++ )
224 for ( j = 0; j < yr; j++ )
226 xoff = x -(xr * 3 / 2) + 3 * i;
227 yoff = y -(yr * 3 / 2) + 3 * j;
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);
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);
240 clearlooks_draw_button (cairo_t *cr,
241 const ClearlooksColors *colors,
242 const WidgetParameters *params,
243 int x, int y, int width, int height)
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];
252 ge_shade_color (border_normal, 0.925, &shadow);
256 cairo_translate (cr, x, y);
257 cairo_set_line_width (cr, 1.0);
259 if (params->xthickness == 3 || params->ythickness == 3)
261 if (params->xthickness == 3)
263 if (params->ythickness == 3)
267 radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
269 if (params->xthickness == 3 || params->ythickness == 3)
271 cairo_translate (cr, 0.5, 0.5);
272 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
273 cairo_translate (cr, -0.5, -0.5);
276 ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
278 height-(yoffset*2)-2,
279 radius, params->corners);
283 cairo_pattern_t *pattern;
284 gdouble shade_size = ((100.0/height)*8.0)/100.0;
285 CairoColor top_shade, bottom_shade, middle_shade;
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);
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);
299 cairo_set_source (cr, pattern);
301 cairo_pattern_destroy (pattern);
305 cairo_pattern_t *pattern;
307 ge_cairo_set_color (cr, fill);
308 cairo_fill_preserve (cr);
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);
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);
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);
330 cairo_pattern_destroy (pattern);
334 /* Drawing the border */
335 if (!params->active && params->is_default)
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);
342 ge_cairo_set_color (cr, d);
343 ge_cairo_stroke_rectangle (cr, 3.5, 3.5, width-7, height-7);
346 ge_cairo_rounded_rectangle (cr, xoffset + 0.5, yoffset + 0.5, width-(xoffset*2)-1, height-(yoffset*2)-1, radius, params->corners);
348 if (params->disabled)
349 ge_cairo_set_color (cr, border_disabled);
352 clearlooks_set_border_gradient (cr, border_normal, 1.32, 0, height);
354 ge_cairo_set_color (cr, border_normal);
358 /* Draw the "shadow" */
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);
368 /* Draw topleft shadow */
369 clearlooks_draw_top_left_highlight (cr, fill, params, width, height, radius);
375 clearlooks_draw_entry (cairo_t *cr,
376 const ClearlooksColors *colors,
377 const WidgetParameters *params,
378 int x, int y, int width, int height)
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));
385 border = colors->spot[2];
387 cairo_translate (cr, x+0.5, y+0.5);
388 cairo_set_line_width (cr, 1.0);
390 /* Fill the background (shouldn't have to) */
391 cairo_rectangle (cr, -0.5, -0.5, width, height);
392 ge_cairo_set_color (cr, ¶ms->parentbg);
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);
400 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width-1, height-1, radius+1, params->corners);
402 /* Draw the inner shadow */
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);
412 ge_shade_color (&border, 0.925, &shadow);
414 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.05 : 0.1);
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);
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);
429 clearlooks_set_border_gradient (cr, &border, 1.32, 0, height);
434 clearlooks_draw_spinbutton (cairo_t *cr,
435 const ClearlooksColors *colors,
436 const WidgetParameters *params,
437 int x, int y, int width, int height)
439 const CairoColor *border = &colors->shade[!params->disabled ? 5 : 3];
442 params->style_functions->draw_button (cr, colors, params, x, y, width, height);
444 ge_shade_color (border, 1.5, &hilight);
446 cairo_translate (cr, x, y);
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);
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);
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)
465 cairo_pattern_t *pattern;
466 double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
468 ge_shade_color (&colors->bg[GTK_STATE_NORMAL], 0.8, &shadow);
470 cairo_translate (cr, x+1, y+1);
472 ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, params->corners);
474 ge_cairo_set_color (cr, &colors->bg[params->state_type]);
476 cairo_fill_preserve (cr);
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);
482 cairo_set_source (cr, pattern);
485 cairo_pattern_destroy (pattern);
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,
496 cairo_pattern_t *pattern;
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);
502 cairo_rectangle (cr, x+0.5, y+0.5, width-1, height-1);
503 cairo_set_source (cr, pattern);
505 cairo_pattern_destroy (pattern);
507 ge_cairo_set_color (cr, c3);
508 ge_cairo_stroke_rectangle (cr, x, y, width, height);
511 #define TROUGH_SIZE 6
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)
519 int trough_width, trough_height;
520 double translate_x, translate_y;
522 if (slider->horizontal)
524 trough_width = width-3;
525 trough_height = TROUGH_SIZE-2;
527 translate_x = x + 0.5;
528 translate_y = y + 0.5 + (height/2) - (TROUGH_SIZE/2);
532 trough_width = TROUGH_SIZE-2;
533 trough_height = height-3;
535 translate_x = x + 0.5 + (width/2) - (TROUGH_SIZE/2);
536 translate_y = y + 0.5;
539 cairo_set_line_width (cr, 1.0);
540 cairo_translate (cr, translate_x, translate_y);
542 if (!slider->fill_level)
543 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, trough_width+2, trough_height+2, 0, 0);
545 cairo_translate (cr, 1, 1);
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,
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,
562 clearlooks_draw_slider (cairo_t *cr,
563 const ClearlooksColors *colors,
564 const WidgetParameters *params,
565 int x, int y, int width, int height)
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));
572 cairo_pattern_t *pattern;
574 cairo_set_line_width (cr, 1.0);
575 cairo_translate (cr, x, y);
577 if (params->prelight)
578 border = &colors->spot[2];
580 /* fill the widget */
581 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
584 if (!params->disabled)
586 const CairoColor *top = &colors->shade[0];
587 const CairoColor *bot = &colors->shade[2];
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);
594 cairo_pattern_destroy (pattern);
598 ge_cairo_set_color (cr, fill);
599 cairo_rectangle (cr, 0.5, 0.5, width-2, height-2);
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);
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);
615 if (params->prelight)
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);
626 ge_shade_color (fill, 1.5, &hilight);
627 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
631 cairo_pattern_destroy (pattern);
635 /* Draw the border */
636 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
638 if (params->prelight || params->disabled)
639 ge_cairo_set_color (cr, border);
641 clearlooks_set_border_gradient (cr, border, 1.2, 0, height);
644 /* Draw handle lines */
647 cairo_move_to (cr, 6, 0.5);
648 cairo_line_to (cr, 6, height-1);
650 cairo_move_to (cr, width-7, 0.5);
651 cairo_line_to (cr, width-7, height-1);
653 cairo_set_line_width (cr, 1.0);
654 cairo_set_source_rgba (cr, border->r,
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)
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);
672 if (!slider->horizontal)
673 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
674 cairo_translate (cr, x+0.5, y+0.5);
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);
680 params->style_functions->draw_gripdots (cr, colors, 0, 0, width-2, height-2, 3, 3, 0);
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)
689 const CairoColor *border = &colors->shade[6];
691 cairo_pattern_t *pattern;
692 double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
696 cairo_set_line_width (cr, 1.0);
698 /* Fill with bg color */
699 ge_cairo_set_color (cr, &colors->bg[params->state_type]);
701 cairo_rectangle (cr, x, y, width, height);
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]);
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);
714 /* clip the corners of the shadows */
715 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
718 ge_shade_color (border, 0.925, &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);
727 cairo_pattern_destroy (pattern);
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);
736 cairo_pattern_destroy (pattern);
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,
749 boolean is_horizontal = progressbar->orientation < 2;
755 cairo_pattern_t *pattern;
760 radius = MAX (0, params->radius - params->xthickness);
765 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
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);
770 /* Clamp the radius so that the _height_ fits ... */
771 radius = MIN (radius, height / 2.0);
773 stroke_width = height*2;
774 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
776 cairo_translate (cr, x, y);
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);
783 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
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);
794 cairo_pattern_destroy (pattern);
796 /* Draw the Strokes */
797 while (tile_pos <= width+x_step)
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);
804 cairo_translate (cr, stroke_width, 0);
805 tile_pos += stroke_width;
808 cairo_set_source_rgba (cr, colors->spot[2].r,
814 cairo_restore (cr); /* rounded clip region */
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);
822 cairo_rectangle (cr, 0, 0, width / 2, height);
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);
828 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
831 cairo_restore (cr); /* clip */
835 cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
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);
841 ge_cairo_rounded_rectangle (cr, -0.5 - radius, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
844 cairo_restore (cr); /* clip */
847 /* Draw the dark lines and the shadow */
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);
852 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
855 border = colors->spot[2];
862 if (progressbar->pulsing)
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);
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);
877 if (progressbar->value < 1.0 || progressbar->pulsing)
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);
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);
895 cairo_restore (cr); /* rotation, mirroring */
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)
905 SeparatorParameters separator;
906 int offset = params->ythickness + 1;
908 params->style_functions->draw_button (cr, colors, params, x, y, width, height);
910 separator.horizontal = FALSE;
911 params->style_functions->draw_separator (cr, colors, params, &separator, x+optionmenu->linepos, y + offset, 2, height - offset*2);
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)
922 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
923 ge_cairo_set_color (cr, &colors->shade[5]);
925 if (separator->horizontal)
926 cairo_rectangle (cr, x, y, width, 1);
928 cairo_rectangle (cr, x, y, 1, height);
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)
942 /* const CairoColor *light = &colors->shade[0]; */
943 const CairoColor *dark = &colors->shade[3];
945 cairo_set_line_width (cr, 1);
946 cairo_translate (cr, x, y+0.5);
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); */
953 cairo_move_to (cr, 0, height-1);
954 cairo_line_to (cr, width, height-1);
955 ge_cairo_set_color (cr, dark);
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)
967 cairo_pattern_t *pattern;
969 ge_shade_color (&colors->bg[0], 0.96, &lower);
971 cairo_translate (cr, x, y);
972 cairo_rectangle (cr, 0, 0, width, height);
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,
979 cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r,
982 cairo_set_source (cr, pattern);
984 cairo_pattern_destroy (pattern);
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]);
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)
1001 const CairoColor *border = &colors->shade[3];
1003 clearlooks_draw_menubar2 (cr, colors, params, menubar,
1004 x, y, width, height);
1006 ge_cairo_set_color (cr, border);
1007 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1011 static menubar_draw_proto clearlooks_menubar_draw[3] =
1013 clearlooks_draw_menubar0,
1014 clearlooks_draw_menubar1,
1015 clearlooks_draw_menubar2
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)
1025 if (menubar->style < 0 || menubar->style > 3)
1028 clearlooks_menubar_draw[menubar->style](cr, colors, params, menubar,
1029 x, y, width, height);
1033 clearlooks_get_frame_gap_clip (int x, int y, int width, int height,
1034 const FrameParameters *frame,
1035 ClearlooksRectangle *bevel,
1036 ClearlooksRectangle *border)
1038 if (frame->gap_side == CL_GAP_TOP)
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);
1045 else if (frame->gap_side == CL_GAP_BOTTOM)
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);
1052 else if (frame->gap_side == CL_GAP_LEFT)
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);
1059 else if (frame->gap_side == CL_GAP_RIGHT)
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);
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)
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));
1082 ge_shade_color (&colors->bg[GTK_STATE_NORMAL], 1.05, &hilight);
1084 if (frame->shadow == CL_SHADOW_NONE)
1087 if (frame->gap_x != -1)
1088 clearlooks_get_frame_gap_clip (x, y, width, height,
1089 frame, &bevel_clip, &frame_clip);
1091 cairo_set_line_width (cr, 1.0);
1092 cairo_translate (cr, x+0.5, y+0.5);
1094 /* save everything */
1096 /* Set clip for the bevel */
1097 if (frame->gap_x != -1)
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);
1106 /* Draw the bevel */
1107 if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
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);
1113 ge_cairo_rounded_rectangle (cr, 0, 0, width-2, height-2, radius, params->corners);
1116 else if (frame->shadow != CL_SHADOW_NONE)
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);
1124 /* restore the previous clip region */
1127 if (frame->gap_x != -1)
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);
1137 if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
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);
1143 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, params->corners);
1147 ge_cairo_set_color (cr, border);
1148 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
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)
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;
1169 cairo_pattern_t *pattern;
1174 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1177 cairo_rectangle (cr, x, y, width, height);
1179 cairo_new_path (cr);
1181 /* Translate and set line width */
1182 cairo_set_line_width (cr, 1.0);
1183 cairo_translate (cr, x+0.5, y+0.5);
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)
1191 strip_size = 2.0/height; /* 2 pixel high strip */
1193 if (tab->gap_side == CL_GAP_TOP)
1194 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
1199 strip_size = 2.0/width;
1201 if (tab->gap_side == CL_GAP_LEFT)
1202 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
1205 /* Set the fill color */
1206 fill = &colors->bg[params->state_type];
1209 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
1210 radius, params->corners);
1213 ge_cairo_set_color (cr, fill);
1217 ge_shade_color (fill, 1.3, &hilight);
1219 /* Draw highlight */
1220 if (!params->active)
1222 ShadowParameters shadow;
1224 shadow.shadow = CL_SHADOW_OUT;
1225 shadow.corners = params->corners;
1227 clearlooks_draw_highlight_and_shade (cr, colors, &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 );
1241 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1243 ge_shade_color (fill, 0.92, &shadow);
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);
1251 cairo_pattern_destroy (pattern);
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 );
1261 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
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);
1270 cairo_pattern_destroy (pattern);
1273 ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1277 ge_cairo_set_color (cr, border2);
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 );
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);
1293 cairo_pattern_destroy (pattern);
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)
1304 CairoColor color = colors->shade[3];
1306 ge_shade_color (&color, 1.4, &hilight);
1309 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
1311 if (separator->horizontal)
1313 cairo_set_line_width (cr, 1.0);
1314 cairo_translate (cr, x, y+0.5);
1316 cairo_move_to (cr, 0.0, 0.0);
1317 cairo_line_to (cr, width, 0.0);
1318 ge_cairo_set_color (cr, &color);
1321 cairo_move_to (cr, 0.0, 1.0);
1322 cairo_line_to (cr, width, 1.0);
1323 ge_cairo_set_color (cr, &hilight);
1328 cairo_set_line_width (cr, 1.0);
1329 cairo_translate (cr, x+0.5, y);
1331 cairo_move_to (cr, 0.0, 0.0);
1332 cairo_line_to (cr, 0.0, height);
1333 ge_cairo_set_color (cr, &color);
1336 cairo_move_to (cr, 1.0, 0.0);
1337 cairo_line_to (cr, 1.0, height);
1338 ge_cairo_set_color (cr, &hilight);
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)
1352 const CairoColor *border = &colors->shade[5];
1353 cairo_pattern_t *pattern;
1357 ge_shade_color (border, 1.5, &hilight);
1358 ge_shade_color (border, 0.925, &shadow);
1360 cairo_translate (cr, x, y);
1361 cairo_set_line_width (cr, 1.0);
1363 /* Draw highlight */
1364 if (header->order == CL_ORDER_FIRST)
1366 cairo_move_to (cr, 0.5, height-1);
1367 cairo_line_to (cr, 0.5, 0.5);
1370 cairo_move_to (cr, 0.0, 0.5);
1372 cairo_line_to (cr, width, 0.5);
1374 ge_cairo_set_color (cr, &hilight);
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);
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);
1388 cairo_rectangle (cr, 0.0, height-5.0, width, 4.0);
1389 cairo_set_source (cr, pattern);
1391 cairo_pattern_destroy (pattern);
1393 /* Draw resize grip */
1394 if ((params->ltr && header->order != CL_ORDER_LAST) ||
1395 (!params->ltr && header->order != CL_ORDER_FIRST) || header->resizable)
1397 SeparatorParameters separator;
1398 separator.horizontal = FALSE;
1401 params->style_functions->draw_separator (cr, colors, params, &separator,
1402 width-1.5, 4.0, 2, height-8.0);
1404 params->style_functions->draw_separator (cr, colors, params, &separator,
1405 1.5, 4.0, 2, height-8.0);
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 */
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)
1418 const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL];
1419 const CairoColor *dark = &colors->shade[3];
1421 ge_shade_color (fill, 1.1, &light);
1423 cairo_set_line_width (cr, 1.0);
1424 cairo_translate (cr, x, y);
1426 ge_cairo_set_color (cr, fill);
1429 if (!toolbar->topmost)
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);
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);
1446 clearlooks_draw_menuitem (cairo_t *cr,
1447 const ClearlooksColors *colors,
1448 const WidgetParameters *widget,
1449 int x, int y, int width, int height)
1451 const CairoColor *fill = &colors->spot[1];
1452 CairoColor fill_shade;
1453 CairoColor border = colors->spot[2];
1454 cairo_pattern_t *pattern;
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);
1460 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
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);
1466 cairo_set_source (cr, pattern);
1467 cairo_fill_preserve (cr);
1468 cairo_pattern_destroy (pattern);
1470 ge_cairo_set_color (cr, &border);
1475 clearlooks_draw_menubaritem (cairo_t *cr,
1476 const ClearlooksColors *colors,
1477 const WidgetParameters *widget,
1478 int x, int y, int width, int height)
1480 const CairoColor *fill = &colors->spot[1];
1481 CairoColor fill_shade;
1482 CairoColor border = colors->spot[2];
1483 cairo_pattern_t *pattern;
1485 ge_shade_color (&border, 1.05, &border);
1486 ge_shade_color (fill, 0.85, &fill_shade);
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);
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);
1495 cairo_set_source (cr, pattern);
1496 cairo_fill_preserve (cr);
1497 cairo_pattern_destroy (pattern);
1499 ge_cairo_set_color (cr, &border);
1500 cairo_stroke_preserve (cr);
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)
1509 CairoColor upper_color;
1510 CairoColor lower_color;
1512 cairo_pattern_t *pattern;
1515 cairo_translate (cr, x, y);
1518 upper_color = colors->base[params->state_type];
1520 upper_color = colors->base[GTK_STATE_ACTIVE];
1522 ge_shade_color(&upper_color, 0.92, &lower_color);
1524 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1525 cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
1528 cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
1532 cairo_set_source (cr, pattern);
1533 cairo_rectangle (cr, 0, 0, width, height);
1536 cairo_pattern_destroy (pattern);
1538 ge_shade_color(&upper_color, 0.8, &border);
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);
1545 ge_cairo_set_color (cr, &border);
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)
1559 const CairoColor *bg = &colors->shade[2];
1560 const CairoColor *border = &colors->shade[5];
1561 CairoColor bg_shade;
1562 cairo_pattern_t *pattern;
1564 ge_shade_color (bg, 0.95, &bg_shade);
1566 cairo_set_line_width (cr, 1);
1567 /* cairo_translate (cr, x, y); */
1569 if (scrollbar->horizontal)
1570 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1572 cairo_translate (cr, x, y);
1575 cairo_rectangle (cr, 1, 0, width-2, height);
1576 ge_cairo_set_color (cr, bg);
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);
1586 cairo_pattern_destroy (pattern);
1589 ge_cairo_set_color (cr, border);
1590 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
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)
1601 CairoCorners corners = CR_CORNER_NONE;
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));
1608 ge_shade_color(&colors->shade[6], 1.05, &border);
1610 if (scrollbar->horizontal)
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;
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;
1625 cairo_translate (cr, x, y);
1626 cairo_set_line_width (cr, 1);
1628 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
1630 if (scrollbar->horizontal)
1631 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1633 pattern = cairo_pattern_create_linear (0, 0, width, 0);
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);
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);
1646 cairo_pattern_destroy (pattern);
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);
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));
1656 cairo_translate (cr, 0.5, 0.5);
1657 shadow.shadow = CL_SHADOW_OUT;
1658 shadow.corners = corners;
1660 clearlooks_draw_highlight_and_shade (cr, &shadow,
1662 height, params->radius);*/
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)
1672 if (scrollbar->junction & CL_JUNCTION_BEGIN)
1674 if (scrollbar->horizontal)
1685 if (scrollbar->junction & CL_JUNCTION_END)
1687 if (scrollbar->horizontal)
1693 if (!scrollbar->horizontal)
1694 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1696 cairo_translate (cr, x, y);
1698 if (scrollbar->has_color)
1700 const CairoColor *border = &colors->shade[7];
1701 CairoColor fill = scrollbar->color;
1703 CairoColor shade1, shade2, shade3;
1704 cairo_pattern_t *pattern;
1706 if (widget->prelight)
1707 ge_shade_color (&fill, 1.1, &fill);
1709 cairo_set_line_width (cr, 1);
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);
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);
1724 cairo_pattern_destroy (pattern);
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);
1729 ge_cairo_set_color (cr, border);
1730 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1734 const CairoColor *dark = &colors->shade[4];
1735 const CairoColor *light = &colors->shade[0];
1737 CairoColor s1, s2, s3, s4, s5;
1738 cairo_pattern_t *pattern;
1741 ge_shade_color(&colors->shade[6], 1.05, &border);
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);
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);
1754 cairo_rectangle (cr, 1, 1, width-2, height-2);
1755 cairo_set_source(cr, pattern);
1757 cairo_pattern_destroy(pattern);
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);
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);
1770 cairo_set_line_width (cr, 1);
1772 bar_x = width/2 - 4;
1773 cairo_translate(cr, 0.5, 0.5);
1776 cairo_move_to (cr, bar_x, 4);
1777 cairo_line_to (cr, bar_x, height-5);
1778 ge_cairo_set_color (cr, dark);
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);
1793 clearlooks_draw_statusbar (cairo_t *cr,
1794 const ClearlooksColors *colors,
1795 const WidgetParameters *widget,
1796 int x, int y, int width, int height)
1798 const CairoColor *dark = &colors->shade[3];
1801 ge_shade_color (dark, 1.4, &hilight);
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);
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);
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)
1823 const CairoColor *border = &colors->shade[5];
1824 cairo_translate (cr, x, y);
1825 cairo_set_line_width (cr, 1);
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);
1831 ge_cairo_set_color (cr, border);
1832 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1836 clearlooks_draw_tooltip (cairo_t *cr,
1837 const ClearlooksColors *colors,
1838 const WidgetParameters *widget,
1839 int x, int y, int width, int height)
1843 ge_shade_color (&colors->bg[widget->state_type], 0.6, &border);
1847 cairo_translate (cr, x, y);
1848 cairo_set_line_width (cr, 1);
1850 ge_cairo_set_color (cr, &colors->bg[widget->state_type]);
1851 cairo_rectangle (cr, 0, 0, width, height);
1854 ge_cairo_set_color (cr, &border);
1855 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
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)
1867 const CairoColor *fill = &colors->bg[params->state_type];
1868 int num_bars = 6; /* shut up gcc warnings */
1871 switch (handle->type)
1873 case CL_HANDLE_TOOLBAR:
1877 case CL_HANDLE_SPLITTER:
1883 if (params->prelight)
1885 cairo_rectangle (cr, x, y, width, height);
1886 ge_cairo_set_color (cr, fill);
1890 cairo_translate (cr, x+0.5, y+0.5);
1892 cairo_set_line_width (cr, 1);
1894 if (handle->horizontal)
1896 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, num_bars, 2, 0.1);
1900 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, 2, num_bars, 0.1);
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)
1911 const CairoColor *dark = &colors->shade[4];
1918 ge_shade_color (dark, 1.5, &hilight);
1920 /* The number of dots fitting into the area. Just hardcoded to 4 right now. */
1921 /* dots = MIN (width - 2, height - 2) / 3; */
1928 case CL_WINDOW_EDGE_NORTH_EAST:
1931 cairo_translate (cr, x + width - 3*dots + 2, y + 1);
1933 case CL_WINDOW_EDGE_SOUTH_EAST:
1936 cairo_translate (cr, x + width - 3*dots + 2, y + height - 3*dots + 2);
1938 case CL_WINDOW_EDGE_SOUTH_WEST:
1941 cairo_translate (cr, x + 1, y + height - 3*dots + 2);
1943 case CL_WINDOW_EDGE_NORTH_WEST:
1946 cairo_translate (cr, x + 1, y + 1);
1949 /* Not implemented. */
1953 for (lx = 0; lx < dots; lx++) /* horizontally */
1955 for (ly = 0; ly <= lx; ly++) /* vertically */
1958 mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
1959 my = y_down * dots + (1 - y_down * 2) * ly - y_down;
1961 ge_cairo_set_color (cr, &hilight);
1962 cairo_rectangle (cr, mx*3-1, my*3-1, 2, 2);
1965 ge_cairo_set_color (cr, dark);
1966 cairo_rectangle (cr, mx*3-1, my*3-1, 1, 1);
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)
1981 const CairoColor *border;
1982 const CairoColor *dot;
1984 CairoColor highlight;
1985 cairo_pattern_t *pt;
1986 gboolean inconsistent;
1987 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
1989 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
1990 draw_bullet |= inconsistent;
1992 if (widget->disabled)
1994 border = &colors->shade[5];
1995 dot = &colors->shade[6];
1999 border = &colors->shade[6];
2000 dot = &colors->text[0];
2003 ge_shade_color (&widget->parentbg, 0.9, &shadow);
2004 ge_shade_color (&widget->parentbg, 1.1, &highlight);
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);
2012 cairo_translate (cr, x, y);
2014 cairo_set_line_width (cr, 2);
2015 cairo_arc (cr, 7, 7, 6, 0, G_PI*2);
2016 cairo_set_source (cr, pt);
2018 cairo_pattern_destroy (pt);
2020 cairo_set_line_width (cr, 1);
2022 cairo_arc (cr, 7, 7, 5.5, 0, G_PI*2);
2024 if (!widget->disabled)
2026 ge_cairo_set_color (cr, &colors->base[0]);
2027 cairo_fill_preserve (cr);
2030 ge_cairo_set_color (cr, border);
2037 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
2038 cairo_set_line_width (cr, 4);
2040 cairo_move_to(cr, 5, 7);
2041 cairo_line_to(cr, 9, 7);
2043 ge_cairo_set_color (cr, dot);
2048 cairo_arc (cr, 7, 7, 3, 0, G_PI*2);
2049 ge_cairo_set_color (cr, dot);
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);
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)
2066 const CairoColor *border;
2067 const CairoColor *dot;
2068 gboolean inconsistent = FALSE;
2069 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2071 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2072 draw_bullet |= inconsistent;
2074 if (widget->disabled)
2076 border = &colors->shade[5];
2077 dot = &colors->shade[6];
2081 border = &colors->shade[6];
2082 dot = &colors->text[GTK_STATE_NORMAL];
2085 cairo_translate (cr, x, y);
2086 cairo_set_line_width (cr, 1);
2088 if (widget->xthickness > 2 && widget->ythickness > 2)
2090 widget->style_functions->draw_inset (cr, &widget->parentbg, 0.5, 0.5, width-1, height-1, 1, CR_CORNER_ALL);
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);
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);
2101 if (!widget->disabled)
2103 ge_cairo_set_color (cr, &colors->base[0]);
2104 cairo_fill_preserve (cr);
2107 ge_cairo_set_color (cr, border);
2112 if (inconsistent) /* Inconsistent */
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);
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));
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));
2130 ge_cairo_set_color (cr, dot);
2136 clearlooks_draw_normal_arrow (cairo_t *cr, const CairoColor *color,
2137 double x, double y, double width, double height)
2140 double arrow_height;
2141 double line_width_2;
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;
2149 cairo_translate (cr, x, y - arrow_height / 2.0);
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);
2160 ge_cairo_set_color (cr, color);
2167 clearlooks_draw_combo_arrow (cairo_t *cr, const CairoColor *color,
2168 double x, double y, double width, double height)
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;
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);
2180 clearlooks_draw_normal_arrow (cr, color, x, y + (arrow_height + gap_size) / 2.0, arrow_width, arrow_height);
2184 _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
2185 ClearlooksDirection dir, ClearlooksArrowType type,
2186 double x, double y, double width, double height)
2190 if (dir == CL_DIRECTION_LEFT)
2192 else if (dir == CL_DIRECTION_RIGHT)
2194 else if (dir == CL_DIRECTION_UP)
2196 else if (dir == CL_DIRECTION_DOWN)
2201 if (type == CL_ARROW_NORMAL)
2203 cairo_translate (cr, x, y);
2204 cairo_rotate (cr, -rotate);
2205 clearlooks_draw_normal_arrow (cr, color, 0, 0, width, height);
2207 else if (type == CL_ARROW_COMBO)
2209 cairo_translate (cr, x, y);
2210 clearlooks_draw_combo_arrow (cr, color, 0, 0, width, height);
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)
2221 const CairoColor *color = &colors->fg[widget->state_type];
2225 ty = y + height/2.0;
2227 if (widget->disabled)
2229 _clearlooks_draw_arrow (cr, &colors->shade[0],
2230 arrow->direction, arrow->type,
2231 tx+0.5, ty+0.5, width, height);
2234 cairo_identity_matrix (cr);
2236 _clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
2237 tx, ty, width, height);
2241 clearlooks_register_style_classic (ClearlooksStyleFunctions *functions)
2243 g_assert (functions);
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;