Diffstat (limited to 'inputmethods/dasher/QtDasherScreen.cc') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/dasher/QtDasherScreen.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/inputmethods/dasher/QtDasherScreen.cc b/inputmethods/dasher/QtDasherScreen.cc index 747b705..2179cfb 100644 --- a/inputmethods/dasher/QtDasherScreen.cc +++ b/inputmethods/dasher/QtDasherScreen.cc | |||
@@ -1,59 +1,64 @@ | |||
1 | // QtDasherScreen.cc | 1 | // QtDasherScreen.cc |
2 | // (c) 2003 Yann Dirson | 2 | // (c) 2003 Yann Dirson |
3 | // Derived from GtkDasherCanvas.cc | 3 | // Derived from GtkDasherCanvas.cc |
4 | // (c) 2002 Philip Cowans | 4 | // (c) 2002 Philip Cowans |
5 | 5 | ||
6 | #include <iostream> | 6 | #include <iostream> |
7 | #include <string> | 7 | #include <string> |
8 | 8 | ||
9 | #include <qpointarray.h> | 9 | #include <qpointarray.h> |
10 | #include <qpoint.h> | 10 | #include <qpoint.h> |
11 | 11 | ||
12 | #include "QtDasherScreen.h" | 12 | #include "QtDasherScreen.h" |
13 | #include "DasherScreen.h" | 13 | #include "DasherScreen.h" |
14 | #include "SettingsStore.h" | 14 | #include "SettingsStore.h" |
15 | 15 | ||
16 | #define MAXFONTSIZE 25 | 16 | #define MAXFONTSIZE 25 |
17 | #define MINFONTSIZE 8 | 17 | #define MINFONTSIZE 8 |
18 | 18 | ||
19 | QtDasherScreen::QtDasherScreen (int _width, int _height, | 19 | QtDasherScreen::QtDasherScreen (int _width, int _height, |
20 | CDasherInterface *_interface, | 20 | CDasherInterface *_interface, |
21 | QWidget * _parent, Dasher::CDashEditbox *edit): | 21 | QWidget * _parent, |
22 | QWidget(_parent), interface( _interface ), | 22 | Dasher::CDashEditbox *_edit): |
23 | fontname( "fixed" ), fontsize(12), | 23 | QWidget(_parent), |
24 | Dasher::CDasherScreen(_width, _height) | 24 | Dasher::CDasherScreen(_width, _height), |
25 | fontsize(12), | ||
26 | interface( _interface ), | ||
27 | fontname( "fixed" ) | ||
25 | { | 28 | { |
26 | font = QFont (fontname.c_str(), fontsize); | 29 | font = QFont (fontname.c_str(), fontsize); |
27 | painter = new QPainter (); | 30 | painter = new QPainter (); |
28 | 31 | ||
29 | pixmap = new QPixmap (_width, _height); | 32 | pixmap = new QPixmap (_width, _height); |
30 | pixmap->setOptimization(QPixmap::BestOptim); | 33 | pixmap->setOptimization(QPixmap::BestOptim); |
31 | interface->SetSettingsStore(new CSettingsStore); | 34 | interface->SetSettingsStore(new CSettingsStore); |
32 | 35 | ||
33 | interface->ChangeLanguageModel(0); | 36 | interface->ChangeLanguageModel(0); |
34 | interface->ChangeView(0); | 37 | interface->ChangeView(0); |
35 | interface->ChangeEdit(edit); | 38 | interface->ChangeEdit(_edit); |
39 | edit = _edit; | ||
40 | |||
36 | 41 | ||
37 | /* interface->GetFontSizes(&FontSizes); | 42 | /* interface->GetFontSizes(&FontSizes); |
38 | 43 | ||
39 | for (int i=0; i<FontSizes.size(); i++) { | 44 | for (int i=0; i<FontSizes.size(); i++) { |
40 | if (FontSizes[i]>Fonts.size()) | 45 | if (FontSizes[i]>Fonts.size()) |
41 | Fonts.resize((FontSizes[i])+1); | 46 | Fonts.resize((FontSizes[i])+1); |
42 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); | 47 | Fonts[FontSizes[i]]= QFont (fontname.c_str(), FontSizes[i]); |
43 | // Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); | 48 | // Fonts[FontSizes[i]].setPixelSize(FontSizes[i]); |
44 | } | 49 | } |
45 | */ | 50 | */ |
46 | interface->ChangeScreen(this); | 51 | interface->ChangeScreen(this); |
47 | 52 | ||
48 | paused=true; | 53 | paused=true; |
49 | 54 | ||
50 | QTimer *tmr = new QTimer(this); | 55 | QTimer *tmr = new QTimer(this); |
51 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); | 56 | connect (tmr, SIGNAL(timeout()), SLOT(timer())); |
52 | tmr->start(200); | 57 | tmr->start(200); |
53 | 58 | ||
54 | } | 59 | } |
55 | 60 | ||
56 | long QtDasherScreen::get_time() | 61 | long QtDasherScreen::get_time() |
57 | { | 62 | { |
58 | long s_now; | 63 | long s_now; |
59 | long ms_now; | 64 | long ms_now; |
@@ -122,49 +127,49 @@ static void Points_to_QPointArray(const Dasher::CDasherScreen::point* const poin | |||
122 | { | 127 | { |
123 | for (int i = 0; i < number; i++) { | 128 | for (int i = 0; i < number; i++) { |
124 | qpa.setPoint (i, points[i].x, points[i].y); | 129 | qpa.setPoint (i, points[i].x, points[i].y); |
125 | } | 130 | } |
126 | } | 131 | } |
127 | 132 | ||
128 | void QtDasherScreen::Polyline(point* Points, int Number) const | 133 | void QtDasherScreen::Polyline(point* Points, int Number) const |
129 | { | 134 | { |
130 | QPointArray qpa(Number); | 135 | QPointArray qpa(Number); |
131 | Points_to_QPointArray (Points, Number, qpa); | 136 | Points_to_QPointArray (Points, Number, qpa); |
132 | painter->setPen (SolidLine); | 137 | painter->setPen (SolidLine); |
133 | painter->drawPolyline (qpa); | 138 | painter->drawPolyline (qpa); |
134 | painter->setPen (NoPen); | 139 | painter->setPen (NoPen); |
135 | } | 140 | } |
136 | 141 | ||
137 | void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, | 142 | void QtDasherScreen::DrawPolygon(point* Points, int Number, int Color, |
138 | Opts::ColorSchemes ColorScheme) const | 143 | Opts::ColorSchemes ColorScheme) const |
139 | { | 144 | { |
140 | painter->setBrush (getColor (Color, ColorScheme)); | 145 | painter->setBrush (getColor (Color, ColorScheme)); |
141 | QPointArray qpa(Number); | 146 | QPointArray qpa(Number); |
142 | Points_to_QPointArray (Points, Number, qpa); | 147 | Points_to_QPointArray (Points, Number, qpa); |
143 | painter->drawPolygon (qpa); | 148 | painter->drawPolygon (qpa); |
144 | } | 149 | } |
145 | 150 | ||
146 | void QtDasherScreen::mousePressEvent (QMouseEvent *e) | 151 | void QtDasherScreen::mousePressEvent (QMouseEvent *) |
147 | { | 152 | { |
148 | paused=false; | 153 | paused=false; |
149 | interface->Unpause(get_time()); | 154 | interface->Unpause(get_time()); |
150 | } | 155 | } |
151 | 156 | ||
152 | void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) | 157 | void QtDasherScreen::mouseReleaseEvent(QMouseEvent *e) |
153 | { | 158 | { |
154 | QPoint p = e->pos(); | 159 | QPoint p = e->pos(); |
155 | interface->PauseAt(p.x(), p.y()); | 160 | interface->PauseAt(p.x(), p.y()); |
156 | paused=true; | 161 | paused=true; |
157 | } | 162 | } |
158 | 163 | ||
159 | void QtDasherScreen::timer() | 164 | void QtDasherScreen::timer() |
160 | { | 165 | { |
161 | if (paused==false) { | 166 | if (paused==false) { |
162 | QPoint cursorpos; | 167 | QPoint cursorpos; |
163 | cursorpos=this->cursor().pos(); | 168 | cursorpos=this->cursor().pos(); |
164 | cursorpos=mapFromGlobal(cursorpos); | 169 | cursorpos=mapFromGlobal(cursorpos); |
165 | 170 | ||
166 | interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); | 171 | interface->TapOn(cursorpos.x(), cursorpos.y(), get_time()); |
167 | } | 172 | } |
168 | } | 173 | } |
169 | 174 | ||
170 | 175 | ||