• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A generic touchscreen calibration program for X.Org


Commit MetaInfo

Revision93ec3c50fc48631bc93ecf53832306a570effd04 (tree)
Time2010-01-09 19:59:54
AuthorTias Guns <tias@ulys...>
CommiterTias Guns

Log Message

make the help_text boxed and 4 lines

Change Summary

Incremental Difference

--- a/gui_gtkmm.cpp
+++ b/gui_gtkmm.cpp
@@ -39,8 +39,14 @@ const int clock_radius = 50;
3939 const int clock_line_width = 10;
4040
4141 // 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+};
4450
4551
4652 /*******************************************
@@ -105,11 +111,31 @@ bool CalibrationArea::on_expose_event(GdkEventExpose *event)
105111 cr->clip();
106112
107113 // Print the text
108- Cairo::TextExtents extent;
109114 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+ }
113139 cr->stroke();
114140
115141 // Draw the points