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>
35 #define SHADE_TOP 1.055
36 #define SHADE_CENTER_TOP 1.01
37 #define SHADE_CENTER_BOTTOM 0.98
38 #define SHADE_BOTTOM 0.90
40 typedef void (*menubar_draw_proto) (cairo_t *cr,
41 const ClearlooksColors *colors,
42 const WidgetParameters *params,
43 const MenuBarParameters *menubar,
44 int x, int y, int width, int height);
47 clearlooks_draw_inset (cairo_t *cr,
48 const CairoColor *bg_color,
49 double x, double y, double width, double height,
50 double radius, uint8 corners)
55 double min = MIN (width, height);
57 line_width = cairo_get_line_width (cr);
59 /* not really sure of shading ratios... we will think */
60 ge_shade_color (bg_color, 0.94, &shadow);
61 ge_shade_color (bg_color, 1.06, &highlight);
66 cairo_move_to (cr, x, y + height);
67 cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
68 cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
69 cairo_line_to (cr, x + width, y);
70 cairo_line_to (cr, x, y);
71 cairo_close_path (cr);
75 ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
76 width - line_width, height - line_width,
79 ge_cairo_set_color (cr, &shadow);
87 cairo_move_to (cr, x, y + height);
88 cairo_line_to (cr, x + min / 2.0, y + height - min / 2.0);
89 cairo_line_to (cr, x + width - min / 2.0, y + min / 2.0);
90 cairo_line_to (cr, x + width, y);
91 cairo_line_to (cr, x + width, y + height);
92 cairo_close_path (cr);
96 ge_cairo_rounded_rectangle (cr, x + line_width / 2.0, y + line_width / 2.0,
97 width - line_width, height - line_width,
100 ge_cairo_set_color (cr, &highlight);
107 clearlooks_draw_shadow (cairo_t *cr, const ClearlooksColors *colors, gfloat radius, int width, int height)
112 ge_shade_color (&colors->shade[6], 0.92, &shadow);
114 cairo_set_line_width (cr, 1.0);
115 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
117 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, 0.1);
119 cairo_move_to (cr, width - 0.5, radius);
120 ge_cairo_rounded_corner (cr, width - 0.5, height - 0.5, radius, CR_CORNER_BOTTOMRIGHT);
121 cairo_line_to (cr, radius, height - 0.5);
127 /* This is copied at least in clearlooks_draw_gummy.c.
128 * KEEP IN SYNC IF POSSIBLE! */
130 clearlooks_draw_top_left_highlight (cairo_t *cr, const CairoColor *color,
131 const WidgetParameters *params,
132 int x, int y, int width, int height,
133 gdouble radius, CairoCorners corners)
137 double line_width = cairo_get_line_width (cr);
138 double offset = line_width / 2.0;
139 double light_top, light_bottom, light_left, light_right;
143 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
145 light_top = y + offset;
146 light_bottom = y + height;
147 light_left = x + offset;
148 light_right = x + width;
150 if (corners & CR_CORNER_BOTTOMLEFT)
151 light_bottom -= radius;
152 if (corners & CR_CORNER_TOPRIGHT)
153 light_right -= radius;
155 ge_shade_color (color, params->style_constants->topleft_highlight_shade, &hilight);
156 cairo_move_to (cr, light_left, light_bottom);
158 ge_cairo_rounded_corner (cr, light_left, light_top, radius, corners & CR_CORNER_TOPLEFT);
160 cairo_line_to (cr, light_right, light_top);
161 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, params->style_constants->topleft_highlight_alpha);
168 #warning seems to be very slow in scrollbar_stepper
172 clearlooks_draw_highlight_and_shade (cairo_t *cr, const ClearlooksColors *colors,
173 const ShadowParameters *params,
174 int width, int height, gdouble radius)
178 uint8 corners = params->corners;
182 ge_shade_color (&colors->bg[0], 1.06, &hilight);
183 ge_shade_color (&colors->bg[0], 0.94, &shadow);
190 /* Top/Left highlight */
191 if (corners & CR_CORNER_BOTTOMLEFT)
192 cairo_move_to (cr, x + 0.5, y+height-radius);
194 cairo_move_to (cr, x + 0.5, y+height);
196 ge_cairo_rounded_corner (cr, x + 0.5, y + 0.5, radius, corners & CR_CORNER_TOPLEFT);
198 if (corners & CR_CORNER_TOPRIGHT)
199 cairo_line_to (cr, x+width-radius, y + 0.5);
201 cairo_line_to (cr, x+width, y + 0.5);
203 if (params->shadow & CL_SHADOW_OUT)
204 ge_cairo_set_color (cr, &hilight);
206 ge_cairo_set_color (cr, &shadow);
210 /* Bottom/Right highlight -- this includes the corners */
211 cairo_arc (cr, x + width - 0.5 - radius, y + radius, radius, G_PI * (3/2.0+1/4.0), G_PI * 2);
212 ge_cairo_rounded_corner (cr, x+width - 0.5, y+height - 0.5, radius, corners & CR_CORNER_BOTTOMRIGHT);
213 cairo_arc (cr, x + radius, y + height - 0.5 - radius, radius, G_PI * 1/2, G_PI * 3/4);
215 if (params->shadow & CL_SHADOW_OUT)
216 ge_cairo_set_color (cr, &shadow);
218 ge_cairo_set_color (cr, &hilight);
226 clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height)
228 cairo_pattern_t *pattern;
230 CairoColor bottom_shade;
231 ge_shade_color (color, hilight, &bottom_shade);
233 pattern = cairo_pattern_create_linear (0, 0, width, height);
234 cairo_pattern_add_color_stop_rgb (pattern, 0, color->r, color->g, color->b);
235 cairo_pattern_add_color_stop_rgb (pattern, 1, bottom_shade.r, bottom_shade.g, bottom_shade.b);
237 cairo_set_source (cr, pattern);
238 cairo_pattern_destroy (pattern);
242 clearlooks_draw_gripdots (cairo_t *cr, const ClearlooksColors *colors, int x, int y,
243 int width, int height, int xr, int yr,
246 const CairoColor *dark = &colors->shade[4];
250 int x_start, y_start;
252 ge_shade_color (dark, 1.5, &hilight);
254 /* The "- 1" is because there is no space in front of the first dot. */
255 x_start = x + width / 2 - ((xr * 3 - 1) / 2);
256 y_start = y + height / 2 - ((yr * 3 - 1) / 2);
258 for ( i = 0; i < xr; i++ )
260 for ( j = 0; j < yr; j++ )
265 cairo_rectangle (cr, x_start + xoff, y_start + yoff, 2, 2);
266 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.8+contrast);
268 cairo_rectangle (cr, x_start + xoff, y_start + yoff, 1, 1);
269 cairo_set_source_rgba (cr, dark->r, dark->g, dark->b, 0.8+contrast);
276 clearlooks_draw_button (cairo_t *cr,
277 const ClearlooksColors *colors,
278 const WidgetParameters *params,
279 int x, int y, int width, int height)
281 double xoffset = 0, yoffset = 0;
282 double radius = params->radius;
283 const CairoColor *fill = &colors->bg[params->state_type];
284 CairoColor border_normal = colors->shade[6];
285 CairoColor border_disabled = colors->shade[4];
288 ge_shade_color (&border_normal, 1.04, &border_normal);
289 ge_shade_color (&border_normal, 0.94, &shadow);
290 ge_shade_color (&border_disabled, 1.08, &border_disabled);
294 cairo_translate (cr, x, y);
295 cairo_set_line_width (cr, 1.0);
297 if (params->xthickness == 3 || params->ythickness == 3)
299 if (params->xthickness == 3)
301 if (params->ythickness == 3)
305 radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
307 if (params->xthickness == 3 || params->ythickness == 3)
309 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, radius+1, params->corners);
312 ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
314 height-(yoffset*2)-2,
315 radius, params->corners);
319 cairo_pattern_t *pattern;
320 CairoColor top_shade, topmiddle_shade, bottom_shade, middle_shade;
322 ge_shade_color (fill, SHADE_TOP, &top_shade);
323 ge_shade_color (fill, SHADE_CENTER_TOP, &topmiddle_shade);
324 ge_shade_color (fill, SHADE_CENTER_BOTTOM, &middle_shade);
325 ge_shade_color (fill, SHADE_BOTTOM, &bottom_shade);
328 cairo_clip_preserve (cr);
330 pattern = cairo_pattern_create_linear (0, 0, 0, height);
331 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top_shade.r, top_shade.g, top_shade.b);
332 cairo_pattern_add_color_stop_rgb (pattern, 0.3, topmiddle_shade.r, topmiddle_shade.g, topmiddle_shade.b);
333 cairo_pattern_add_color_stop_rgb (pattern, 0.7, middle_shade.r, middle_shade.g, middle_shade.b);
334 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bottom_shade.r, bottom_shade.g, bottom_shade.b);
335 cairo_set_source (cr, pattern);
337 cairo_pattern_destroy (pattern);
339 cairo_move_to (cr, width-(xoffset*2)-0.5, 0);
340 cairo_line_to (cr, width-(xoffset*2)-0.5, height);
341 ge_cairo_set_color (cr, &bottom_shade);
344 /* Draw topleft shadow */
345 params->style_functions->draw_top_left_highlight (cr, fill, params, xoffset + 1, yoffset + 1,
346 width - 2*(xoffset + 1), height - 2*(yoffset + 1),
347 MAX(radius-1, 0), params->corners);
353 cairo_pattern_t *pattern;
355 ge_cairo_set_color (cr, fill);
356 cairo_fill_preserve (cr);
358 pattern = cairo_pattern_create_linear (0, 0, 0, height);
359 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.0);
360 cairo_pattern_add_color_stop_rgba (pattern, 0.4, shadow.r, shadow.g, shadow.b, 0.0);
361 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.2);
362 cairo_set_source (cr, pattern);
363 cairo_fill_preserve (cr);
364 cairo_pattern_destroy (pattern);
366 pattern = cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
367 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
368 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
369 cairo_set_source (cr, pattern);
370 cairo_fill_preserve (cr);
371 cairo_pattern_destroy (pattern);
373 pattern = cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
374 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.32);
375 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
376 cairo_set_source (cr, pattern);
378 cairo_pattern_destroy (pattern);
381 /* Drawing the border */
382 if (!params->active && params->is_default)
384 ge_shade_color (&border_normal, 0.74, &border_normal);
387 ge_cairo_inner_rounded_rectangle (cr, xoffset, yoffset, width-(xoffset*2), height-(yoffset*2), radius, params->corners);
389 if (params->disabled)
391 ge_cairo_set_color (cr, &border_disabled);
396 clearlooks_set_border_gradient (cr, &border_normal,
397 params->is_default ? 1.1 : 1.3, 0, height);
400 ge_shade_color (&border_normal, 1.08, &border_normal);
401 ge_cairo_set_color (cr, &border_normal);
411 clearlooks_draw_entry (cairo_t *cr,
412 const ClearlooksColors *colors,
413 const WidgetParameters *params,
414 int x, int y, int width, int height)
416 const CairoColor *base = &colors->base[params->state_type];
417 CairoColor border = colors->shade[params->disabled ? 3 : 6];
418 double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
421 border = colors->spot[2];
425 cairo_translate (cr, x, y);
426 cairo_set_line_width (cr, 1.0);
428 /* Now fill the area we want to be base[NORMAL]. */
429 ge_cairo_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
430 ge_cairo_set_color (cr, base);
433 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, radius+1, params->corners);
435 /* Draw the inner shadow */
438 ge_cairo_set_color (cr, &colors->spot[0]);
439 ge_cairo_inner_rounded_rectangle (cr, 2, 2, width-4, height-4, MAX(0, radius-1), params->corners);
445 ge_shade_color (&border, 0.925, &shadow);
447 cairo_set_source_rgba (cr, shadow.r, shadow.g, shadow.b, params->disabled ? 0.05 : 0.1);
449 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
450 cairo_move_to (cr, 2.5, height-radius);
451 cairo_arc (cr, 2.5+MAX(0, radius-1), 2.5+MAX(0, radius-1), MAX(0, radius-1), G_PI, 270*(G_PI/180));
452 cairo_line_to (cr, width-radius, 2.5);
456 ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, params->corners);
457 if (params->focus || params->disabled)
458 ge_cairo_set_color (cr, &border);
460 clearlooks_set_border_gradient (cr, &border, 1.32, 0, height);
467 clearlooks_draw_spinbutton (cairo_t *cr,
468 const ClearlooksColors *colors,
469 const WidgetParameters *params,
470 int x, int y, int width, int height)
472 const CairoColor *border = &colors->shade[!params->disabled ? 5 : 3];
475 params->style_functions->draw_button (cr, colors, params, x, y, width, height);
477 ge_shade_color (&colors->bg[0], params->style_constants->topleft_highlight_shade, &hilight);
478 hilight.a = params->style_constants->topleft_highlight_alpha;
480 cairo_translate (cr, x, y);
482 cairo_move_to (cr, params->xthickness + 0.5, (height/2) + 0.5);
483 cairo_line_to (cr, width-params->xthickness - 0.5, (height/2) + 0.5);
484 ge_cairo_set_color (cr, border);
487 cairo_move_to (cr, params->xthickness + 0.5, (height/2)+1.5);
488 cairo_line_to (cr, width-params->xthickness - 0.5, (height/2)+1.5);
489 ge_cairo_set_color (cr, &hilight);
494 clearlooks_draw_spinbutton_down (cairo_t *cr,
495 const ClearlooksColors *colors,
496 const WidgetParameters *params,
497 int x, int y, int width, int height)
499 cairo_pattern_t *pattern;
500 double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0));
502 ge_shade_color (&colors->bg[0], 0.8, &shadow);
504 cairo_translate (cr, x+1, y+1);
506 ge_cairo_rounded_rectangle (cr, 1, 1, width-4, height-4, radius, params->corners);
508 ge_cairo_set_color (cr, &colors->bg[params->state_type]);
510 cairo_fill_preserve (cr);
512 pattern = cairo_pattern_create_linear (0, 0, 0, height);
513 cairo_pattern_add_color_stop_rgb (pattern, 0.0, shadow.r, shadow.g, shadow.b);
514 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
516 cairo_set_source (cr, pattern);
519 cairo_pattern_destroy (pattern);
523 clearlooks_scale_draw_gradient (cairo_t *cr,
524 const CairoColor *c1,
525 const CairoColor *c2,
526 const CairoColor *c3,
527 int x, int y, int width, int height,
530 cairo_pattern_t *pattern;
532 pattern = cairo_pattern_create_linear (0.5, 0.5, horizontal ? 0.5 : width + 1, horizontal ? height + 1: 0.5);
533 cairo_pattern_add_color_stop_rgb (pattern, 0.0, c1->r, c1->g, c1->b);
534 cairo_pattern_add_color_stop_rgb (pattern, 1.0, c2->r, c2->g, c2->b);
536 cairo_rectangle (cr, x, y, width, height);
537 cairo_set_source (cr, pattern);
539 cairo_pattern_destroy (pattern);
541 ge_cairo_set_color (cr, c3);
542 ge_cairo_inner_rectangle (cr, x, y, width, height);
546 #define TROUGH_SIZE 7
548 clearlooks_draw_scale_trough (cairo_t *cr,
549 const ClearlooksColors *colors,
550 const WidgetParameters *params,
551 const SliderParameters *slider,
552 int x, int y, int width, int height)
554 int trough_width, trough_height;
555 double translate_x, translate_y;
559 if (slider->horizontal)
561 trough_width = width;
562 trough_height = TROUGH_SIZE;
565 translate_y = y + (height/2) - (TROUGH_SIZE/2);
569 trough_width = TROUGH_SIZE;
570 trough_height = height;
572 translate_x = x + (width/2) - (TROUGH_SIZE/2);
576 cairo_set_line_width (cr, 1.0);
577 cairo_translate (cr, translate_x, translate_y);
579 if (!slider->fill_level)
580 params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, trough_width, trough_height, 0, 0);
582 if (!slider->lower && !slider->fill_level)
585 ge_shade_color (&colors->shade[2], 0.96, &shadow);
587 clearlooks_scale_draw_gradient (cr, &shadow, /* top */
588 &colors->shade[2], /* bottom */
589 &colors->shade[4], /* border */
590 1.0, 1.0, trough_width - 2, trough_height - 2,
595 CairoColor border = colors->spot[2];
598 clearlooks_scale_draw_gradient (cr, &colors->spot[1], /* top */
599 &colors->spot[0], /* bottom */
600 &border, /* border */
601 1.0, 1.0, trough_width - 2, trough_height - 2,
608 clearlooks_draw_slider (cairo_t *cr,
609 const ClearlooksColors *colors,
610 const WidgetParameters *params,
611 int x, int y, int width, int height)
613 const CairoColor *spot = &colors->spot[1];
614 const CairoColor *fill = &colors->shade[2];
615 CairoColor border = colors->shade[params->disabled ? 4 : 6];
616 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
618 cairo_pattern_t *pattern;
620 cairo_set_line_width (cr, 1.0);
621 cairo_translate (cr, x, y);
623 if (params->prelight)
624 border = colors->spot[2];
626 /* fill the widget */
627 ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-2, height-2, radius, params->corners);
630 if (!params->disabled)
632 const CairoColor *top = &colors->shade[0];
633 const CairoColor *bot = &colors->shade[2];
635 pattern = cairo_pattern_create_linear (0, 0, 0, height);
636 cairo_pattern_add_color_stop_rgb (pattern, 0.0, top->r, top->g, top->b);
637 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bot->r, bot->g, bot->b);
638 cairo_set_source (cr, pattern);
640 cairo_pattern_destroy (pattern);
644 ge_cairo_set_color (cr, fill);
650 cairo_rectangle (cr, 1.0, 1.0, 6, height-2);
651 cairo_rectangle (cr, width-7.0, 1.0, 6, height-2);
652 cairo_clip_preserve (cr);
656 /* Draw the handles */
657 ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners);
658 pattern = cairo_pattern_create_linear (1.0, 1.0, 1.0, 1.0+height);
660 if (params->prelight)
662 CairoColor highlight;
663 ge_shade_color (spot, 1.3, &highlight);
664 cairo_pattern_add_color_stop_rgb (pattern, 0.0, highlight.r, highlight.g, highlight.b);
665 cairo_pattern_add_color_stop_rgb (pattern, 1.0, spot->r, spot->g, spot->b);
666 cairo_set_source (cr, pattern);
671 ge_shade_color (fill, 1.3, &hilight);
672 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
676 cairo_pattern_destroy (pattern);
680 /* Draw the border */
681 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
683 if (params->prelight || params->disabled)
684 ge_cairo_set_color (cr, &border);
686 clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
689 /* Draw handle lines */
692 cairo_move_to (cr, 6.5, 1.0);
693 cairo_line_to (cr, 6.5, height-1);
695 cairo_move_to (cr, width-6.5, 1.0);
696 cairo_line_to (cr, width-6.5, height-1);
698 cairo_set_line_width (cr, 1.0);
699 border.a = params->disabled ? 0.6 : 0.3;
700 ge_cairo_set_color (cr, &border);
706 clearlooks_draw_slider_button (cairo_t *cr,
707 const ClearlooksColors *colors,
708 const WidgetParameters *params,
709 const SliderParameters *slider,
710 int x, int y, int width, int height)
712 double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
715 cairo_set_line_width (cr, 1.0);
717 if (!slider->horizontal)
718 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
719 cairo_translate (cr, x, y);
721 params->style_functions->draw_shadow (cr, colors, radius, width, height);
722 params->style_functions->draw_slider (cr, colors, params, 1, 1, width-2, height-2);
725 params->style_functions->draw_gripdots (cr, colors, 1, 1, width-2, height-2, 3, 3, 0);
731 clearlooks_draw_progressbar_trough (cairo_t *cr,
732 const ClearlooksColors *colors,
733 const WidgetParameters *params,
734 int x, int y, int width, int height)
736 const CairoColor *border = &colors->shade[4];
738 cairo_pattern_t *pattern;
739 double radius = MIN (params->radius, MIN ((height-2.0) / 2.0, (width-2.0) / 2.0));
743 cairo_set_line_width (cr, 1.0);
745 /* Create trough box */
746 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
747 ge_cairo_set_color (cr, &colors->shade[2]);
751 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners);
752 ge_cairo_set_color (cr, border);
755 /* clip the corners of the shadows */
756 ge_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners);
759 ge_shade_color (border, 0.925, &shadow);
762 cairo_rectangle (cr, x+1, y+1, width-2, 4);
763 pattern = cairo_pattern_create_linear (x, y, x, y+4);
764 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.2);
765 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0);
766 cairo_set_source (cr, pattern);
768 cairo_pattern_destroy (pattern);
771 cairo_rectangle (cr, x+1, y+1, 4, height-2);
772 pattern = cairo_pattern_create_linear (x, y, x+4, y);
773 cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.2);
774 cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0);
775 cairo_set_source (cr, pattern);
777 cairo_pattern_destroy (pattern);
783 clearlooks_draw_progressbar_fill (cairo_t *cr,
784 const ClearlooksColors *colors,
785 const WidgetParameters *params,
786 const ProgressBarParameters *progressbar,
787 int x, int y, int width, int height,
790 boolean is_horizontal = progressbar->orientation < 2;
796 cairo_pattern_t *pattern;
801 radius = MAX (0, params->radius - params->xthickness);
806 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
808 if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
809 ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
811 /* Clamp the radius so that the _height_ fits ... */
812 radius = MIN (radius, height / 2.0);
814 stroke_width = height;
815 x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
817 cairo_translate (cr, x, y);
820 /* This is kind of nasty ... Clip twice from each side in case the length
821 * of the fill is smaller than twice the radius. */
822 ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
824 ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
827 /* Draw the background gradient */
828 ge_shade_color (&colors->spot[1], 1.1, &bg_shade);
830 /* Just leave this disabled, maybe we could use the same gradient
831 * as the buttons in the future, not flat fill */
832 /* pattern = cairo_pattern_create_linear (0, 0, 0, height);*/
833 /* cairo_pattern_add_color_stop_rgb (pattern, 0.0, bg_shade.r, bg_shade.g, bg_shade.b);*/
834 /* cairo_pattern_add_color_stop_rgb (pattern, 0.6, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);*/
835 /* cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg_shade.r, bg_shade.g, bg_shade.b);*/
836 /* cairo_set_source (cr, pattern);*/
837 /* cairo_paint (cr);*/
838 /* cairo_pattern_destroy (pattern);*/
840 ge_cairo_set_color (cr, &bg_shade);
843 /* Draw the Strokes */
844 while (tile_pos <= width+x_step)
846 cairo_move_to (cr, stroke_width/2-x_step, 0);
847 cairo_line_to (cr, stroke_width-x_step, 0);
848 cairo_line_to (cr, stroke_width/2-x_step, height);
849 cairo_line_to (cr, -x_step, height);
851 cairo_translate (cr, stroke_width, 0);
852 tile_pos += stroke_width;
855 pattern = cairo_pattern_create_linear (0, 0, 0, height);
856 cairo_pattern_add_color_stop_rgba (pattern, 0.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0);
857 cairo_pattern_add_color_stop_rgba (pattern, 1.0, colors->spot[2].r, colors->spot[2].g, colors->spot[2].b, 0.24);
858 cairo_set_source (cr, pattern);
860 cairo_pattern_destroy (pattern);
862 cairo_restore (cr); /* rounded clip region */
864 /* Draw the dark lines and the shadow */
866 /* Again, this weird clip area. */
867 ge_cairo_rounded_rectangle (cr, -1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
869 ge_cairo_rounded_rectangle (cr, -radius - 1.0, 0, width + radius + 2.0, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
877 if (progressbar->pulsing)
879 /* At the beginning of the bar. */
880 cairo_move_to (cr, -0.5 + radius, height + 0.5);
881 ge_cairo_rounded_corner (cr, -0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMLEFT);
882 ge_cairo_rounded_corner (cr, -0.5, -0.5, radius + 1, CR_CORNER_TOPLEFT);
883 ge_cairo_set_color (cr, &shadow);
886 if (progressbar->value < 1.0 || progressbar->pulsing)
888 /* At the end of the bar. */
889 cairo_move_to (cr, width + 0.5 - radius, -0.5);
890 ge_cairo_rounded_corner (cr, width + 0.5, -0.5, radius + 1, CR_CORNER_TOPRIGHT);
891 ge_cairo_rounded_corner (cr, width + 0.5, height + 0.5, radius + 1, CR_CORNER_BOTTOMRIGHT);
892 ge_cairo_set_color (cr, &shadow);
896 /* ge_cairo_rounded_rectangle (cr, 1.5,1.5, width-2, height-2, radius, CR_CORNER_ALL);*/
897 /* cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 1);*/
898 /* cairo_stroke (cr);*/
900 params->style_functions->draw_top_left_highlight (cr, &colors->spot[1], params, 1.5, 1.5,
901 width - 1, height - 1,
902 radius, params->corners);
904 border = colors->spot[2];
906 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, CR_CORNER_ALL);
907 ge_cairo_set_color (cr, &border);
912 cairo_restore (cr); /* rotation, mirroring */
916 clearlooks_draw_optionmenu (cairo_t *cr,
917 const ClearlooksColors *colors,
918 const WidgetParameters *params,
919 const OptionMenuParameters *optionmenu,
920 int x, int y, int width, int height)
922 SeparatorParameters separator;
923 int offset = params->ythickness + 2;
925 params->style_functions->draw_button (cr, colors, params, x, y, width, height);
927 separator.horizontal = FALSE;
928 params->style_functions->draw_separator (cr, colors, params, &separator, x+optionmenu->linepos, y + offset, 2, height - offset*2);
932 clearlooks_draw_menu_item_separator (cairo_t *cr,
933 const ClearlooksColors *colors,
934 const WidgetParameters *widget,
935 const SeparatorParameters *separator,
936 int x, int y, int width, int height)
939 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
940 ge_cairo_set_color (cr, &colors->shade[5]);
942 if (separator->horizontal)
943 cairo_rectangle (cr, x, y, width, 1);
945 cairo_rectangle (cr, x, y, 1, height);
953 clearlooks_draw_menubar0 (cairo_t *cr,
954 const ClearlooksColors *colors,
955 const WidgetParameters *params,
956 const MenuBarParameters *menubar,
957 int x, int y, int width, int height)
959 const CairoColor *dark = &colors->shade[3];
963 cairo_set_line_width (cr, 1);
964 cairo_translate (cr, x, y);
966 cairo_move_to (cr, 0, height-0.5);
967 cairo_line_to (cr, width, height-0.5);
968 ge_cairo_set_color (cr, dark);
975 clearlooks_draw_menubar2 (cairo_t *cr,
976 const ClearlooksColors *colors,
977 const WidgetParameters *params,
978 const MenuBarParameters *menubar,
979 int x, int y, int width, int height)
982 cairo_pattern_t *pattern;
986 ge_shade_color (&colors->bg[0], 0.96, &lower);
988 cairo_translate (cr, x, y);
989 cairo_rectangle (cr, 0, 0, width, height);
991 /* Draw the gradient */
992 pattern = cairo_pattern_create_linear (0, 0, 0, height);
993 cairo_pattern_add_color_stop_rgb (pattern, 0.0, colors->bg[0].r,
996 cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower.r,
999 cairo_set_source (cr, pattern);
1001 cairo_pattern_destroy (pattern);
1003 /* Draw bottom line */
1004 cairo_set_line_width (cr, 1.0);
1005 cairo_move_to (cr, 0, height-0.5);
1006 cairo_line_to (cr, width, height-0.5);
1007 ge_cairo_set_color (cr, &colors->shade[3]);
1014 clearlooks_draw_menubar1 (cairo_t *cr,
1015 const ClearlooksColors *colors,
1016 const WidgetParameters *params,
1017 const MenuBarParameters *menubar,
1018 int x, int y, int width, int height)
1020 const CairoColor *border = &colors->shade[3];
1022 clearlooks_draw_menubar2 (cr, colors, params, menubar,
1023 x, y, width, height);
1025 ge_cairo_set_color (cr, border);
1026 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1030 static menubar_draw_proto clearlooks_menubar_draw[3] =
1032 clearlooks_draw_menubar0,
1033 clearlooks_draw_menubar1,
1034 clearlooks_draw_menubar2
1038 clearlooks_draw_menubar (cairo_t *cr,
1039 const ClearlooksColors *colors,
1040 const WidgetParameters *params,
1041 const MenuBarParameters *menubar,
1042 int x, int y, int width, int height)
1044 if (menubar->style < 0 || menubar->style >= G_N_ELEMENTS (clearlooks_menubar_draw))
1047 clearlooks_menubar_draw[menubar->style](cr, colors, params, menubar,
1048 x, y, width, height);
1052 clearlooks_get_frame_gap_clip (int x, int y, int width, int height,
1053 const FrameParameters *frame,
1054 ClearlooksRectangle *bevel,
1055 ClearlooksRectangle *border)
1057 if (frame->gap_side == CL_GAP_TOP)
1059 CLEARLOOKS_RECTANGLE_SET (*bevel, 2.0 + frame->gap_x, 0.0,
1060 frame->gap_width - 3, 2.0);
1061 CLEARLOOKS_RECTANGLE_SET (*border, 1.0 + frame->gap_x, 0.0,
1062 frame->gap_width - 2, 2.0);
1064 else if (frame->gap_side == CL_GAP_BOTTOM)
1066 CLEARLOOKS_RECTANGLE_SET (*bevel, 2.0 + frame->gap_x, height - 2.0,
1067 frame->gap_width - 3, 2.0);
1068 CLEARLOOKS_RECTANGLE_SET (*border, 1.0 + frame->gap_x, height - 1.0,
1069 frame->gap_width - 2, 2.0);
1071 else if (frame->gap_side == CL_GAP_LEFT)
1073 CLEARLOOKS_RECTANGLE_SET (*bevel, 0.0, 2.0 + frame->gap_x,
1074 2.0, frame->gap_width - 3);
1075 CLEARLOOKS_RECTANGLE_SET (*border, 0.0, 1.0 + frame->gap_x,
1076 1.0, frame->gap_width - 2);
1078 else if (frame->gap_side == CL_GAP_RIGHT)
1080 CLEARLOOKS_RECTANGLE_SET (*bevel, width - 2.0, 2.0 + frame->gap_x,
1081 2.0, frame->gap_width - 3);
1082 CLEARLOOKS_RECTANGLE_SET (*border, width - 1.0, 1.0 + frame->gap_x,
1083 1.0, frame->gap_width - 2);
1088 clearlooks_draw_frame (cairo_t *cr,
1089 const ClearlooksColors *colors,
1090 const WidgetParameters *params,
1091 const FrameParameters *frame,
1092 int x, int y, int width, int height)
1094 const CairoColor *border = frame->border;
1095 const CairoColor *dark = (CairoColor*)&colors->shade[4];
1096 ClearlooksRectangle bevel_clip = {0, 0, 0, 0};
1097 ClearlooksRectangle frame_clip = {0, 0, 0, 0};
1098 double radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1101 ge_shade_color (&colors->bg[0], 1.05, &hilight);
1103 if (frame->shadow == CL_SHADOW_NONE)
1106 if (frame->gap_x != -1)
1107 clearlooks_get_frame_gap_clip (x, y, width, height,
1108 frame, &bevel_clip, &frame_clip);
1110 cairo_set_line_width (cr, 1.0);
1111 cairo_translate (cr, x, y);
1113 /* save everything */
1115 /* Set clip for the bevel */
1116 if (frame->gap_x != -1)
1118 /* Set clip for gap */
1119 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1120 cairo_rectangle (cr, 0, 0, width, height);
1121 cairo_rectangle (cr, bevel_clip.x, bevel_clip.y, bevel_clip.width, bevel_clip.height);
1125 /* Draw the bevel */
1126 if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
1128 ge_cairo_set_color (cr, &hilight);
1129 if (frame->shadow == CL_SHADOW_ETCHED_IN)
1130 ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
1132 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1135 else if (frame->shadow != CL_SHADOW_NONE)
1137 ShadowParameters shadow;
1138 shadow.corners = params->corners;
1139 shadow.shadow = frame->shadow;
1140 clearlooks_draw_highlight_and_shade (cr, colors, &shadow, width, height, radius);
1143 /* restore the previous clip region */
1146 if (frame->gap_x != -1)
1148 /* Set clip for gap */
1149 cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
1150 cairo_rectangle (cr, 0, 0, width, height);
1151 cairo_rectangle (cr, frame_clip.x, frame_clip.y, frame_clip.width, frame_clip.height);
1156 if (frame->shadow == CL_SHADOW_ETCHED_IN || frame->shadow == CL_SHADOW_ETCHED_OUT)
1158 ge_cairo_set_color (cr, dark);
1159 if (frame->shadow == CL_SHADOW_ETCHED_IN)
1160 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width-1, height-1, radius, params->corners);
1162 ge_cairo_inner_rounded_rectangle (cr, 1, 1, width-1, height-1, radius, params->corners);
1166 ge_cairo_set_color (cr, border);
1167 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
1175 clearlooks_draw_tab (cairo_t *cr,
1176 const ClearlooksColors *colors,
1177 const WidgetParameters *params,
1178 const TabParameters *tab,
1179 int x, int y, int width, int height)
1181 const CairoColor *border1 = &colors->shade[6];
1182 const CairoColor *border2 = &colors->shade[5];
1183 const CairoColor *stripe_fill = &colors->spot[1];
1184 const CairoColor *stripe_border = &colors->spot[2];
1185 const CairoColor *fill;
1188 cairo_pattern_t *pattern;
1191 double stripe_size = 2.0;
1192 double stripe_fill_size;
1195 radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1200 cairo_rectangle (cr, x, y, width, height);
1202 cairo_new_path (cr);
1204 /* Translate and set line width */
1205 cairo_set_line_width (cr, 1.0);
1206 cairo_translate (cr, x, y);
1209 /* Make the tabs slightly bigger than they should be, to create a gap */
1210 /* And calculate the strip size too, while you're at it */
1211 if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
1215 stripe_fill_size = (tab->gap_side == CL_GAP_TOP ? stripe_size/height : stripe_size/(height-2));
1217 if (tab->gap_side == CL_GAP_TOP)
1218 cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
1224 stripe_fill_size = (tab->gap_side == CL_GAP_LEFT ? stripe_size/width : stripe_size/(width-2));
1226 if (tab->gap_side == CL_GAP_LEFT)
1227 cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
1230 /* Set the fill color */
1231 fill = &colors->bg[params->state_type];
1234 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
1235 radius, params->corners);
1238 ge_cairo_set_color (cr, fill);
1242 ge_shade_color (fill, 1.3, &hilight);
1244 /* Draw highlight */
1245 if (!params->active)
1247 ShadowParameters shadow;
1249 shadow.shadow = CL_SHADOW_OUT;
1250 shadow.corners = params->corners;
1252 clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
1261 switch (tab->gap_side)
1264 pattern = cairo_pattern_create_linear (0.5, height-1.5, 0.5, 0.5);
1267 pattern = cairo_pattern_create_linear (0.5, 1.5, 0.5, height+0.5);
1270 pattern = cairo_pattern_create_linear (width-1.5, 0.5, 1.5, 0.5);
1273 pattern = cairo_pattern_create_linear (1.5, 0.5, width-1.5, 0.5);
1279 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
1281 ge_shade_color (fill, 0.92, &shadow);
1283 cairo_pattern_add_color_stop_rgba (pattern, 0.0, hilight.r, hilight.g, hilight.b, 0.4);
1284 cairo_pattern_add_color_stop_rgba (pattern, 1.0/length, hilight.r, hilight.g, hilight.b, 0.4);
1285 cairo_pattern_add_color_stop_rgb (pattern, 1.0/length, fill->r,fill->g,fill->b);
1286 cairo_pattern_add_color_stop_rgb (pattern, 1.0, shadow.r,shadow.g,shadow.b);
1287 cairo_set_source (cr, pattern);
1289 cairo_pattern_destroy (pattern);
1294 switch (tab->gap_side)
1297 pattern = cairo_pattern_create_linear (0.5, height-1.5, 0.5, 0.5);
1300 pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, height+0.5);
1303 pattern = cairo_pattern_create_linear (width-1.5, 0.5, 0.5, 0.5);
1306 pattern = cairo_pattern_create_linear (0.5, 0.5, width+0.5, 0.5);
1312 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, params->corners);
1314 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_fill->r, stripe_fill->g, stripe_fill->b);
1315 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_fill->r, stripe_fill->g, stripe_fill->b);
1316 cairo_pattern_add_color_stop_rgba (pattern, stripe_fill_size, hilight.r, hilight.g, hilight.b, 0.5);
1317 cairo_pattern_add_color_stop_rgba (pattern, 0.8, hilight.r, hilight.g, hilight.b, 0.0);
1318 cairo_set_source (cr, pattern);
1320 cairo_pattern_destroy (pattern);
1323 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
1327 ge_cairo_set_color (cr, border2);
1332 switch (tab->gap_side)
1335 pattern = cairo_pattern_create_linear (2.5, height-1.5, 2.5, 2.5);
1338 pattern = cairo_pattern_create_linear (2.5, 2.5, 2.5, height+0.5);
1341 pattern = cairo_pattern_create_linear (width-1.5, 2.5, 2.5, 2.5);
1344 pattern = cairo_pattern_create_linear (2.5, 2.5, width+0.5, 2.5);
1350 cairo_pattern_add_color_stop_rgb (pattern, 0.0, stripe_border->r, stripe_border->g, stripe_border->b);
1351 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, stripe_border->r, stripe_border->g, stripe_border->b);
1352 cairo_pattern_add_color_stop_rgb (pattern, stripe_fill_size, border1->r, border1->g, border1->b);
1353 cairo_pattern_add_color_stop_rgb (pattern, 1.0, border2->r, border2->g, border2->b);
1354 cairo_set_source (cr, pattern);
1356 cairo_pattern_destroy (pattern);
1363 clearlooks_draw_separator (cairo_t *cr,
1364 const ClearlooksColors *colors,
1365 const WidgetParameters *widget,
1366 const SeparatorParameters *separator,
1367 int x, int y, int width, int height)
1369 CairoColor color = colors->shade[2];
1371 ge_shade_color (&colors->bg[0], 1.065, &hilight);
1374 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
1376 if (separator->horizontal)
1378 cairo_set_line_width (cr, 1.0);
1379 cairo_translate (cr, x, y+0.5);
1381 cairo_move_to (cr, 0.0, 0.0);
1382 cairo_line_to (cr, width, 0.0);
1383 ge_cairo_set_color (cr, &color);
1386 cairo_move_to (cr, 0.0, 1.0);
1387 cairo_line_to (cr, width, 1.0);
1388 ge_cairo_set_color (cr, &hilight);
1393 cairo_set_line_width (cr, 1.0);
1394 cairo_translate (cr, x+0.5, y);
1396 cairo_move_to (cr, 0.0, 0.0);
1397 cairo_line_to (cr, 0.0, height);
1398 ge_cairo_set_color (cr, &color);
1401 cairo_move_to (cr, 1.0, 0.0);
1402 cairo_line_to (cr, 1.0, height);
1403 ge_cairo_set_color (cr, &hilight);
1411 clearlooks_draw_list_view_header (cairo_t *cr,
1412 const ClearlooksColors *colors,
1413 const WidgetParameters *params,
1414 const ListViewHeaderParameters *header,
1415 int x, int y, int width, int height)
1417 const CairoColor *border = &colors->shade[4];
1420 ge_shade_color (&colors->bg[params->state_type],
1421 params->style_constants->topleft_highlight_shade, &hilight);
1422 hilight.a = params->style_constants->topleft_highlight_alpha;
1424 cairo_translate (cr, x, y);
1425 cairo_set_line_width (cr, 1.0);
1427 /* Draw highlight */
1428 if (header->order & CL_ORDER_FIRST)
1430 cairo_move_to (cr, 0.5, height-1);
1431 cairo_line_to (cr, 0.5, 0.5);
1434 cairo_move_to (cr, 0.0, 0.5);
1436 cairo_line_to (cr, width, 0.5);
1438 ge_cairo_set_color (cr, &hilight);
1441 /* Draw bottom border */
1442 cairo_move_to (cr, 0.0, height-0.5);
1443 cairo_line_to (cr, width, height-0.5);
1444 ge_cairo_set_color (cr, border);
1447 /* Draw resize grip */
1448 if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
1449 (!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
1451 SeparatorParameters separator;
1452 separator.horizontal = FALSE;
1455 params->style_functions->draw_separator (cr, colors, params, &separator,
1456 width-1.5, 4.0, 2, height-8.0);
1458 params->style_functions->draw_separator (cr, colors, params, &separator,
1459 1.5, 4.0, 2, height-8.0);
1463 /* We can't draw transparent things here, since it will be called on the same
1464 * surface multiple times, when placed on a handlebox_bin or dockitem_bin */
1466 clearlooks_draw_toolbar (cairo_t *cr,
1467 const ClearlooksColors *colors,
1468 const WidgetParameters *widget,
1469 const ToolbarParameters *toolbar,
1470 int x, int y, int width, int height)
1472 const CairoColor *fill = &colors->bg[0];
1473 const CairoColor *dark = &colors->shade[3];
1475 ge_shade_color (fill, 1.065, &light);
1477 cairo_set_line_width (cr, 1.0);
1478 cairo_translate (cr, x, y);
1480 ge_cairo_set_color (cr, fill);
1483 if (!toolbar->topmost)
1485 /* Draw highlight */
1486 cairo_move_to (cr, 0, 0.5);
1487 cairo_line_to (cr, width-1, 0.5);
1488 ge_cairo_set_color (cr, &light);
1493 cairo_move_to (cr, 0, height-0.5);
1494 cairo_line_to (cr, width-1, height-0.5);
1495 ge_cairo_set_color (cr, dark);
1500 clearlooks_draw_menuitem (cairo_t *cr,
1501 const ClearlooksColors *colors,
1502 const WidgetParameters *widget,
1503 int x, int y, int width, int height)
1505 const CairoColor *fill = &colors->spot[1];
1506 CairoColor fill_shade;
1507 CairoColor border = colors->spot[2];
1508 cairo_pattern_t *pattern;
1510 ge_shade_color (&border, 1.05, &border);
1511 ge_shade_color (fill, 0.85, &fill_shade);
1512 cairo_set_line_width (cr, 1.0);
1514 ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, widget->radius, widget->corners);
1516 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1517 cairo_pattern_add_color_stop_rgb (pattern, 0, fill->r, fill->g, fill->b);
1518 cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1520 cairo_set_source (cr, pattern);
1521 cairo_fill_preserve (cr);
1522 cairo_pattern_destroy (pattern);
1524 ge_cairo_set_color (cr, &border);
1529 clearlooks_draw_menubaritem (cairo_t *cr,
1530 const ClearlooksColors *colors,
1531 const WidgetParameters *widget,
1532 int x, int y, int width, int height)
1534 const CairoColor *fill = &colors->spot[1];
1535 CairoColor fill_shade;
1536 CairoColor border = colors->spot[2];
1537 cairo_pattern_t *pattern;
1539 ge_shade_color (&border, 1.05, &border);
1540 ge_shade_color (fill, 0.85, &fill_shade);
1542 cairo_set_line_width (cr, 1.0);
1543 ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners);
1545 pattern = cairo_pattern_create_linear (x, y, x, y + height);
1546 cairo_pattern_add_color_stop_rgb (pattern, 0, fill->r, fill->g, fill->b);
1547 cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill_shade.r, fill_shade.g, fill_shade.b);
1549 cairo_set_source (cr, pattern);
1550 cairo_fill_preserve (cr);
1551 cairo_pattern_destroy (pattern);
1553 ge_cairo_set_color (cr, &border);
1554 cairo_stroke_preserve (cr);
1558 clearlooks_draw_selected_cell (cairo_t *cr,
1559 const ClearlooksColors *colors,
1560 const WidgetParameters *params,
1561 int x, int y, int width, int height)
1563 CairoColor upper_color;
1564 CairoColor lower_color;
1565 cairo_pattern_t *pattern;
1568 cairo_translate (cr, x, y);
1571 upper_color = colors->base[params->state_type];
1573 upper_color = colors->base[GTK_STATE_ACTIVE];
1575 ge_shade_color(&upper_color, 0.92, &lower_color);
1577 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1578 cairo_pattern_add_color_stop_rgb (pattern, 0.0, upper_color.r,
1581 cairo_pattern_add_color_stop_rgb (pattern, 1.0, lower_color.r,
1585 cairo_set_source (cr, pattern);
1586 cairo_rectangle (cr, 0, 0, width, height);
1589 cairo_pattern_destroy (pattern);
1596 clearlooks_draw_scrollbar_trough (cairo_t *cr,
1597 const ClearlooksColors *colors,
1598 const WidgetParameters *widget,
1599 const ScrollBarParameters *scrollbar,
1600 int x, int y, int width, int height)
1602 const CairoColor *bg = &colors->shade[2];
1603 const CairoColor *border = &colors->shade[5];
1604 CairoColor bg_shade;
1605 cairo_pattern_t *pattern;
1606 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1608 ge_shade_color (bg, 0.95, &bg_shade);
1610 cairo_set_line_width (cr, 1);
1611 /* cairo_translate (cr, x, y); */
1613 if (scrollbar->horizontal)
1614 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1616 cairo_translate (cr, x, y);
1620 ge_cairo_rounded_rectangle (cr, 1, 0, width-2, height,
1621 radius, widget->corners);
1623 cairo_rectangle (cr, 1, 0, width-2, height);
1624 ge_cairo_set_color (cr, bg);
1628 pattern = cairo_pattern_create_linear (1, 0, 3, 0);
1629 cairo_pattern_add_color_stop_rgb (pattern, 0, bg_shade.r, bg_shade.g, bg_shade.b);
1630 cairo_pattern_add_color_stop_rgb (pattern, 1.0, bg->r, bg->g, bg->b);
1631 cairo_rectangle (cr, 1, 0, 4, height);
1632 cairo_set_source (cr, pattern);
1634 cairo_pattern_destroy (pattern);
1638 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1,
1639 radius, widget->corners);
1641 cairo_rectangle (cr, 0.5, 0.5, width-1, height-1);
1642 ge_cairo_set_color (cr, border);
1647 clearlooks_draw_scrollbar_stepper (cairo_t *cr,
1648 const ClearlooksColors *colors,
1649 const WidgetParameters *widget,
1650 const ScrollBarParameters *scrollbar,
1651 const ScrollBarStepperParameters *stepper,
1652 int x, int y, int width, int height)
1654 CairoCorners corners = CR_CORNER_NONE;
1656 CairoColor s1, s2, s3, s4;
1657 cairo_pattern_t *pattern;
1658 double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
1660 ge_shade_color(&colors->shade[6], 1.08, &border);
1662 if (scrollbar->horizontal)
1664 if (stepper->stepper == CL_STEPPER_A)
1665 corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
1666 else if (stepper->stepper == CL_STEPPER_D)
1667 corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
1671 if (stepper->stepper == CL_STEPPER_A)
1672 corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
1673 else if (stepper->stepper == CL_STEPPER_D)
1674 corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
1677 cairo_translate (cr, x, y);
1678 cairo_set_line_width (cr, 1);
1680 ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
1682 if (scrollbar->horizontal)
1683 pattern = cairo_pattern_create_linear (0, 0, 0, height);
1685 pattern = cairo_pattern_create_linear (0, 0, width, 0);
1687 ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
1688 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
1689 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
1690 ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
1692 cairo_pattern_add_color_stop_rgb(pattern, 0, s1.r, s1.g, s1.b);
1693 cairo_pattern_add_color_stop_rgb(pattern, 0.3, s2.r, s2.g, s2.b);
1694 cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
1695 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
1696 cairo_set_source (cr, pattern);
1698 cairo_pattern_destroy (pattern);
1700 widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width - 2, height - 2, MAX(radius - 1, 0), corners);
1702 ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, corners);
1703 clearlooks_set_border_gradient (cr, &border, 1.1, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
1708 clearlooks_draw_scrollbar_slider (cairo_t *cr,
1709 const ClearlooksColors *colors,
1710 const WidgetParameters *widget,
1711 const ScrollBarParameters *scrollbar,
1712 int x, int y, int width, int height)
1716 if (scrollbar->junction & CL_JUNCTION_BEGIN)
1718 if (scrollbar->horizontal)
1729 if (scrollbar->junction & CL_JUNCTION_END)
1731 if (scrollbar->horizontal)
1737 if (!scrollbar->horizontal)
1738 ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
1740 cairo_translate (cr, x, y);
1742 if (scrollbar->has_color)
1744 const CairoColor *border = &colors->shade[7];
1745 CairoColor fill = scrollbar->color;
1747 CairoColor shade1, shade2, shade3;
1748 cairo_pattern_t *pattern;
1750 if (widget->prelight)
1751 ge_shade_color (&fill, 1.1, &fill);
1753 cairo_set_line_width (cr, 1);
1755 ge_shade_color (&fill, 1.3, &hilight);
1756 ge_shade_color (&fill, 1.1, &shade1);
1757 ge_shade_color (&fill, 1.05, &shade2);
1758 ge_shade_color (&fill, 0.98, &shade3);
1760 pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
1761 cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b);
1762 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
1763 cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
1764 cairo_pattern_add_color_stop_rgb (pattern, 1, fill.r, fill.g, fill.b);
1765 cairo_rectangle (cr, 1, 1, width-2, height-2);
1766 cairo_set_source (cr, pattern);
1768 cairo_pattern_destroy (pattern);
1770 cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
1771 ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
1773 ge_cairo_set_color (cr, border);
1774 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1778 const CairoColor *dark = &colors->shade[4];
1779 const CairoColor *light = &colors->shade[0];
1781 CairoColor s1, s2, s3, s4, s5;
1782 cairo_pattern_t *pattern;
1785 ge_shade_color (&colors->shade[6], 1.08, &border);
1786 ge_shade_color (&colors->bg[widget->state_type], SHADE_TOP, &s1);
1787 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_TOP, &s2);
1788 ge_shade_color (&colors->bg[widget->state_type], SHADE_CENTER_BOTTOM, &s3);
1789 ge_shade_color (&colors->bg[widget->state_type], SHADE_BOTTOM, &s4);
1791 pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
1792 cairo_pattern_add_color_stop_rgb(pattern, 0, s1.r, s1.g, s1.b);
1793 cairo_pattern_add_color_stop_rgb(pattern, 0.3, s2.r, s2.g, s2.b);
1794 cairo_pattern_add_color_stop_rgb(pattern, 0.7, s3.r, s3.g, s3.b);
1795 cairo_pattern_add_color_stop_rgb(pattern, 1.0, s4.r, s4.g, s4.b);
1797 cairo_rectangle (cr, 1, 1, width-2, height-2);
1798 cairo_set_source(cr, pattern);
1800 cairo_pattern_destroy(pattern);
1802 clearlooks_set_border_gradient (cr, &border, 1.1, 0, height);
1803 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1805 cairo_move_to (cr, 1.5, height-1.5);
1806 cairo_line_to (cr, 1.5, 1.5);
1807 cairo_line_to (cr, width-1.5, 1.5);
1808 ge_shade_color (&s2, widget->style_constants->topleft_highlight_shade, &s5);
1809 s5.a = widget->style_constants->topleft_highlight_alpha;
1810 ge_cairo_set_color (cr, &s5);
1814 cairo_set_line_width (cr, 1);
1815 cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
1817 bar_x = width/2 - 4;
1821 cairo_move_to (cr, bar_x + 0.5, 4);
1822 cairo_line_to (cr, bar_x + 0.5, height-4);
1823 ge_cairo_set_color (cr, dark);
1826 cairo_move_to (cr, bar_x+1.5, 4);
1827 cairo_line_to (cr, bar_x+1.5, height-4);
1828 ge_cairo_set_color (cr, light);
1839 clearlooks_draw_statusbar (cairo_t *cr,
1840 const ClearlooksColors *colors,
1841 const WidgetParameters *widget,
1842 int x, int y, int width, int height)
1844 const CairoColor *dark = &colors->shade[3];
1847 ge_shade_color (dark, 1.4, &hilight);
1849 cairo_set_line_width (cr, 1);
1850 cairo_translate (cr, x, y+0.5);
1851 cairo_move_to (cr, 0, 0);
1852 cairo_line_to (cr, width, 0);
1853 ge_cairo_set_color (cr, dark);
1856 cairo_translate (cr, 0, 1);
1857 cairo_move_to (cr, 0, 0);
1858 cairo_line_to (cr, width, 0);
1859 ge_cairo_set_color (cr, &hilight);
1864 clearlooks_draw_menu_frame (cairo_t *cr,
1865 const ClearlooksColors *colors,
1866 const WidgetParameters *widget,
1867 int x, int y, int width, int height)
1869 const CairoColor *border = &colors->shade[5];
1870 cairo_translate (cr, x, y);
1871 cairo_set_line_width (cr, 1);
1873 ge_cairo_set_color (cr, border);
1874 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1878 clearlooks_draw_tooltip (cairo_t *cr,
1879 const ClearlooksColors *colors,
1880 const WidgetParameters *widget,
1881 int x, int y, int width, int height)
1885 ge_shade_color (&colors->bg[widget->state_type], 0.6, &border);
1889 cairo_translate (cr, x, y);
1890 cairo_set_line_width (cr, 1);
1892 ge_cairo_set_color (cr, &colors->bg[widget->state_type]);
1893 cairo_rectangle (cr, 0, 0, width, height);
1896 ge_cairo_set_color (cr, &border);
1897 ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
1903 clearlooks_draw_handle (cairo_t *cr,
1904 const ClearlooksColors *colors,
1905 const WidgetParameters *params,
1906 const HandleParameters *handle,
1907 int x, int y, int width, int height)
1909 const CairoColor *fill = &colors->bg[params->state_type];
1910 int num_bars = 6; /* shut up gcc warnings */
1914 switch (handle->type)
1916 case CL_HANDLE_TOOLBAR:
1919 case CL_HANDLE_SPLITTER:
1924 if (params->prelight)
1926 cairo_rectangle (cr, x, y, width, height);
1927 ge_cairo_set_color (cr, fill);
1931 cairo_translate (cr, x, y);
1933 cairo_set_line_width (cr, 1);
1935 if (handle->horizontal)
1937 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, num_bars, 2, 0.1);
1941 params->style_functions->draw_gripdots (cr, colors, 0, 0, width, height, 2, num_bars, 0.1);
1948 clearlooks_draw_resize_grip (cairo_t *cr,
1949 const ClearlooksColors *colors,
1950 const WidgetParameters *widget,
1951 const ResizeGripParameters *grip,
1952 int x, int y, int width, int height)
1954 const CairoColor *dark = &colors->shade[4];
1961 ge_shade_color (dark, 1.5, &hilight);
1963 /* The number of dots fitting into the area. Just hardcoded to 4 right now. */
1964 /* dots = MIN (width - 2, height - 2) / 3; */
1971 case CL_WINDOW_EDGE_NORTH_EAST:
1974 cairo_translate (cr, x + width - 3*dots + 2, y + 1);
1976 case CL_WINDOW_EDGE_SOUTH_EAST:
1979 cairo_translate (cr, x + width - 3*dots + 2, y + height - 3*dots + 2);
1981 case CL_WINDOW_EDGE_SOUTH_WEST:
1984 cairo_translate (cr, x + 1, y + height - 3*dots + 2);
1986 case CL_WINDOW_EDGE_NORTH_WEST:
1989 cairo_translate (cr, x + 1, y + 1);
1992 /* Not implemented. */
1996 for (lx = 0; lx < dots; lx++) /* horizontally */
1998 for (ly = 0; ly <= lx; ly++) /* vertically */
2001 mx = x_down * dots + (1 - x_down * 2) * lx - x_down;
2002 my = y_down * dots + (1 - y_down * 2) * ly - y_down;
2004 ge_cairo_set_color (cr, &hilight);
2005 cairo_rectangle (cr, mx*3-1, my*3-1, 2, 2);
2008 ge_cairo_set_color (cr, dark);
2009 cairo_rectangle (cr, mx*3-1, my*3-1, 1, 1);
2018 clearlooks_draw_radiobutton (cairo_t *cr,
2019 const ClearlooksColors *colors,
2020 const WidgetParameters *widget,
2021 const CheckboxParameters *checkbox,
2022 int x, int y, int width, int height)
2024 const CairoColor *border;
2025 const CairoColor *dot;
2027 CairoColor highlight;
2028 cairo_pattern_t *pt;
2029 gboolean inconsistent;
2030 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2031 gdouble w, h, cx, cy, radius;
2033 w = (gdouble) width;
2034 h = (gdouble) height;
2037 radius = MIN (width, height) / 2.0;
2039 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2040 draw_bullet |= inconsistent;
2042 if (widget->disabled)
2044 border = &colors->shade[5];
2045 dot = &colors->shade[6];
2049 border = &colors->shade[6];
2050 dot = &colors->text[0];
2053 ge_shade_color (&widget->parentbg, 0.9, &shadow);
2054 ge_shade_color (&widget->parentbg, 1.1, &highlight);
2056 pt = cairo_pattern_create_linear (0, 0, radius * 2.0, radius * 2.0);
2057 cairo_pattern_add_color_stop_rgb (pt, 0.0, shadow.r, shadow.b, shadow.g);
2058 cairo_pattern_add_color_stop_rgba (pt, 0.5, shadow.r, shadow.b, shadow.g, 0.5);
2059 cairo_pattern_add_color_stop_rgba (pt, 0.5, highlight.r, highlight.g, highlight.b, 0.5);
2060 cairo_pattern_add_color_stop_rgb (pt, 1.0, highlight.r, highlight.g, highlight.b);
2062 cairo_translate (cr, x, y);
2064 cairo_set_line_width (cr, MAX (1.0, floor (radius/3)));
2065 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius - 0.1), 0, G_PI*2);
2066 cairo_set_source (cr, pt);
2068 cairo_pattern_destroy (pt);
2070 cairo_set_line_width (cr, MAX (1.0, floor (radius/6)));
2072 cairo_arc (cr, ceil (cx), ceil (cy), MAX (1.0, ceil (radius) - 1.5), 0, G_PI*2);
2074 if (!widget->disabled)
2076 ge_cairo_set_color (cr, &colors->base[0]);
2077 cairo_fill_preserve (cr);
2080 ge_cairo_set_color (cr, border);
2087 cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND);
2088 cairo_set_line_width (cr, ceil (radius * 2 / 3));
2090 cairo_move_to (cr, ceil (cx - radius/3.0), ceil (cy));
2091 cairo_line_to (cr, ceil (cx + radius/3.0), ceil (cy));
2093 ge_cairo_set_color (cr, dot);
2098 cairo_arc (cr, ceil (cx), ceil (cy), floor (radius/2.0), 0, G_PI*2);
2099 ge_cairo_set_color (cr, dot);
2102 cairo_arc (cr, floor (cx - radius/10.0), floor (cy - radius/10.0), floor (radius/6.0), 0, G_PI*2);
2103 cairo_set_source_rgba (cr, highlight.r, highlight.g, highlight.b, 0.5);
2110 clearlooks_draw_checkbox (cairo_t *cr,
2111 const ClearlooksColors *colors,
2112 const WidgetParameters *widget,
2113 const CheckboxParameters *checkbox,
2114 int x, int y, int width, int height)
2116 const CairoColor *border;
2117 const CairoColor *dot;
2118 gboolean inconsistent = FALSE;
2119 gboolean draw_bullet = (checkbox->shadow_type == GTK_SHADOW_IN);
2121 inconsistent = (checkbox->shadow_type == GTK_SHADOW_ETCHED_IN);
2122 draw_bullet |= inconsistent;
2124 if (widget->disabled)
2126 border = &colors->shade[5];
2127 dot = &colors->shade[6];
2131 border = &colors->shade[6];
2132 dot = &colors->text[GTK_STATE_NORMAL];
2135 cairo_translate (cr, x, y);
2136 cairo_set_line_width (cr, 1);
2138 if (widget->xthickness > 2 && widget->ythickness > 2)
2140 widget->style_functions->draw_inset (cr, &widget->parentbg, 0, 0, width, height, 1, CR_CORNER_ALL);
2142 /* Draw the rectangle for the checkbox itself */
2143 ge_cairo_rounded_rectangle (cr, 1.5, 1.5, width-3, height-3, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2147 /* Draw the rectangle for the checkbox itself */
2148 ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, (widget->radius > 0)? 1 : 0, CR_CORNER_ALL);
2151 if (!widget->disabled)
2153 ge_cairo_set_color (cr, &colors->base[0]);
2154 cairo_fill_preserve (cr);
2157 ge_cairo_set_color (cr, border);
2162 if (inconsistent) /* Inconsistent */
2164 cairo_set_line_width (cr, 2.0);
2165 cairo_move_to (cr, 3, height*0.5);
2166 cairo_line_to (cr, width-3, height*0.5);
2170 cairo_set_line_width (cr, 1.7);
2171 cairo_move_to (cr, 0.5 + (width*0.2), (height*0.5));
2172 cairo_line_to (cr, 0.5 + (width*0.4), (height*0.7));
2174 cairo_curve_to (cr, 0.5 + (width*0.4), (height*0.7),
2175 0.5 + (width*0.5), (height*0.4),
2176 0.5 + (width*0.70), (height*0.25));
2180 ge_cairo_set_color (cr, dot);
2186 clearlooks_draw_normal_arrow (cairo_t *cr, const CairoColor *color,
2187 double x, double y, double width, double height)
2190 double arrow_height;
2191 double line_width_2;
2195 arrow_width = MIN (height * 2.0 + MAX (1.0, ceil (height * 2.0 / 6.0 * 2.0) / 2.0) / 2.0, width);
2196 line_width_2 = MAX (1.0, ceil (arrow_width / 6.0 * 2.0) / 2.0) / 2.0;
2197 arrow_height = arrow_width / 2.0 + line_width_2;
2199 cairo_translate (cr, x, y - arrow_height / 2.0);
2201 cairo_move_to (cr, -arrow_width / 2.0, line_width_2);
2202 cairo_line_to (cr, -arrow_width / 2.0 + line_width_2, 0);
2203 /* cairo_line_to (cr, 0, arrow_height - line_width_2); */
2204 cairo_arc_negative (cr, 0, arrow_height - 2*line_width_2 - 2*line_width_2 * sqrt(2), 2*line_width_2, G_PI_2 + G_PI_4, G_PI_4);
2205 cairo_line_to (cr, arrow_width / 2.0 - line_width_2, 0);
2206 cairo_line_to (cr, arrow_width / 2.0, line_width_2);
2207 cairo_line_to (cr, 0, arrow_height);
2208 cairo_close_path (cr);
2210 ge_cairo_set_color (cr, color);
2217 clearlooks_draw_combo_arrow (cairo_t *cr, const CairoColor *color,
2218 double x, double y, double width, double height)
2220 double arrow_width = MIN (height * 2 / 3.0, width);
2221 double arrow_height = arrow_width / 2.0;
2222 double gap_size = 1.0 * arrow_height;
2225 cairo_translate (cr, x, y - (arrow_height + gap_size) / 2.0);
2226 cairo_rotate (cr, G_PI);
2227 clearlooks_draw_normal_arrow (cr, color, 0, 0, arrow_width, arrow_height);
2230 clearlooks_draw_normal_arrow (cr, color, x, y + (arrow_height + gap_size) / 2.0, arrow_width, arrow_height);
2234 _clearlooks_draw_arrow (cairo_t *cr, const CairoColor *color,
2235 ClearlooksDirection dir, ClearlooksArrowType type,
2236 double x, double y, double width, double height)
2240 if (dir == CL_DIRECTION_LEFT)
2242 else if (dir == CL_DIRECTION_RIGHT)
2244 else if (dir == CL_DIRECTION_UP)
2246 else if (dir == CL_DIRECTION_DOWN)
2251 if (type == CL_ARROW_NORMAL)
2253 cairo_translate (cr, x, y);
2254 cairo_rotate (cr, -rotate);
2255 clearlooks_draw_normal_arrow (cr, color, 0, 0, width, height);
2257 else if (type == CL_ARROW_COMBO)
2259 cairo_translate (cr, x, y);
2260 clearlooks_draw_combo_arrow (cr, color, 0, 0, width, height);
2265 clearlooks_draw_arrow (cairo_t *cr,
2266 const ClearlooksColors *colors,
2267 const WidgetParameters *widget,
2268 const ArrowParameters *arrow,
2269 int x, int y, int width, int height)
2271 const CairoColor *color = &colors->fg[widget->state_type];
2275 ty = y + height/2.0;
2277 if (widget->disabled)
2279 _clearlooks_draw_arrow (cr, &colors->shade[0],
2280 arrow->direction, arrow->type,
2281 tx+0.5, ty+0.5, width, height);
2284 cairo_identity_matrix (cr);
2286 _clearlooks_draw_arrow (cr, color, arrow->direction, arrow->type,
2287 tx, ty, width, height);
2291 clearlooks_draw_focus (cairo_t *cr,
2292 const ClearlooksColors *colors,
2293 const WidgetParameters *widget,
2294 const FocusParameters *focus,
2295 int x, int y, int width, int height)
2297 if (focus->has_color)
2298 ge_cairo_set_color (cr, &focus->color);
2299 else if (focus->type == CL_FOCUS_COLOR_WHEEL_LIGHT)
2300 cairo_set_source_rgb (cr, 0., 0., 0.);
2301 else if (focus->type == CL_FOCUS_COLOR_WHEEL_DARK)
2302 cairo_set_source_rgb (cr, 1., 1., 1.);
2304 cairo_set_source_rgba (cr,
2305 colors->fg[widget->state_type].r,
2306 colors->fg[widget->state_type].g,
2307 colors->fg[widget->state_type].b,
2310 cairo_set_line_width (cr, focus->line_width);
2312 if (focus->dash_list[0])
2314 gint n_dashes = strlen ((gchar *)focus->dash_list);
2315 gdouble *dashes = g_new (gdouble, n_dashes);
2316 gdouble total_length = 0;
2317 gdouble dash_offset;
2320 for (i = 0; i < n_dashes; i++)
2322 dashes[i] = focus->dash_list[i];
2323 total_length += focus->dash_list[i];
2326 dash_offset = -focus->line_width / 2.0;
2327 while (dash_offset < 0)
2328 dash_offset += total_length;
2330 cairo_set_dash (cr, dashes, n_dashes, dash_offset);
2334 cairo_rectangle (cr,
2335 x + focus->line_width / 2.0,
2336 y + focus->line_width / 2.0,
2337 width - focus->line_width, height - focus->line_width);
2342 clearlooks_register_style_classic (ClearlooksStyleFunctions *functions, ClearlooksStyleConstants *constants)
2344 g_assert (functions);
2346 functions->draw_top_left_highlight = clearlooks_draw_top_left_highlight;
2347 functions->draw_button = clearlooks_draw_button;
2348 functions->draw_scale_trough = clearlooks_draw_scale_trough;
2349 functions->draw_progressbar_trough = clearlooks_draw_progressbar_trough;
2350 functions->draw_progressbar_fill = clearlooks_draw_progressbar_fill;
2351 functions->draw_slider_button = clearlooks_draw_slider_button;
2352 functions->draw_entry = clearlooks_draw_entry;
2353 functions->draw_spinbutton = clearlooks_draw_spinbutton;
2354 functions->draw_spinbutton_down = clearlooks_draw_spinbutton_down;
2355 functions->draw_optionmenu = clearlooks_draw_optionmenu;
2356 functions->draw_inset = clearlooks_draw_inset;
2357 functions->draw_menubar = clearlooks_draw_menubar;
2358 functions->draw_tab = clearlooks_draw_tab;
2359 functions->draw_frame = clearlooks_draw_frame;
2360 functions->draw_separator = clearlooks_draw_separator;
2361 functions->draw_menu_item_separator = clearlooks_draw_menu_item_separator;
2362 functions->draw_list_view_header = clearlooks_draw_list_view_header;
2363 functions->draw_toolbar = clearlooks_draw_toolbar;
2364 functions->draw_menuitem = clearlooks_draw_menuitem;
2365 functions->draw_menubaritem = clearlooks_draw_menubaritem;
2366 functions->draw_selected_cell = clearlooks_draw_selected_cell;
2367 functions->draw_scrollbar_stepper = clearlooks_draw_scrollbar_stepper;
2368 functions->draw_scrollbar_slider = clearlooks_draw_scrollbar_slider;
2369 functions->draw_scrollbar_trough = clearlooks_draw_scrollbar_trough;
2370 functions->draw_statusbar = clearlooks_draw_statusbar;
2371 functions->draw_menu_frame = clearlooks_draw_menu_frame;
2372 functions->draw_tooltip = clearlooks_draw_tooltip;
2373 functions->draw_handle = clearlooks_draw_handle;
2374 functions->draw_resize_grip = clearlooks_draw_resize_grip;
2375 functions->draw_arrow = clearlooks_draw_arrow;
2376 functions->draw_focus = clearlooks_draw_focus;
2377 functions->draw_checkbox = clearlooks_draw_checkbox;
2378 functions->draw_radiobutton = clearlooks_draw_radiobutton;
2379 functions->draw_shadow = clearlooks_draw_shadow;
2380 functions->draw_slider = clearlooks_draw_slider;
2381 functions->draw_gripdots = clearlooks_draw_gripdots;
2383 constants->topleft_highlight_shade = 1.3;
2384 constants->topleft_highlight_alpha = 0.6;