-rw-r--r-- | inputmethods/jumpx/keyboard.cpp | 1 | ||||
-rw-r--r-- | inputmethods/jumpx/keyboard.h | 5 | ||||
-rw-r--r-- | inputmethods/jumpx/keyboardimpl.cpp | 4 | ||||
-rw-r--r-- | inputmethods/jumpx/keyboardimpl.h | 12 |
4 files changed, 18 insertions, 4 deletions
diff --git a/inputmethods/jumpx/keyboard.cpp b/inputmethods/jumpx/keyboard.cpp index 0b8fc14..0cfb4be 100644 --- a/inputmethods/jumpx/keyboard.cpp +++ b/inputmethods/jumpx/keyboard.cpp | |||
@@ -1,524 +1,525 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /**************************************************************************************94x78** |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | *********************************************************************************************/ | 11 | *********************************************************************************************/ |
12 | #include "keyboard.h" | 12 | #include "keyboard.h" |
13 | 13 | ||
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | //#include <iostream.h> | 16 | //#include <iostream.h> |
17 | 17 | ||
18 | 18 | ||
19 | static const int autorepeatDelaytime = 500; // ms | 19 | static const int autorepeatDelaytime = 500; // ms |
20 | static const int autorepeatRate = 20; // chars per second | 20 | static const int autorepeatRate = 20; // chars per second |
21 | 21 | ||
22 | static const int mod1x1 = 0; | 22 | static const int mod1x1 = 0; |
23 | static const int mod1x2 = 23; | 23 | static const int mod1x2 = 23; |
24 | static const int mod1w = mod1x2 - mod1x1; | 24 | static const int mod1w = mod1x2 - mod1x1; |
25 | 25 | ||
26 | static const int letterx1 = 27; | 26 | static const int letterx1 = 27; |
27 | static const int letterx2 = 129; | 27 | static const int letterx2 = 129; |
28 | static const int letterw = 17; | 28 | static const int letterw = 17; |
29 | static const int letterh = 14; | 29 | static const int letterh = 14; |
30 | 30 | ||
31 | static const int num1x1 = 130; | 31 | static const int num1x1 = 130; |
32 | static const int num1x2 = 137; | 32 | static const int num1x2 = 137; |
33 | static const int num1w = num1x2 - num1x1; | 33 | static const int num1w = num1x2 - num1x1; |
34 | 34 | ||
35 | static const int specialx1 = 138; | 35 | static const int specialx1 = 138; |
36 | static const int specialx2 = 170; | 36 | static const int specialx2 = 170; |
37 | static const int specialw = 16; | 37 | static const int specialw = 16; |
38 | 38 | ||
39 | static const int num2x1 = 171; | 39 | static const int num2x1 = 171; |
40 | static const int num2x2 = 178; | 40 | static const int num2x2 = 178; |
41 | static const int num2w = num2x2 - num2x1; | 41 | static const int num2w = num2x2 - num2x1; |
42 | 42 | ||
43 | static const int mod2x1 = 179; | 43 | static const int mod2x1 = 179; |
44 | static const int mod2x2 = 203; | 44 | static const int mod2x2 = 203; |
45 | static const int mod2w = mod2x2 - mod2x1; | 45 | static const int mod2w = mod2x2 - mod2x1; |
46 | 46 | ||
47 | static const int cursorx1 = 207; | 47 | static const int cursorx1 = 207; |
48 | static const int cursorw = 16; | 48 | static const int cursorw = 16; |
49 | 49 | ||
50 | static const int myParenID = -10; | 50 | static const int myParenID = -10; |
51 | 51 | ||
52 | 52 | ||
53 | typedef struct mapElement | 53 | typedef struct mapElement |
54 | { | 54 | { |
55 | int qcode; | 55 | int qcode; |
56 | ushort unicode; | 56 | ushort unicode; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static const mapElement mod1Map[] = { | 59 | static const mapElement mod1Map[] = { |
60 | { Qt::Key_Escape, 27 }, | 60 | { Qt::Key_Escape, 27 }, |
61 | { Qt::Key_Tab, 9 }, | 61 | { Qt::Key_Tab, 9 }, |
62 | { Qt::Key_Return, 13 }, | 62 | { Qt::Key_Return, 13 }, |
63 | { Qt::Key_Alt, 0 }, | 63 | { Qt::Key_Alt, 0 }, |
64 | { Qt::Key_Control, 0 }, | 64 | { Qt::Key_Control, 0 }, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static const uchar *const letterMap[] = { | 67 | static const uchar *const letterMap[] = { |
68 | (const uchar *const)"zvchwk", | 68 | (const uchar *const)"zvchwk", |
69 | (const uchar *const)"fitaly", | 69 | (const uchar *const)"fitaly", |
70 | (const uchar *const)" ne ", | 70 | (const uchar *const)" ne ", |
71 | (const uchar *const)"gdorsb", | 71 | (const uchar *const)"gdorsb", |
72 | (const uchar *const)"qjumpx", | 72 | (const uchar *const)"qjumpx", |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static const uchar *const letterMapShift[] = { | 75 | static const uchar *const letterMapShift[] = { |
76 | (const uchar *const)"ZVCHWK", | 76 | (const uchar *const)"ZVCHWK", |
77 | (const uchar *const)"FITALY", | 77 | (const uchar *const)"FITALY", |
78 | (const uchar *const)" NE ", | 78 | (const uchar *const)" NE ", |
79 | (const uchar *const)"GDORSB", | 79 | (const uchar *const)"GDORSB", |
80 | (const uchar *const)"QJUMPX", | 80 | (const uchar *const)"QJUMPX", |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const uchar *const num1Map = (const uchar *const)"12345"; | 83 | static const uchar *const num1Map = (const uchar *const)"12345"; |
84 | 84 | ||
85 | static const uchar *const specialMap[] = { | 85 | static const uchar *const specialMap[] = { |
86 | (const uchar *const)"-+", | 86 | (const uchar *const)"-+", |
87 | (const uchar *const)"*!", | 87 | (const uchar *const)"*!", |
88 | (const uchar *const)",'", | 88 | (const uchar *const)",'", |
89 | (const uchar *const)".%", | 89 | (const uchar *const)".%", |
90 | (const uchar *const)"/$", | 90 | (const uchar *const)"/$", |
91 | }; | 91 | }; |
92 | 92 | ||
93 | static const uchar *const specialMapShift[] = { | 93 | static const uchar *const specialMapShift[] = { |
94 | (const uchar *const)"_=", | 94 | (const uchar *const)"_=", |
95 | (const uchar *const)"#?", | 95 | (const uchar *const)"#?", |
96 | (const uchar *const)";\"", | 96 | (const uchar *const)";\"", |
97 | (const uchar *const)":|", | 97 | (const uchar *const)":|", |
98 | (const uchar *const)"\\&", | 98 | (const uchar *const)"\\&", |
99 | }; | 99 | }; |
100 | 100 | ||
101 | static const uchar *const specialMapParen[] = { | 101 | static const uchar *const specialMapParen[] = { |
102 | (const uchar *const)"()", | 102 | (const uchar *const)"()", |
103 | (const uchar *const)"[]", | 103 | (const uchar *const)"[]", |
104 | (const uchar *const)"{}", | 104 | (const uchar *const)"{}", |
105 | (const uchar *const)"<>", | 105 | (const uchar *const)"<>", |
106 | (const uchar *const)"@~", | 106 | (const uchar *const)"@~", |
107 | }; | 107 | }; |
108 | 108 | ||
109 | static const uchar *const num2Map = (const uchar *const)"67890"; | 109 | static const uchar *const num2Map = (const uchar *const)"67890"; |
110 | 110 | ||
111 | static const mapElement mod2Map[] = { | 111 | static const mapElement mod2Map[] = { |
112 | { Qt::Key_Backspace, 8 }, | 112 | { Qt::Key_Backspace, 8 }, |
113 | { Qt::Key_Delete, 0 }, | 113 | { Qt::Key_Delete, 0 }, |
114 | { Qt::Key_Return, 13 }, | 114 | { Qt::Key_Return, 13 }, |
115 | { Qt::Key_Shift, 0 }, | 115 | { Qt::Key_Shift, 0 }, |
116 | { myParenID, 0 }, | 116 | { myParenID, 0 }, |
117 | }; | 117 | }; |
118 | 118 | ||
119 | static const int cursorMap[][2] = { | 119 | static const int cursorMap[][2] = { |
120 | { Qt::Key_Home, Qt::Key_PageUp }, | 120 | { Qt::Key_Home, Qt::Key_PageUp }, |
121 | { Qt::Key_End, Qt::Key_PageDown }, | 121 | { Qt::Key_End, Qt::Key_PageDown }, |
122 | { Qt::Key_Up, Qt::Key_Up }, | 122 | { Qt::Key_Up, Qt::Key_Up }, |
123 | { Qt::Key_Left, Qt::Key_Right }, | 123 | { Qt::Key_Left, Qt::Key_Right }, |
124 | { Qt::Key_Down, Qt::Key_Down }, | 124 | { Qt::Key_Down, Qt::Key_Down }, |
125 | }; | 125 | }; |
126 | 126 | ||
127 | using namespace JumpX; | ||
127 | 128 | ||
128 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 129 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
129 | QFrame(parent, name, f), | 130 | QFrame(parent, name, f), |
130 | shift(0), paren(0), ctrl(0), alt(0), | 131 | shift(0), paren(0), ctrl(0), alt(0), |
131 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), | 132 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), |
132 | isnoncont(false), | 133 | isnoncont(false), |
133 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), | 134 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), |
134 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), | 135 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), |
135 | releasedPix(NULL), pressedPix(NULL) | 136 | releasedPix(NULL), pressedPix(NULL) |
136 | { | 137 | { |
137 | //setPalette(QPalette(QColor(240,240,230))); // Beige! | 138 | //setPalette(QPalette(QColor(240,240,230))); // Beige! |
138 | 139 | ||
139 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("jumpx/released"); | 140 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("jumpx/released"); |
140 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("jumpx/pressed"); | 141 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("jumpx/pressed"); |
141 | pressedDigit = Resource::loadPixmap("jumpx/pressed"); | 142 | pressedDigit = Resource::loadPixmap("jumpx/pressed"); |
142 | 143 | ||
143 | QPixmap tmp; | 144 | QPixmap tmp; |
144 | 145 | ||
145 | tmp = Resource::loadPixmap("jumpx/releasedShift"); | 146 | tmp = Resource::loadPixmap("jumpx/releasedShift"); |
146 | bitBlt(&releasedShift, letterx1, 0, &tmp); | 147 | bitBlt(&releasedShift, letterx1, 0, &tmp); |
147 | 148 | ||
148 | tmp = Resource::loadPixmap("jumpx/releasedParen"); | 149 | tmp = Resource::loadPixmap("jumpx/releasedParen"); |
149 | bitBlt(&releasedParen, specialx1, 0, &tmp); | 150 | bitBlt(&releasedParen, specialx1, 0, &tmp); |
150 | 151 | ||
151 | tmp = Resource::loadPixmap("jumpx/pressedShift"); | 152 | tmp = Resource::loadPixmap("jumpx/pressedShift"); |
152 | bitBlt(&pressedShift, letterx1, 0, &tmp); | 153 | bitBlt(&pressedShift, letterx1, 0, &tmp); |
153 | 154 | ||
154 | tmp = Resource::loadPixmap("jumpx/pressedParen"); | 155 | tmp = Resource::loadPixmap("jumpx/pressedParen"); |
155 | bitBlt(&pressedParen, specialx1, 0, &tmp); | 156 | bitBlt(&pressedParen, specialx1, 0, &tmp); |
156 | 157 | ||
157 | tmp = Resource::loadPixmap("jumpx/pressedDigit"); | 158 | tmp = Resource::loadPixmap("jumpx/pressedDigit"); |
158 | bitBlt(&pressedDigit, specialx1, 0, &tmp); | 159 | bitBlt(&pressedDigit, specialx1, 0, &tmp); |
159 | 160 | ||
160 | offscreen = QPixmap( releasedPlain ); | 161 | offscreen = QPixmap( releasedPlain ); |
161 | 162 | ||
162 | releasedPix = &releasedPlain; | 163 | releasedPix = &releasedPlain; |
163 | pressedPix = &pressedPlain; | 164 | pressedPix = &pressedPlain; |
164 | slidePix = &pressedPlain; | 165 | slidePix = &pressedPlain; |
165 | 166 | ||
166 | delayTimer = new QTimer(this); | 167 | delayTimer = new QTimer(this); |
167 | rateTimer = new QTimer(this); | 168 | rateTimer = new QTimer(this); |
168 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); | 169 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); |
169 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 170 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
170 | } | 171 | } |
171 | 172 | ||
172 | void Keyboard::resizeEvent(QResizeEvent*) | 173 | void Keyboard::resizeEvent(QResizeEvent*) |
173 | { | 174 | { |
174 | //cout << "resizeEvent()" << endl; | 175 | //cout << "resizeEvent()" << endl; |
175 | } | 176 | } |
176 | 177 | ||
177 | void Keyboard::paintEvent(QPaintEvent*) | 178 | void Keyboard::paintEvent(QPaintEvent*) |
178 | { | 179 | { |
179 | bitBlt(this, 0, 0, &offscreen); | 180 | bitBlt(this, 0, 0, &offscreen); |
180 | } | 181 | } |
181 | 182 | ||
182 | void Keyboard::mousePressEvent(QMouseEvent *e) | 183 | void Keyboard::mousePressEvent(QMouseEvent *e) |
183 | { | 184 | { |
184 | pressedx = -1; | 185 | pressedx = -1; |
185 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; | 186 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; |
186 | 187 | ||
187 | int x = e->x(); | 188 | int x = e->x(); |
188 | int y = e->y(); | 189 | int y = e->y(); |
189 | 190 | ||
190 | int row = (y - 1) / letterh; | 191 | int row = (y - 1) / letterh; |
191 | 192 | ||
192 | if ( x <= mod1x2 ) // mod1 | 193 | if ( x <= mod1x2 ) // mod1 |
193 | { | 194 | { |
194 | pressedx = mod1x1; | 195 | pressedx = mod1x1; |
195 | pressedy = row * letterh; | 196 | pressedy = row * letterh; |
196 | pressedw = mod1w + 1; | 197 | pressedw = mod1w + 1; |
197 | pressedh = letterh + 1; | 198 | pressedh = letterh + 1; |
198 | if ( row == 2 ) // return | 199 | if ( row == 2 ) // return |
199 | { | 200 | { |
200 | pressed2x = mod2x1; | 201 | pressed2x = mod2x1; |
201 | pressed2y = 2 * letterh; | 202 | pressed2y = 2 * letterh; |
202 | pressed2w = mod2w + 1; | 203 | pressed2w = mod2w + 1; |
203 | pressed2h = letterh + 1; | 204 | pressed2h = letterh + 1; |
204 | isnoncont = true; | 205 | isnoncont = true; |
205 | } | 206 | } |
206 | else if ( row == 3 ) // alt | 207 | else if ( row == 3 ) // alt |
207 | alt = 1; | 208 | alt = 1; |
208 | else if ( row == 4 ) // ctrl | 209 | else if ( row == 4 ) // ctrl |
209 | ctrl = 1; | 210 | ctrl = 1; |
210 | pressedKeyUnicode = mod1Map[row].unicode; | 211 | pressedKeyUnicode = mod1Map[row].unicode; |
211 | pressedKeyQcode = mod1Map[row].qcode; | 212 | pressedKeyQcode = mod1Map[row].qcode; |
212 | } | 213 | } |
213 | else if ( x >= letterx1 && x <= letterx2 ) // letter | 214 | else if ( x >= letterx1 && x <= letterx2 ) // letter |
214 | { | 215 | { |
215 | int column = (x - letterx1 - 1) / letterw; | 216 | int column = (x - letterx1 - 1) / letterw; |
216 | QChar temp; | 217 | QChar temp; |
217 | if ( shift ) | 218 | if ( shift ) |
218 | temp = QChar( letterMapShift[row][column] ); | 219 | temp = QChar( letterMapShift[row][column] ); |
219 | else | 220 | else |
220 | temp = QChar( letterMap[row][column] ); | 221 | temp = QChar( letterMap[row][column] ); |
221 | if ( temp == ' ' ) // space | 222 | if ( temp == ' ' ) // space |
222 | { | 223 | { |
223 | if ( column < 3 ) | 224 | if ( column < 3 ) |
224 | { | 225 | { |
225 | pressedx = letterx1; | 226 | pressedx = letterx1; |
226 | pressed2x = letterx1 + letterw * 4; | 227 | pressed2x = letterx1 + letterw * 4; |
227 | } | 228 | } |
228 | else | 229 | else |
229 | { | 230 | { |
230 | pressedx = letterx1 + letterw * 4; | 231 | pressedx = letterx1 + letterw * 4; |
231 | pressed2x = letterx1; | 232 | pressed2x = letterx1; |
232 | } | 233 | } |
233 | pressedy = pressed2y = row * letterh; | 234 | pressedy = pressed2y = row * letterh; |
234 | pressedw = pressed2w = letterw * 2 + 1; | 235 | pressedw = pressed2w = letterw * 2 + 1; |
235 | pressedh = pressed2h = letterh + 1; | 236 | pressedh = pressed2h = letterh + 1; |
236 | isnoncont = true; | 237 | isnoncont = true; |
237 | } | 238 | } |
238 | else | 239 | else |
239 | { | 240 | { |
240 | pressedx = letterx1 + column * letterw; | 241 | pressedx = letterx1 + column * letterw; |
241 | pressedy = row * letterh; | 242 | pressedy = row * letterh; |
242 | pressedw = letterw + 1; | 243 | pressedw = letterw + 1; |
243 | pressedh = letterh + 1; | 244 | pressedh = letterh + 1; |
244 | } | 245 | } |
245 | pressedKeyUnicode = temp.unicode(); | 246 | pressedKeyUnicode = temp.unicode(); |
246 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); | 247 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); |
247 | if ( temp == ' ' ) | 248 | if ( temp == ' ' ) |
248 | { | 249 | { |
249 | slideKeyUnicodeH = slideKeyUnicodeV = 8; | 250 | slideKeyUnicodeH = slideKeyUnicodeV = 8; |
250 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; | 251 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; |
251 | } | 252 | } |
252 | else if ( temp == temp.lower() ) | 253 | else if ( temp == temp.lower() ) |
253 | { | 254 | { |
254 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); | 255 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); |
255 | slidePixH = slidePixV = &pressedShift; | 256 | slidePixH = slidePixV = &pressedShift; |
256 | } | 257 | } |
257 | else | 258 | else |
258 | { | 259 | { |
259 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); | 260 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); |
260 | slidePixH = slidePixV = &pressedPlain; | 261 | slidePixH = slidePixV = &pressedPlain; |
261 | } | 262 | } |
262 | enableMouseTracking = true; | 263 | enableMouseTracking = true; |
263 | } | 264 | } |
264 | else if ( x >= num1x1 && x <= num1x2 ) // num1 | 265 | else if ( x >= num1x1 && x <= num1x2 ) // num1 |
265 | { | 266 | { |
266 | pressedx = num1x1; | 267 | pressedx = num1x1; |
267 | pressedy = row * letterh; | 268 | pressedy = row * letterh; |
268 | pressedw = num1w + 1; | 269 | pressedw = num1w + 1; |
269 | pressedh = letterh + 1; | 270 | pressedh = letterh + 1; |
270 | QChar temp = QChar( num1Map[row] ); | 271 | QChar temp = QChar( num1Map[row] ); |
271 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 272 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
272 | } | 273 | } |
273 | else if ( x >= specialx1 && x <= specialx2 ) // special | 274 | else if ( x >= specialx1 && x <= specialx2 ) // special |
274 | { | 275 | { |
275 | int column = (x - specialx1 - 1) / specialw; | 276 | int column = (x - specialx1 - 1) / specialw; |
276 | pressedx = specialx1 + column * specialw; | 277 | pressedx = specialx1 + column * specialw; |
277 | pressedy = row * letterh; | 278 | pressedy = row * letterh; |
278 | pressedw = specialw + 1; | 279 | pressedw = specialw + 1; |
279 | pressedh = letterh + 1; | 280 | pressedh = letterh + 1; |
280 | QChar temp; | 281 | QChar temp; |
281 | if ( shift ) | 282 | if ( shift ) |
282 | temp = QChar( specialMapShift[row][column] ); | 283 | temp = QChar( specialMapShift[row][column] ); |
283 | else if ( paren ) | 284 | else if ( paren ) |
284 | temp = QChar( specialMapParen[row][column] ); | 285 | temp = QChar( specialMapParen[row][column] ); |
285 | else | 286 | else |
286 | temp = QChar( specialMap[row][column] ); | 287 | temp = QChar( specialMap[row][column] ); |
287 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 288 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
288 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = | 289 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = |
289 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; | 290 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; |
290 | slidePixH = slidePixV = &pressedDigit; | 291 | slidePixH = slidePixV = &pressedDigit; |
291 | if ( shift ) | 292 | if ( shift ) |
292 | { | 293 | { |
293 | slideKeyUnicodeV = slideKeyQcodeV = | 294 | slideKeyUnicodeV = slideKeyQcodeV = |
294 | QChar( specialMap[row][column] ).unicode(); | 295 | QChar( specialMap[row][column] ).unicode(); |
295 | slidePixV = &pressedPlain; | 296 | slidePixV = &pressedPlain; |
296 | } | 297 | } |
297 | else if ( !(shift || paren) ) | 298 | else if ( !(shift || paren) ) |
298 | { | 299 | { |
299 | slideKeyUnicodeV = slideKeyQcodeV = | 300 | slideKeyUnicodeV = slideKeyQcodeV = |
300 | QChar( specialMapShift[row][column] ).unicode(); | 301 | QChar( specialMapShift[row][column] ).unicode(); |
301 | slidePixV = &pressedShift; | 302 | slidePixV = &pressedShift; |
302 | } | 303 | } |
303 | enableMouseTracking = true; | 304 | enableMouseTracking = true; |
304 | } | 305 | } |
305 | else if ( x >= num2x1 && x <= num2x2 ) // num2 | 306 | else if ( x >= num2x1 && x <= num2x2 ) // num2 |
306 | { | 307 | { |
307 | pressedx = num2x1; | 308 | pressedx = num2x1; |
308 | pressedy = row * letterh; | 309 | pressedy = row * letterh; |
309 | pressedw = num2w + 1; | 310 | pressedw = num2w + 1; |
310 | pressedh = letterh + 1; | 311 | pressedh = letterh + 1; |
311 | QChar temp = QChar( num2Map[row] ); | 312 | QChar temp = QChar( num2Map[row] ); |
312 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 313 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
313 | } | 314 | } |
314 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 | 315 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 |
315 | { | 316 | { |
316 | pressedx = mod2x1; | 317 | pressedx = mod2x1; |
317 | pressedy = row * letterh; | 318 | pressedy = row * letterh; |
318 | pressedw = mod2w + 1; | 319 | pressedw = mod2w + 1; |
319 | pressedh = letterh + 1; | 320 | pressedh = letterh + 1; |
320 | if ( row == 2 ) // return | 321 | if ( row == 2 ) // return |
321 | { | 322 | { |
322 | pressed2x = mod1x1; | 323 | pressed2x = mod1x1; |
323 | pressed2y = 2 * letterh; | 324 | pressed2y = 2 * letterh; |
324 | pressed2w = mod2w + 1; | 325 | pressed2w = mod2w + 1; |
325 | pressed2h = letterh + 1; | 326 | pressed2h = letterh + 1; |
326 | isnoncont = true; | 327 | isnoncont = true; |
327 | } | 328 | } |
328 | pressedKeyUnicode = mod2Map[row].unicode; | 329 | pressedKeyUnicode = mod2Map[row].unicode; |
329 | pressedKeyQcode = mod2Map[row].qcode; | 330 | pressedKeyQcode = mod2Map[row].qcode; |
330 | 331 | ||
331 | if ( row == 3 ) // shift | 332 | if ( row == 3 ) // shift |
332 | { | 333 | { |
333 | paren = 0; | 334 | paren = 0; |
334 | switch ( shift ) | 335 | switch ( shift ) |
335 | { | 336 | { |
336 | case 0: | 337 | case 0: |
337 | { | 338 | { |
338 | shift = 1; | 339 | shift = 1; |
339 | releasedPix = &releasedShift; | 340 | releasedPix = &releasedShift; |
340 | pressedPix = &pressedShift; | 341 | pressedPix = &pressedShift; |
341 | bitBlt( &offscreen, 0, 0, releasedPix ); | 342 | bitBlt( &offscreen, 0, 0, releasedPix ); |
342 | break; | 343 | break; |
343 | } | 344 | } |
344 | case 1: | 345 | case 1: |
345 | { | 346 | { |
346 | shift = 2; | 347 | shift = 2; |
347 | break; | 348 | break; |
348 | } | 349 | } |
349 | case 2: | 350 | case 2: |
350 | { | 351 | { |
351 | shift = 0; | 352 | shift = 0; |
352 | releasedPix = &releasedPlain; | 353 | releasedPix = &releasedPlain; |
353 | pressedPix = &pressedPlain; | 354 | pressedPix = &pressedPlain; |
354 | bitBlt( &offscreen, 0, 0, releasedPix ); | 355 | bitBlt( &offscreen, 0, 0, releasedPix ); |
355 | break; | 356 | break; |
356 | } | 357 | } |
357 | } | 358 | } |
358 | } | 359 | } |
359 | else if ( row == 4 ) // parenthesis | 360 | else if ( row == 4 ) // parenthesis |
360 | { | 361 | { |
361 | shift = 0; | 362 | shift = 0; |
362 | switch ( paren ) | 363 | switch ( paren ) |
363 | { | 364 | { |
364 | case 0: | 365 | case 0: |
365 | { | 366 | { |
366 | paren = 1; | 367 | paren = 1; |
367 | releasedPix = &releasedParen; | 368 | releasedPix = &releasedParen; |
368 | pressedPix = &pressedParen; | 369 | pressedPix = &pressedParen; |
369 | bitBlt( &offscreen, 0, 0, releasedPix ); | 370 | bitBlt( &offscreen, 0, 0, releasedPix ); |
370 | break; | 371 | break; |
371 | } | 372 | } |
372 | case 1: | 373 | case 1: |
373 | { | 374 | { |
374 | paren = 2; | 375 | paren = 2; |
375 | break; | 376 | break; |
376 | } | 377 | } |
377 | case 2: | 378 | case 2: |
378 | { | 379 | { |
379 | paren = 0; | 380 | paren = 0; |
380 | releasedPix = &releasedPlain; | 381 | releasedPix = &releasedPlain; |
381 | pressedPix = &pressedPlain; | 382 | pressedPix = &pressedPlain; |
382 | bitBlt( &offscreen, 0, 0, releasedPix ); | 383 | bitBlt( &offscreen, 0, 0, releasedPix ); |
383 | break; | 384 | break; |
384 | } | 385 | } |
385 | } | 386 | } |
386 | } | 387 | } |
387 | } | 388 | } |
388 | else if ( x >= cursorx1 ) // cursor | 389 | else if ( x >= cursorx1 ) // cursor |
389 | { | 390 | { |
390 | int column = (x - cursorx1 - 1) / cursorw; | 391 | int column = (x - cursorx1 - 1) / cursorw; |
391 | if ( row == 2 || row == 4 ) | 392 | if ( row == 2 || row == 4 ) |
392 | pressedx = cursorx1 + cursorw / 2; | 393 | pressedx = cursorx1 + cursorw / 2; |
393 | else | 394 | else |
394 | pressedx = cursorx1 + column * cursorw; | 395 | pressedx = cursorx1 + column * cursorw; |
395 | pressedy = row * letterh; | 396 | pressedy = row * letterh; |
396 | pressedw = cursorw + 1; | 397 | pressedw = cursorw + 1; |
397 | pressedh = letterh + 1; | 398 | pressedh = letterh + 1; |
398 | pressedKeyQcode = cursorMap[row][column]; | 399 | pressedKeyQcode = cursorMap[row][column]; |
399 | } | 400 | } |
400 | 401 | ||
401 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | | 402 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | |
402 | ( ctrl ? Qt::ControlButton : 0 ) | | 403 | ( ctrl ? Qt::ControlButton : 0 ) | |
403 | ( alt ? Qt::AltButton : 0 ); | 404 | ( alt ? Qt::AltButton : 0 ); |
404 | 405 | ||
405 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); | 406 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); |
406 | delayTimer->start( autorepeatDelaytime, true ); | 407 | delayTimer->start( autorepeatDelaytime, true ); |
407 | 408 | ||
408 | if ( pressedx == -1 ) | 409 | if ( pressedx == -1 ) |
409 | return; | 410 | return; |
410 | 411 | ||
411 | bitBlt( &offscreen, pressedx, pressedy, | 412 | bitBlt( &offscreen, pressedx, pressedy, |
412 | pressedPix, pressedx, pressedy, pressedw, pressedh ); | 413 | pressedPix, pressedx, pressedy, pressedw, pressedh ); |
413 | if ( isnoncont ) | 414 | if ( isnoncont ) |
414 | bitBlt( &offscreen, pressed2x, pressed2y, | 415 | bitBlt( &offscreen, pressed2x, pressed2y, |
415 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); | 416 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); |
416 | 417 | ||
417 | repaint( false ); | 418 | repaint( false ); |
418 | } | 419 | } |
419 | 420 | ||
420 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 421 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
421 | { | 422 | { |
422 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; | 423 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; |
423 | 424 | ||
424 | delayTimer->stop(); | 425 | delayTimer->stop(); |
425 | rateTimer->stop(); | 426 | rateTimer->stop(); |
426 | enableMouseTracking = false; | 427 | enableMouseTracking = false; |
427 | 428 | ||
428 | if ( pressedx == -1 ) | 429 | if ( pressedx == -1 ) |
429 | return; | 430 | return; |
430 | 431 | ||
431 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) | 432 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) |
432 | return; | 433 | return; |
433 | if ( paren == 2 && pressedKeyQcode == myParenID ) | 434 | if ( paren == 2 && pressedKeyQcode == myParenID ) |
434 | return; | 435 | return; |
435 | 436 | ||
436 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) | 437 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) |
437 | { | 438 | { |
438 | shift = 0; | 439 | shift = 0; |
439 | releasedPix = &releasedPlain; | 440 | releasedPix = &releasedPlain; |
440 | pressedPix = &pressedPlain; | 441 | pressedPix = &pressedPlain; |
441 | bitBlt( &offscreen, 0, 0, releasedPix ); | 442 | bitBlt( &offscreen, 0, 0, releasedPix ); |
442 | } | 443 | } |
443 | 444 | ||
444 | if ( paren == 1 && pressedKeyQcode != myParenID ) | 445 | if ( paren == 1 && pressedKeyQcode != myParenID ) |
445 | { | 446 | { |
446 | paren = 0; | 447 | paren = 0; |
447 | releasedPix = &releasedPlain; | 448 | releasedPix = &releasedPlain; |
448 | pressedPix = &pressedPlain; | 449 | pressedPix = &pressedPlain; |
449 | bitBlt( &offscreen, 0, 0, releasedPix ); | 450 | bitBlt( &offscreen, 0, 0, releasedPix ); |
450 | } | 451 | } |
451 | 452 | ||
452 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) | 453 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) |
453 | alt = 0; | 454 | alt = 0; |
454 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) | 455 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) |
455 | ctrl = 0; | 456 | ctrl = 0; |
456 | 457 | ||
457 | bitBlt( &offscreen, pressedx, pressedy, | 458 | bitBlt( &offscreen, pressedx, pressedy, |
458 | releasedPix, pressedx, pressedy, pressedw, pressedh ); | 459 | releasedPix, pressedx, pressedy, pressedw, pressedh ); |
459 | 460 | ||
460 | if ( isnoncont ) | 461 | if ( isnoncont ) |
461 | { | 462 | { |
462 | isnoncont = false; | 463 | isnoncont = false; |
463 | bitBlt( &offscreen, pressed2x, pressed2y, | 464 | bitBlt( &offscreen, pressed2x, pressed2y, |
464 | releasedPix, pressed2x, pressed2y, pressed2w, pressed2h ); | 465 | releasedPix, pressed2x, pressed2y, pressed2w, pressed2h ); |
465 | } | 466 | } |
466 | 467 | ||
467 | repaint( false ); | 468 | repaint( false ); |
468 | } | 469 | } |
469 | 470 | ||
470 | void Keyboard::mouseMoveEvent(QMouseEvent *e) | 471 | void Keyboard::mouseMoveEvent(QMouseEvent *e) |
471 | { | 472 | { |
472 | if ( !enableMouseTracking ) | 473 | if ( !enableMouseTracking ) |
473 | return; | 474 | return; |
474 | 475 | ||
475 | if ( e->x() < pressedx || e->x() >= pressedx + pressedw ) | 476 | if ( e->x() < pressedx || e->x() >= pressedx + pressedw ) |
476 | { | 477 | { |
477 | pressedKeyUnicode = slideKeyUnicodeH; | 478 | pressedKeyUnicode = slideKeyUnicodeH; |
478 | pressedKeyQcode = slideKeyQcodeH; | 479 | pressedKeyQcode = slideKeyQcodeH; |
479 | slidePix = slidePixH; | 480 | slidePix = slidePixH; |
480 | } | 481 | } |
481 | else if ( e->y() < pressedy || e->y() >= pressedy + pressedh ) | 482 | else if ( e->y() < pressedy || e->y() >= pressedy + pressedh ) |
482 | { | 483 | { |
483 | pressedKeyUnicode = slideKeyUnicodeV; | 484 | pressedKeyUnicode = slideKeyUnicodeV; |
484 | pressedKeyQcode = slideKeyQcodeV; | 485 | pressedKeyQcode = slideKeyQcodeV; |
485 | slidePix = slidePixV; | 486 | slidePix = slidePixV; |
486 | } | 487 | } |
487 | else | 488 | else |
488 | return; | 489 | return; |
489 | 490 | ||
490 | enableMouseTracking = false; | 491 | enableMouseTracking = false; |
491 | 492 | ||
492 | delayTimer->stop(); | 493 | delayTimer->stop(); |
493 | rateTimer->stop(); | 494 | rateTimer->stop(); |
494 | 495 | ||
495 | bitBlt( &offscreen, pressedx, pressedy, | 496 | bitBlt( &offscreen, pressedx, pressedy, |
496 | slidePix, pressedx, pressedy, pressedw, pressedh ); | 497 | slidePix, pressedx, pressedy, pressedw, pressedh ); |
497 | 498 | ||
498 | emit key( 8, Qt::Key_Backspace, pressedMod, true, false ); | 499 | emit key( 8, Qt::Key_Backspace, pressedMod, true, false ); |
499 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); | 500 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); |
500 | delayTimer->start( autorepeatDelaytime, true ); | 501 | delayTimer->start( autorepeatDelaytime, true ); |
501 | 502 | ||
502 | repaint( false ); | 503 | repaint( false ); |
503 | } | 504 | } |
504 | 505 | ||
505 | void Keyboard::delayTimerDone() | 506 | void Keyboard::delayTimerDone() |
506 | { | 507 | { |
507 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); | 508 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); |
508 | rateTimer->start( 1000/autorepeatRate, false ); | 509 | rateTimer->start( 1000/autorepeatRate, false ); |
509 | } | 510 | } |
510 | 511 | ||
511 | void Keyboard::rateTimerDone() | 512 | void Keyboard::rateTimerDone() |
512 | { | 513 | { |
513 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); | 514 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); |
514 | } | 515 | } |
515 | 516 | ||
516 | QSize Keyboard::sizeHint() const | 517 | QSize Keyboard::sizeHint() const |
517 | { | 518 | { |
518 | return offscreen.size(); | 519 | return offscreen.size(); |
519 | } | 520 | } |
520 | 521 | ||
521 | void Keyboard::resetState() | 522 | void Keyboard::resetState() |
522 | { | 523 | { |
523 | //cout << "resetState()" << endl; | 524 | //cout << "resetState()" << endl; |
524 | } | 525 | } |
diff --git a/inputmethods/jumpx/keyboard.h b/inputmethods/jumpx/keyboard.h index 1be095d..689d95a 100644 --- a/inputmethods/jumpx/keyboard.h +++ b/inputmethods/jumpx/keyboard.h | |||
@@ -1,71 +1,76 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /**************************************************************************************94x78** |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | *********************************************************************************************/ | 11 | *********************************************************************************************/ |
12 | #include <qframe.h> | 12 | #include <qframe.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | #include <qtimer.h> | 14 | #include <qtimer.h> |
15 | 15 | ||
16 | namespace JumpX | ||
17 | { | ||
18 | |||
16 | class Keyboard : public QFrame | 19 | class Keyboard : public QFrame |
17 | { | 20 | { |
18 | Q_OBJECT | 21 | Q_OBJECT |
19 | public: | 22 | public: |
20 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 23 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
21 | 24 | ||
22 | void resetState(); | 25 | void resetState(); |
23 | 26 | ||
24 | void mousePressEvent(QMouseEvent*); | 27 | void mousePressEvent(QMouseEvent*); |
25 | void mouseReleaseEvent(QMouseEvent*); | 28 | void mouseReleaseEvent(QMouseEvent*); |
26 | void mouseMoveEvent(QMouseEvent*); | 29 | void mouseMoveEvent(QMouseEvent*); |
27 | void resizeEvent(QResizeEvent*); | 30 | void resizeEvent(QResizeEvent*); |
28 | void paintEvent(QPaintEvent* e); | 31 | void paintEvent(QPaintEvent* e); |
29 | //void timerEvent(QTimerEvent* e); | 32 | //void timerEvent(QTimerEvent* e); |
30 | 33 | ||
31 | QSize sizeHint() const; | 34 | QSize sizeHint() const; |
32 | 35 | ||
33 | signals: | 36 | signals: |
34 | void key( ushort unicode, ushort qcode, ushort modifiers, bool, bool ); | 37 | void key( ushort unicode, ushort qcode, ushort modifiers, bool, bool ); |
35 | 38 | ||
36 | private slots: | 39 | private slots: |
37 | void delayTimerDone(); | 40 | void delayTimerDone(); |
38 | void rateTimerDone(); | 41 | void rateTimerDone(); |
39 | 42 | ||
40 | private: | 43 | private: |
41 | int shift; // 0, 1, 2 | 44 | int shift; // 0, 1, 2 |
42 | int paren; // 0, 1, 2 | 45 | int paren; // 0, 1, 2 |
43 | int ctrl; // 0, 1 | 46 | int ctrl; // 0, 1 |
44 | int alt; // 0, 1 | 47 | int alt; // 0, 1 |
45 | 48 | ||
46 | int pressedKeyUnicode, pressedKeyQcode, pressedMod; | 49 | int pressedKeyUnicode, pressedKeyQcode, pressedMod; |
47 | int pressedx, pressedy, pressedw, pressedh; | 50 | int pressedx, pressedy, pressedw, pressedh; |
48 | bool isnoncont; | 51 | bool isnoncont; |
49 | int pressed2x, pressed2y, pressed2w, pressed2h; | 52 | int pressed2x, pressed2y, pressed2w, pressed2h; |
50 | 53 | ||
51 | int slideKeyUnicodeH, slideKeyQcodeH, slideKeyUnicodeV, slideKeyQcodeV; | 54 | int slideKeyUnicodeH, slideKeyQcodeH, slideKeyUnicodeV, slideKeyQcodeV; |
52 | bool enableMouseTracking; | 55 | bool enableMouseTracking; |
53 | QPixmap *slidePix, *slidePixH, *slidePixV; | 56 | QPixmap *slidePix, *slidePixH, *slidePixV; |
54 | 57 | ||
55 | QPixmap releasedPlain; | 58 | QPixmap releasedPlain; |
56 | QPixmap releasedShift; | 59 | QPixmap releasedShift; |
57 | QPixmap releasedParen; | 60 | QPixmap releasedParen; |
58 | 61 | ||
59 | QPixmap pressedPlain; | 62 | QPixmap pressedPlain; |
60 | QPixmap pressedShift; | 63 | QPixmap pressedShift; |
61 | QPixmap pressedParen; | 64 | QPixmap pressedParen; |
62 | QPixmap pressedDigit; | 65 | QPixmap pressedDigit; |
63 | 66 | ||
64 | QPixmap offscreen; | 67 | QPixmap offscreen; |
65 | 68 | ||
66 | QPixmap *releasedPix; | 69 | QPixmap *releasedPix; |
67 | QPixmap *pressedPix; | 70 | QPixmap *pressedPix; |
68 | 71 | ||
69 | QTimer *delayTimer; | 72 | QTimer *delayTimer; |
70 | QTimer *rateTimer; | 73 | QTimer *rateTimer; |
71 | }; | 74 | }; |
75 | |||
76 | } // namespace JumpX | ||
diff --git a/inputmethods/jumpx/keyboardimpl.cpp b/inputmethods/jumpx/keyboardimpl.cpp index 92abb09..34c227f 100644 --- a/inputmethods/jumpx/keyboardimpl.cpp +++ b/inputmethods/jumpx/keyboardimpl.cpp | |||
@@ -1,97 +1,97 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /**************************************************************************************94x78** |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | *********************************************************************************************/ | 11 | *********************************************************************************************/ |
12 | #include <qapplication.h> | 12 | #include <qapplication.h> |
13 | #include <qpixmap.h> | 13 | #include <qpixmap.h> |
14 | #include "keyboard.h" | 14 | #include "keyboard.h" |
15 | #include "keyboardimpl.h" | 15 | #include "keyboardimpl.h" |
16 | 16 | ||
17 | /* XPM */ | 17 | /* XPM */ |
18 | static const char * icon_xpm[] = { | 18 | static const char * const icon_xpm[] = { |
19 | "26 13 2 1", | 19 | "26 13 2 1", |
20 | " c None", | 20 | " c None", |
21 | ".c #000000", | 21 | ".c #000000", |
22 | " ... ... ... ... ... ... ", | 22 | " ... ... ... ... ... ... ", |
23 | ". . . . . . . ", | 23 | ". . . . . . . ", |
24 | ". . . . . . . ", | 24 | ". . . . . . . ", |
25 | ". . . . . . . ", | 25 | ". . . . . . . ", |
26 | " ....... ... ... ....... ", | 26 | " ....... ... ... ....... ", |
27 | ". . . . . ", | 27 | ". . . . . ", |
28 | ". . . . . ", | 28 | ". . . . . ", |
29 | ". . . . . ", | 29 | ". . . . . ", |
30 | " ....... ... ... ....... ", | 30 | " ....... ... ... ....... ", |
31 | ". . . . . . . ", | 31 | ". . . . . . . ", |
32 | ". . . . . . . ", | 32 | ". . . . . . . ", |
33 | ". . . . . . . ", | 33 | ". . . . . . . ", |
34 | " ... ... ... ... ... ... "}; | 34 | " ... ... ... ... ... ... "}; |
35 | 35 | ||
36 | 36 | ||
37 | KeyboardImpl::KeyboardImpl() | 37 | KeyboardImpl::KeyboardImpl() |
38 | : input(0), icn(0), ref(0) | 38 | : input(0), icn(0), ref(0) |
39 | { | 39 | { |
40 | } | 40 | } |
41 | 41 | ||
42 | KeyboardImpl::~KeyboardImpl() | 42 | KeyboardImpl::~KeyboardImpl() |
43 | { | 43 | { |
44 | delete input; | 44 | delete input; |
45 | delete icn; | 45 | delete icn; |
46 | } | 46 | } |
47 | 47 | ||
48 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 48 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
49 | { | 49 | { |
50 | if ( !input ) | 50 | if ( !input ) |
51 | input = new Keyboard( parent, "Keyboard", f ); | 51 | input = new JumpX::Keyboard( parent, "Keyboard", f ); |
52 | return input; | 52 | return input; |
53 | } | 53 | } |
54 | 54 | ||
55 | void KeyboardImpl::resetState() | 55 | void KeyboardImpl::resetState() |
56 | { | 56 | { |
57 | if ( input ) | 57 | if ( input ) |
58 | input->resetState(); | 58 | input->resetState(); |
59 | } | 59 | } |
60 | 60 | ||
61 | QPixmap *KeyboardImpl::icon() | 61 | QPixmap *KeyboardImpl::icon() |
62 | { | 62 | { |
63 | if ( !icn ) | 63 | if ( !icn ) |
64 | icn = new QPixmap( (const char **)icon_xpm ); | 64 | icn = new QPixmap( (const char **)icon_xpm ); |
65 | return icn; | 65 | return icn; |
66 | } | 66 | } |
67 | 67 | ||
68 | QString KeyboardImpl::name() | 68 | QString KeyboardImpl::name() |
69 | { | 69 | { |
70 | return qApp->translate( "InputMethods", "JumpX" ); | 70 | return qApp->translate( "InputMethods", "JumpX" ); |
71 | } | 71 | } |
72 | 72 | ||
73 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 73 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
74 | { | 74 | { |
75 | if ( input ) | 75 | if ( input ) |
76 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 76 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
77 | } | 77 | } |
78 | 78 | ||
79 | #ifndef QT_NO_COMPONENT | 79 | #ifndef QT_NO_COMPONENT |
80 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 80 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
81 | { | 81 | { |
82 | *iface = 0; | 82 | *iface = 0; |
83 | if ( uuid == IID_QUnknown ) | 83 | if ( uuid == IID_QUnknown ) |
84 | *iface = this; | 84 | *iface = this; |
85 | else if ( uuid == IID_InputMethod ) | 85 | else if ( uuid == IID_InputMethod ) |
86 | *iface = this; | 86 | *iface = this; |
87 | 87 | ||
88 | if ( *iface ) | 88 | if ( *iface ) |
89 | (*iface)->addRef(); | 89 | (*iface)->addRef(); |
90 | return QS_OK; | 90 | return QS_OK; |
91 | } | 91 | } |
92 | 92 | ||
93 | Q_EXPORT_INTERFACE() | 93 | Q_EXPORT_INTERFACE() |
94 | { | 94 | { |
95 | Q_CREATE_INSTANCE( KeyboardImpl ) | 95 | Q_CREATE_INSTANCE( KeyboardImpl ) |
96 | } | 96 | } |
97 | #endif | 97 | #endif |
diff --git a/inputmethods/jumpx/keyboardimpl.h b/inputmethods/jumpx/keyboardimpl.h index a82ec4a..087781f 100644 --- a/inputmethods/jumpx/keyboardimpl.h +++ b/inputmethods/jumpx/keyboardimpl.h | |||
@@ -1,43 +1,51 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /**************************************************************************************94x78** |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | *********************************************************************************************/ | 11 | *********************************************************************************************/ |
12 | #ifndef KEYBOARDIMPL_H | 12 | #ifndef KEYBOARDIMPL_H |
13 | #define KEYBOARDIMPL_H | 13 | #define KEYBOARDIMPL_H |
14 | 14 | ||
15 | #include <qpe/inputmethodinterface.h> | 15 | #include <qpe/inputmethodinterface.h> |
16 | 16 | ||
17 | class Keyboard; | 17 | namespace JumpX |
18 | { | ||
19 | class Keyboard; | ||
20 | }; | ||
18 | class QPixmap; | 21 | class QPixmap; |
19 | 22 | ||
23 | namespace | ||
24 | { | ||
25 | |||
20 | class KeyboardImpl : public InputMethodInterface | 26 | class KeyboardImpl : public InputMethodInterface |
21 | { | 27 | { |
22 | public: | 28 | public: |
23 | KeyboardImpl(); | 29 | KeyboardImpl(); |
24 | virtual ~KeyboardImpl(); | 30 | virtual ~KeyboardImpl(); |
25 | 31 | ||
26 | #ifndef QT_NO_COMPONENT | 32 | #ifndef QT_NO_COMPONENT |
27 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 33 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
28 | Q_REFCOUNT | 34 | Q_REFCOUNT |
29 | #endif | 35 | #endif |
30 | 36 | ||
31 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | 37 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); |
32 | virtual void resetState(); | 38 | virtual void resetState(); |
33 | virtual QPixmap *icon(); | 39 | virtual QPixmap *icon(); |
34 | virtual QString name(); | 40 | virtual QString name(); |
35 | virtual void onKeyPress( QObject *receiver, const char *slot ); | 41 | virtual void onKeyPress( QObject *receiver, const char *slot ); |
36 | 42 | ||
37 | private: | 43 | private: |
38 | Keyboard *input; | 44 | JumpX::Keyboard *input; |
39 | QPixmap *icn; | 45 | QPixmap *icn; |
40 | ulong ref; | 46 | ulong ref; |
41 | }; | 47 | }; |
42 | 48 | ||
49 | } // anonymous namespace | ||
50 | |||
43 | #endif | 51 | #endif |