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