2 Copyright 2009 by Hans Baier
10 public class ValueDisplay
: DrawingArea
{
12 private string _text
= "";
25 public bool show_matrix
{get; set;}
27 private int width
= 36;
28 private int height
= 16;
31 set_size_request (width
, height
);
35 /* Widget is asked to draw itself */
36 public override bool expose_event (Gdk
.EventExpose event
) {
37 //Gdk.Color test_color = color_from_string ("#ff0000");
39 width
= allocation
.width
;
40 height
= allocation
.height
;
42 // Create a Cairo context
43 var cr
= Gdk
.cairo_create (this
.window
);
45 // Set clipping area in order to avoid unnecessary drawing
46 cr
.rectangle (event
.area
.x
, event
.area
.y
,
47 event
.area
.width
, event
.area
.height
);
50 DisplayBase
.outer_rim_for_display (cr
, 0, 0, width
, height
, style
.bg
[Gtk
.StateType
.SELECTED
]);
54 var inner_width
= width
- 6;
55 var inner_height
= height
- 6;
58 DisplayBase
.dot_matrix (cr
, 0.5, 0.5, inner_width
, inner_height
, DisplayBase
.matrix_dot_color ());
61 DisplayBase
.lcd(cr
, inner_width
, inner_height
, 3.0);
64 double font_size
= inner_height
;
66 cr
.select_font_face ("FreeSans", Cairo
.FontSlant
.NORMAL
, Cairo
.FontWeight
.NORMAL
);
67 cr
.set_font_size (font_size
);
68 Cairo
.TextExtents ext
= Cairo
.TextExtents();
69 cr
.text_extents (text
, ref ext
);
70 double x
= (inner_width
- ext
.x_advance
) / 2.0;
71 double y
= inner_height
* 0.85;
73 DisplayBase
.text (cr
, text
, x
, y
, font_size
);
75 DisplayBase
.reflection(cr
, inner_width
, inner_height
);
81 } // namespace Prolooks