2 Copyright 2009 by Hans Baier
10 public class GlossDemo
: DrawingArea
{
14 // Set favored widget size
15 set_size_request (500, 55);
16 draw
.connect(on_draw
);
19 /* Widget is asked to draw itself */
20 public bool on_draw (Cairo
.Context cr
) {
21 Gtk
.Allocation allocation
;
22 get_allocation(out allocation
);
24 set_source_color_string(cr
, "#EDEDED");
25 set_source_color(cr
, gdk_color_to_rgba(style
.bg
[(int)Gtk
.StateType
.NORMAL
]));
26 cr
.rectangle(0, 0, allocation
.width
, allocation
.height
);
30 double glossbar_height
= allocation
.height
- 2 * padding
;
31 double glossbar_width
= (allocation
.width
- 2 * padding
) / 5.0 ;
33 Cairo
.Pattern gloss_red
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
+ padding
, rgba_from_string("#D84212"), 50);
34 Cairo
.Pattern gloss_green
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
+ padding
, rgba_from_string("#237000"), 50);
35 Cairo
.Pattern gloss_blue
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
+ padding
, rgba_from_string("#0081FF"), 50);
36 Cairo
.Pattern gloss_violet
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
+ padding
, rgba_from_string("#9331AB"), 50);
37 Cairo
.Pattern gloss_gray
= gloss_gradient_pattern(0.0, padding
, 0.0, glossbar_height
+ padding
, rgba_from_string("#5B5B57"), 50);
39 cr
.rectangle(padding
, padding
, glossbar_width
, glossbar_height
);
40 cr
.set_source(gloss_blue
);
43 cr
.rectangle(padding
+ glossbar_width
, padding
, glossbar_width
, glossbar_height
);
44 cr
.set_source(gloss_red
);
47 cr
.rectangle(padding
+ 2.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
48 cr
.set_source(gloss_green
);
51 cr
.rectangle(padding
+ 3.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
52 cr
.set_source(gloss_violet
);
55 cr
.rectangle(padding
+ 4.0 * glossbar_width
, padding
, glossbar_width
, glossbar_height
);
56 cr
.set_source(gloss_gray
);
63 static int main (string[] args
) {
65 var window
= new
Window (WindowType
.TOPLEVEL
);
67 var glossDemo
= new
GlossDemo();
69 window
.add (glossDemo
);
70 window
.destroy
.connect(Gtk
.main_quit
);
75 } // namespace Prolooks