-rw-r--r-- | inputmethods/kjumpx/keyboard.cpp | 1 | ||||
-rw-r--r-- | inputmethods/kjumpx/keyboard.h | 5 | ||||
-rw-r--r-- | inputmethods/kjumpx/keyboardimpl.cpp | 4 | ||||
-rw-r--r-- | inputmethods/kjumpx/keyboardimpl.h | 12 |
4 files changed, 18 insertions, 4 deletions
diff --git a/inputmethods/kjumpx/keyboard.cpp b/inputmethods/kjumpx/keyboard.cpp index 3af6a78..dc44805 100644 --- a/inputmethods/kjumpx/keyboard.cpp +++ b/inputmethods/kjumpx/keyboard.cpp | |||
@@ -1,855 +1,856 @@ | |||
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 ushort kletterMap[][6] = { | 75 | static const ushort kletterMap[][6] = { |
76 | { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 }, | 76 | { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 }, |
77 | { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 }, | 77 | { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 }, |
78 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, | 78 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, |
79 | { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 }, | 79 | { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 }, |
80 | { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 }, | 80 | { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 }, |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const uchar *const letterMapShift[] = { | 83 | static const uchar *const letterMapShift[] = { |
84 | (const uchar *const)"ZVCHWK", | 84 | (const uchar *const)"ZVCHWK", |
85 | (const uchar *const)"FITALY", | 85 | (const uchar *const)"FITALY", |
86 | (const uchar *const)" NE ", | 86 | (const uchar *const)" NE ", |
87 | (const uchar *const)"GDORSB", | 87 | (const uchar *const)"GDORSB", |
88 | (const uchar *const)"QJUMPX", | 88 | (const uchar *const)"QJUMPX", |
89 | }; | 89 | }; |
90 | 90 | ||
91 | static const ushort kletterMapShift[][6] = { | 91 | static const ushort kletterMapShift[][6] = { |
92 | { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 }, | 92 | { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 }, |
93 | { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 }, | 93 | { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 }, |
94 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, | 94 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, |
95 | { 0x1110, 0x1104, 0x1102, 0x1169, 0x1173, 0x1168 }, | 95 | { 0x1110, 0x1104, 0x1102, 0x1169, 0x1173, 0x1168 }, |
96 | { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 }, | 96 | { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 }, |
97 | }; | 97 | }; |
98 | 98 | ||
99 | static const uchar *const num1Map = (const uchar *const)"12345"; | 99 | static const uchar *const num1Map = (const uchar *const)"12345"; |
100 | 100 | ||
101 | static const uchar *const specialMap[] = { | 101 | static const uchar *const specialMap[] = { |
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 specialMapShift[] = { | 109 | static const uchar *const specialMapShift[] = { |
110 | (const uchar *const)"_=", | 110 | (const uchar *const)"_=", |
111 | (const uchar *const)"#?", | 111 | (const uchar *const)"#?", |
112 | (const uchar *const)";\"", | 112 | (const uchar *const)";\"", |
113 | (const uchar *const)":|", | 113 | (const uchar *const)":|", |
114 | (const uchar *const)"\\&", | 114 | (const uchar *const)"\\&", |
115 | }; | 115 | }; |
116 | 116 | ||
117 | static const uchar *const specialMapParen[] = { | 117 | static const uchar *const specialMapParen[] = { |
118 | (const uchar *const)"()", | 118 | (const uchar *const)"()", |
119 | (const uchar *const)"[]", | 119 | (const uchar *const)"[]", |
120 | (const uchar *const)"{}", | 120 | (const uchar *const)"{}", |
121 | (const uchar *const)"<>", | 121 | (const uchar *const)"<>", |
122 | (const uchar *const)"@~", | 122 | (const uchar *const)"@~", |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static const uchar *const num2Map = (const uchar *const)"67890"; | 125 | static const uchar *const num2Map = (const uchar *const)"67890"; |
126 | 126 | ||
127 | static const mapElement mod2Map[] = { | 127 | static const mapElement mod2Map[] = { |
128 | { Qt::Key_Backspace, 8 }, | 128 | { Qt::Key_Backspace, 8 }, |
129 | { Qt::Key_Delete, 0 }, | 129 | { Qt::Key_Delete, 0 }, |
130 | { Qt::Key_Return, 13 }, | 130 | { Qt::Key_Return, 13 }, |
131 | { Qt::Key_Shift, 0 }, | 131 | { Qt::Key_Shift, 0 }, |
132 | { myParenID, 0 }, | 132 | { myParenID, 0 }, |
133 | }; | 133 | }; |
134 | 134 | ||
135 | static const int cursorMap[][2] = { | 135 | static const int cursorMap[][2] = { |
136 | { Qt::Key_Home, Qt::Key_PageUp }, | 136 | { Qt::Key_Home, Qt::Key_PageUp }, |
137 | { Qt::Key_End, Qt::Key_PageDown }, | 137 | { Qt::Key_End, Qt::Key_PageDown }, |
138 | { Qt::Key_Up, Qt::Key_Up }, | 138 | { Qt::Key_Up, Qt::Key_Up }, |
139 | { Qt::Key_Left, Qt::Key_Right }, | 139 | { Qt::Key_Left, Qt::Key_Right }, |
140 | { Qt::Key_Down, Qt::Key_Down }, | 140 | { Qt::Key_Down, Qt::Key_Down }, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | using namespace KJumpX; | ||
143 | 144 | ||
144 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 145 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
145 | QFrame(parent, name, f), | 146 | QFrame(parent, name, f), |
146 | shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), | 147 | shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), |
147 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), | 148 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), |
148 | isnoncont(false), | 149 | isnoncont(false), |
149 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), | 150 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), |
150 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), | 151 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), |
151 | releasedPix(NULL), pressedPix(NULL) | 152 | releasedPix(NULL), pressedPix(NULL) |
152 | { | 153 | { |
153 | //setPalette(QPalette(QColor(240,240,230))); // Beige! | 154 | //setPalette(QPalette(QColor(240,240,230))); // Beige! |
154 | 155 | ||
155 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); | 156 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); |
156 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); | 157 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); |
157 | pressedDigit = Resource::loadPixmap("kjumpx/pressed"); | 158 | pressedDigit = Resource::loadPixmap("kjumpx/pressed"); |
158 | 159 | ||
159 | QPixmap tmp; | 160 | QPixmap tmp; |
160 | 161 | ||
161 | tmp = Resource::loadPixmap("kjumpx/releasedShift"); | 162 | tmp = Resource::loadPixmap("kjumpx/releasedShift"); |
162 | bitBlt(&releasedShift, letterx1, 0, &tmp); | 163 | bitBlt(&releasedShift, letterx1, 0, &tmp); |
163 | 164 | ||
164 | tmp = Resource::loadPixmap("kjumpx/releasedParen"); | 165 | tmp = Resource::loadPixmap("kjumpx/releasedParen"); |
165 | bitBlt(&releasedParen, specialx1, 0, &tmp); | 166 | bitBlt(&releasedParen, specialx1, 0, &tmp); |
166 | 167 | ||
167 | tmp = Resource::loadPixmap("kjumpx/pressedShift"); | 168 | tmp = Resource::loadPixmap("kjumpx/pressedShift"); |
168 | bitBlt(&pressedShift, letterx1, 0, &tmp); | 169 | bitBlt(&pressedShift, letterx1, 0, &tmp); |
169 | 170 | ||
170 | tmp = Resource::loadPixmap("kjumpx/pressedParen"); | 171 | tmp = Resource::loadPixmap("kjumpx/pressedParen"); |
171 | bitBlt(&pressedParen, specialx1, 0, &tmp); | 172 | bitBlt(&pressedParen, specialx1, 0, &tmp); |
172 | 173 | ||
173 | tmp = Resource::loadPixmap("kjumpx/pressedDigit"); | 174 | tmp = Resource::loadPixmap("kjumpx/pressedDigit"); |
174 | bitBlt(&pressedDigit, specialx1, 0, &tmp); | 175 | bitBlt(&pressedDigit, specialx1, 0, &tmp); |
175 | 176 | ||
176 | offscreen = QPixmap( releasedPlain ); | 177 | offscreen = QPixmap( releasedPlain ); |
177 | 178 | ||
178 | releasedPix = &releasedPlain; | 179 | releasedPix = &releasedPlain; |
179 | pressedPix = &pressedPlain; | 180 | pressedPix = &pressedPlain; |
180 | slidePix = &pressedPlain; | 181 | slidePix = &pressedPlain; |
181 | 182 | ||
182 | delayTimer = new QTimer(this); | 183 | delayTimer = new QTimer(this); |
183 | rateTimer = new QTimer(this); | 184 | rateTimer = new QTimer(this); |
184 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); | 185 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); |
185 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 186 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
186 | } | 187 | } |
187 | 188 | ||
188 | void Keyboard::resizeEvent(QResizeEvent*) | 189 | void Keyboard::resizeEvent(QResizeEvent*) |
189 | { | 190 | { |
190 | //cout << "resizeEvent()" << endl; | 191 | //cout << "resizeEvent()" << endl; |
191 | } | 192 | } |
192 | 193 | ||
193 | void Keyboard::paintEvent(QPaintEvent*) | 194 | void Keyboard::paintEvent(QPaintEvent*) |
194 | { | 195 | { |
195 | bitBlt(this, 0, 0, &offscreen); | 196 | bitBlt(this, 0, 0, &offscreen); |
196 | } | 197 | } |
197 | 198 | ||
198 | void Keyboard::mousePressEvent(QMouseEvent *e) | 199 | void Keyboard::mousePressEvent(QMouseEvent *e) |
199 | { | 200 | { |
200 | pressedx = -1; | 201 | pressedx = -1; |
201 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; | 202 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; |
202 | 203 | ||
203 | int x = e->x(); | 204 | int x = e->x(); |
204 | int y = e->y(); | 205 | int y = e->y(); |
205 | 206 | ||
206 | int row = (y - 1) / letterh; | 207 | int row = (y - 1) / letterh; |
207 | 208 | ||
208 | if ( x <= mod1x2 ) // mod1 | 209 | if ( x <= mod1x2 ) // mod1 |
209 | { | 210 | { |
210 | pressedx = mod1x1; | 211 | pressedx = mod1x1; |
211 | pressedy = row * letterh; | 212 | pressedy = row * letterh; |
212 | pressedw = mod1w + 1; | 213 | pressedw = mod1w + 1; |
213 | pressedh = letterh + 1; | 214 | pressedh = letterh + 1; |
214 | if ( row == 2 ) // return | 215 | if ( row == 2 ) // return |
215 | { | 216 | { |
216 | pressed2x = mod2x1; | 217 | pressed2x = mod2x1; |
217 | pressed2y = 2 * letterh; | 218 | pressed2y = 2 * letterh; |
218 | pressed2w = mod2w + 1; | 219 | pressed2w = mod2w + 1; |
219 | pressed2h = letterh + 1; | 220 | pressed2h = letterh + 1; |
220 | isnoncont = true; | 221 | isnoncont = true; |
221 | } | 222 | } |
222 | else if ( row == 3 ) // alt | 223 | else if ( row == 3 ) // alt |
223 | alt = 1; | 224 | alt = 1; |
224 | else if ( row == 4 ) // ctrl | 225 | else if ( row == 4 ) // ctrl |
225 | ctrl = 1; | 226 | ctrl = 1; |
226 | pressedKeyUnicode = mod1Map[row].unicode; | 227 | pressedKeyUnicode = mod1Map[row].unicode; |
227 | pressedKeyQcode = mod1Map[row].qcode; | 228 | pressedKeyQcode = mod1Map[row].qcode; |
228 | } | 229 | } |
229 | else if ( x >= letterx1 && x <= letterx2 ) // letter | 230 | else if ( x >= letterx1 && x <= letterx2 ) // letter |
230 | { | 231 | { |
231 | int column = (x - letterx1 - 1) / letterw; | 232 | int column = (x - letterx1 - 1) / letterw; |
232 | QChar temp; | 233 | QChar temp; |
233 | if (lang == 0) // english | 234 | if (lang == 0) // english |
234 | if ( shift ) | 235 | if ( shift ) |
235 | temp = QChar( letterMapShift[row][column] ); | 236 | temp = QChar( letterMapShift[row][column] ); |
236 | else | 237 | else |
237 | temp = QChar( letterMap[row][column] ); | 238 | temp = QChar( letterMap[row][column] ); |
238 | else if (lang == 1) // korean | 239 | else if (lang == 1) // korean |
239 | if ( shift ) | 240 | if ( shift ) |
240 | temp = parseKoreanInput( kletterMapShift[row][column] ); | 241 | temp = parseKoreanInput( kletterMapShift[row][column] ); |
241 | else | 242 | else |
242 | temp = parseKoreanInput( kletterMap[row][column] ); | 243 | temp = parseKoreanInput( kletterMap[row][column] ); |
243 | 244 | ||
244 | if ( temp == ' ' ) // space | 245 | if ( temp == ' ' ) // space |
245 | { | 246 | { |
246 | if ( column < 3 ) | 247 | if ( column < 3 ) |
247 | { | 248 | { |
248 | pressedx = letterx1; | 249 | pressedx = letterx1; |
249 | pressed2x = letterx1 + letterw * 4; | 250 | pressed2x = letterx1 + letterw * 4; |
250 | } | 251 | } |
251 | else | 252 | else |
252 | { | 253 | { |
253 | pressedx = letterx1 + letterw * 4; | 254 | pressedx = letterx1 + letterw * 4; |
254 | pressed2x = letterx1; | 255 | pressed2x = letterx1; |
255 | } | 256 | } |
256 | pressedy = pressed2y = row * letterh; | 257 | pressedy = pressed2y = row * letterh; |
257 | pressedw = pressed2w = letterw * 2 + 1; | 258 | pressedw = pressed2w = letterw * 2 + 1; |
258 | pressedh = pressed2h = letterh + 1; | 259 | pressedh = pressed2h = letterh + 1; |
259 | isnoncont = true; | 260 | isnoncont = true; |
260 | } | 261 | } |
261 | else | 262 | else |
262 | { | 263 | { |
263 | pressedx = letterx1 + column * letterw; | 264 | pressedx = letterx1 + column * letterw; |
264 | pressedy = row * letterh; | 265 | pressedy = row * letterh; |
265 | pressedw = letterw + 1; | 266 | pressedw = letterw + 1; |
266 | pressedh = letterh + 1; | 267 | pressedh = letterh + 1; |
267 | } | 268 | } |
268 | pressedKeyUnicode = temp.unicode(); | 269 | pressedKeyUnicode = temp.unicode(); |
269 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); | 270 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); |
270 | if ( temp == ' ' ) | 271 | if ( temp == ' ' ) |
271 | { | 272 | { |
272 | slideKeyUnicodeH = slideKeyUnicodeV = 8; | 273 | slideKeyUnicodeH = slideKeyUnicodeV = 8; |
273 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; | 274 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; |
274 | } | 275 | } |
275 | else if ( temp == temp.lower() ) | 276 | else if ( temp == temp.lower() ) |
276 | { | 277 | { |
277 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); | 278 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); |
278 | slidePixH = slidePixV = &pressedShift; | 279 | slidePixH = slidePixV = &pressedShift; |
279 | } | 280 | } |
280 | else | 281 | else |
281 | { | 282 | { |
282 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); | 283 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); |
283 | slidePixH = slidePixV = &pressedPlain; | 284 | slidePixH = slidePixV = &pressedPlain; |
284 | } | 285 | } |
285 | enableMouseTracking = true; | 286 | enableMouseTracking = true; |
286 | } | 287 | } |
287 | else if ( x >= num1x1 && x <= num1x2 ) // num1 | 288 | else if ( x >= num1x1 && x <= num1x2 ) // num1 |
288 | { | 289 | { |
289 | pressedx = num1x1; | 290 | pressedx = num1x1; |
290 | pressedy = row * letterh; | 291 | pressedy = row * letterh; |
291 | pressedw = num1w + 1; | 292 | pressedw = num1w + 1; |
292 | pressedh = letterh + 1; | 293 | pressedh = letterh + 1; |
293 | QChar temp = QChar( num1Map[row] ); | 294 | QChar temp = QChar( num1Map[row] ); |
294 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 295 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
295 | } | 296 | } |
296 | else if ( x >= specialx1 && x <= specialx2 ) // special | 297 | else if ( x >= specialx1 && x <= specialx2 ) // special |
297 | { | 298 | { |
298 | int column = (x - specialx1 - 1) / specialw; | 299 | int column = (x - specialx1 - 1) / specialw; |
299 | pressedx = specialx1 + column * specialw; | 300 | pressedx = specialx1 + column * specialw; |
300 | pressedy = row * letterh; | 301 | pressedy = row * letterh; |
301 | pressedw = specialw + 1; | 302 | pressedw = specialw + 1; |
302 | pressedh = letterh + 1; | 303 | pressedh = letterh + 1; |
303 | QChar temp; | 304 | QChar temp; |
304 | if ( shift ) | 305 | if ( shift ) |
305 | temp = QChar( specialMapShift[row][column] ); | 306 | temp = QChar( specialMapShift[row][column] ); |
306 | else if ( paren ) | 307 | else if ( paren ) |
307 | temp = QChar( specialMapParen[row][column] ); | 308 | temp = QChar( specialMapParen[row][column] ); |
308 | else | 309 | else |
309 | temp = QChar( specialMap[row][column] ); | 310 | temp = QChar( specialMap[row][column] ); |
310 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 311 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
311 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = | 312 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = |
312 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; | 313 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; |
313 | slidePixH = slidePixV = &pressedDigit; | 314 | slidePixH = slidePixV = &pressedDigit; |
314 | if ( shift ) | 315 | if ( shift ) |
315 | { | 316 | { |
316 | slideKeyUnicodeV = slideKeyQcodeV = | 317 | slideKeyUnicodeV = slideKeyQcodeV = |
317 | QChar( specialMap[row][column] ).unicode(); | 318 | QChar( specialMap[row][column] ).unicode(); |
318 | slidePixV = &pressedPlain; | 319 | slidePixV = &pressedPlain; |
319 | } | 320 | } |
320 | else if ( !(shift || paren) ) | 321 | else if ( !(shift || paren) ) |
321 | { | 322 | { |
322 | slideKeyUnicodeV = slideKeyQcodeV = | 323 | slideKeyUnicodeV = slideKeyQcodeV = |
323 | QChar( specialMapShift[row][column] ).unicode(); | 324 | QChar( specialMapShift[row][column] ).unicode(); |
324 | slidePixV = &pressedShift; | 325 | slidePixV = &pressedShift; |
325 | } | 326 | } |
326 | enableMouseTracking = true; | 327 | enableMouseTracking = true; |
327 | } | 328 | } |
328 | else if ( x >= num2x1 && x <= num2x2 ) // num2 | 329 | else if ( x >= num2x1 && x <= num2x2 ) // num2 |
329 | { | 330 | { |
330 | pressedx = num2x1; | 331 | pressedx = num2x1; |
331 | pressedy = row * letterh; | 332 | pressedy = row * letterh; |
332 | pressedw = num2w + 1; | 333 | pressedw = num2w + 1; |
333 | pressedh = letterh + 1; | 334 | pressedh = letterh + 1; |
334 | QChar temp = QChar( num2Map[row] ); | 335 | QChar temp = QChar( num2Map[row] ); |
335 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 336 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
336 | } | 337 | } |
337 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 | 338 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 |
338 | { | 339 | { |
339 | pressedx = mod2x1; | 340 | pressedx = mod2x1; |
340 | pressedy = row * letterh; | 341 | pressedy = row * letterh; |
341 | pressedw = mod2w + 1; | 342 | pressedw = mod2w + 1; |
342 | pressedh = letterh + 1; | 343 | pressedh = letterh + 1; |
343 | if ( row == 2 ) // return | 344 | if ( row == 2 ) // return |
344 | { | 345 | { |
345 | pressed2x = mod1x1; | 346 | pressed2x = mod1x1; |
346 | pressed2y = 2 * letterh; | 347 | pressed2y = 2 * letterh; |
347 | pressed2w = mod2w + 1; | 348 | pressed2w = mod2w + 1; |
348 | pressed2h = letterh + 1; | 349 | pressed2h = letterh + 1; |
349 | isnoncont = true; | 350 | isnoncont = true; |
350 | } | 351 | } |
351 | pressedKeyUnicode = mod2Map[row].unicode; | 352 | pressedKeyUnicode = mod2Map[row].unicode; |
352 | pressedKeyQcode = mod2Map[row].qcode; | 353 | pressedKeyQcode = mod2Map[row].qcode; |
353 | 354 | ||
354 | if ( row == 3 ) // shift | 355 | if ( row == 3 ) // shift |
355 | { | 356 | { |
356 | paren = 0; | 357 | paren = 0; |
357 | switch ( shift ) | 358 | switch ( shift ) |
358 | { | 359 | { |
359 | case 0: | 360 | case 0: |
360 | { | 361 | { |
361 | shift = 1; | 362 | shift = 1; |
362 | releasedPix = &releasedShift; | 363 | releasedPix = &releasedShift; |
363 | pressedPix = &pressedShift; | 364 | pressedPix = &pressedShift; |
364 | bitBlt( &offscreen, 0, 0, releasedPix ); | 365 | bitBlt( &offscreen, 0, 0, releasedPix ); |
365 | break; | 366 | break; |
366 | } | 367 | } |
367 | case 1: | 368 | case 1: |
368 | { | 369 | { |
369 | shift = 2; | 370 | shift = 2; |
370 | break; | 371 | break; |
371 | } | 372 | } |
372 | case 2: | 373 | case 2: |
373 | { | 374 | { |
374 | shift = 0; | 375 | shift = 0; |
375 | releasedPix = &releasedPlain; | 376 | releasedPix = &releasedPlain; |
376 | pressedPix = &pressedPlain; | 377 | pressedPix = &pressedPlain; |
377 | bitBlt( &offscreen, 0, 0, releasedPix ); | 378 | bitBlt( &offscreen, 0, 0, releasedPix ); |
378 | break; | 379 | break; |
379 | } | 380 | } |
380 | } | 381 | } |
381 | } | 382 | } |
382 | else if ( row == 4 ) // parenthesis | 383 | else if ( row == 4 ) // parenthesis |
383 | { | 384 | { |
384 | shift = 0; | 385 | shift = 0; |
385 | switch ( paren ) | 386 | switch ( paren ) |
386 | { | 387 | { |
387 | case 0: | 388 | case 0: |
388 | { | 389 | { |
389 | paren = 1; | 390 | paren = 1; |
390 | releasedPix = &releasedParen; | 391 | releasedPix = &releasedParen; |
391 | pressedPix = &pressedParen; | 392 | pressedPix = &pressedParen; |
392 | bitBlt( &offscreen, 0, 0, releasedPix ); | 393 | bitBlt( &offscreen, 0, 0, releasedPix ); |
393 | break; | 394 | break; |
394 | } | 395 | } |
395 | case 1: | 396 | case 1: |
396 | { | 397 | { |
397 | paren = 2; | 398 | paren = 2; |
398 | break; | 399 | break; |
399 | } | 400 | } |
400 | case 2: | 401 | case 2: |
401 | { | 402 | { |
402 | paren = 0; | 403 | paren = 0; |
403 | releasedPix = &releasedPlain; | 404 | releasedPix = &releasedPlain; |
404 | pressedPix = &pressedPlain; | 405 | pressedPix = &pressedPlain; |
405 | bitBlt( &offscreen, 0, 0, releasedPix ); | 406 | bitBlt( &offscreen, 0, 0, releasedPix ); |
406 | break; | 407 | break; |
407 | } | 408 | } |
408 | } | 409 | } |
409 | } | 410 | } |
410 | } | 411 | } |
411 | else if ( x >= cursorx1 ) // cursor | 412 | else if ( x >= cursorx1 ) // cursor |
412 | { | 413 | { |
413 | int column = (x - cursorx1 - 1) / cursorw; | 414 | int column = (x - cursorx1 - 1) / cursorw; |
414 | if ( row == 2 || row == 4 ) | 415 | if ( row == 2 || row == 4 ) |
415 | pressedx = cursorx1 + cursorw / 2; | 416 | pressedx = cursorx1 + cursorw / 2; |
416 | else | 417 | else |
417 | pressedx = cursorx1 + column * cursorw; | 418 | pressedx = cursorx1 + column * cursorw; |
418 | pressedy = row * letterh; | 419 | pressedy = row * letterh; |
419 | pressedw = cursorw + 1; | 420 | pressedw = cursorw + 1; |
420 | pressedh = letterh + 1; | 421 | pressedh = letterh + 1; |
421 | pressedKeyQcode = cursorMap[row][column]; | 422 | pressedKeyQcode = cursorMap[row][column]; |
422 | } | 423 | } |
423 | 424 | ||
424 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | | 425 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | |
425 | ( ctrl ? Qt::ControlButton : 0 ) | | 426 | ( ctrl ? Qt::ControlButton : 0 ) | |
426 | ( alt ? Qt::AltButton : 0 ); | 427 | ( alt ? Qt::AltButton : 0 ); |
427 | 428 | ||
428 | lastKey = pressedKeyUnicode; | 429 | lastKey = pressedKeyUnicode; |
429 | 430 | ||
430 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); | 431 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); |
431 | delayTimer->start( autorepeatDelaytime, true ); | 432 | delayTimer->start( autorepeatDelaytime, true ); |
432 | 433 | ||
433 | if ( pressedx == -1 ) | 434 | if ( pressedx == -1 ) |
434 | return; | 435 | return; |
435 | 436 | ||
436 | bitBlt( &offscreen, pressedx, pressedy, | 437 | bitBlt( &offscreen, pressedx, pressedy, |
437 | pressedPix, pressedx, pressedy, pressedw, pressedh ); | 438 | pressedPix, pressedx, pressedy, pressedw, pressedh ); |
438 | if ( isnoncont ) | 439 | if ( isnoncont ) |
439 | bitBlt( &offscreen, pressed2x, pressed2y, | 440 | bitBlt( &offscreen, pressed2x, pressed2y, |
440 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); | 441 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); |
441 | 442 | ||
442 | repaint( false ); | 443 | repaint( false ); |
443 | } | 444 | } |
444 | 445 | ||
445 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 446 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
446 | { | 447 | { |
447 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; | 448 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; |
448 | 449 | ||
449 | delayTimer->stop(); | 450 | delayTimer->stop(); |
450 | rateTimer->stop(); | 451 | rateTimer->stop(); |
451 | enableMouseTracking = false; | 452 | enableMouseTracking = false; |
452 | 453 | ||
453 | if ( pressedx == -1 ) | 454 | if ( pressedx == -1 ) |
454 | return; | 455 | return; |
455 | 456 | ||
456 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) | 457 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) |
457 | return; | 458 | return; |
458 | if ( paren == 2 && pressedKeyQcode == myParenID ) | 459 | if ( paren == 2 && pressedKeyQcode == myParenID ) |
459 | return; | 460 | return; |
460 | 461 | ||
461 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) | 462 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) |
462 | { | 463 | { |
463 | shift = 0; | 464 | shift = 0; |
464 | releasedPix = &releasedPlain; | 465 | releasedPix = &releasedPlain; |
465 | pressedPix = &pressedPlain; | 466 | pressedPix = &pressedPlain; |
466 | bitBlt( &offscreen, 0, 0, releasedPix ); | 467 | bitBlt( &offscreen, 0, 0, releasedPix ); |
467 | } | 468 | } |
468 | 469 | ||
469 | if ( paren == 1 && pressedKeyQcode != myParenID ) | 470 | if ( paren == 1 && pressedKeyQcode != myParenID ) |
470 | { | 471 | { |
471 | paren = 0; | 472 | paren = 0; |
472 | releasedPix = &releasedPlain; | 473 | releasedPix = &releasedPlain; |
473 | pressedPix = &pressedPlain; | 474 | pressedPix = &pressedPlain; |
474 | bitBlt( &offscreen, 0, 0, releasedPix ); | 475 | bitBlt( &offscreen, 0, 0, releasedPix ); |
475 | } | 476 | } |
476 | 477 | ||
477 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) | 478 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) |
478 | alt = 0; | 479 | alt = 0; |
479 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) | 480 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) |
480 | ctrl = 0; | 481 | ctrl = 0; |
481 | 482 | ||
482 | bitBlt( &offscreen, pressedx, pressedy, | 483 | bitBlt( &offscreen, pressedx, pressedy, |
483 | releasedPix, pressedx, pressedy, pressedw, pressedh ); | 484 | releasedPix, pressedx, pressedy, pressedw, pressedh ); |
484 | 485 | ||
485 | if ( isnoncont ) | 486 | if ( isnoncont ) |
486 | { | 487 | { |
487 | isnoncont = false; | 488 | isnoncont = false; |
488 | bitBlt( &offscreen, pressed2x, pressed2y, | 489 | bitBlt( &offscreen, pressed2x, pressed2y, |
489 | releasedPix, pressed2x, pressed2y, pressed2w, pressed2h ); | 490 | releasedPix, pressed2x, pressed2y, pressed2w, pressed2h ); |
490 | } | 491 | } |
491 | 492 | ||
492 | repaint( false ); | 493 | repaint( false ); |
493 | } | 494 | } |
494 | 495 | ||
495 | void Keyboard::mouseMoveEvent(QMouseEvent *e) | 496 | void Keyboard::mouseMoveEvent(QMouseEvent *e) |
496 | { | 497 | { |
497 | if ( !enableMouseTracking ) | 498 | if ( !enableMouseTracking ) |
498 | return; | 499 | return; |
499 | 500 | ||
500 | if ( e->x() < pressedx || e->x() >= pressedx + pressedw ) | 501 | if ( e->x() < pressedx || e->x() >= pressedx + pressedw ) |
501 | { | 502 | { |
502 | pressedKeyUnicode = slideKeyUnicodeH; | 503 | pressedKeyUnicode = slideKeyUnicodeH; |
503 | pressedKeyQcode = slideKeyQcodeH; | 504 | pressedKeyQcode = slideKeyQcodeH; |
504 | slidePix = slidePixH; | 505 | slidePix = slidePixH; |
505 | } | 506 | } |
506 | else if ( e->y() < pressedy || e->y() >= pressedy + pressedh ) | 507 | else if ( e->y() < pressedy || e->y() >= pressedy + pressedh ) |
507 | { | 508 | { |
508 | pressedKeyUnicode = slideKeyUnicodeV; | 509 | pressedKeyUnicode = slideKeyUnicodeV; |
509 | pressedKeyQcode = slideKeyQcodeV; | 510 | pressedKeyQcode = slideKeyQcodeV; |
510 | slidePix = slidePixV; | 511 | slidePix = slidePixV; |
511 | } | 512 | } |
512 | else | 513 | else |
513 | return; | 514 | return; |
514 | 515 | ||
515 | enableMouseTracking = false; | 516 | enableMouseTracking = false; |
516 | 517 | ||
517 | delayTimer->stop(); | 518 | delayTimer->stop(); |
518 | rateTimer->stop(); | 519 | rateTimer->stop(); |
519 | 520 | ||
520 | bitBlt( &offscreen, pressedx, pressedy, | 521 | bitBlt( &offscreen, pressedx, pressedy, |
521 | slidePix, pressedx, pressedy, pressedw, pressedh ); | 522 | slidePix, pressedx, pressedy, pressedw, pressedh ); |
522 | 523 | ||
523 | emit key( 8, Qt::Key_Backspace, pressedMod, true, false ); | 524 | emit key( 8, Qt::Key_Backspace, pressedMod, true, false ); |
524 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); | 525 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); |
525 | delayTimer->start( autorepeatDelaytime, true ); | 526 | delayTimer->start( autorepeatDelaytime, true ); |
526 | 527 | ||
527 | repaint( false ); | 528 | repaint( false ); |
528 | } | 529 | } |
529 | 530 | ||
530 | void Keyboard::delayTimerDone() | 531 | void Keyboard::delayTimerDone() |
531 | { | 532 | { |
532 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); | 533 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); |
533 | rateTimer->start( 1000/autorepeatRate, false ); | 534 | rateTimer->start( 1000/autorepeatRate, false ); |
534 | } | 535 | } |
535 | 536 | ||
536 | void Keyboard::rateTimerDone() | 537 | void Keyboard::rateTimerDone() |
537 | { | 538 | { |
538 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); | 539 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); |
539 | } | 540 | } |
540 | 541 | ||
541 | QSize Keyboard::sizeHint() const | 542 | QSize Keyboard::sizeHint() const |
542 | { | 543 | { |
543 | return offscreen.size(); | 544 | return offscreen.size(); |
544 | } | 545 | } |
545 | 546 | ||
546 | void Keyboard::resetState() | 547 | void Keyboard::resetState() |
547 | { | 548 | { |
548 | //cout << "resetState()" << endl; | 549 | //cout << "resetState()" << endl; |
549 | } | 550 | } |
550 | 551 | ||
551 | /* | 552 | /* |
552 | * | 553 | * |
553 | * TODO | 554 | * TODO |
554 | * one major problem with this implementation is that you can't move the | 555 | * one major problem with this implementation is that you can't move the |
555 | * cursor after inputing korean chars, otherwise it will eat up and replace | 556 | * cursor after inputing korean chars, otherwise it will eat up and replace |
556 | * the char before the cursor you move to. fix that | 557 | * the char before the cursor you move to. fix that |
557 | * | 558 | * |
558 | * make a kor/eng swaping key | 559 | * make a kor/eng swaping key |
559 | * | 560 | * |
560 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 561 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
561 | * | 562 | * |
562 | * how korean input works | 563 | * how korean input works |
563 | * | 564 | * |
564 | * all following chars means unicode char value and are in hex | 565 | * all following chars means unicode char value and are in hex |
565 | * | 566 | * |
566 | * ÃÊÀ½ = schar (start char) | 567 | * ÃÊÀ½ = schar (start char) |
567 | * ÁßÀ½ = mchar (middle char) | 568 | * ÁßÀ½ = mchar (middle char) |
568 | * ³¡À½ = echar (end char) | 569 | * ³¡À½ = echar (end char) |
569 | * | 570 | * |
570 | * there are 19 schars. unicode position is at 1100 - 1112 | 571 | * there are 19 schars. unicode position is at 1100 - 1112 |
571 | * there are 21 mchars. unicode position is at 1161 - 1175 | 572 | * there are 21 mchars. unicode position is at 1161 - 1175 |
572 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 573 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
573 | * | 574 | * |
574 | * the map with everything combined is at ac00 - d7a3 | 575 | * the map with everything combined is at ac00 - d7a3 |
575 | * | 576 | * |
576 | * to find a combination of schar + mchar in the map, lookup | 577 | * to find a combination of schar + mchar in the map, lookup |
577 | * ((schar - 0x1100) * 587) + ((mchar - 0x1161) * 27) + (echar - 0x11a8) + 0xac00) | 578 | * ((schar - 0x1100) * 587) + ((mchar - 0x1161) * 27) + (echar - 0x11a8) + 0xac00) |
578 | * | 579 | * |
579 | */ | 580 | */ |
580 | 581 | ||
581 | QChar Keyboard::parseKoreanInput (ushort c) { | 582 | QChar Keyboard::parseKoreanInput (ushort c) { |
582 | 583 | ||
583 | static ushort schar, mchar, echar; | 584 | static ushort schar, mchar, echar; |
584 | 585 | ||
585 | if ((lastKey < 0x1100 || 0x11c2 < lastKey) && (lastKey < 0xac00 || 0xd7a3 < lastKey) | 586 | if ((lastKey < 0x1100 || 0x11c2 < lastKey) && (lastKey < 0xac00 || 0xd7a3 < lastKey) |
586 | && !(lastKey == 0 && (shift || paren || ctrl || alt))) { | 587 | && !(lastKey == 0 && (shift || paren || ctrl || alt))) { |
587 | 588 | ||
588 | //printf ("reset...\n"); | 589 | //printf ("reset...\n"); |
589 | schar = 0, mchar = 0, echar = 0; | 590 | schar = 0, mchar = 0, echar = 0; |
590 | } | 591 | } |
591 | 592 | ||
592 | //printf ("in %x %x %x %x %x\n", schar, mchar, echar, c, lastKey); | 593 | //printf ("in %x %x %x %x %x\n", schar, mchar, echar, c, lastKey); |
593 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 594 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
594 | 595 | ||
595 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 596 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
596 | schar = c; mchar = 0; echar = 0; | 597 | schar = c; mchar = 0; echar = 0; |
597 | return QChar(c); | 598 | return QChar(c); |
598 | } | 599 | } |
599 | else if (mchar != 0) { | 600 | else if (mchar != 0) { |
600 | 601 | ||
601 | if (echar == 0) { | 602 | if (echar == 0) { |
602 | 603 | ||
603 | if (!(echar = constoe(c))) { | 604 | if (!(echar = constoe(c))) { |
604 | 605 | ||
605 | schar = c; mchar = 0; echar = 0; | 606 | schar = c; mchar = 0; echar = 0; |
606 | return QChar(c); | 607 | return QChar(c); |
607 | } | 608 | } |
608 | 609 | ||
609 | } | 610 | } |
610 | else { // must figure out what the echar is | 611 | else { // must figure out what the echar is |
611 | 612 | ||
612 | if (echar == 0x11a8) { // ¤¡ | 613 | if (echar == 0x11a8) { // ¤¡ |
613 | 614 | ||
614 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ | 615 | if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ |
615 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ | 616 | else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ |
616 | else { | 617 | else { |
617 | schar = c; mchar = 0; echar = 0; | 618 | schar = c; mchar = 0; echar = 0; |
618 | return QChar(c); | 619 | return QChar(c); |
619 | } | 620 | } |
620 | 621 | ||
621 | } else if (echar == 0x11ab) { // ¤¤ | 622 | } else if (echar == 0x11ab) { // ¤¤ |
622 | 623 | ||
623 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ | 624 | if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ |
624 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ | 625 | else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ |
625 | else { | 626 | else { |
626 | schar = c; mchar = 0; echar = 0; | 627 | schar = c; mchar = 0; echar = 0; |
627 | return QChar(c); | 628 | return QChar(c); |
628 | } | 629 | } |
629 | 630 | ||
630 | } else if (echar == 0x11af) { // ¤© | 631 | } else if (echar == 0x11af) { // ¤© |
631 | 632 | ||
632 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ | 633 | if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ |
633 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± | 634 | else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± |
634 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² | 635 | else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² |
635 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ | 636 | else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ |
636 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ | 637 | else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ |
637 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ | 638 | else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ |
638 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ | 639 | else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ |
639 | else { | 640 | else { |
640 | schar = c; mchar = 0; echar = 0; | 641 | schar = c; mchar = 0; echar = 0; |
641 | return QChar(c); | 642 | return QChar(c); |
642 | } | 643 | } |
643 | 644 | ||
644 | } else if (echar == 0x11b8) { // ¤² | 645 | } else if (echar == 0x11b8) { // ¤² |
645 | 646 | ||
646 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ | 647 | if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ |
647 | else { | 648 | else { |
648 | schar = c; mchar = 0; echar = 0; | 649 | schar = c; mchar = 0; echar = 0; |
649 | return QChar(c); | 650 | return QChar(c); |
650 | } | 651 | } |
651 | 652 | ||
652 | } else if (echar == 0x11ba) { // ¤µ | 653 | } else if (echar == 0x11ba) { // ¤µ |
653 | 654 | ||
654 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ | 655 | if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ |
655 | else { | 656 | else { |
656 | schar = c; mchar = 0; echar = 0; | 657 | schar = c; mchar = 0; echar = 0; |
657 | return QChar(c); | 658 | return QChar(c); |
658 | } | 659 | } |
659 | 660 | ||
660 | } else { // if any other char, cannot combine chars | 661 | } else { // if any other char, cannot combine chars |
661 | 662 | ||
662 | schar = c; mchar = 0; echar = 0; | 663 | schar = c; mchar = 0; echar = 0; |
663 | return QChar(c); | 664 | return QChar(c); |
664 | } | 665 | } |
665 | 666 | ||
666 | lastKey = echar; | 667 | lastKey = echar; |
667 | } | 668 | } |
668 | } | 669 | } |
669 | 670 | ||
670 | } | 671 | } |
671 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 672 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
672 | 673 | ||
673 | if (schar != 0 && mchar == 0) { mchar = c; } | 674 | if (schar != 0 && mchar == 0) { mchar = c; } |
674 | 675 | ||
675 | else if (schar != 0 && mchar != 0 && echar == 0) { | 676 | else if (schar != 0 && mchar != 0 && echar == 0) { |
676 | 677 | ||
677 | switch (mchar) { | 678 | switch (mchar) { |
678 | case 0x1169: | 679 | case 0x1169: |
679 | if (c == 0x1161) mchar = 0x116a; | 680 | if (c == 0x1161) mchar = 0x116a; |
680 | else if (c == 0x1162) mchar = 0x116b; | 681 | else if (c == 0x1162) mchar = 0x116b; |
681 | else if (c == 0x1175) mchar = 0x116c; | 682 | else if (c == 0x1175) mchar = 0x116c; |
682 | else { | 683 | else { |
683 | schar = 0; mchar = 0; echar = 0; | 684 | schar = 0; mchar = 0; echar = 0; |
684 | return QChar(c); | 685 | return QChar(c); |
685 | } | 686 | } |
686 | break; | 687 | break; |
687 | case 0x116e: | 688 | case 0x116e: |
688 | if (c == 0x1165) mchar = 0x116f; | 689 | if (c == 0x1165) mchar = 0x116f; |
689 | else if (c == 0x1166) mchar = 0x1170; | 690 | else if (c == 0x1166) mchar = 0x1170; |
690 | else if (c == 0x1175) mchar = 0x1171; | 691 | else if (c == 0x1175) mchar = 0x1171; |
691 | else { | 692 | else { |
692 | schar = 0; mchar = 0; echar = 0; | 693 | schar = 0; mchar = 0; echar = 0; |
693 | return QChar(c); | 694 | return QChar(c); |
694 | } | 695 | } |
695 | break; | 696 | break; |
696 | case 0x1173: | 697 | case 0x1173: |
697 | if (c == 0x1175) mchar = 0x1174; | 698 | if (c == 0x1175) mchar = 0x1174; |
698 | else { | 699 | else { |
699 | schar = 0; mchar = 0; echar = 0; | 700 | schar = 0; mchar = 0; echar = 0; |
700 | return QChar(c); | 701 | return QChar(c); |
701 | } | 702 | } |
702 | break; | 703 | break; |
703 | default: | 704 | default: |
704 | schar = 0; mchar = 0; echar = 0; | 705 | schar = 0; mchar = 0; echar = 0; |
705 | return QChar(c); | 706 | return QChar(c); |
706 | } | 707 | } |
707 | } | 708 | } |
708 | else if (schar != 0 && mchar != 0 && echar != 0) { | 709 | else if (schar != 0 && mchar != 0 && echar != 0) { |
709 | 710 | ||
710 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 711 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
711 | 712 | ||
712 | ushort prev = 0; | 713 | ushort prev = 0; |
713 | switch (echar) { | 714 | switch (echar) { |
714 | /* | 715 | /* |
715 | case 0x11a9: | 716 | case 0x11a9: |
716 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 717 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
717 | schar = 0x1100; | 718 | schar = 0x1100; |
718 | break; | 719 | break; |
719 | */ | 720 | */ |
720 | case 0x11aa: | 721 | case 0x11aa: |
721 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 722 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
722 | schar = 0x1109; | 723 | schar = 0x1109; |
723 | break; | 724 | break; |
724 | case 0x11ac: | 725 | case 0x11ac: |
725 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 726 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
726 | schar = 0x110c; | 727 | schar = 0x110c; |
727 | break; | 728 | break; |
728 | case 0x11ad: | 729 | case 0x11ad: |
729 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 730 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
730 | schar = 0x1112; | 731 | schar = 0x1112; |
731 | break; | 732 | break; |
732 | case 0x11b0: | 733 | case 0x11b0: |
733 | prev = combineKoreanChars(schar, mchar, 0x11af); | 734 | prev = combineKoreanChars(schar, mchar, 0x11af); |
734 | schar = 0x1100; | 735 | schar = 0x1100; |
735 | break; | 736 | break; |
736 | case 0x11b1: | 737 | case 0x11b1: |
737 | prev = combineKoreanChars(schar, mchar, 0x11af); | 738 | prev = combineKoreanChars(schar, mchar, 0x11af); |
738 | schar = 0x1106; | 739 | schar = 0x1106; |
739 | break; | 740 | break; |
740 | case 0x11b2: | 741 | case 0x11b2: |
741 | prev = combineKoreanChars(schar, mchar, 0x11af); | 742 | prev = combineKoreanChars(schar, mchar, 0x11af); |
742 | schar = 0x1107; | 743 | schar = 0x1107; |
743 | break; | 744 | break; |
744 | case 0x11b3: | 745 | case 0x11b3: |
745 | prev = combineKoreanChars(schar, mchar, 0x11af); | 746 | prev = combineKoreanChars(schar, mchar, 0x11af); |
746 | schar = 0x1109; | 747 | schar = 0x1109; |
747 | break; | 748 | break; |
748 | case 0x11b4: | 749 | case 0x11b4: |
749 | prev = combineKoreanChars(schar, mchar, 0x11af); | 750 | prev = combineKoreanChars(schar, mchar, 0x11af); |
750 | schar = 0x1110; | 751 | schar = 0x1110; |
751 | break; | 752 | break; |
752 | case 0x11b9: | 753 | case 0x11b9: |
753 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 754 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
754 | schar = 0x1109; | 755 | schar = 0x1109; |
755 | break; | 756 | break; |
756 | /* | 757 | /* |
757 | case 0x11bb: | 758 | case 0x11bb: |
758 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 759 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
759 | schar = 0x1109; | 760 | schar = 0x1109; |
760 | break; | 761 | break; |
761 | */ | 762 | */ |
762 | default: | 763 | default: |
763 | 764 | ||
764 | if (constoe(echar)) { | 765 | if (constoe(echar)) { |
765 | 766 | ||
766 | prev = combineKoreanChars(schar, mchar, 0); | 767 | prev = combineKoreanChars(schar, mchar, 0); |
767 | schar = constoe(echar); | 768 | schar = constoe(echar); |
768 | } | 769 | } |
769 | break; | 770 | break; |
770 | } | 771 | } |
771 | 772 | ||
772 | emit key( prev, prev, 0, true, false ); | 773 | emit key( prev, prev, 0, true, false ); |
773 | 774 | ||
774 | mchar = c; echar = 0; | 775 | mchar = c; echar = 0; |
775 | 776 | ||
776 | return QChar(combineKoreanChars(schar, mchar, 0)); | 777 | return QChar(combineKoreanChars(schar, mchar, 0)); |
777 | 778 | ||
778 | } | 779 | } |
779 | else { | 780 | else { |
780 | schar = 0; mchar = 0; echar = 0; | 781 | schar = 0; mchar = 0; echar = 0; |
781 | return QChar(c); | 782 | return QChar(c); |
782 | } | 783 | } |
783 | 784 | ||
784 | } | 785 | } |
785 | else if (c == ' ') return QChar(c); | 786 | else if (c == ' ') return QChar(c); |
786 | 787 | ||
787 | 788 | ||
788 | // and now... finally delete previous char, and return new char | 789 | // and now... finally delete previous char, and return new char |
789 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 790 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
790 | 791 | ||
791 | //printf ("out %x %x %x %x\n", schar, mchar, echar, c); | 792 | //printf ("out %x %x %x %x\n", schar, mchar, echar, c); |
792 | 793 | ||
793 | 794 | ||
794 | return QChar (combineKoreanChars( schar, mchar, echar)); | 795 | return QChar (combineKoreanChars( schar, mchar, echar)); |
795 | 796 | ||
796 | } | 797 | } |
797 | 798 | ||
798 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 799 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
799 | 800 | ||
800 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 801 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
801 | 802 | ||
802 | } | 803 | } |
803 | 804 | ||
804 | ushort Keyboard::constoe(const ushort c) { | 805 | ushort Keyboard::constoe(const ushort c) { |
805 | 806 | ||
806 | // converts schars to echars if possible | 807 | // converts schars to echars if possible |
807 | 808 | ||
808 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 809 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
809 | 810 | ||
810 | switch (c) { | 811 | switch (c) { |
811 | case 0x1100: return 0x11a8; | 812 | case 0x1100: return 0x11a8; |
812 | case 0x1101: return 0x11a9; | 813 | case 0x1101: return 0x11a9; |
813 | case 0x1102: return 0x11ab; | 814 | case 0x1102: return 0x11ab; |
814 | case 0x1103: return 0x11ae; | 815 | case 0x1103: return 0x11ae; |
815 | case 0x1105: return 0x11af; | 816 | case 0x1105: return 0x11af; |
816 | case 0x1106: return 0x11b7; | 817 | case 0x1106: return 0x11b7; |
817 | case 0x1107: return 0x11b8; | 818 | case 0x1107: return 0x11b8; |
818 | case 0x1109: return 0x11ba; | 819 | case 0x1109: return 0x11ba; |
819 | case 0x110a: return 0x11bb; | 820 | case 0x110a: return 0x11bb; |
820 | case 0x110b: return 0x11bc; | 821 | case 0x110b: return 0x11bc; |
821 | case 0x110c: return 0x11bd; | 822 | case 0x110c: return 0x11bd; |
822 | case 0x110e: return 0x11be; | 823 | case 0x110e: return 0x11be; |
823 | case 0x110f: return 0x11bf; | 824 | case 0x110f: return 0x11bf; |
824 | case 0x1110: return 0x11c0; | 825 | case 0x1110: return 0x11c0; |
825 | case 0x1111: return 0x11c1; | 826 | case 0x1111: return 0x11c1; |
826 | case 0x1112: return 0x11c2; | 827 | case 0x1112: return 0x11c2; |
827 | default: return 0; | 828 | default: return 0; |
828 | 829 | ||
829 | } | 830 | } |
830 | 831 | ||
831 | } else { //echar to schar | 832 | } else { //echar to schar |
832 | 833 | ||
833 | switch (c) { | 834 | switch (c) { |
834 | case 0x11a8: return 0x1100; | 835 | case 0x11a8: return 0x1100; |
835 | case 0x11a9: return 0x1101; | 836 | case 0x11a9: return 0x1101; |
836 | case 0x11ab: return 0x1102; | 837 | case 0x11ab: return 0x1102; |
837 | case 0x11ae: return 0x1103; | 838 | case 0x11ae: return 0x1103; |
838 | case 0x11af: return 0x1105; | 839 | case 0x11af: return 0x1105; |
839 | case 0x11b7: return 0x1106; | 840 | case 0x11b7: return 0x1106; |
840 | case 0x11b8: return 0x1107; | 841 | case 0x11b8: return 0x1107; |
841 | case 0x11ba: return 0x1109; | 842 | case 0x11ba: return 0x1109; |
842 | case 0x11bb: return 0x110a; | 843 | case 0x11bb: return 0x110a; |
843 | case 0x11bc: return 0x110b; | 844 | case 0x11bc: return 0x110b; |
844 | case 0x11bd: return 0x110c; | 845 | case 0x11bd: return 0x110c; |
845 | case 0x11be: return 0x110e; | 846 | case 0x11be: return 0x110e; |
846 | case 0x11bf: return 0x110f; | 847 | case 0x11bf: return 0x110f; |
847 | case 0x11c0: return 0x1110; | 848 | case 0x11c0: return 0x1110; |
848 | case 0x11c1: return 0x1111; | 849 | case 0x11c1: return 0x1111; |
849 | case 0x11c2: return 0x1112; | 850 | case 0x11c2: return 0x1112; |
850 | default: return 0; | 851 | default: return 0; |
851 | 852 | ||
852 | } | 853 | } |
853 | 854 | ||
854 | } | 855 | } |
855 | } | 856 | } |
diff --git a/inputmethods/kjumpx/keyboard.h b/inputmethods/kjumpx/keyboard.h index 148cb72..ca83915 100644 --- a/inputmethods/kjumpx/keyboard.h +++ b/inputmethods/kjumpx/keyboard.h | |||
@@ -1,79 +1,84 @@ | |||
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 KJumpX | ||
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 | QChar parseKoreanInput(ushort); | 36 | QChar parseKoreanInput(ushort); |
34 | ushort combineKoreanChars(const ushort, const ushort, const ushort); | 37 | ushort combineKoreanChars(const ushort, const ushort, const ushort); |
35 | ushort constoe(const ushort); | 38 | ushort constoe(const ushort); |
36 | 39 | ||
37 | 40 | ||
38 | signals: | 41 | signals: |
39 | void key( ushort unicode, ushort qcode, ushort modifiers, bool, bool ); | 42 | void key( ushort unicode, ushort qcode, ushort modifiers, bool, bool ); |
40 | 43 | ||
41 | private slots: | 44 | private slots: |
42 | void delayTimerDone(); | 45 | void delayTimerDone(); |
43 | void rateTimerDone(); | 46 | void rateTimerDone(); |
44 | 47 | ||
45 | private: | 48 | private: |
46 | int shift; // 0, 1, 2 | 49 | int shift; // 0, 1, 2 |
47 | int paren; // 0, 1, 2 | 50 | int paren; // 0, 1, 2 |
48 | int ctrl; // 0, 1 | 51 | int ctrl; // 0, 1 |
49 | int alt; // 0, 1 | 52 | int alt; // 0, 1 |
50 | bool lang; // 0 -> english, 1 -> korean | 53 | bool lang; // 0 -> english, 1 -> korean |
51 | 54 | ||
52 | int lastKey; | 55 | int lastKey; |
53 | 56 | ||
54 | int pressedKeyUnicode, pressedKeyQcode, pressedMod; | 57 | int pressedKeyUnicode, pressedKeyQcode, pressedMod; |
55 | int pressedx, pressedy, pressedw, pressedh; | 58 | int pressedx, pressedy, pressedw, pressedh; |
56 | bool isnoncont; | 59 | bool isnoncont; |
57 | int pressed2x, pressed2y, pressed2w, pressed2h; | 60 | int pressed2x, pressed2y, pressed2w, pressed2h; |
58 | 61 | ||
59 | int slideKeyUnicodeH, slideKeyQcodeH, slideKeyUnicodeV, slideKeyQcodeV; | 62 | int slideKeyUnicodeH, slideKeyQcodeH, slideKeyUnicodeV, slideKeyQcodeV; |
60 | bool enableMouseTracking; | 63 | bool enableMouseTracking; |
61 | QPixmap *slidePix, *slidePixH, *slidePixV; | 64 | QPixmap *slidePix, *slidePixH, *slidePixV; |
62 | 65 | ||
63 | QPixmap releasedPlain; | 66 | QPixmap releasedPlain; |
64 | QPixmap releasedShift; | 67 | QPixmap releasedShift; |
65 | QPixmap releasedParen; | 68 | QPixmap releasedParen; |
66 | 69 | ||
67 | QPixmap pressedPlain; | 70 | QPixmap pressedPlain; |
68 | QPixmap pressedShift; | 71 | QPixmap pressedShift; |
69 | QPixmap pressedParen; | 72 | QPixmap pressedParen; |
70 | QPixmap pressedDigit; | 73 | QPixmap pressedDigit; |
71 | 74 | ||
72 | QPixmap offscreen; | 75 | QPixmap offscreen; |
73 | 76 | ||
74 | QPixmap *releasedPix; | 77 | QPixmap *releasedPix; |
75 | QPixmap *pressedPix; | 78 | QPixmap *pressedPix; |
76 | 79 | ||
77 | QTimer *delayTimer; | 80 | QTimer *delayTimer; |
78 | QTimer *rateTimer; | 81 | QTimer *rateTimer; |
79 | }; | 82 | }; |
83 | |||
84 | } // namespace KJumpX | ||
diff --git a/inputmethods/kjumpx/keyboardimpl.cpp b/inputmethods/kjumpx/keyboardimpl.cpp index 5d8e0d3..976d816 100644 --- a/inputmethods/kjumpx/keyboardimpl.cpp +++ b/inputmethods/kjumpx/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 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 KJumpX::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", "KJumpX" ); | 70 | return qApp->translate( "InputMethods", "KJumpX" ); |
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/kjumpx/keyboardimpl.h b/inputmethods/kjumpx/keyboardimpl.h index a82ec4a..1ff1034 100644 --- a/inputmethods/kjumpx/keyboardimpl.h +++ b/inputmethods/kjumpx/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 KJumpX |
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 | KJumpX::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 |