A generic touchscreen calibration program for X.Org
Revision | 93ec3c50fc48631bc93ecf53832306a570effd04 (tree) |
---|---|
Time | 2010-01-09 19:59:54 |
Author | Tias Guns <tias@ulys...> |
Commiter | Tias Guns |
make the help_text boxed and 4 lines
@@ -39,8 +39,14 @@ const int clock_radius = 50; | ||
39 | 39 | const int clock_line_width = 10; |
40 | 40 | |
41 | 41 | // Text printed on screen |
42 | -const int font_size = 20; | |
43 | -const std::string help_text = "Press the point with the stylus"; | |
42 | +const int font_size = 18; | |
43 | +const int help_lines = 4; | |
44 | +const std::string help_text[help_lines] = { | |
45 | + "Touchscreen Calibration", | |
46 | + "Press the point, use a stylus to increase precision.", | |
47 | + "", | |
48 | + "(To abort, press any key or wait)" | |
49 | +}; | |
44 | 50 | |
45 | 51 | |
46 | 52 | /******************************************* |
@@ -105,11 +111,31 @@ bool CalibrationArea::on_expose_event(GdkEventExpose *event) | ||
105 | 111 | cr->clip(); |
106 | 112 | |
107 | 113 | // Print the text |
108 | - Cairo::TextExtents extent; | |
109 | 114 | cr->set_font_size(font_size); |
110 | - cr->get_text_extents(help_text, extent); | |
111 | - cr->move_to((display_width-extent.width)/2, 0.3*display_height); | |
112 | - cr->show_text(help_text); | |
115 | + double text_height = -1; | |
116 | + double text_width = -1; | |
117 | + Cairo::TextExtents extent; | |
118 | + for (int i = 0; i != help_lines; i++) { | |
119 | + cr->get_text_extents(help_text[i], extent); | |
120 | + text_width = std::max(text_width, extent.width); | |
121 | + text_height = std::max(text_height, extent.height); | |
122 | + } | |
123 | + text_height += 2; | |
124 | + | |
125 | + double x = (display_width - text_width) / 2; | |
126 | + double y = (display_height - text_height) / 2 - 60; | |
127 | + cr->set_line_width(3); | |
128 | + cr->rectangle(x - 10, y - (help_lines*text_height) - 10, | |
129 | + text_width + 20, (help_lines*text_height) + 20); | |
130 | + | |
131 | + // Print help lines | |
132 | + y -= 3; | |
133 | + for (int i = help_lines-1; i != -1; i--) { | |
134 | + cr->get_text_extents(help_text[i], extent); | |
135 | + cr->move_to(x + (text_width-extent.width)/2, y); | |
136 | + cr->show_text(help_text[i]); | |
137 | + y -= text_height; | |
138 | + } | |
113 | 139 | cr->stroke(); |
114 | 140 | |
115 | 141 | // Draw the points |