2 Copyright 2009 by Hans Baier
10 public class GlossDemo
: DrawingArea
{
14 // Set favored widget size
15 set_size_request (500, 100);
18 /* Widget is asked to draw itself */
19 public override bool expose_event (Gdk
.EventExpose event
) {
21 // Create a Cairo context
22 var cr
= Gdk
.cairo_create (this
.window
);
24 // Set clipping area in order to avoid unnecessary drawing
25 cr
.rectangle (event
.area
.x
, event
.area
.y
,
26 event
.area
.width
, event
.area
.height
);
29 set_source_color_string(cr
, "#EDEDED");
30 set_source_color(cr
, style
.bg
[(int)Gtk
.StateType
.NORMAL
]);
31 cr
.rectangle(0, 0, allocation
.width
, allocation
.height
);
35 double glossbar_height
= allocation
.height
- 2 * padding
;
36 double glossbar_width
= (allocation
.width
- 2 * padding
) / 5.0 ;
38 Cairo
.Pattern gloss_red
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
, cairo_color_from_string("#D84212"));
39 Cairo
.Pattern gloss_green
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
, cairo_color_from_string("#237000"));
40 Cairo
.Pattern gloss_blue
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
, cairo_color_from_string("#0081FF"));
41 Cairo
.Pattern gloss_violet
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
, cairo_color_from_string("#9331AB"));
42 Cairo
.Pattern gloss_gray
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
, cairo_color_from_string("#5B5B57"));
44 cr
.rectangle(padding
, padding
, glossbar_width
, glossbar_height
);
45 cr
.set_source(gloss_blue
);
48 cr
.rectangle(padding
+ glossbar_width
, padding
, glossbar_width
, glossbar_height
);
49 cr
.set_source(gloss_red
);
52 cr
.rectangle(padding
+ 2.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
53 cr
.set_source(gloss_green
);
56 cr
.rectangle(padding
+ 3.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
57 cr
.set_source(gloss_violet
);
60 cr
.rectangle(padding
+ 4.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
61 cr
.set_source(gloss_gray
);
68 static int main (string[] args
) {
71 var window
= new
Window (WindowType
.TOPLEVEL
);
73 var glossDemo
= new
GlossDemo();
75 window
.add (glossDemo
);
76 window
.destroy
+= Gtk
.main_quit
;
83 } // namespace Prolooks