-rw-r--r-- | inputmethods/dvorak/dvorak.cpp | 2 | ||||
-rw-r--r-- | inputmethods/dvorak/dvorak.h | 4 | ||||
-rw-r--r-- | inputmethods/dvorak/dvorakimpl.cpp | 6 | ||||
-rw-r--r-- | inputmethods/dvorak/dvorakimpl.h | 13 | ||||
-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 | ||||
-rw-r--r-- | inputmethods/keyboard/keyboard.cpp | 1 | ||||
-rw-r--r-- | inputmethods/keyboard/keyboard.h | 5 | ||||
-rw-r--r-- | inputmethods/keyboard/keyboardimpl.cpp | 8 | ||||
-rw-r--r-- | inputmethods/keyboard/keyboardimpl.h | 13 | ||||
-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 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 1 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.h | 5 | ||||
-rw-r--r-- | inputmethods/multikey/keyboardimpl.cpp | 4 | ||||
-rw-r--r-- | inputmethods/multikey/keyboardimpl.h | 13 |
20 files changed, 94 insertions, 25 deletions
diff --git a/inputmethods/dvorak/dvorak.cpp b/inputmethods/dvorak/dvorak.cpp index 29b5bd0..97afa0a 100644 --- a/inputmethods/dvorak/dvorak.cpp +++ b/inputmethods/dvorak/dvorak.cpp | |||
@@ -1,793 +1,795 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "dvorak.h" | 21 | #include "dvorak.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | 31 | ||
32 | #define USE_SMALL_BACKSPACE | 32 | #define USE_SMALL_BACKSPACE |
33 | 33 | ||
34 | using namespace Dvorak; | ||
35 | |||
34 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 36 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
35 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), | 37 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), |
36 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), | 38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), |
37 | unicode(-1), qkeycode(0), modifiers(0) | 39 | unicode(-1), qkeycode(0), modifiers(0) |
38 | { | 40 | { |
39 | // setPalette(QPalette(QColor(240,240,230))); // Beige! | 41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! |
40 | // setFont( QFont( "Helvetica", 8 ) ); | 42 | // setFont( QFont( "Helvetica", 8 ) ); |
41 | // setPalette(QPalette(QColor(200,200,200))); // Gray | 43 | // setPalette(QPalette(QColor(200,200,200))); // Gray |
42 | setPalette(QPalette(QColor(220,220,220))); // Gray | 44 | setPalette(QPalette(QColor(220,220,220))); // Gray |
43 | 45 | ||
44 | picks = new KeyboardPicks( this ); | 46 | picks = new KeyboardPicks( this ); |
45 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 47 | picks->setFont( QFont( "smallsmooth", 9 ) ); |
46 | setFont( QFont( "smallsmooth", 9 ) ); | 48 | setFont( QFont( "smallsmooth", 9 ) ); |
47 | picks->initialise(); | 49 | picks->initialise(); |
48 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
49 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
50 | 52 | ||
51 | repeatTimer = new QTimer( this ); | 53 | repeatTimer = new QTimer( this ); |
52 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 54 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
53 | } | 55 | } |
54 | 56 | ||
55 | void Keyboard::resizeEvent(QResizeEvent*) | 57 | void Keyboard::resizeEvent(QResizeEvent*) |
56 | { | 58 | { |
57 | int ph = picks->sizeHint().height(); | 59 | int ph = picks->sizeHint().height(); |
58 | picks->setGeometry( 0, 0, width(), ph ); | 60 | picks->setGeometry( 0, 0, width(), ph ); |
59 | keyHeight = (height()-ph)/5; | 61 | keyHeight = (height()-ph)/5; |
60 | int nk; | 62 | int nk; |
61 | if ( useOptiKeys ) { | 63 | if ( useOptiKeys ) { |
62 | nk = 15; | 64 | nk = 15; |
63 | } else if ( useLargeKeys ) { | 65 | } else if ( useLargeKeys ) { |
64 | nk = 15; | 66 | nk = 15; |
65 | } else { | 67 | } else { |
66 | nk = 19; | 68 | nk = 19; |
67 | } | 69 | } |
68 | defaultKeyWidth = width()/nk; | 70 | defaultKeyWidth = width()/nk; |
69 | xoffs = (width()-defaultKeyWidth*nk)/2; | 71 | xoffs = (width()-defaultKeyWidth*nk)/2; |
70 | } | 72 | } |
71 | 73 | ||
72 | void KeyboardPicks::initialise() | 74 | void KeyboardPicks::initialise() |
73 | { | 75 | { |
74 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 76 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
75 | mode = 0; | 77 | mode = 0; |
76 | dc = new KeyboardConfig(this); | 78 | dc = new KeyboardConfig(this); |
77 | configs.append(dc); | 79 | configs.append(dc); |
78 | } | 80 | } |
79 | 81 | ||
80 | QSize KeyboardPicks::sizeHint() const | 82 | QSize KeyboardPicks::sizeHint() const |
81 | { | 83 | { |
82 | return QSize(240,fontMetrics().lineSpacing()); | 84 | return QSize(240,fontMetrics().lineSpacing()); |
83 | } | 85 | } |
84 | 86 | ||
85 | 87 | ||
86 | void KeyboardConfig::generateText(const QString &s) | 88 | void KeyboardConfig::generateText(const QString &s) |
87 | { | 89 | { |
88 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 90 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
89 | for (int i=0; i<(int)backspaces; i++) { | 91 | for (int i=0; i<(int)backspaces; i++) { |
90 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 92 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
91 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 93 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
92 | } | 94 | } |
93 | for (int i=0; i<(int)s.length(); i++) { | 95 | for (int i=0; i<(int)s.length(); i++) { |
94 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 96 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
95 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 97 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
96 | } | 98 | } |
97 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 99 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
98 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 100 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
99 | backspaces = 0; | 101 | backspaces = 0; |
100 | #endif | 102 | #endif |
101 | } | 103 | } |
102 | 104 | ||
103 | 105 | ||
104 | //PC keyboard layout and scancodes | 106 | //PC keyboard layout and scancodes |
105 | 107 | ||
106 | /* | 108 | /* |
107 | Format: length, code, length, code, ..., 0 | 109 | Format: length, code, length, code, ..., 0 |
108 | 110 | ||
109 | length is measured in half the width of a standard key. | 111 | length is measured in half the width of a standard key. |
110 | If code < 0x80 we have length/2 consecutive standard keys, | 112 | If code < 0x80 we have length/2 consecutive standard keys, |
111 | starting with scancode code. | 113 | starting with scancode code. |
112 | 114 | ||
113 | Special keys are hardcoded, one at a time, with length of key | 115 | Special keys are hardcoded, one at a time, with length of key |
114 | and code >= 0x80, these are NOT standard PC scancodes, but are looked | 116 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
115 | up in specialM[]. (The special keys are not keymappable.) | 117 | up in specialM[]. (The special keys are not keymappable.) |
116 | 118 | ||
117 | */ | 119 | */ |
118 | 120 | ||
119 | static const uchar * const keyboard_opti[5] = { | 121 | static const uchar * const keyboard_opti[5] = { |
120 | (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", | 122 | (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", |
121 | (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", | 123 | (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", |
122 | (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", | 124 | (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", |
123 | (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", | 125 | (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", |
124 | (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" | 126 | (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" |
125 | }; | 127 | }; |
126 | 128 | ||
127 | static const uchar * const keyboard_standard[5] = { | 129 | static const uchar * const keyboard_standard[5] = { |
128 | 130 | ||
129 | #ifdef USE_SMALL_BACKSPACE | 131 | #ifdef USE_SMALL_BACKSPACE |
130 | (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002[\002]\002\200\002\223\002\215\002\216\002\217", | 132 | (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002[\002]\002\200\002\223\002\215\002\216\002\217", |
131 | #else | 133 | #else |
132 | (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002[\002]\004\200\002\223\002\215\002\216\002\217", | 134 | (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002[\002]\004\200\002\223\002\215\002\216\002\217", |
133 | #endif | 135 | #endif |
134 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP | 136 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP |
135 | 137 | ||
136 | (const uchar *const)"\003\201\002'\002,\002.\002p\002y\002f\002g\002c\002r\002l\002/\002=\002\\\001\224\002\223\002\221\002\220\002\222", | 138 | (const uchar *const)"\003\201\002'\002,\002.\002p\002y\002f\002g\002c\002r\002l\002/\002=\002\\\001\224\002\223\002\221\002\220\002\222", |
137 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN | 139 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN |
138 | 140 | ||
139 | (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203", | 141 | (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203", |
140 | //CAPS + asdf.. + RETURN | 142 | //CAPS + asdf.. + RETURN |
141 | 143 | ||
142 | (const uchar *const)"\005\204\002;\002q\002j\002k\002x\002b\002m\002w\002v\002z\005\204\002\223\002\223\002\211", | 144 | (const uchar *const)"\005\204\002;\002q\002j\002k\002x\002b\002m\002w\002v\002z\005\204\002\223\002\223\002\211", |
143 | //SHIFT + zxcv... //+ UP | 145 | //SHIFT + zxcv... //+ UP |
144 | 146 | ||
145 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" | 147 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" |
146 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT | 148 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT |
147 | 149 | ||
148 | }; | 150 | }; |
149 | 151 | ||
150 | 152 | ||
151 | struct ShiftMap { | 153 | struct ShiftMap { |
152 | char normal; | 154 | char normal; |
153 | char shifted; | 155 | char shifted; |
154 | }; | 156 | }; |
155 | 157 | ||
156 | 158 | ||
157 | static const ShiftMap shiftMap[] = { | 159 | static const ShiftMap shiftMap[] = { |
158 | { '`', '~' }, | 160 | { '`', '~' }, |
159 | { '1', '!' }, | 161 | { '1', '!' }, |
160 | { '2', '@' }, | 162 | { '2', '@' }, |
161 | { '3', '#' }, | 163 | { '3', '#' }, |
162 | { '4', '$' }, | 164 | { '4', '$' }, |
163 | { '5', '%' }, | 165 | { '5', '%' }, |
164 | { '6', '^' }, | 166 | { '6', '^' }, |
165 | { '7', '&' }, | 167 | { '7', '&' }, |
166 | { '8', '*' }, | 168 | { '8', '*' }, |
167 | { '9', '(' }, | 169 | { '9', '(' }, |
168 | { '0', ')' }, | 170 | { '0', ')' }, |
169 | { '-', '_' }, | 171 | { '-', '_' }, |
170 | { '=', '+' }, | 172 | { '=', '+' }, |
171 | { '\\', '|' }, | 173 | { '\\', '|' }, |
172 | { '[', '{' }, | 174 | { '[', '{' }, |
173 | { ']', '}' }, | 175 | { ']', '}' }, |
174 | { ';', ':' }, | 176 | { ';', ':' }, |
175 | { '\'', '"' }, | 177 | { '\'', '"' }, |
176 | { ',', '<' }, | 178 | { ',', '<' }, |
177 | { '.', '>' }, | 179 | { '.', '>' }, |
178 | { '/', '?' } | 180 | { '/', '?' } |
179 | }; | 181 | }; |
180 | 182 | ||
181 | 183 | ||
182 | /* XPM */ | 184 | /* XPM */ |
183 | static const char * const uparrow_xpm[]={ | 185 | static const char * const uparrow_xpm[]={ |
184 | "9 9 2 1", | 186 | "9 9 2 1", |
185 | "a c #000000", | 187 | "a c #000000", |
186 | ". c None", | 188 | ". c None", |
187 | ".........", | 189 | ".........", |
188 | "....a....", | 190 | "....a....", |
189 | "...aaa...", | 191 | "...aaa...", |
190 | "..aaaaa..", | 192 | "..aaaaa..", |
191 | "....a....", | 193 | "....a....", |
192 | "....a....", | 194 | "....a....", |
193 | "....a....", | 195 | "....a....", |
194 | "....a....", | 196 | "....a....", |
195 | "........."}; | 197 | "........."}; |
196 | /* XPM */ | 198 | /* XPM */ |
197 | static const char * const leftarrow_xpm[]={ | 199 | static const char * const leftarrow_xpm[]={ |
198 | "9 9 2 1", | 200 | "9 9 2 1", |
199 | "a c #000000", | 201 | "a c #000000", |
200 | ". c None", | 202 | ". c None", |
201 | ".........", | 203 | ".........", |
202 | ".........", | 204 | ".........", |
203 | "...a.....", | 205 | "...a.....", |
204 | "..aa.....", | 206 | "..aa.....", |
205 | ".aaaaaaa.", | 207 | ".aaaaaaa.", |
206 | "..aa.....", | 208 | "..aa.....", |
207 | "...a.....", | 209 | "...a.....", |
208 | ".........", | 210 | ".........", |
209 | "........."}; | 211 | "........."}; |
210 | /* XPM */ | 212 | /* XPM */ |
211 | static const char * const downarrow_xpm[]={ | 213 | static const char * const downarrow_xpm[]={ |
212 | "9 9 2 1", | 214 | "9 9 2 1", |
213 | "a c #000000", | 215 | "a c #000000", |
214 | ". c None", | 216 | ". c None", |
215 | ".........", | 217 | ".........", |
216 | "....a....", | 218 | "....a....", |
217 | "....a....", | 219 | "....a....", |
218 | "....a....", | 220 | "....a....", |
219 | "....a....", | 221 | "....a....", |
220 | "..aaaaa..", | 222 | "..aaaaa..", |
221 | "...aaa...", | 223 | "...aaa...", |
222 | "....a....", | 224 | "....a....", |
223 | "........."}; | 225 | "........."}; |
224 | /* XPM */ | 226 | /* XPM */ |
225 | static const char * const rightarrow_xpm[]={ | 227 | static const char * const rightarrow_xpm[]={ |
226 | "9 9 2 1", | 228 | "9 9 2 1", |
227 | "a c #000000", | 229 | "a c #000000", |
228 | ". c None", | 230 | ". c None", |
229 | ".........", | 231 | ".........", |
230 | ".........", | 232 | ".........", |
231 | ".....a...", | 233 | ".....a...", |
232 | ".....aa..", | 234 | ".....aa..", |
233 | ".aaaaaaa.", | 235 | ".aaaaaaa.", |
234 | ".....aa..", | 236 | ".....aa..", |
235 | ".....a...", | 237 | ".....a...", |
236 | ".........", | 238 | ".........", |
237 | "........."}; | 239 | "........."}; |
238 | /* XPM */ | 240 | /* XPM */ |
239 | static const char * const insert_xpm[]={ | 241 | static const char * const insert_xpm[]={ |
240 | "9 9 2 1", | 242 | "9 9 2 1", |
241 | "a c #000000", | 243 | "a c #000000", |
242 | ". c None", | 244 | ". c None", |
243 | ".........", | 245 | ".........", |
244 | "a........", | 246 | "a........", |
245 | "a.aaa.aaa", | 247 | "a.aaa.aaa", |
246 | "a.a.a.a..", | 248 | "a.a.a.a..", |
247 | "a.a.a..a.", | 249 | "a.a.a..a.", |
248 | "a.a.a...a", | 250 | "a.a.a...a", |
249 | "a.a.a.aaa", | 251 | "a.a.a.aaa", |
250 | ".........", | 252 | ".........", |
251 | "........."}; | 253 | "........."}; |
252 | /* XPM */ | 254 | /* XPM */ |
253 | static const char * const delete_xpm[]={ | 255 | static const char * const delete_xpm[]={ |
254 | "9 9 2 1", | 256 | "9 9 2 1", |
255 | "a c #000000", | 257 | "a c #000000", |
256 | ". c None", | 258 | ". c None", |
257 | ".........", | 259 | ".........", |
258 | "aa......a", | 260 | "aa......a", |
259 | "a.a.aaa.a", | 261 | "a.a.aaa.a", |
260 | "a.a.a.a.a", | 262 | "a.a.a.a.a", |
261 | "a.a.aaa.a.", | 263 | "a.a.aaa.a.", |
262 | "a.a.a...a", | 264 | "a.a.a...a", |
263 | "aaa.aaa.a", | 265 | "aaa.aaa.a", |
264 | ".........", | 266 | ".........", |
265 | "........."}; | 267 | "........."}; |
266 | /* XPM */ | 268 | /* XPM */ |
267 | static const char * const home_xpm[]={ | 269 | static const char * const home_xpm[]={ |
268 | "9 9 2 1", | 270 | "9 9 2 1", |
269 | "a c #000000", | 271 | "a c #000000", |
270 | ". c None", | 272 | ". c None", |
271 | "....a....", | 273 | "....a....", |
272 | "...a.a...", | 274 | "...a.a...", |
273 | "..a...a..", | 275 | "..a...a..", |
274 | ".a.....a.", | 276 | ".a.....a.", |
275 | "aa.aaa.aa", | 277 | "aa.aaa.aa", |
276 | ".a.a.a.a.", | 278 | ".a.a.a.a.", |
277 | ".a.a.a.a.", | 279 | ".a.a.a.a.", |
278 | ".aaaaaaa.", | 280 | ".aaaaaaa.", |
279 | "........."}; | 281 | "........."}; |
280 | /* XPM */ | 282 | /* XPM */ |
281 | static const char * const end_xpm[]={ | 283 | static const char * const end_xpm[]={ |
282 | "10 9 2 1", | 284 | "10 9 2 1", |
283 | "a c #000000", | 285 | "a c #000000", |
284 | ". c None", | 286 | ". c None", |
285 | "..........", | 287 | "..........", |
286 | "aa.......a", | 288 | "aa.......a", |
287 | "a..aaa.aaa", | 289 | "a..aaa.aaa", |
288 | "aa.a.a.a.a", | 290 | "aa.a.a.a.a", |
289 | "a..a.a.a.a", | 291 | "a..a.a.a.a", |
290 | "a..a.a.a.a", | 292 | "a..a.a.a.a", |
291 | "aa.a.a.aaa", | 293 | "aa.a.a.aaa", |
292 | "..........", | 294 | "..........", |
293 | ".........."}; | 295 | ".........."}; |
294 | /* XPM */ | 296 | /* XPM */ |
295 | static const char * const pageup_xpm[]={ | 297 | static const char * const pageup_xpm[]={ |
296 | "9 9 2 1", | 298 | "9 9 2 1", |
297 | "a c #000000", | 299 | "a c #000000", |
298 | ". c None", | 300 | ". c None", |
299 | ".aaa.aaa.", | 301 | ".aaa.aaa.", |
300 | ".a.a.a.a.", | 302 | ".a.a.a.a.", |
301 | ".aaa..aa.", | 303 | ".aaa..aa.", |
302 | ".a...aaa.", | 304 | ".a...aaa.", |
303 | ".........", | 305 | ".........", |
304 | ".a.a.aaa.", | 306 | ".a.a.aaa.", |
305 | ".a.a.a.a.", | 307 | ".a.a.a.a.", |
306 | ".aaa.aaa.", | 308 | ".aaa.aaa.", |
307 | ".....a..."}; | 309 | ".....a..."}; |
308 | /* XPM */ | 310 | /* XPM */ |
309 | static const char * const pagedown_xpm[]={ | 311 | static const char * const pagedown_xpm[]={ |
310 | "9 9 2 1", | 312 | "9 9 2 1", |
311 | "a c #000000", | 313 | "a c #000000", |
312 | ". c None", | 314 | ". c None", |
313 | ".aaa.aaa.", | 315 | ".aaa.aaa.", |
314 | ".a.a.a.a.", | 316 | ".a.a.a.a.", |
315 | ".aaa..aa.", | 317 | ".aaa..aa.", |
316 | ".a...aaa.", | 318 | ".a...aaa.", |
317 | ".........", | 319 | ".........", |
318 | "...a.....", | 320 | "...a.....", |
319 | ".aaa.aaa.", | 321 | ".aaa.aaa.", |
320 | ".a.a.a.a.", | 322 | ".a.a.a.a.", |
321 | ".aaa.a.a."}; | 323 | ".aaa.a.a."}; |
322 | /* XPM */ | 324 | /* XPM */ |
323 | static const char * const expand_xpm[]={ | 325 | static const char * const expand_xpm[]={ |
324 | "4 9 2 1", | 326 | "4 9 2 1", |
325 | "a c #408040", | 327 | "a c #408040", |
326 | ". c None", | 328 | ". c None", |
327 | "a...", | 329 | "a...", |
328 | "aa..", | 330 | "aa..", |
329 | "aaa.", | 331 | "aaa.", |
330 | "aaaa", | 332 | "aaaa", |
331 | "aaaa", | 333 | "aaaa", |
332 | "aaaa", | 334 | "aaaa", |
333 | "aaa.", | 335 | "aaa.", |
334 | "aa..", | 336 | "aa..", |
335 | "a..."}; | 337 | "a..."}; |
336 | /* XPM */ | 338 | /* XPM */ |
337 | #ifdef USE_SMALL_BACKSPACE | 339 | #ifdef USE_SMALL_BACKSPACE |
338 | static const char * const backspace_xpm[]={ | 340 | static const char * const backspace_xpm[]={ |
339 | "9 9 2 1", | 341 | "9 9 2 1", |
340 | "a c #000000", | 342 | "a c #000000", |
341 | ". c None", | 343 | ". c None", |
342 | ".........", | 344 | ".........", |
343 | ".........", | 345 | ".........", |
344 | "...a.....", | 346 | "...a.....", |
345 | "..aa.....", | 347 | "..aa.....", |
346 | ".aaaaaaaa", | 348 | ".aaaaaaaa", |
347 | "..aa.....", | 349 | "..aa.....", |
348 | "...a.....", | 350 | "...a.....", |
349 | ".........", | 351 | ".........", |
350 | "........."}; | 352 | "........."}; |
351 | #else | 353 | #else |
352 | static const char * const backspace_xpm[]={ | 354 | static const char * const backspace_xpm[]={ |
353 | "21 9 2 1", | 355 | "21 9 2 1", |
354 | "a c #000000", | 356 | "a c #000000", |
355 | ". c None", | 357 | ". c None", |
356 | ".....................", | 358 | ".....................", |
357 | ".....................", | 359 | ".....................", |
358 | ".....aaa..a..........", | 360 | ".....aaa..a..........", |
359 | ".a...a..a.a.a.aaa.aaa", | 361 | ".a...a..a.a.a.aaa.aaa", |
360 | "aaaa.aaa..aa..aa..a.a", | 362 | "aaaa.aaa..aa..aa..a.a", |
361 | ".a...a..a.aaa..aa.a.a", | 363 | ".a...a..a.aaa..aa.a.a", |
362 | ".....aaaa.a.a.aaa.aa.", | 364 | ".....aaaa.a.a.aaa.aa.", |
363 | "..................a..", | 365 | "..................a..", |
364 | "....................."}; | 366 | "....................."}; |
365 | #endif | 367 | #endif |
366 | /* XPM */ | 368 | /* XPM */ |
367 | static const char * const escape_xpm[]={ | 369 | static const char * const escape_xpm[]={ |
368 | "9 9 2 1", | 370 | "9 9 2 1", |
369 | "a c #000000", | 371 | "a c #000000", |
370 | ". c None", | 372 | ". c None", |
371 | ".........", | 373 | ".........", |
372 | ".........", | 374 | ".........", |
373 | ".aa.aa.aa", | 375 | ".aa.aa.aa", |
374 | ".a..a..a.", | 376 | ".a..a..a.", |
375 | ".aa.aa.a.", | 377 | ".aa.aa.a.", |
376 | ".a...a.a.", | 378 | ".a...a.a.", |
377 | ".aa.aa.aa", | 379 | ".aa.aa.aa", |
378 | ".........", | 380 | ".........", |
379 | "........."}; | 381 | "........."}; |
380 | 382 | ||
381 | 383 | ||
382 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, | 384 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, |
383 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, | 385 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, |
384 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, | 386 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, |
385 | Opti, ResetDict, | 387 | Opti, ResetDict, |
386 | Divide, Multiply, Add, Subtract, Decimal, Equal, | 388 | Divide, Multiply, Add, Subtract, Decimal, Equal, |
387 | Percent, Sqrt, Inverse, Escape }; | 389 | Percent, Sqrt, Inverse, Escape }; |
388 | 390 | ||
389 | typedef struct SpecialMap { | 391 | typedef struct SpecialMap { |
390 | int qcode; | 392 | int qcode; |
391 | ushort unicode; | 393 | ushort unicode; |
392 | const char * label; | 394 | const char * label; |
393 | const char * const * xpm; | 395 | const char * const * xpm; |
394 | }; | 396 | }; |
395 | 397 | ||
396 | 398 | ||
397 | static const SpecialMap specialM[] = { | 399 | static const SpecialMap specialM[] = { |
398 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, | 400 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, |
399 | { Qt::Key_Tab, 9,"Tab", NULL }, | 401 | { Qt::Key_Tab, 9,"Tab", NULL }, |
400 | { Qt::Key_CapsLock, 0,"Caps", NULL }, | 402 | { Qt::Key_CapsLock, 0,"Caps", NULL }, |
401 | { Qt::Key_Return, 13,"Ret", NULL }, | 403 | { Qt::Key_Return, 13,"Ret", NULL }, |
402 | { Qt::Key_Shift, 0,"Shift", NULL }, | 404 | { Qt::Key_Shift, 0,"Shift", NULL }, |
403 | { Qt::Key_Control, 0,"Ctrl", NULL }, | 405 | { Qt::Key_Control, 0,"Ctrl", NULL }, |
404 | { Qt::Key_Alt, 0,"Alt", NULL }, | 406 | { Qt::Key_Alt, 0,"Alt", NULL }, |
405 | { Qt::Key_Space, ' ',"", NULL }, | 407 | { Qt::Key_Space, ' ',"", NULL }, |
406 | { BackSlash, 43,"\\", NULL }, | 408 | { BackSlash, 43,"\\", NULL }, |
407 | 409 | ||
408 | // Need images? | 410 | // Need images? |
409 | { Qt::Key_Up, 0,"^", uparrow_xpm }, | 411 | { Qt::Key_Up, 0,"^", uparrow_xpm }, |
410 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, | 412 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, |
411 | { Qt::Key_Down, 0,"v", downarrow_xpm }, | 413 | { Qt::Key_Down, 0,"v", downarrow_xpm }, |
412 | { Qt::Key_Right, 0,">", rightarrow_xpm }, | 414 | { Qt::Key_Right, 0,">", rightarrow_xpm }, |
413 | { Qt::Key_Insert, 0,"I", insert_xpm }, | 415 | { Qt::Key_Insert, 0,"I", insert_xpm }, |
414 | { Qt::Key_Home, 0,"H", home_xpm }, | 416 | { Qt::Key_Home, 0,"H", home_xpm }, |
415 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, | 417 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, |
416 | { Qt::Key_End, 0,"E", end_xpm }, | 418 | { Qt::Key_End, 0,"E", end_xpm }, |
417 | { Qt::Key_Delete, 0,"X", delete_xpm }, | 419 | { Qt::Key_Delete, 0,"X", delete_xpm }, |
418 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, | 420 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, |
419 | { Blank, 0," ", NULL }, | 421 | { Blank, 0," ", NULL }, |
420 | { Expand, 0,"->", expand_xpm }, | 422 | { Expand, 0,"->", expand_xpm }, |
421 | { Opti, 0,"#", NULL }, | 423 | { Opti, 0,"#", NULL }, |
422 | { ResetDict, 0,"R", NULL }, | 424 | { ResetDict, 0,"R", NULL }, |
423 | 425 | ||
424 | // number pad stuff | 426 | // number pad stuff |
425 | { Divide, 0,"/", NULL }, | 427 | { Divide, 0,"/", NULL }, |
426 | { Multiply, 0,"*", NULL }, | 428 | { Multiply, 0,"*", NULL }, |
427 | { Add, 0,"+", NULL }, | 429 | { Add, 0,"+", NULL }, |
428 | { Subtract, 0,"-", NULL }, | 430 | { Subtract, 0,"-", NULL }, |
429 | { Decimal, 0,".", NULL }, | 431 | { Decimal, 0,".", NULL }, |
430 | { Equal, 0,"=", NULL }, | 432 | { Equal, 0,"=", NULL }, |
431 | { Percent, 0,"%", NULL }, | 433 | { Percent, 0,"%", NULL }, |
432 | { Sqrt, 0, "^1/2", NULL }, | 434 | { Sqrt, 0, "^1/2", NULL }, |
433 | { Inverse, 0, "1/x", NULL }, | 435 | { Inverse, 0, "1/x", NULL }, |
434 | 436 | ||
435 | { Escape, 27, "ESC", escape_xpm } | 437 | { Escape, 27, "ESC", escape_xpm } |
436 | }; | 438 | }; |
437 | 439 | ||
438 | 440 | ||
439 | static int keycode( int i2, int j, const uchar **keyboard ) | 441 | static int keycode( int i2, int j, const uchar **keyboard ) |
440 | { | 442 | { |
441 | if ( j <0 || j >= 5 ) | 443 | if ( j <0 || j >= 5 ) |
442 | return 0; | 444 | return 0; |
443 | 445 | ||
444 | const uchar *row = keyboard[j]; | 446 | const uchar *row = keyboard[j]; |
445 | 447 | ||
446 | while ( *row && *row <= i2 ) { | 448 | while ( *row && *row <= i2 ) { |
447 | i2 -= *row; | 449 | i2 -= *row; |
448 | row += 2; | 450 | row += 2; |
449 | } | 451 | } |
450 | 452 | ||
451 | if ( !*row ) return 0; | 453 | if ( !*row ) return 0; |
452 | 454 | ||
453 | int k; | 455 | int k; |
454 | if ( row[1] >= 0x80 ) { | 456 | if ( row[1] >= 0x80 ) { |
455 | k = row[1]; | 457 | k = row[1]; |
456 | } else { | 458 | } else { |
457 | k = row[1]+i2/2; | 459 | k = row[1]+i2/2; |
458 | } | 460 | } |
459 | 461 | ||
460 | return k; | 462 | return k; |
461 | } | 463 | } |
462 | 464 | ||
463 | 465 | ||
464 | /* | 466 | /* |
465 | return scancode and width of first key in row \a j if \a j >= 0, | 467 | return scancode and width of first key in row \a j if \a j >= 0, |
466 | or next key on current row if \a j < 0. | 468 | or next key on current row if \a j < 0. |
467 | 469 | ||
468 | */ | 470 | */ |
469 | 471 | ||
470 | int Keyboard::getKey( int &w, int j ) { | 472 | int Keyboard::getKey( int &w, int j ) { |
471 | static const uchar *row = 0; | 473 | static const uchar *row = 0; |
472 | static int key_i = 0; | 474 | static int key_i = 0; |
473 | static int scancode = 0; | 475 | static int scancode = 0; |
474 | static int half = 0; | 476 | static int half = 0; |
475 | 477 | ||
476 | if ( j >= 0 && j < 5 ) { | 478 | if ( j >= 0 && j < 5 ) { |
477 | if (useOptiKeys) | 479 | if (useOptiKeys) |
478 | row = keyboard_opti[j]; | 480 | row = keyboard_opti[j]; |
479 | else | 481 | else |
480 | row = keyboard_standard[j]; | 482 | row = keyboard_standard[j]; |
481 | half=0; | 483 | half=0; |
482 | } | 484 | } |
483 | 485 | ||
484 | if ( !row || !*row ) { | 486 | if ( !row || !*row ) { |
485 | return 0; | 487 | return 0; |
486 | } else if ( row[1] >= 0x80 ) { | 488 | } else if ( row[1] >= 0x80 ) { |
487 | scancode = row[1]; | 489 | scancode = row[1]; |
488 | w = (row[0] * w + (half++&1)) / 2; | 490 | w = (row[0] * w + (half++&1)) / 2; |
489 | row += 2; | 491 | row += 2; |
490 | return scancode; | 492 | return scancode; |
491 | } else if ( key_i <= 0 ) { | 493 | } else if ( key_i <= 0 ) { |
492 | key_i = row[0]/2; | 494 | key_i = row[0]/2; |
493 | scancode = row[1]; | 495 | scancode = row[1]; |
494 | } | 496 | } |
495 | key_i--; | 497 | key_i--; |
496 | if ( key_i <= 0 ) | 498 | if ( key_i <= 0 ) |
497 | row += 2; | 499 | row += 2; |
498 | return scancode++; | 500 | return scancode++; |
499 | } | 501 | } |
500 | 502 | ||
501 | 503 | ||
502 | void Keyboard::paintEvent(QPaintEvent* e) | 504 | void Keyboard::paintEvent(QPaintEvent* e) |
503 | { | 505 | { |
504 | QPainter painter(this); | 506 | QPainter painter(this); |
505 | painter.setClipRect(e->rect()); | 507 | painter.setClipRect(e->rect()); |
506 | drawKeyboard( painter ); | 508 | drawKeyboard( painter ); |
507 | picks->dc->draw( &painter ); | 509 | picks->dc->draw( &painter ); |
508 | } | 510 | } |
509 | 511 | ||
510 | 512 | ||
511 | /* | 513 | /* |
512 | Draw the keyboard. | 514 | Draw the keyboard. |
513 | 515 | ||
514 | If key >= 0, only the specified key is drawn. | 516 | If key >= 0, only the specified key is drawn. |
515 | */ | 517 | */ |
516 | void Keyboard::drawKeyboard( QPainter &p, int key ) | 518 | void Keyboard::drawKeyboard( QPainter &p, int key ) |
517 | { | 519 | { |
518 | const bool threeD = FALSE; | 520 | const bool threeD = FALSE; |
519 | const QColorGroup& cg = colorGroup(); | 521 | const QColorGroup& cg = colorGroup(); |
520 | QColor keycolor = // cg.background(); | 522 | QColor keycolor = // cg.background(); |
521 | QColor(240,240,230); // Beige! | 523 | QColor(240,240,230); // Beige! |
522 | QColor keycolor_pressed = cg.mid(); | 524 | QColor keycolor_pressed = cg.mid(); |
523 | QColor keycolor_lo = cg.dark(); | 525 | QColor keycolor_lo = cg.dark(); |
524 | QColor keycolor_hi = cg.light(); | 526 | QColor keycolor_hi = cg.light(); |
525 | QColor textcolor = QColor(0,0,0); // cg.text(); | 527 | QColor textcolor = QColor(0,0,0); // cg.text(); |
526 | 528 | ||
527 | int margin = threeD ? 1 : 0; | 529 | int margin = threeD ? 1 : 0; |
528 | 530 | ||
529 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); | 531 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); |
530 | 532 | ||
531 | for ( int j = 0; j < 5; j++ ) { | 533 | for ( int j = 0; j < 5; j++ ) { |
532 | int y = j * keyHeight + picks->height() + 1; | 534 | int y = j * keyHeight + picks->height() + 1; |
533 | int x = xoffs; | 535 | int x = xoffs; |
534 | int kw = defaultKeyWidth; | 536 | int kw = defaultKeyWidth; |
535 | int k= getKey( kw, j ); | 537 | int k= getKey( kw, j ); |
536 | while ( k ) { | 538 | while ( k ) { |
537 | if ( key < 0 || k == key ) { | 539 | if ( key < 0 || k == key ) { |
538 | QString s; | 540 | QString s; |
539 | bool pressed = (k == pressedKey); | 541 | bool pressed = (k == pressedKey); |
540 | bool blank = (k == 0223); | 542 | bool blank = (k == 0223); |
541 | const char * const * xpm = NULL; | 543 | const char * const * xpm = NULL; |
542 | 544 | ||
543 | if ( k >= 0x80 ) { | 545 | if ( k >= 0x80 ) { |
544 | s = specialM[k - 0x80].label; | 546 | s = specialM[k - 0x80].label; |
545 | 547 | ||
546 | xpm = specialM[k - 0x80].xpm; | 548 | xpm = specialM[k - 0x80].xpm; |
547 | 549 | ||
548 | if ( k == ShiftCode ) { | 550 | if ( k == ShiftCode ) { |
549 | pressed = shift; | 551 | pressed = shift; |
550 | } else if ( k == CapsCode ) { | 552 | } else if ( k == CapsCode ) { |
551 | pressed = lock; | 553 | pressed = lock; |
552 | } else if ( k == CtrlCode ) { | 554 | } else if ( k == CtrlCode ) { |
553 | pressed = ctrl; | 555 | pressed = ctrl; |
554 | } else if ( k == AltCode ) { | 556 | } else if ( k == AltCode ) { |
555 | pressed = alt; | 557 | pressed = alt; |
556 | } | 558 | } |
557 | } else { | 559 | } else { |
558 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 560 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
559 | /* | 561 | /* |
560 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : | 562 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : |
561 | QWSServer::keyMap()[k].unicode); | 563 | QWSServer::keyMap()[k].unicode); |
562 | */ | 564 | */ |
563 | // ### Fixme, bad code, needs improving, whole thing needs to | 565 | // ### Fixme, bad code, needs improving, whole thing needs to |
564 | // be re-coded to get rid of the way it did things with scancodes etc | 566 | // be re-coded to get rid of the way it did things with scancodes etc |
565 | char shifted = k; | 567 | char shifted = k; |
566 | if ( !isalpha( k ) ) { | 568 | if ( !isalpha( k ) ) { |
567 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 569 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
568 | if ( shiftMap[i].normal == k ) | 570 | if ( shiftMap[i].normal == k ) |
569 | shifted = shiftMap[i].shifted; | 571 | shifted = shiftMap[i].shifted; |
570 | } else { | 572 | } else { |
571 | shifted = toupper( k ); | 573 | shifted = toupper( k ); |
572 | } | 574 | } |
573 | s = QChar( shift^lock ? shifted : k ); | 575 | s = QChar( shift^lock ? shifted : k ); |
574 | #endif | 576 | #endif |
575 | } | 577 | } |
576 | 578 | ||
577 | if (!blank) { | 579 | if (!blank) { |
578 | if ( pressed ) | 580 | if ( pressed ) |
579 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); | 581 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); |
580 | else | 582 | else |
581 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); | 583 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); |
582 | 584 | ||
583 | if ( threeD ) { | 585 | if ( threeD ) { |
584 | p.setPen(pressed ? keycolor_lo : keycolor_hi); | 586 | p.setPen(pressed ? keycolor_lo : keycolor_hi); |
585 | p.drawLine( x, y+1, x, y+keyHeight-2 ); | 587 | p.drawLine( x, y+1, x, y+keyHeight-2 ); |
586 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); | 588 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); |
587 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); | 589 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); |
588 | } else if ( j == 0 ) { | 590 | } else if ( j == 0 ) { |
589 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 591 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
590 | p.drawLine( x, y, x+kw, y ); | 592 | p.drawLine( x, y, x+kw, y ); |
591 | } | 593 | } |
592 | 594 | ||
593 | // right | 595 | // right |
594 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 596 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
595 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); | 597 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); |
596 | 598 | ||
597 | if ( threeD ) { | 599 | if ( threeD ) { |
598 | p.setPen(keycolor_lo.light()); | 600 | p.setPen(keycolor_lo.light()); |
599 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); | 601 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); |
600 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); | 602 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); |
601 | } | 603 | } |
602 | 604 | ||
603 | if (xpm) { | 605 | if (xpm) { |
604 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); | 606 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); |
605 | } else { | 607 | } else { |
606 | p.setPen(textcolor); | 608 | p.setPen(textcolor); |
607 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); | 609 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); |
608 | } | 610 | } |
609 | 611 | ||
610 | if ( threeD ) { | 612 | if ( threeD ) { |
611 | p.setPen(keycolor_hi); | 613 | p.setPen(keycolor_hi); |
612 | p.drawLine( x, y, x+kw-1, y ); | 614 | p.drawLine( x, y, x+kw-1, y ); |
613 | } | 615 | } |
614 | 616 | ||
615 | // bottom | 617 | // bottom |
616 | p.setPen(keycolor_lo); | 618 | p.setPen(keycolor_lo); |
617 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); | 619 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); |
618 | 620 | ||
619 | } else { | 621 | } else { |
620 | p.fillRect( x, y, kw, keyHeight, cg.background() ); | 622 | p.fillRect( x, y, kw, keyHeight, cg.background() ); |
621 | } | 623 | } |
622 | } | 624 | } |
623 | 625 | ||
624 | x += kw; | 626 | x += kw; |
625 | kw = defaultKeyWidth; | 627 | kw = defaultKeyWidth; |
626 | k = getKey( kw ); | 628 | k = getKey( kw ); |
627 | } | 629 | } |
628 | } | 630 | } |
629 | } | 631 | } |
630 | 632 | ||
631 | 633 | ||
632 | void Keyboard::mousePressEvent(QMouseEvent *e) | 634 | void Keyboard::mousePressEvent(QMouseEvent *e) |
633 | { | 635 | { |
634 | clearHighlight(); // typing fast? | 636 | clearHighlight(); // typing fast? |
635 | 637 | ||
636 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; | 638 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; |
637 | int j = (e->y() - picks->height()) / keyHeight; | 639 | int j = (e->y() - picks->height()) / keyHeight; |
638 | 640 | ||
639 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); | 641 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); |
640 | bool need_repaint = FALSE; | 642 | bool need_repaint = FALSE; |
641 | unicode = -1; | 643 | unicode = -1; |
642 | qkeycode = 0; | 644 | qkeycode = 0; |
643 | if ( k >= 0x80 ) { | 645 | if ( k >= 0x80 ) { |
644 | if ( k == ShiftCode ) { | 646 | if ( k == ShiftCode ) { |
645 | shift = !shift; | 647 | shift = !shift; |
646 | need_repaint = TRUE; | 648 | need_repaint = TRUE; |
647 | } else if ( k == AltCode ){ | 649 | } else if ( k == AltCode ){ |
648 | alt = !alt; | 650 | alt = !alt; |
649 | need_repaint = TRUE; | 651 | need_repaint = TRUE; |
650 | } else if ( k == CapsCode ) { | 652 | } else if ( k == CapsCode ) { |
651 | lock = !lock; | 653 | lock = !lock; |
652 | need_repaint = TRUE; | 654 | need_repaint = TRUE; |
653 | } else if ( k == CtrlCode ) { | 655 | } else if ( k == CtrlCode ) { |
654 | ctrl = !ctrl; | 656 | ctrl = !ctrl; |
655 | need_repaint = TRUE; | 657 | need_repaint = TRUE; |
656 | } else if ( k == 0224 /* Expand */ ) { | 658 | } else if ( k == 0224 /* Expand */ ) { |
657 | useLargeKeys = !useLargeKeys; | 659 | useLargeKeys = !useLargeKeys; |
658 | resizeEvent(0); | 660 | resizeEvent(0); |
659 | repaint( TRUE ); // need it to clear first | 661 | repaint( TRUE ); // need it to clear first |
660 | } else if ( k == 0225 /* Opti/Toggle */ ) { | 662 | } else if ( k == 0225 /* Opti/Toggle */ ) { |
661 | useOptiKeys = !useOptiKeys; | 663 | useOptiKeys = !useOptiKeys; |
662 | resizeEvent(0); | 664 | resizeEvent(0); |
663 | repaint( TRUE ); // need it to clear first | 665 | repaint( TRUE ); // need it to clear first |
664 | } else { | 666 | } else { |
665 | qkeycode = specialM[ k - 0x80 ].qcode; | 667 | qkeycode = specialM[ k - 0x80 ].qcode; |
666 | unicode = specialM[ k - 0x80 ].unicode; | 668 | unicode = specialM[ k - 0x80 ].unicode; |
667 | } | 669 | } |
668 | } else { | 670 | } else { |
669 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 671 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
670 | /* | 672 | /* |
671 | qk = QWSServer::keyMap()[k].key_code; | 673 | qk = QWSServer::keyMap()[k].key_code; |
672 | if ( qk != Key_unknown ) { | 674 | if ( qk != Key_unknown ) { |
673 | if ( ctrl ) | 675 | if ( ctrl ) |
674 | u = QWSServer::keyMap()[k].ctrl_unicode; | 676 | u = QWSServer::keyMap()[k].ctrl_unicode; |
675 | else if ( shift^lock ) | 677 | else if ( shift^lock ) |
676 | u = QWSServer::keyMap()[k].shift_unicode; | 678 | u = QWSServer::keyMap()[k].shift_unicode; |
677 | else | 679 | else |
678 | u = QWSServer::keyMap()[k].unicode; | 680 | u = QWSServer::keyMap()[k].unicode; |
679 | } | 681 | } |
680 | */ | 682 | */ |
681 | char shifted = k; | 683 | char shifted = k; |
682 | if ( !isalpha( k ) ) { | 684 | if ( !isalpha( k ) ) { |
683 | // ### Fixme, bad code, needs improving, whole thing needs to | 685 | // ### Fixme, bad code, needs improving, whole thing needs to |
684 | // be re-coded to get rid of the way it did things with scancodes etc | 686 | // be re-coded to get rid of the way it did things with scancodes etc |
685 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 687 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
686 | if ( shiftMap[i].normal == k ) | 688 | if ( shiftMap[i].normal == k ) |
687 | shifted = shiftMap[i].shifted; | 689 | shifted = shiftMap[i].shifted; |
688 | } else { | 690 | } else { |
689 | shifted = toupper( k ); | 691 | shifted = toupper( k ); |
690 | } | 692 | } |
691 | QChar tempChar( shift^lock ? shifted : k ); | 693 | QChar tempChar( shift^lock ? shifted : k ); |
692 | unicode = tempChar.unicode(); | 694 | unicode = tempChar.unicode(); |
693 | #endif | 695 | #endif |
694 | } | 696 | } |
695 | if ( unicode != -1 ) { | 697 | if ( unicode != -1 ) { |
696 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | | 698 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | |
697 | (alt ? Qt::AltButton : 0); | 699 | (alt ? Qt::AltButton : 0); |
698 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 700 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
699 | emit key( unicode, qkeycode, modifiers, true, false ); | 701 | emit key( unicode, qkeycode, modifiers, true, false ); |
700 | repeatTimer->start( 500 ); | 702 | repeatTimer->start( 500 ); |
701 | #endif | 703 | #endif |
702 | need_repaint = shift || alt || ctrl; | 704 | need_repaint = shift || alt || ctrl; |
703 | shift = alt = ctrl = FALSE; | 705 | shift = alt = ctrl = FALSE; |
704 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); | 706 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); |
705 | 707 | ||
706 | KeyboardConfig *dc = picks->dc; | 708 | KeyboardConfig *dc = picks->dc; |
707 | 709 | ||
708 | if (dc) { | 710 | if (dc) { |
709 | if (qkeycode == Qt::Key_Backspace) { | 711 | if (qkeycode == Qt::Key_Backspace) { |
710 | dc->input.remove(dc->input.last()); // remove last input | 712 | dc->input.remove(dc->input.last()); // remove last input |
711 | dc->decBackspaces(); | 713 | dc->decBackspaces(); |
712 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || | 714 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || |
713 | qkeycode == Qt::Key_Space || | 715 | qkeycode == Qt::Key_Space || |
714 | QChar(unicode).isPunct() ) { | 716 | QChar(unicode).isPunct() ) { |
715 | dc->input.clear(); | 717 | dc->input.clear(); |
716 | dc->resetBackspaces(); | 718 | dc->resetBackspaces(); |
717 | } else { | 719 | } else { |
718 | dc->add(QString(QChar(unicode))); | 720 | dc->add(QString(QChar(unicode))); |
719 | dc->incBackspaces(); | 721 | dc->incBackspaces(); |
720 | } | 722 | } |
721 | } | 723 | } |
722 | 724 | ||
723 | picks->repaint(); | 725 | picks->repaint(); |
724 | 726 | ||
725 | } | 727 | } |
726 | pressedKey = k; | 728 | pressedKey = k; |
727 | if ( need_repaint ) { | 729 | if ( need_repaint ) { |
728 | repaint( FALSE ); | 730 | repaint( FALSE ); |
729 | } else { | 731 | } else { |
730 | QPainter p(this); | 732 | QPainter p(this); |
731 | drawKeyboard( p, pressedKey ); | 733 | drawKeyboard( p, pressedKey ); |
732 | } | 734 | } |
733 | pressTid = startTimer(80); | 735 | pressTid = startTimer(80); |
734 | pressed = TRUE; | 736 | pressed = TRUE; |
735 | } | 737 | } |
736 | 738 | ||
737 | 739 | ||
738 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 740 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
739 | { | 741 | { |
740 | if ( pressTid == 0 ) | 742 | if ( pressTid == 0 ) |
741 | clearHighlight(); | 743 | clearHighlight(); |
742 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 744 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
743 | if ( unicode != -1 ) { | 745 | if ( unicode != -1 ) { |
744 | emit key( unicode, qkeycode, modifiers, false, false ); | 746 | emit key( unicode, qkeycode, modifiers, false, false ); |
745 | repeatTimer->stop(); | 747 | repeatTimer->stop(); |
746 | } | 748 | } |
747 | #endif | 749 | #endif |
748 | pressed = FALSE; | 750 | pressed = FALSE; |
749 | } | 751 | } |
750 | 752 | ||
751 | void Keyboard::timerEvent(QTimerEvent* e) | 753 | void Keyboard::timerEvent(QTimerEvent* e) |
752 | { | 754 | { |
753 | if ( e->timerId() == pressTid ) { | 755 | if ( e->timerId() == pressTid ) { |
754 | killTimer(pressTid); | 756 | killTimer(pressTid); |
755 | pressTid = 0; | 757 | pressTid = 0; |
756 | if ( !pressed ) | 758 | if ( !pressed ) |
757 | clearHighlight(); | 759 | clearHighlight(); |
758 | } | 760 | } |
759 | } | 761 | } |
760 | 762 | ||
761 | void Keyboard::repeat() | 763 | void Keyboard::repeat() |
762 | { | 764 | { |
763 | repeatTimer->start( 150 ); | 765 | repeatTimer->start( 150 ); |
764 | emit key( unicode, qkeycode, modifiers, true, true ); | 766 | emit key( unicode, qkeycode, modifiers, true, true ); |
765 | } | 767 | } |
766 | 768 | ||
767 | void Keyboard::clearHighlight() | 769 | void Keyboard::clearHighlight() |
768 | { | 770 | { |
769 | if ( pressedKey >= 0 ) { | 771 | if ( pressedKey >= 0 ) { |
770 | int tmp = pressedKey; | 772 | int tmp = pressedKey; |
771 | pressedKey = -1; | 773 | pressedKey = -1; |
772 | QPainter p(this); | 774 | QPainter p(this); |
773 | drawKeyboard( p, tmp ); | 775 | drawKeyboard( p, tmp ); |
774 | } | 776 | } |
775 | } | 777 | } |
776 | 778 | ||
777 | 779 | ||
778 | QSize Keyboard::sizeHint() const | 780 | QSize Keyboard::sizeHint() const |
779 | { | 781 | { |
780 | QFontMetrics fm=fontMetrics(); | 782 | QFontMetrics fm=fontMetrics(); |
781 | int keyHeight = fm.lineSpacing()+2; | 783 | int keyHeight = fm.lineSpacing()+2; |
782 | 784 | ||
783 | if (useOptiKeys) | 785 | if (useOptiKeys) |
784 | keyHeight += 1; | 786 | keyHeight += 1; |
785 | 787 | ||
786 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); | 788 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); |
787 | } | 789 | } |
788 | 790 | ||
789 | 791 | ||
790 | void Keyboard::resetState() | 792 | void Keyboard::resetState() |
791 | { | 793 | { |
792 | picks->resetState(); | 794 | picks->resetState(); |
793 | } | 795 | } |
diff --git a/inputmethods/dvorak/dvorak.h b/inputmethods/dvorak/dvorak.h index 38ae338..216b5e5 100644 --- a/inputmethods/dvorak/dvorak.h +++ b/inputmethods/dvorak/dvorak.h | |||
@@ -1,103 +1,107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include "../pickboard/pickboardcfg.h" | 21 | #include "../pickboard/pickboardcfg.h" |
22 | #include "../pickboard/pickboardpicks.h" | 22 | #include "../pickboard/pickboardpicks.h" |
23 | 23 | ||
24 | class QTimer; | 24 | class QTimer; |
25 | 25 | ||
26 | namespace Dvorak | ||
27 | { | ||
28 | |||
26 | class KeyboardConfig : public DictFilterConfig | 29 | class KeyboardConfig : public DictFilterConfig |
27 | { | 30 | { |
28 | public: | 31 | public: |
29 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 32 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
30 | virtual void generateText(const QString &s); | 33 | virtual void generateText(const QString &s); |
31 | void decBackspaces() { if (backspaces) backspaces--; } | 34 | void decBackspaces() { if (backspaces) backspaces--; } |
32 | void incBackspaces() { backspaces++; } | 35 | void incBackspaces() { backspaces++; } |
33 | void resetBackspaces() { backspaces = 0; } | 36 | void resetBackspaces() { backspaces = 0; } |
34 | private: | 37 | private: |
35 | int backspaces; | 38 | int backspaces; |
36 | }; | 39 | }; |
37 | 40 | ||
38 | 41 | ||
39 | class KeyboardPicks : public PickboardPicks | 42 | class KeyboardPicks : public PickboardPicks |
40 | { | 43 | { |
41 | Q_OBJECT | 44 | Q_OBJECT |
42 | public: | 45 | public: |
43 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 46 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
44 | : PickboardPicks(parent, name, f) { } | 47 | : PickboardPicks(parent, name, f) { } |
45 | void initialise(); | 48 | void initialise(); |
46 | virtual QSize sizeHint() const; | 49 | virtual QSize sizeHint() const; |
47 | KeyboardConfig *dc; | 50 | KeyboardConfig *dc; |
48 | }; | 51 | }; |
49 | 52 | ||
50 | class Keyboard : public QFrame | 53 | class Keyboard : public QFrame |
51 | { | 54 | { |
52 | Q_OBJECT | 55 | Q_OBJECT |
53 | public: | 56 | public: |
54 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 57 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
55 | 58 | ||
56 | void resetState(); | 59 | void resetState(); |
57 | 60 | ||
58 | void mousePressEvent(QMouseEvent*); | 61 | void mousePressEvent(QMouseEvent*); |
59 | void mouseReleaseEvent(QMouseEvent*); | 62 | void mouseReleaseEvent(QMouseEvent*); |
60 | void resizeEvent(QResizeEvent*); | 63 | void resizeEvent(QResizeEvent*); |
61 | void paintEvent(QPaintEvent* e); | 64 | void paintEvent(QPaintEvent* e); |
62 | void timerEvent(QTimerEvent* e); | 65 | void timerEvent(QTimerEvent* e); |
63 | void drawKeyboard( QPainter &p, int key = -1 ); | 66 | void drawKeyboard( QPainter &p, int key = -1 ); |
64 | 67 | ||
65 | void setMode(int mode) { useOptiKeys = mode; } | 68 | void setMode(int mode) { useOptiKeys = mode; } |
66 | 69 | ||
67 | QSize sizeHint() const; | 70 | QSize sizeHint() const; |
68 | 71 | ||
69 | signals: | 72 | signals: |
70 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 73 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
71 | 74 | ||
72 | private slots: | 75 | private slots: |
73 | void repeat(); | 76 | void repeat(); |
74 | 77 | ||
75 | private: | 78 | private: |
76 | int getKey( int &w, int j = -1 ); | 79 | int getKey( int &w, int j = -1 ); |
77 | void clearHighlight(); | 80 | void clearHighlight(); |
78 | 81 | ||
79 | uint shift:1; | 82 | uint shift:1; |
80 | uint lock:1; | 83 | uint lock:1; |
81 | uint ctrl:1; | 84 | uint ctrl:1; |
82 | uint alt:1; | 85 | uint alt:1; |
83 | uint useLargeKeys:1; | 86 | uint useLargeKeys:1; |
84 | uint useOptiKeys:1; | 87 | uint useOptiKeys:1; |
85 | 88 | ||
86 | int pressedKey; | 89 | int pressedKey; |
87 | 90 | ||
88 | KeyboardPicks *picks; | 91 | KeyboardPicks *picks; |
89 | 92 | ||
90 | int keyHeight; | 93 | int keyHeight; |
91 | int defaultKeyWidth; | 94 | int defaultKeyWidth; |
92 | int xoffs; | 95 | int xoffs; |
93 | 96 | ||
94 | int unicode; | 97 | int unicode; |
95 | int qkeycode; | 98 | int qkeycode; |
96 | int modifiers; | 99 | int modifiers; |
97 | 100 | ||
98 | int pressTid; | 101 | int pressTid; |
99 | bool pressed; | 102 | bool pressed; |
100 | 103 | ||
101 | QTimer *repeatTimer; | 104 | QTimer *repeatTimer; |
102 | }; | 105 | }; |
103 | 106 | ||
107 | } // namespace Dvorak | ||
diff --git a/inputmethods/dvorak/dvorakimpl.cpp b/inputmethods/dvorak/dvorakimpl.cpp index 3c83464..8050ce1 100644 --- a/inputmethods/dvorak/dvorakimpl.cpp +++ b/inputmethods/dvorak/dvorakimpl.cpp | |||
@@ -1,130 +1,130 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include "dvorak.h" | 22 | #include "dvorak.h" |
23 | #include "dvorakimpl.h" | 23 | #include "dvorakimpl.h" |
24 | 24 | ||
25 | /* XPM */ | 25 | /* XPM */ |
26 | static const char * kb_xpm[] = { | 26 | static const char * const kb_xpm[] = { |
27 | "28 13 4 1", | 27 | "28 13 4 1", |
28 | " c None", | 28 | " c None", |
29 | ". c #4C4C4C", | 29 | ". c #4C4C4C", |
30 | "+ c #FFF7DD", | 30 | "+ c #FFF7DD", |
31 | "@ c #D6CFBA", | 31 | "@ c #D6CFBA", |
32 | " .......................... ", | 32 | " .......................... ", |
33 | " .+++.+++.+++.+++.+++.++++. ", | 33 | " .+++.+++.+++.+++.+++.++++. ", |
34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", | 34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", |
35 | " .......................... ", | 35 | " .......................... ", |
36 | " .+++++.+++.+++.+++.++++++. ", | 36 | " .+++++.+++.+++.+++.++++++. ", |
37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", | 37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", |
38 | " .......................... ", | 38 | " .......................... ", |
39 | " .++++++.+++.+++.+++.+++++. ", | 39 | " .++++++.+++.+++.+++.+++++. ", |
40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", | 40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", |
41 | " .......................... ", | 41 | " .......................... ", |
42 | " .++++.++++++++++++++.++++. ", | 42 | " .++++.++++++++++++++.++++. ", |
43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", | 43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", |
44 | " .......................... "}; | 44 | " .......................... "}; |
45 | 45 | ||
46 | 46 | ||
47 | /* XPM */ | 47 | /* XPM */ |
48 | static char * opti_xpm[] = { | 48 | static const char * const opti_xpm[] = { |
49 | "28 13 4 1", | 49 | "28 13 4 1", |
50 | " c None", | 50 | " c None", |
51 | ". c #4C4C4C", | 51 | ". c #4C4C4C", |
52 | "+ c #FFF7DD", | 52 | "+ c #FFF7DD", |
53 | "@ c #D6CFBA", | 53 | "@ c #D6CFBA", |
54 | " ......................... ", | 54 | " ......................... ", |
55 | " .+++.+++.+++.+++.+++.+++. ", | 55 | " .+++.+++.+++.+++.+++.+++. ", |
56 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 56 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
57 | " ......................... ", | 57 | " ......................... ", |
58 | " .+++.+++.+++.+++.+++.+++. ", | 58 | " .+++.+++.+++.+++.+++.+++. ", |
59 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 59 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
60 | " ......................... ", | 60 | " ......................... ", |
61 | " .+++.+++.+++.+++.+++.+++. ", | 61 | " .+++.+++.+++.+++.+++.+++. ", |
62 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 62 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
63 | " ......................... ", | 63 | " ......................... ", |
64 | " .+++.+++.+++.+++.+++.+++. ", | 64 | " .+++.+++.+++.+++.+++.+++. ", |
65 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 65 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
66 | " ......................... "}; | 66 | " ......................... "}; |
67 | 67 | ||
68 | 68 | ||
69 | 69 | ||
70 | KeyboardImpl::KeyboardImpl() | 70 | KeyboardImpl::KeyboardImpl() |
71 | : input(0), icn(0), ref(0) | 71 | : input(0), icn(0), ref(0) |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | KeyboardImpl::~KeyboardImpl() | 75 | KeyboardImpl::~KeyboardImpl() |
76 | { | 76 | { |
77 | delete input; | 77 | delete input; |
78 | delete icn; | 78 | delete icn; |
79 | } | 79 | } |
80 | 80 | ||
81 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 81 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
82 | { | 82 | { |
83 | if ( !input ) | 83 | if ( !input ) |
84 | input = new Keyboard( parent, "Keyboard", f ); | 84 | input = new Dvorak::Keyboard( parent, "Keyboard", f ); |
85 | return input; | 85 | return input; |
86 | } | 86 | } |
87 | 87 | ||
88 | void KeyboardImpl::resetState() | 88 | void KeyboardImpl::resetState() |
89 | { | 89 | { |
90 | if ( input ) | 90 | if ( input ) |
91 | input->resetState(); | 91 | input->resetState(); |
92 | } | 92 | } |
93 | 93 | ||
94 | QPixmap *KeyboardImpl::icon() | 94 | QPixmap *KeyboardImpl::icon() |
95 | { | 95 | { |
96 | if ( !icn ) | 96 | if ( !icn ) |
97 | icn = new QPixmap( (const char **)kb_xpm ); | 97 | icn = new QPixmap( (const char **)kb_xpm ); |
98 | return icn; | 98 | return icn; |
99 | } | 99 | } |
100 | 100 | ||
101 | QString KeyboardImpl::name() | 101 | QString KeyboardImpl::name() |
102 | { | 102 | { |
103 | return qApp->translate( "InputMethods", "Dvorak" ); | 103 | return qApp->translate( "InputMethods", "Dvorak" ); |
104 | } | 104 | } |
105 | 105 | ||
106 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 106 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
107 | { | 107 | { |
108 | if ( input ) | 108 | if ( input ) |
109 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 109 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
110 | } | 110 | } |
111 | 111 | ||
112 | #ifndef QT_NO_COMPONENT | 112 | #ifndef QT_NO_COMPONENT |
113 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 113 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
114 | { | 114 | { |
115 | *iface = 0; | 115 | *iface = 0; |
116 | if ( uuid == IID_QUnknown ) | 116 | if ( uuid == IID_QUnknown ) |
117 | *iface = this; | 117 | *iface = this; |
118 | else if ( uuid == IID_InputMethod ) | 118 | else if ( uuid == IID_InputMethod ) |
119 | *iface = this; | 119 | *iface = this; |
120 | 120 | ||
121 | if ( *iface ) | 121 | if ( *iface ) |
122 | (*iface)->addRef(); | 122 | (*iface)->addRef(); |
123 | return QS_OK; | 123 | return QS_OK; |
124 | } | 124 | } |
125 | 125 | ||
126 | Q_EXPORT_INTERFACE() | 126 | Q_EXPORT_INTERFACE() |
127 | { | 127 | { |
128 | Q_CREATE_INSTANCE( KeyboardImpl ) | 128 | Q_CREATE_INSTANCE( KeyboardImpl ) |
129 | } | 129 | } |
130 | #endif | 130 | #endif |
diff --git a/inputmethods/dvorak/dvorakimpl.h b/inputmethods/dvorak/dvorakimpl.h index e756364..bd9fa88 100644 --- a/inputmethods/dvorak/dvorakimpl.h +++ b/inputmethods/dvorak/dvorakimpl.h | |||
@@ -1,51 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef KEYBOARDIMPL_H | 20 | #ifndef KEYBOARDIMPL_H |
21 | #define KEYBOARDIMPL_H | 21 | #define KEYBOARDIMPL_H |
22 | 22 | ||
23 | #include <qpe/inputmethodinterface.h> | 23 | #include <qpe/inputmethodinterface.h> |
24 | 24 | ||
25 | class Keyboard; | 25 | namespace Dvorak |
26 | { | ||
27 | class Keyboard; | ||
28 | } | ||
29 | |||
26 | class QPixmap; | 30 | class QPixmap; |
27 | 31 | ||
32 | namespace | ||
33 | { | ||
34 | |||
28 | class KeyboardImpl : public InputMethodInterface | 35 | class KeyboardImpl : public InputMethodInterface |
29 | { | 36 | { |
30 | public: | 37 | public: |
31 | KeyboardImpl(); | 38 | KeyboardImpl(); |
32 | virtual ~KeyboardImpl(); | 39 | virtual ~KeyboardImpl(); |
33 | 40 | ||
34 | #ifndef QT_NO_COMPONENT | 41 | #ifndef QT_NO_COMPONENT |
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
36 | Q_REFCOUNT | 43 | Q_REFCOUNT |
37 | #endif | 44 | #endif |
38 | 45 | ||
39 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | 46 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); |
40 | virtual void resetState(); | 47 | virtual void resetState(); |
41 | virtual QPixmap *icon(); | 48 | virtual QPixmap *icon(); |
42 | virtual QString name(); | 49 | virtual QString name(); |
43 | virtual void onKeyPress( QObject *receiver, const char *slot ); | 50 | virtual void onKeyPress( QObject *receiver, const char *slot ); |
44 | 51 | ||
45 | private: | 52 | private: |
46 | Keyboard *input; | 53 | Dvorak::Keyboard *input; |
47 | QPixmap *icn; | 54 | QPixmap *icn; |
48 | ulong ref; | 55 | ulong ref; |
49 | }; | 56 | }; |
50 | 57 | ||
58 | } // anonymous namespace | ||
59 | |||
51 | #endif | 60 | #endif |
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 |
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp index 0f0b188..a85a7b1 100644 --- a/inputmethods/keyboard/keyboard.cpp +++ b/inputmethods/keyboard/keyboard.cpp | |||
@@ -1,809 +1,810 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | #include <sys/utsname.h> | 31 | #include <sys/utsname.h> |
32 | 32 | ||
33 | using namespace KeyboardInput; | ||
33 | 34 | ||
34 | #define USE_SMALL_BACKSPACE | 35 | #define USE_SMALL_BACKSPACE |
35 | 36 | ||
36 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 37 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
37 | QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), | 38 | QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), |
38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), | 39 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), |
39 | unicode(-1), qkeycode(0), modifiers(0) | 40 | unicode(-1), qkeycode(0), modifiers(0) |
40 | { | 41 | { |
41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! | 42 | // setPalette(QPalette(QColor(240,240,230))); // Beige! |
42 | // setFont( QFont( "Helvetica", 8 ) ); | 43 | // setFont( QFont( "Helvetica", 8 ) ); |
43 | // setPalette(QPalette(QColor(200,200,200))); // Gray | 44 | // setPalette(QPalette(QColor(200,200,200))); // Gray |
44 | setPalette(QPalette(QColor(220,220,220))); // Gray | 45 | setPalette(QPalette(QColor(220,220,220))); // Gray |
45 | 46 | ||
46 | picks = new KeyboardPicks( this ); | 47 | picks = new KeyboardPicks( this ); |
47 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 48 | picks->setFont( QFont( "smallsmooth", 9 ) ); |
48 | setFont( QFont( "smallsmooth", 9 ) ); | 49 | setFont( QFont( "smallsmooth", 9 ) ); |
49 | picks->initialise(); | 50 | picks->initialise(); |
50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 51 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 52 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
52 | 53 | ||
53 | repeatTimer = new QTimer( this ); | 54 | repeatTimer = new QTimer( this ); |
54 | 55 | ||
55 | // temporary quick and dirty fix for the "sticky keyboard bug" | 56 | // temporary quick and dirty fix for the "sticky keyboard bug" |
56 | // on ipaq. | 57 | // on ipaq. |
57 | // struct utsname name; | 58 | // struct utsname name; |
58 | // if (uname(&name) != -1) | 59 | // if (uname(&name) != -1) |
59 | // { | 60 | // { |
60 | //QString release=name.release; | 61 | //QString release=name.release; |
61 | //qWarning("System release: %s\n", name.release); | 62 | //qWarning("System release: %s\n", name.release); |
62 | //if(release.find("embedix",0,TRUE) !=-1) | 63 | //if(release.find("embedix",0,TRUE) !=-1) |
63 | // { | 64 | // { |
64 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 65 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
65 | // } | 66 | // } |
66 | // } | 67 | // } |
67 | } | 68 | } |
68 | 69 | ||
69 | void Keyboard::resizeEvent(QResizeEvent*) | 70 | void Keyboard::resizeEvent(QResizeEvent*) |
70 | { | 71 | { |
71 | int ph = picks->sizeHint().height(); | 72 | int ph = picks->sizeHint().height(); |
72 | picks->setGeometry( 0, 0, width(), ph ); | 73 | picks->setGeometry( 0, 0, width(), ph ); |
73 | keyHeight = (height()-ph)/5; | 74 | keyHeight = (height()-ph)/5; |
74 | int nk; | 75 | int nk; |
75 | if ( useOptiKeys ) { | 76 | if ( useOptiKeys ) { |
76 | nk = 15; | 77 | nk = 15; |
77 | } else if ( useLargeKeys ) { | 78 | } else if ( useLargeKeys ) { |
78 | nk = 15; | 79 | nk = 15; |
79 | } else { | 80 | } else { |
80 | nk = 19; | 81 | nk = 19; |
81 | } | 82 | } |
82 | defaultKeyWidth = width()/nk; | 83 | defaultKeyWidth = width()/nk; |
83 | xoffs = (width()-defaultKeyWidth*nk)/2; | 84 | xoffs = (width()-defaultKeyWidth*nk)/2; |
84 | } | 85 | } |
85 | 86 | ||
86 | void KeyboardPicks::initialise() | 87 | void KeyboardPicks::initialise() |
87 | { | 88 | { |
88 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 89 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
89 | mode = 0; | 90 | mode = 0; |
90 | dc = new KeyboardConfig(this); | 91 | dc = new KeyboardConfig(this); |
91 | configs.append(dc); | 92 | configs.append(dc); |
92 | } | 93 | } |
93 | 94 | ||
94 | QSize KeyboardPicks::sizeHint() const | 95 | QSize KeyboardPicks::sizeHint() const |
95 | { | 96 | { |
96 | return QSize(240,fontMetrics().lineSpacing()); | 97 | return QSize(240,fontMetrics().lineSpacing()); |
97 | } | 98 | } |
98 | 99 | ||
99 | 100 | ||
100 | void KeyboardConfig::generateText(const QString &s) | 101 | void KeyboardConfig::generateText(const QString &s) |
101 | { | 102 | { |
102 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 103 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
103 | for (int i=0; i<(int)backspaces; i++) { | 104 | for (int i=0; i<(int)backspaces; i++) { |
104 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 105 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
105 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 106 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
106 | } | 107 | } |
107 | for (int i=0; i<(int)s.length(); i++) { | 108 | for (int i=0; i<(int)s.length(); i++) { |
108 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 109 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
109 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 110 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
110 | } | 111 | } |
111 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 112 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
112 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 113 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
113 | backspaces = 0; | 114 | backspaces = 0; |
114 | #endif | 115 | #endif |
115 | } | 116 | } |
116 | 117 | ||
117 | 118 | ||
118 | //PC keyboard layout and scancodes | 119 | //PC keyboard layout and scancodes |
119 | 120 | ||
120 | /* | 121 | /* |
121 | Format: length, code, length, code, ..., 0 | 122 | Format: length, code, length, code, ..., 0 |
122 | 123 | ||
123 | length is measured in half the width of a standard key. | 124 | length is measured in half the width of a standard key. |
124 | If code < 0x80 we have length/2 consecutive standard keys, | 125 | If code < 0x80 we have length/2 consecutive standard keys, |
125 | starting with scancode code. | 126 | starting with scancode code. |
126 | 127 | ||
127 | Special keys are hardcoded, one at a time, with length of key | 128 | Special keys are hardcoded, one at a time, with length of key |
128 | and code >= 0x80, these are NOT standard PC scancodes, but are looked | 129 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
129 | up in specialM[]. (The special keys are not keymappable.) | 130 | up in specialM[]. (The special keys are not keymappable.) |
130 | 131 | ||
131 | */ | 132 | */ |
132 | 133 | ||
133 | static const uchar * const keyboard_opti[5] = { | 134 | static const uchar * const keyboard_opti[5] = { |
134 | (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", | 135 | (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", |
135 | (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", | 136 | (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", |
136 | (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", | 137 | (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", |
137 | (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", | 138 | (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", |
138 | (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" | 139 | (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" |
139 | }; | 140 | }; |
140 | 141 | ||
141 | 142 | ||
142 | static const uchar * const keyboard_standard[5] = { | 143 | static const uchar * const keyboard_standard[5] = { |
143 | 144 | ||
144 | #ifdef USE_SMALL_BACKSPACE | 145 | #ifdef USE_SMALL_BACKSPACE |
145 | (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\002\200\002\223\002\215\002\216\002\217", | 146 | (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\002\200\002\223\002\215\002\216\002\217", |
146 | #else | 147 | #else |
147 | (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217", | 148 | (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217", |
148 | #endif | 149 | #endif |
149 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP | 150 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP |
150 | 151 | ||
151 | (const uchar *const)"\003\201\002q\002w\002e\002r\002t\002y\002u\002i\002o\002p\002[\002]\002\\\001\224\002\223\002\221\002\220\002\222", | 152 | (const uchar *const)"\003\201\002q\002w\002e\002r\002t\002y\002u\002i\002o\002p\002[\002]\002\\\001\224\002\223\002\221\002\220\002\222", |
152 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN | 153 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN |
153 | 154 | ||
154 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", | 155 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", |
155 | //CAPS + asdf.. + RETURN | 156 | //CAPS + asdf.. + RETURN |
156 | 157 | ||
157 | (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", | 158 | (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", |
158 | //SHIFT + zxcv... //+ UP | 159 | //SHIFT + zxcv... //+ UP |
159 | 160 | ||
160 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" | 161 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" |
161 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT | 162 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT |
162 | 163 | ||
163 | }; | 164 | }; |
164 | 165 | ||
165 | 166 | ||
166 | struct ShiftMap { | 167 | struct ShiftMap { |
167 | char normal; | 168 | char normal; |
168 | char shifted; | 169 | char shifted; |
169 | }; | 170 | }; |
170 | 171 | ||
171 | 172 | ||
172 | static const ShiftMap shiftMap[] = { | 173 | static const ShiftMap shiftMap[] = { |
173 | { '`', '~' }, | 174 | { '`', '~' }, |
174 | { '1', '!' }, | 175 | { '1', '!' }, |
175 | { '2', '@' }, | 176 | { '2', '@' }, |
176 | { '3', '#' }, | 177 | { '3', '#' }, |
177 | { '4', '$' }, | 178 | { '4', '$' }, |
178 | { '5', '%' }, | 179 | { '5', '%' }, |
179 | { '6', '^' }, | 180 | { '6', '^' }, |
180 | { '7', '&' }, | 181 | { '7', '&' }, |
181 | { '8', '*' }, | 182 | { '8', '*' }, |
182 | { '9', '(' }, | 183 | { '9', '(' }, |
183 | { '0', ')' }, | 184 | { '0', ')' }, |
184 | { '-', '_' }, | 185 | { '-', '_' }, |
185 | { '=', '+' }, | 186 | { '=', '+' }, |
186 | { '\\', '|' }, | 187 | { '\\', '|' }, |
187 | { '[', '{' }, | 188 | { '[', '{' }, |
188 | { ']', '}' }, | 189 | { ']', '}' }, |
189 | { ';', ':' }, | 190 | { ';', ':' }, |
190 | { '\'', '"' }, | 191 | { '\'', '"' }, |
191 | { ',', '<' }, | 192 | { ',', '<' }, |
192 | { '.', '>' }, | 193 | { '.', '>' }, |
193 | { '/', '?' } | 194 | { '/', '?' } |
194 | }; | 195 | }; |
195 | 196 | ||
196 | 197 | ||
197 | /* XPM */ | 198 | /* XPM */ |
198 | static const char * const uparrow_xpm[]={ | 199 | static const char * const uparrow_xpm[]={ |
199 | "9 9 2 1", | 200 | "9 9 2 1", |
200 | "a c #000000", | 201 | "a c #000000", |
201 | ". c None", | 202 | ". c None", |
202 | ".........", | 203 | ".........", |
203 | "....a....", | 204 | "....a....", |
204 | "...aaa...", | 205 | "...aaa...", |
205 | "..aaaaa..", | 206 | "..aaaaa..", |
206 | "....a....", | 207 | "....a....", |
207 | "....a....", | 208 | "....a....", |
208 | "....a....", | 209 | "....a....", |
209 | "....a....", | 210 | "....a....", |
210 | "........."}; | 211 | "........."}; |
211 | /* XPM */ | 212 | /* XPM */ |
212 | static const char * const leftarrow_xpm[]={ | 213 | static const char * const leftarrow_xpm[]={ |
213 | "9 9 2 1", | 214 | "9 9 2 1", |
214 | "a c #000000", | 215 | "a c #000000", |
215 | ". c None", | 216 | ". c None", |
216 | ".........", | 217 | ".........", |
217 | ".........", | 218 | ".........", |
218 | "...a.....", | 219 | "...a.....", |
219 | "..aa.....", | 220 | "..aa.....", |
220 | ".aaaaaaa.", | 221 | ".aaaaaaa.", |
221 | "..aa.....", | 222 | "..aa.....", |
222 | "...a.....", | 223 | "...a.....", |
223 | ".........", | 224 | ".........", |
224 | "........."}; | 225 | "........."}; |
225 | /* XPM */ | 226 | /* XPM */ |
226 | static const char * const downarrow_xpm[]={ | 227 | static const char * const downarrow_xpm[]={ |
227 | "9 9 2 1", | 228 | "9 9 2 1", |
228 | "a c #000000", | 229 | "a c #000000", |
229 | ". c None", | 230 | ". c None", |
230 | ".........", | 231 | ".........", |
231 | "....a....", | 232 | "....a....", |
232 | "....a....", | 233 | "....a....", |
233 | "....a....", | 234 | "....a....", |
234 | "....a....", | 235 | "....a....", |
235 | "..aaaaa..", | 236 | "..aaaaa..", |
236 | "...aaa...", | 237 | "...aaa...", |
237 | "....a....", | 238 | "....a....", |
238 | "........."}; | 239 | "........."}; |
239 | /* XPM */ | 240 | /* XPM */ |
240 | static const char * const rightarrow_xpm[]={ | 241 | static const char * const rightarrow_xpm[]={ |
241 | "9 9 2 1", | 242 | "9 9 2 1", |
242 | "a c #000000", | 243 | "a c #000000", |
243 | ". c None", | 244 | ". c None", |
244 | ".........", | 245 | ".........", |
245 | ".........", | 246 | ".........", |
246 | ".....a...", | 247 | ".....a...", |
247 | ".....aa..", | 248 | ".....aa..", |
248 | ".aaaaaaa.", | 249 | ".aaaaaaa.", |
249 | ".....aa..", | 250 | ".....aa..", |
250 | ".....a...", | 251 | ".....a...", |
251 | ".........", | 252 | ".........", |
252 | "........."}; | 253 | "........."}; |
253 | /* XPM */ | 254 | /* XPM */ |
254 | static const char * const insert_xpm[]={ | 255 | static const char * const insert_xpm[]={ |
255 | "9 9 2 1", | 256 | "9 9 2 1", |
256 | "a c #000000", | 257 | "a c #000000", |
257 | ". c None", | 258 | ". c None", |
258 | ".........", | 259 | ".........", |
259 | "a........", | 260 | "a........", |
260 | "a.aaa.aaa", | 261 | "a.aaa.aaa", |
261 | "a.a.a.a..", | 262 | "a.a.a.a..", |
262 | "a.a.a..a.", | 263 | "a.a.a..a.", |
263 | "a.a.a...a", | 264 | "a.a.a...a", |
264 | "a.a.a.aaa", | 265 | "a.a.a.aaa", |
265 | ".........", | 266 | ".........", |
266 | "........."}; | 267 | "........."}; |
267 | /* XPM */ | 268 | /* XPM */ |
268 | static const char * const delete_xpm[]={ | 269 | static const char * const delete_xpm[]={ |
269 | "9 9 2 1", | 270 | "9 9 2 1", |
270 | "a c #000000", | 271 | "a c #000000", |
271 | ". c None", | 272 | ". c None", |
272 | ".........", | 273 | ".........", |
273 | "aa......a", | 274 | "aa......a", |
274 | "a.a.aaa.a", | 275 | "a.a.aaa.a", |
275 | "a.a.a.a.a", | 276 | "a.a.a.a.a", |
276 | "a.a.aaa.a.", | 277 | "a.a.aaa.a.", |
277 | "a.a.a...a", | 278 | "a.a.a...a", |
278 | "aaa.aaa.a", | 279 | "aaa.aaa.a", |
279 | ".........", | 280 | ".........", |
280 | "........."}; | 281 | "........."}; |
281 | /* XPM */ | 282 | /* XPM */ |
282 | static const char * const home_xpm[]={ | 283 | static const char * const home_xpm[]={ |
283 | "9 9 2 1", | 284 | "9 9 2 1", |
284 | "a c #000000", | 285 | "a c #000000", |
285 | ". c None", | 286 | ". c None", |
286 | "....a....", | 287 | "....a....", |
287 | "...a.a...", | 288 | "...a.a...", |
288 | "..a...a..", | 289 | "..a...a..", |
289 | ".a.....a.", | 290 | ".a.....a.", |
290 | "aa.aaa.aa", | 291 | "aa.aaa.aa", |
291 | ".a.a.a.a.", | 292 | ".a.a.a.a.", |
292 | ".a.a.a.a.", | 293 | ".a.a.a.a.", |
293 | ".aaaaaaa.", | 294 | ".aaaaaaa.", |
294 | "........."}; | 295 | "........."}; |
295 | /* XPM */ | 296 | /* XPM */ |
296 | static const char * const end_xpm[]={ | 297 | static const char * const end_xpm[]={ |
297 | "10 9 2 1", | 298 | "10 9 2 1", |
298 | "a c #000000", | 299 | "a c #000000", |
299 | ". c None", | 300 | ". c None", |
300 | "..........", | 301 | "..........", |
301 | "aa.......a", | 302 | "aa.......a", |
302 | "a..aaa.aaa", | 303 | "a..aaa.aaa", |
303 | "aa.a.a.a.a", | 304 | "aa.a.a.a.a", |
304 | "a..a.a.a.a", | 305 | "a..a.a.a.a", |
305 | "a..a.a.a.a", | 306 | "a..a.a.a.a", |
306 | "aa.a.a.aaa", | 307 | "aa.a.a.aaa", |
307 | "..........", | 308 | "..........", |
308 | ".........."}; | 309 | ".........."}; |
309 | /* XPM */ | 310 | /* XPM */ |
310 | static const char * const pageup_xpm[]={ | 311 | static const char * const pageup_xpm[]={ |
311 | "9 9 2 1", | 312 | "9 9 2 1", |
312 | "a c #000000", | 313 | "a c #000000", |
313 | ". c None", | 314 | ". c None", |
314 | ".aaa.aaa.", | 315 | ".aaa.aaa.", |
315 | ".a.a.a.a.", | 316 | ".a.a.a.a.", |
316 | ".aaa..aa.", | 317 | ".aaa..aa.", |
317 | ".a...aaa.", | 318 | ".a...aaa.", |
318 | ".........", | 319 | ".........", |
319 | ".a.a.aaa.", | 320 | ".a.a.aaa.", |
320 | ".a.a.a.a.", | 321 | ".a.a.a.a.", |
321 | ".aaa.aaa.", | 322 | ".aaa.aaa.", |
322 | ".....a..."}; | 323 | ".....a..."}; |
323 | /* XPM */ | 324 | /* XPM */ |
324 | static const char * const pagedown_xpm[]={ | 325 | static const char * const pagedown_xpm[]={ |
325 | "9 9 2 1", | 326 | "9 9 2 1", |
326 | "a c #000000", | 327 | "a c #000000", |
327 | ". c None", | 328 | ". c None", |
328 | ".aaa.aaa.", | 329 | ".aaa.aaa.", |
329 | ".a.a.a.a.", | 330 | ".a.a.a.a.", |
330 | ".aaa..aa.", | 331 | ".aaa..aa.", |
331 | ".a...aaa.", | 332 | ".a...aaa.", |
332 | ".........", | 333 | ".........", |
333 | "...a.....", | 334 | "...a.....", |
334 | ".aaa.aaa.", | 335 | ".aaa.aaa.", |
335 | ".a.a.a.a.", | 336 | ".a.a.a.a.", |
336 | ".aaa.a.a."}; | 337 | ".aaa.a.a."}; |
337 | /* XPM */ | 338 | /* XPM */ |
338 | static const char * const expand_xpm[]={ | 339 | static const char * const expand_xpm[]={ |
339 | "4 9 2 1", | 340 | "4 9 2 1", |
340 | "a c #408040", | 341 | "a c #408040", |
341 | ". c None", | 342 | ". c None", |
342 | "a...", | 343 | "a...", |
343 | "aa..", | 344 | "aa..", |
344 | "aaa.", | 345 | "aaa.", |
345 | "aaaa", | 346 | "aaaa", |
346 | "aaaa", | 347 | "aaaa", |
347 | "aaaa", | 348 | "aaaa", |
348 | "aaa.", | 349 | "aaa.", |
349 | "aa..", | 350 | "aa..", |
350 | "a..."}; | 351 | "a..."}; |
351 | /* XPM */ | 352 | /* XPM */ |
352 | #ifdef USE_SMALL_BACKSPACE | 353 | #ifdef USE_SMALL_BACKSPACE |
353 | static const char * const backspace_xpm[]={ | 354 | static const char * const backspace_xpm[]={ |
354 | "9 9 2 1", | 355 | "9 9 2 1", |
355 | "a c #000000", | 356 | "a c #000000", |
356 | ". c None", | 357 | ". c None", |
357 | ".........", | 358 | ".........", |
358 | ".........", | 359 | ".........", |
359 | "...a.....", | 360 | "...a.....", |
360 | "..aa.....", | 361 | "..aa.....", |
361 | ".aaaaaaaa", | 362 | ".aaaaaaaa", |
362 | "..aa.....", | 363 | "..aa.....", |
363 | "...a.....", | 364 | "...a.....", |
364 | ".........", | 365 | ".........", |
365 | "........."}; | 366 | "........."}; |
366 | #else | 367 | #else |
367 | static const char * const backspace_xpm[]={ | 368 | static const char * const backspace_xpm[]={ |
368 | "21 9 2 1", | 369 | "21 9 2 1", |
369 | "a c #000000", | 370 | "a c #000000", |
370 | ". c None", | 371 | ". c None", |
371 | ".....................", | 372 | ".....................", |
372 | ".....................", | 373 | ".....................", |
373 | ".....aaa..a..........", | 374 | ".....aaa..a..........", |
374 | ".a...a..a.a.a.aaa.aaa", | 375 | ".a...a..a.a.a.aaa.aaa", |
375 | "aaaa.aaa..aa..aa..a.a", | 376 | "aaaa.aaa..aa..aa..a.a", |
376 | ".a...a..a.aaa..aa.a.a", | 377 | ".a...a..a.aaa..aa.a.a", |
377 | ".....aaaa.a.a.aaa.aa.", | 378 | ".....aaaa.a.a.aaa.aa.", |
378 | "..................a..", | 379 | "..................a..", |
379 | "....................."}; | 380 | "....................."}; |
380 | #endif | 381 | #endif |
381 | /* XPM */ | 382 | /* XPM */ |
382 | static const char * const escape_xpm[]={ | 383 | static const char * const escape_xpm[]={ |
383 | "9 9 2 1", | 384 | "9 9 2 1", |
384 | "a c #000000", | 385 | "a c #000000", |
385 | ". c None", | 386 | ". c None", |
386 | ".........", | 387 | ".........", |
387 | ".........", | 388 | ".........", |
388 | ".aa.aa.aa", | 389 | ".aa.aa.aa", |
389 | ".a..a..a.", | 390 | ".a..a..a.", |
390 | ".aa.aa.a.", | 391 | ".aa.aa.a.", |
391 | ".a...a.a.", | 392 | ".a...a.a.", |
392 | ".aa.aa.aa", | 393 | ".aa.aa.aa", |
393 | ".........", | 394 | ".........", |
394 | "........."}; | 395 | "........."}; |
395 | 396 | ||
396 | 397 | ||
397 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, | 398 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, |
398 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, | 399 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, |
399 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, | 400 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, |
400 | Opti, ResetDict, | 401 | Opti, ResetDict, |
401 | Divide, Multiply, Add, Subtract, Decimal, Equal, | 402 | Divide, Multiply, Add, Subtract, Decimal, Equal, |
402 | Percent, Sqrt, Inverse, Escape }; | 403 | Percent, Sqrt, Inverse, Escape }; |
403 | 404 | ||
404 | typedef struct SpecialMap { | 405 | typedef struct SpecialMap { |
405 | int qcode; | 406 | int qcode; |
406 | ushort unicode; | 407 | ushort unicode; |
407 | const char * label; | 408 | const char * label; |
408 | const char * const * xpm; | 409 | const char * const * xpm; |
409 | }; | 410 | }; |
410 | 411 | ||
411 | 412 | ||
412 | static const SpecialMap specialM[] = { | 413 | static const SpecialMap specialM[] = { |
413 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, | 414 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, |
414 | { Qt::Key_Tab, 9,"Tab", NULL }, | 415 | { Qt::Key_Tab, 9,"Tab", NULL }, |
415 | { Qt::Key_CapsLock, 0,"Caps", NULL }, | 416 | { Qt::Key_CapsLock, 0,"Caps", NULL }, |
416 | { Qt::Key_Return, 13,"Ret", NULL }, | 417 | { Qt::Key_Return, 13,"Ret", NULL }, |
417 | { Qt::Key_Shift, 0,"Shift", NULL }, | 418 | { Qt::Key_Shift, 0,"Shift", NULL }, |
418 | { Qt::Key_Control, 0,"Ctrl", NULL }, | 419 | { Qt::Key_Control, 0,"Ctrl", NULL }, |
419 | { Qt::Key_Alt, 0,"Alt", NULL }, | 420 | { Qt::Key_Alt, 0,"Alt", NULL }, |
420 | { Qt::Key_Space, ' ',"", NULL }, | 421 | { Qt::Key_Space, ' ',"", NULL }, |
421 | { BackSlash, 43,"\\", NULL }, | 422 | { BackSlash, 43,"\\", NULL }, |
422 | 423 | ||
423 | // Need images? | 424 | // Need images? |
424 | { Qt::Key_Up, 0,"^", uparrow_xpm }, | 425 | { Qt::Key_Up, 0,"^", uparrow_xpm }, |
425 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, | 426 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, |
426 | { Qt::Key_Down, 0,"v", downarrow_xpm }, | 427 | { Qt::Key_Down, 0,"v", downarrow_xpm }, |
427 | { Qt::Key_Right, 0,">", rightarrow_xpm }, | 428 | { Qt::Key_Right, 0,">", rightarrow_xpm }, |
428 | { Qt::Key_Insert, 0,"I", insert_xpm }, | 429 | { Qt::Key_Insert, 0,"I", insert_xpm }, |
429 | { Qt::Key_Home, 0,"H", home_xpm }, | 430 | { Qt::Key_Home, 0,"H", home_xpm }, |
430 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, | 431 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, |
431 | { Qt::Key_End, 0,"E", end_xpm }, | 432 | { Qt::Key_End, 0,"E", end_xpm }, |
432 | { Qt::Key_Delete, 0,"X", delete_xpm }, | 433 | { Qt::Key_Delete, 0,"X", delete_xpm }, |
433 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, | 434 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, |
434 | { Blank, 0," ", NULL }, | 435 | { Blank, 0," ", NULL }, |
435 | { Expand, 0,"->", expand_xpm }, | 436 | { Expand, 0,"->", expand_xpm }, |
436 | { Opti, 0,"#", NULL }, | 437 | { Opti, 0,"#", NULL }, |
437 | { ResetDict, 0,"R", NULL }, | 438 | { ResetDict, 0,"R", NULL }, |
438 | 439 | ||
439 | // number pad stuff | 440 | // number pad stuff |
440 | { Divide, 0,"/", NULL }, | 441 | { Divide, 0,"/", NULL }, |
441 | { Multiply, 0,"*", NULL }, | 442 | { Multiply, 0,"*", NULL }, |
442 | { Add, 0,"+", NULL }, | 443 | { Add, 0,"+", NULL }, |
443 | { Subtract, 0,"-", NULL }, | 444 | { Subtract, 0,"-", NULL }, |
444 | { Decimal, 0,".", NULL }, | 445 | { Decimal, 0,".", NULL }, |
445 | { Equal, 0,"=", NULL }, | 446 | { Equal, 0,"=", NULL }, |
446 | { Percent, 0,"%", NULL }, | 447 | { Percent, 0,"%", NULL }, |
447 | { Sqrt, 0, "^1/2", NULL }, | 448 | { Sqrt, 0, "^1/2", NULL }, |
448 | { Inverse, 0, "1/x", NULL }, | 449 | { Inverse, 0, "1/x", NULL }, |
449 | 450 | ||
450 | { Escape, 27, "ESC", escape_xpm } | 451 | { Escape, 27, "ESC", escape_xpm } |
451 | }; | 452 | }; |
452 | 453 | ||
453 | 454 | ||
454 | static int keycode( int i2, int j, const uchar **keyboard ) | 455 | static int keycode( int i2, int j, const uchar **keyboard ) |
455 | { | 456 | { |
456 | if ( j <0 || j >= 5 ) | 457 | if ( j <0 || j >= 5 ) |
457 | return 0; | 458 | return 0; |
458 | 459 | ||
459 | const uchar *row = keyboard[j]; | 460 | const uchar *row = keyboard[j]; |
460 | 461 | ||
461 | while ( *row && *row <= i2 ) { | 462 | while ( *row && *row <= i2 ) { |
462 | i2 -= *row; | 463 | i2 -= *row; |
463 | row += 2; | 464 | row += 2; |
464 | } | 465 | } |
465 | 466 | ||
466 | if ( !*row ) return 0; | 467 | if ( !*row ) return 0; |
467 | 468 | ||
468 | int k; | 469 | int k; |
469 | if ( row[1] >= 0x80 ) { | 470 | if ( row[1] >= 0x80 ) { |
470 | k = row[1]; | 471 | k = row[1]; |
471 | } else { | 472 | } else { |
472 | k = row[1]+i2/2; | 473 | k = row[1]+i2/2; |
473 | } | 474 | } |
474 | 475 | ||
475 | return k; | 476 | return k; |
476 | } | 477 | } |
477 | 478 | ||
478 | 479 | ||
479 | /* | 480 | /* |
480 | return scancode and width of first key in row \a j if \a j >= 0, | 481 | return scancode and width of first key in row \a j if \a j >= 0, |
481 | or next key on current row if \a j < 0. | 482 | or next key on current row if \a j < 0. |
482 | 483 | ||
483 | */ | 484 | */ |
484 | 485 | ||
485 | int Keyboard::getKey( int &w, int j ) { | 486 | int Keyboard::getKey( int &w, int j ) { |
486 | static const uchar *row = 0; | 487 | static const uchar *row = 0; |
487 | static int key_i = 0; | 488 | static int key_i = 0; |
488 | static int scancode = 0; | 489 | static int scancode = 0; |
489 | static int half = 0; | 490 | static int half = 0; |
490 | 491 | ||
491 | if ( j >= 0 && j < 5 ) { | 492 | if ( j >= 0 && j < 5 ) { |
492 | if (useOptiKeys) | 493 | if (useOptiKeys) |
493 | row = keyboard_opti[j]; | 494 | row = keyboard_opti[j]; |
494 | else | 495 | else |
495 | row = keyboard_standard[j]; | 496 | row = keyboard_standard[j]; |
496 | half=0; | 497 | half=0; |
497 | } | 498 | } |
498 | 499 | ||
499 | if ( !row || !*row ) { | 500 | if ( !row || !*row ) { |
500 | return 0; | 501 | return 0; |
501 | } else if ( row[1] >= 0x80 ) { | 502 | } else if ( row[1] >= 0x80 ) { |
502 | scancode = row[1]; | 503 | scancode = row[1]; |
503 | w = (row[0] * w + (half++&1)) / 2; | 504 | w = (row[0] * w + (half++&1)) / 2; |
504 | row += 2; | 505 | row += 2; |
505 | return scancode; | 506 | return scancode; |
506 | } else if ( key_i <= 0 ) { | 507 | } else if ( key_i <= 0 ) { |
507 | key_i = row[0]/2; | 508 | key_i = row[0]/2; |
508 | scancode = row[1]; | 509 | scancode = row[1]; |
509 | } | 510 | } |
510 | key_i--; | 511 | key_i--; |
511 | if ( key_i <= 0 ) | 512 | if ( key_i <= 0 ) |
512 | row += 2; | 513 | row += 2; |
513 | return scancode++; | 514 | return scancode++; |
514 | } | 515 | } |
515 | 516 | ||
516 | 517 | ||
517 | void Keyboard::paintEvent(QPaintEvent* e) | 518 | void Keyboard::paintEvent(QPaintEvent* e) |
518 | { | 519 | { |
519 | QPainter painter(this); | 520 | QPainter painter(this); |
520 | painter.setClipRect(e->rect()); | 521 | painter.setClipRect(e->rect()); |
521 | drawKeyboard( painter ); | 522 | drawKeyboard( painter ); |
522 | picks->dc->draw( &painter ); | 523 | picks->dc->draw( &painter ); |
523 | } | 524 | } |
524 | 525 | ||
525 | 526 | ||
526 | /* | 527 | /* |
527 | Draw the keyboard. | 528 | Draw the keyboard. |
528 | 529 | ||
529 | If key >= 0, only the specified key is drawn. | 530 | If key >= 0, only the specified key is drawn. |
530 | */ | 531 | */ |
531 | void Keyboard::drawKeyboard( QPainter &p, int key ) | 532 | void Keyboard::drawKeyboard( QPainter &p, int key ) |
532 | { | 533 | { |
533 | const bool threeD = FALSE; | 534 | const bool threeD = FALSE; |
534 | const QColorGroup& cg = colorGroup(); | 535 | const QColorGroup& cg = colorGroup(); |
535 | QColor keycolor = // cg.background(); | 536 | QColor keycolor = // cg.background(); |
536 | QColor(240,240,230); // Beige! | 537 | QColor(240,240,230); // Beige! |
537 | QColor keycolor_pressed = cg.mid(); | 538 | QColor keycolor_pressed = cg.mid(); |
538 | QColor keycolor_lo = cg.dark(); | 539 | QColor keycolor_lo = cg.dark(); |
539 | QColor keycolor_hi = cg.light(); | 540 | QColor keycolor_hi = cg.light(); |
540 | QColor textcolor = QColor(0,0,0); // cg.text(); | 541 | QColor textcolor = QColor(0,0,0); // cg.text(); |
541 | 542 | ||
542 | int margin = threeD ? 1 : 0; | 543 | int margin = threeD ? 1 : 0; |
543 | 544 | ||
544 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); | 545 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); |
545 | 546 | ||
546 | for ( int j = 0; j < 5; j++ ) { | 547 | for ( int j = 0; j < 5; j++ ) { |
547 | int y = j * keyHeight + picks->height() + 1; | 548 | int y = j * keyHeight + picks->height() + 1; |
548 | int x = xoffs; | 549 | int x = xoffs; |
549 | int kw = defaultKeyWidth; | 550 | int kw = defaultKeyWidth; |
550 | int k= getKey( kw, j ); | 551 | int k= getKey( kw, j ); |
551 | while ( k ) { | 552 | while ( k ) { |
552 | if ( key < 0 || k == key ) { | 553 | if ( key < 0 || k == key ) { |
553 | QString s; | 554 | QString s; |
554 | bool pressed = (k == pressedKey); | 555 | bool pressed = (k == pressedKey); |
555 | bool blank = (k == 0223); | 556 | bool blank = (k == 0223); |
556 | const char * const * xpm = NULL; | 557 | const char * const * xpm = NULL; |
557 | 558 | ||
558 | if ( k >= 0x80 ) { | 559 | if ( k >= 0x80 ) { |
559 | s = specialM[k - 0x80].label; | 560 | s = specialM[k - 0x80].label; |
560 | 561 | ||
561 | xpm = specialM[k - 0x80].xpm; | 562 | xpm = specialM[k - 0x80].xpm; |
562 | 563 | ||
563 | if ( k == ShiftCode ) { | 564 | if ( k == ShiftCode ) { |
564 | pressed = shift; | 565 | pressed = shift; |
565 | } else if ( k == CapsCode ) { | 566 | } else if ( k == CapsCode ) { |
566 | pressed = lock; | 567 | pressed = lock; |
567 | } else if ( k == CtrlCode ) { | 568 | } else if ( k == CtrlCode ) { |
568 | pressed = ctrl; | 569 | pressed = ctrl; |
569 | } else if ( k == AltCode ) { | 570 | } else if ( k == AltCode ) { |
570 | pressed = alt; | 571 | pressed = alt; |
571 | } | 572 | } |
572 | } else { | 573 | } else { |
573 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 574 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
574 | /* | 575 | /* |
575 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : | 576 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : |
576 | QWSServer::keyMap()[k].unicode); | 577 | QWSServer::keyMap()[k].unicode); |
577 | */ | 578 | */ |
578 | // ### Fixme, bad code, needs improving, whole thing needs to | 579 | // ### Fixme, bad code, needs improving, whole thing needs to |
579 | // be re-coded to get rid of the way it did things with scancodes etc | 580 | // be re-coded to get rid of the way it did things with scancodes etc |
580 | char shifted = k; | 581 | char shifted = k; |
581 | if ( !isalpha( k ) ) { | 582 | if ( !isalpha( k ) ) { |
582 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 583 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
583 | if ( shiftMap[i].normal == k ) | 584 | if ( shiftMap[i].normal == k ) |
584 | shifted = shiftMap[i].shifted; | 585 | shifted = shiftMap[i].shifted; |
585 | } else { | 586 | } else { |
586 | shifted = toupper( k ); | 587 | shifted = toupper( k ); |
587 | } | 588 | } |
588 | s = QChar( shift^lock ? shifted : k ); | 589 | s = QChar( shift^lock ? shifted : k ); |
589 | #endif | 590 | #endif |
590 | } | 591 | } |
591 | 592 | ||
592 | if (!blank) { | 593 | if (!blank) { |
593 | if ( pressed ) | 594 | if ( pressed ) |
594 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); | 595 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); |
595 | else | 596 | else |
596 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); | 597 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); |
597 | 598 | ||
598 | if ( threeD ) { | 599 | if ( threeD ) { |
599 | p.setPen(pressed ? keycolor_lo : keycolor_hi); | 600 | p.setPen(pressed ? keycolor_lo : keycolor_hi); |
600 | p.drawLine( x, y+1, x, y+keyHeight-2 ); | 601 | p.drawLine( x, y+1, x, y+keyHeight-2 ); |
601 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); | 602 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); |
602 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); | 603 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); |
603 | } else if ( j == 0 ) { | 604 | } else if ( j == 0 ) { |
604 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 605 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
605 | p.drawLine( x, y, x+kw, y ); | 606 | p.drawLine( x, y, x+kw, y ); |
606 | } | 607 | } |
607 | 608 | ||
608 | // right | 609 | // right |
609 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 610 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
610 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); | 611 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); |
611 | 612 | ||
612 | if ( threeD ) { | 613 | if ( threeD ) { |
613 | p.setPen(keycolor_lo.light()); | 614 | p.setPen(keycolor_lo.light()); |
614 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); | 615 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); |
615 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); | 616 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); |
616 | } | 617 | } |
617 | 618 | ||
618 | if (xpm) { | 619 | if (xpm) { |
619 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); | 620 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); |
620 | } else { | 621 | } else { |
621 | p.setPen(textcolor); | 622 | p.setPen(textcolor); |
622 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); | 623 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); |
623 | } | 624 | } |
624 | 625 | ||
625 | if ( threeD ) { | 626 | if ( threeD ) { |
626 | p.setPen(keycolor_hi); | 627 | p.setPen(keycolor_hi); |
627 | p.drawLine( x, y, x+kw-1, y ); | 628 | p.drawLine( x, y, x+kw-1, y ); |
628 | } | 629 | } |
629 | 630 | ||
630 | // bottom | 631 | // bottom |
631 | p.setPen(keycolor_lo); | 632 | p.setPen(keycolor_lo); |
632 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); | 633 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); |
633 | 634 | ||
634 | } else { | 635 | } else { |
635 | p.fillRect( x, y, kw, keyHeight, cg.background() ); | 636 | p.fillRect( x, y, kw, keyHeight, cg.background() ); |
636 | } | 637 | } |
637 | } | 638 | } |
638 | 639 | ||
639 | x += kw; | 640 | x += kw; |
640 | kw = defaultKeyWidth; | 641 | kw = defaultKeyWidth; |
641 | k = getKey( kw ); | 642 | k = getKey( kw ); |
642 | } | 643 | } |
643 | } | 644 | } |
644 | } | 645 | } |
645 | 646 | ||
646 | 647 | ||
647 | void Keyboard::mousePressEvent(QMouseEvent *e) | 648 | void Keyboard::mousePressEvent(QMouseEvent *e) |
648 | { | 649 | { |
649 | clearHighlight(); // typing fast? | 650 | clearHighlight(); // typing fast? |
650 | 651 | ||
651 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; | 652 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; |
652 | int j = (e->y() - picks->height()) / keyHeight; | 653 | int j = (e->y() - picks->height()) / keyHeight; |
653 | 654 | ||
654 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); | 655 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); |
655 | bool need_repaint = FALSE; | 656 | bool need_repaint = FALSE; |
656 | unicode = -1; | 657 | unicode = -1; |
657 | qkeycode = 0; | 658 | qkeycode = 0; |
658 | if ( k >= 0x80 ) { | 659 | if ( k >= 0x80 ) { |
659 | if ( k == ShiftCode ) { | 660 | if ( k == ShiftCode ) { |
660 | shift = !shift; | 661 | shift = !shift; |
661 | need_repaint = TRUE; | 662 | need_repaint = TRUE; |
662 | } else if ( k == AltCode ){ | 663 | } else if ( k == AltCode ){ |
663 | alt = !alt; | 664 | alt = !alt; |
664 | need_repaint = TRUE; | 665 | need_repaint = TRUE; |
665 | } else if ( k == CapsCode ) { | 666 | } else if ( k == CapsCode ) { |
666 | lock = !lock; | 667 | lock = !lock; |
667 | need_repaint = TRUE; | 668 | need_repaint = TRUE; |
668 | } else if ( k == CtrlCode ) { | 669 | } else if ( k == CtrlCode ) { |
669 | ctrl = !ctrl; | 670 | ctrl = !ctrl; |
670 | need_repaint = TRUE; | 671 | need_repaint = TRUE; |
671 | } else if ( k == 0224 /* Expand */ ) { | 672 | } else if ( k == 0224 /* Expand */ ) { |
672 | useLargeKeys = !useLargeKeys; | 673 | useLargeKeys = !useLargeKeys; |
673 | resizeEvent(0); | 674 | resizeEvent(0); |
674 | repaint( TRUE ); // need it to clear first | 675 | repaint( TRUE ); // need it to clear first |
675 | } else if ( k == 0225 /* Opti/Toggle */ ) { | 676 | } else if ( k == 0225 /* Opti/Toggle */ ) { |
676 | useOptiKeys = !useOptiKeys; | 677 | useOptiKeys = !useOptiKeys; |
677 | resizeEvent(0); | 678 | resizeEvent(0); |
678 | repaint( TRUE ); // need it to clear first | 679 | repaint( TRUE ); // need it to clear first |
679 | } else { | 680 | } else { |
680 | qkeycode = specialM[ k - 0x80 ].qcode; | 681 | qkeycode = specialM[ k - 0x80 ].qcode; |
681 | unicode = specialM[ k - 0x80 ].unicode; | 682 | unicode = specialM[ k - 0x80 ].unicode; |
682 | } | 683 | } |
683 | } else { | 684 | } else { |
684 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 685 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
685 | /* | 686 | /* |
686 | qk = QWSServer::keyMap()[k].key_code; | 687 | qk = QWSServer::keyMap()[k].key_code; |
687 | if ( qk != Key_unknown ) { | 688 | if ( qk != Key_unknown ) { |
688 | if ( ctrl ) | 689 | if ( ctrl ) |
689 | u = QWSServer::keyMap()[k].ctrl_unicode; | 690 | u = QWSServer::keyMap()[k].ctrl_unicode; |
690 | else if ( shift^lock ) | 691 | else if ( shift^lock ) |
691 | u = QWSServer::keyMap()[k].shift_unicode; | 692 | u = QWSServer::keyMap()[k].shift_unicode; |
692 | else | 693 | else |
693 | u = QWSServer::keyMap()[k].unicode; | 694 | u = QWSServer::keyMap()[k].unicode; |
694 | } | 695 | } |
695 | */ | 696 | */ |
696 | char shifted = k; | 697 | char shifted = k; |
697 | if ( !isalpha( k ) ) { | 698 | if ( !isalpha( k ) ) { |
698 | // ### Fixme, bad code, needs improving, whole thing needs to | 699 | // ### Fixme, bad code, needs improving, whole thing needs to |
699 | // be re-coded to get rid of the way it did things with scancodes etc | 700 | // be re-coded to get rid of the way it did things with scancodes etc |
700 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 701 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
701 | if ( shiftMap[i].normal == k ) | 702 | if ( shiftMap[i].normal == k ) |
702 | shifted = shiftMap[i].shifted; | 703 | shifted = shiftMap[i].shifted; |
703 | } else { | 704 | } else { |
704 | shifted = toupper( k ); | 705 | shifted = toupper( k ); |
705 | } | 706 | } |
706 | QChar tempChar( shift^lock ? shifted : k ); | 707 | QChar tempChar( shift^lock ? shifted : k ); |
707 | unicode = tempChar.unicode(); | 708 | unicode = tempChar.unicode(); |
708 | #endif | 709 | #endif |
709 | } | 710 | } |
710 | if ( unicode != -1 ) { | 711 | if ( unicode != -1 ) { |
711 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | | 712 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | |
712 | (alt ? Qt::AltButton : 0); | 713 | (alt ? Qt::AltButton : 0); |
713 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 714 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
714 | emit key( unicode, qkeycode, modifiers, true, false ); | 715 | emit key( unicode, qkeycode, modifiers, true, false ); |
715 | repeatTimer->start( 500 ); | 716 | repeatTimer->start( 500 ); |
716 | #endif | 717 | #endif |
717 | need_repaint = shift || alt || ctrl; | 718 | need_repaint = shift || alt || ctrl; |
718 | shift = alt = ctrl = FALSE; | 719 | shift = alt = ctrl = FALSE; |
719 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); | 720 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); |
720 | 721 | ||
721 | KeyboardConfig *dc = picks->dc; | 722 | KeyboardConfig *dc = picks->dc; |
722 | 723 | ||
723 | if (dc) { | 724 | if (dc) { |
724 | if (qkeycode == Qt::Key_Backspace) { | 725 | if (qkeycode == Qt::Key_Backspace) { |
725 | dc->input.remove(dc->input.last()); // remove last input | 726 | dc->input.remove(dc->input.last()); // remove last input |
726 | dc->decBackspaces(); | 727 | dc->decBackspaces(); |
727 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || | 728 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || |
728 | qkeycode == Qt::Key_Space || | 729 | qkeycode == Qt::Key_Space || |
729 | QChar(unicode).isPunct() ) { | 730 | QChar(unicode).isPunct() ) { |
730 | dc->input.clear(); | 731 | dc->input.clear(); |
731 | dc->resetBackspaces(); | 732 | dc->resetBackspaces(); |
732 | } else { | 733 | } else { |
733 | dc->add(QString(QChar(unicode))); | 734 | dc->add(QString(QChar(unicode))); |
734 | dc->incBackspaces(); | 735 | dc->incBackspaces(); |
735 | } | 736 | } |
736 | } | 737 | } |
737 | 738 | ||
738 | picks->repaint(); | 739 | picks->repaint(); |
739 | 740 | ||
740 | } | 741 | } |
741 | pressedKey = k; | 742 | pressedKey = k; |
742 | if ( need_repaint ) { | 743 | if ( need_repaint ) { |
743 | repaint( FALSE ); | 744 | repaint( FALSE ); |
744 | } else { | 745 | } else { |
745 | QPainter p(this); | 746 | QPainter p(this); |
746 | drawKeyboard( p, pressedKey ); | 747 | drawKeyboard( p, pressedKey ); |
747 | } | 748 | } |
748 | pressTid = startTimer(80); | 749 | pressTid = startTimer(80); |
749 | pressed = TRUE; | 750 | pressed = TRUE; |
750 | } | 751 | } |
751 | 752 | ||
752 | 753 | ||
753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 754 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
754 | { | 755 | { |
755 | if ( pressTid == 0 ) | 756 | if ( pressTid == 0 ) |
756 | clearHighlight(); | 757 | clearHighlight(); |
757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 758 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
758 | if ( unicode != -1 ) { | 759 | if ( unicode != -1 ) { |
759 | emit key( unicode, qkeycode, modifiers, false, false ); | 760 | emit key( unicode, qkeycode, modifiers, false, false ); |
760 | repeatTimer->stop(); | 761 | repeatTimer->stop(); |
761 | } | 762 | } |
762 | #endif | 763 | #endif |
763 | pressed = FALSE; | 764 | pressed = FALSE; |
764 | } | 765 | } |
765 | 766 | ||
766 | void Keyboard::timerEvent(QTimerEvent* e) | 767 | void Keyboard::timerEvent(QTimerEvent* e) |
767 | { | 768 | { |
768 | if ( e->timerId() == pressTid ) { | 769 | if ( e->timerId() == pressTid ) { |
769 | killTimer(pressTid); | 770 | killTimer(pressTid); |
770 | pressTid = 0; | 771 | pressTid = 0; |
771 | if ( !pressed ) | 772 | if ( !pressed ) |
772 | clearHighlight(); | 773 | clearHighlight(); |
773 | } | 774 | } |
774 | } | 775 | } |
775 | 776 | ||
776 | void Keyboard::repeat() | 777 | void Keyboard::repeat() |
777 | { | 778 | { |
778 | 779 | ||
779 | repeatTimer->start( 200 ); | 780 | repeatTimer->start( 200 ); |
780 | emit key( unicode, qkeycode, modifiers, true, true ); | 781 | emit key( unicode, qkeycode, modifiers, true, true ); |
781 | } | 782 | } |
782 | 783 | ||
783 | void Keyboard::clearHighlight() | 784 | void Keyboard::clearHighlight() |
784 | { | 785 | { |
785 | if ( pressedKey >= 0 ) { | 786 | if ( pressedKey >= 0 ) { |
786 | int tmp = pressedKey; | 787 | int tmp = pressedKey; |
787 | pressedKey = -1; | 788 | pressedKey = -1; |
788 | QPainter p(this); | 789 | QPainter p(this); |
789 | drawKeyboard( p, tmp ); | 790 | drawKeyboard( p, tmp ); |
790 | } | 791 | } |
791 | } | 792 | } |
792 | 793 | ||
793 | 794 | ||
794 | QSize Keyboard::sizeHint() const | 795 | QSize Keyboard::sizeHint() const |
795 | { | 796 | { |
796 | QFontMetrics fm=fontMetrics(); | 797 | QFontMetrics fm=fontMetrics(); |
797 | int keyHeight = fm.lineSpacing()+2; | 798 | int keyHeight = fm.lineSpacing()+2; |
798 | 799 | ||
799 | if (useOptiKeys) | 800 | if (useOptiKeys) |
800 | keyHeight += 1; | 801 | keyHeight += 1; |
801 | 802 | ||
802 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); | 803 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); |
803 | } | 804 | } |
804 | 805 | ||
805 | 806 | ||
806 | void Keyboard::resetState() | 807 | void Keyboard::resetState() |
807 | { | 808 | { |
808 | picks->resetState(); | 809 | picks->resetState(); |
809 | } | 810 | } |
diff --git a/inputmethods/keyboard/keyboard.h b/inputmethods/keyboard/keyboard.h index 38ae338..cc7f3f5 100644 --- a/inputmethods/keyboard/keyboard.h +++ b/inputmethods/keyboard/keyboard.h | |||
@@ -1,103 +1,108 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include "../pickboard/pickboardcfg.h" | 21 | #include "../pickboard/pickboardcfg.h" |
22 | #include "../pickboard/pickboardpicks.h" | 22 | #include "../pickboard/pickboardpicks.h" |
23 | 23 | ||
24 | class QTimer; | 24 | class QTimer; |
25 | 25 | ||
26 | namespace KeyboardInput | ||
27 | { | ||
28 | |||
26 | class KeyboardConfig : public DictFilterConfig | 29 | class KeyboardConfig : public DictFilterConfig |
27 | { | 30 | { |
28 | public: | 31 | public: |
29 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 32 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
30 | virtual void generateText(const QString &s); | 33 | virtual void generateText(const QString &s); |
31 | void decBackspaces() { if (backspaces) backspaces--; } | 34 | void decBackspaces() { if (backspaces) backspaces--; } |
32 | void incBackspaces() { backspaces++; } | 35 | void incBackspaces() { backspaces++; } |
33 | void resetBackspaces() { backspaces = 0; } | 36 | void resetBackspaces() { backspaces = 0; } |
34 | private: | 37 | private: |
35 | int backspaces; | 38 | int backspaces; |
36 | }; | 39 | }; |
37 | 40 | ||
38 | 41 | ||
39 | class KeyboardPicks : public PickboardPicks | 42 | class KeyboardPicks : public PickboardPicks |
40 | { | 43 | { |
41 | Q_OBJECT | 44 | Q_OBJECT |
42 | public: | 45 | public: |
43 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 46 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
44 | : PickboardPicks(parent, name, f) { } | 47 | : PickboardPicks(parent, name, f) { } |
45 | void initialise(); | 48 | void initialise(); |
46 | virtual QSize sizeHint() const; | 49 | virtual QSize sizeHint() const; |
47 | KeyboardConfig *dc; | 50 | KeyboardConfig *dc; |
48 | }; | 51 | }; |
49 | 52 | ||
50 | class Keyboard : public QFrame | 53 | class Keyboard : public QFrame |
51 | { | 54 | { |
52 | Q_OBJECT | 55 | Q_OBJECT |
53 | public: | 56 | public: |
54 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 57 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
55 | 58 | ||
56 | void resetState(); | 59 | void resetState(); |
57 | 60 | ||
58 | void mousePressEvent(QMouseEvent*); | 61 | void mousePressEvent(QMouseEvent*); |
59 | void mouseReleaseEvent(QMouseEvent*); | 62 | void mouseReleaseEvent(QMouseEvent*); |
60 | void resizeEvent(QResizeEvent*); | 63 | void resizeEvent(QResizeEvent*); |
61 | void paintEvent(QPaintEvent* e); | 64 | void paintEvent(QPaintEvent* e); |
62 | void timerEvent(QTimerEvent* e); | 65 | void timerEvent(QTimerEvent* e); |
63 | void drawKeyboard( QPainter &p, int key = -1 ); | 66 | void drawKeyboard( QPainter &p, int key = -1 ); |
64 | 67 | ||
65 | void setMode(int mode) { useOptiKeys = mode; } | 68 | void setMode(int mode) { useOptiKeys = mode; } |
66 | 69 | ||
67 | QSize sizeHint() const; | 70 | QSize sizeHint() const; |
68 | 71 | ||
69 | signals: | 72 | signals: |
70 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 73 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
71 | 74 | ||
72 | private slots: | 75 | private slots: |
73 | void repeat(); | 76 | void repeat(); |
74 | 77 | ||
75 | private: | 78 | private: |
76 | int getKey( int &w, int j = -1 ); | 79 | int getKey( int &w, int j = -1 ); |
77 | void clearHighlight(); | 80 | void clearHighlight(); |
78 | 81 | ||
79 | uint shift:1; | 82 | uint shift:1; |
80 | uint lock:1; | 83 | uint lock:1; |
81 | uint ctrl:1; | 84 | uint ctrl:1; |
82 | uint alt:1; | 85 | uint alt:1; |
83 | uint useLargeKeys:1; | 86 | uint useLargeKeys:1; |
84 | uint useOptiKeys:1; | 87 | uint useOptiKeys:1; |
85 | 88 | ||
86 | int pressedKey; | 89 | int pressedKey; |
87 | 90 | ||
88 | KeyboardPicks *picks; | 91 | KeyboardPicks *picks; |
89 | 92 | ||
90 | int keyHeight; | 93 | int keyHeight; |
91 | int defaultKeyWidth; | 94 | int defaultKeyWidth; |
92 | int xoffs; | 95 | int xoffs; |
93 | 96 | ||
94 | int unicode; | 97 | int unicode; |
95 | int qkeycode; | 98 | int qkeycode; |
96 | int modifiers; | 99 | int modifiers; |
97 | 100 | ||
98 | int pressTid; | 101 | int pressTid; |
99 | bool pressed; | 102 | bool pressed; |
100 | 103 | ||
101 | QTimer *repeatTimer; | 104 | QTimer *repeatTimer; |
102 | }; | 105 | }; |
103 | 106 | ||
107 | } // namespace KeyboardInput | ||
108 | |||
diff --git a/inputmethods/keyboard/keyboardimpl.cpp b/inputmethods/keyboard/keyboardimpl.cpp index bc96402..3c77fe6 100644 --- a/inputmethods/keyboard/keyboardimpl.cpp +++ b/inputmethods/keyboard/keyboardimpl.cpp | |||
@@ -1,130 +1,128 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include "keyboard.h" | 22 | #include "keyboard.h" |
23 | #include "keyboardimpl.h" | 23 | #include "keyboardimpl.h" |
24 | 24 | ||
25 | /* XPM */ | 25 | /* XPM */ |
26 | static const char * kb_xpm[] = { | 26 | static const char * const kb_xpm[] = { |
27 | "28 13 4 1", | 27 | "28 13 4 1", |
28 | " c None", | 28 | " c None", |
29 | ". c #4C4C4C", | 29 | ". c #4C4C4C", |
30 | "+ c #FFF7DD", | 30 | "+ c #FFF7DD", |
31 | "@ c #D6CFBA", | 31 | "@ c #D6CFBA", |
32 | " .......................... ", | 32 | " .......................... ", |
33 | " .+++.+++.+++.+++.+++.++++. ", | 33 | " .+++.+++.+++.+++.+++.++++. ", |
34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", | 34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", |
35 | " .......................... ", | 35 | " .......................... ", |
36 | " .+++++.+++.+++.+++.++++++. ", | 36 | " .+++++.+++.+++.+++.++++++. ", |
37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", | 37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", |
38 | " .......................... ", | 38 | " .......................... ", |
39 | " .++++++.+++.+++.+++.+++++. ", | 39 | " .++++++.+++.+++.+++.+++++. ", |
40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", | 40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", |
41 | " .......................... ", | 41 | " .......................... ", |
42 | " .++++.++++++++++++++.++++. ", | 42 | " .++++.++++++++++++++.++++. ", |
43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", | 43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", |
44 | " .......................... "}; | 44 | " .......................... "}; |
45 | 45 | ||
46 | 46 | ||
47 | /* XPM */ | 47 | /* XPM */ |
48 | static char * opti_xpm[] = { | 48 | static const char * const ipti_xpm[] = { |
49 | "28 13 4 1", | 49 | "28 13 4 1", |
50 | " c None", | 50 | " c None", |
51 | ". c #4C4C4C", | 51 | ". c #4C4C4C", |
52 | "+ c #FFF7DD", | 52 | "+ c #FFF7DD", |
53 | "@ c #D6CFBA", | 53 | "@ c #D6CFBA", |
54 | " ......................... ", | 54 | " ......................... ", |
55 | " .+++.+++.+++.+++.+++.+++. ", | 55 | " .+++.+++.+++.+++.+++.+++. ", |
56 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 56 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
57 | " ......................... ", | 57 | " ......................... ", |
58 | " .+++.+++.+++.+++.+++.+++. ", | 58 | " .+++.+++.+++.+++.+++.+++. ", |
59 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 59 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
60 | " ......................... ", | 60 | " ......................... ", |
61 | " .+++.+++.+++.+++.+++.+++. ", | 61 | " .+++.+++.+++.+++.+++.+++. ", |
62 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 62 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
63 | " ......................... ", | 63 | " ......................... ", |
64 | " .+++.+++.+++.+++.+++.+++. ", | 64 | " .+++.+++.+++.+++.+++.+++. ", |
65 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", | 65 | " .+@@.+@@.+@@.+@@.+@@.+@@. ", |
66 | " ......................... "}; | 66 | " ......................... "}; |
67 | 67 | ||
68 | |||
69 | |||
70 | KeyboardImpl::KeyboardImpl() | 68 | KeyboardImpl::KeyboardImpl() |
71 | : input(0), icn(0), ref(0) | 69 | : input(0), icn(0), ref(0) |
72 | { | 70 | { |
73 | } | 71 | } |
74 | 72 | ||
75 | KeyboardImpl::~KeyboardImpl() | 73 | KeyboardImpl::~KeyboardImpl() |
76 | { | 74 | { |
77 | delete input; | 75 | delete input; |
78 | delete icn; | 76 | delete icn; |
79 | } | 77 | } |
80 | 78 | ||
81 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 79 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
82 | { | 80 | { |
83 | if ( !input ) | 81 | if ( !input ) |
84 | input = new Keyboard( parent, "Keyboard", f ); | 82 | input = new KeyboardInput::Keyboard( parent, "Keyboard", f ); |
85 | return input; | 83 | return input; |
86 | } | 84 | } |
87 | 85 | ||
88 | void KeyboardImpl::resetState() | 86 | void KeyboardImpl::resetState() |
89 | { | 87 | { |
90 | if ( input ) | 88 | if ( input ) |
91 | input->resetState(); | 89 | input->resetState(); |
92 | } | 90 | } |
93 | 91 | ||
94 | QPixmap *KeyboardImpl::icon() | 92 | QPixmap *KeyboardImpl::icon() |
95 | { | 93 | { |
96 | if ( !icn ) | 94 | if ( !icn ) |
97 | icn = new QPixmap( (const char **)kb_xpm ); | 95 | icn = new QPixmap( (const char **)kb_xpm ); |
98 | return icn; | 96 | return icn; |
99 | } | 97 | } |
100 | 98 | ||
101 | QString KeyboardImpl::name() | 99 | QString KeyboardImpl::name() |
102 | { | 100 | { |
103 | return qApp->translate( "InputMethods", "Keyboard" ); | 101 | return qApp->translate( "InputMethods", "Keyboard" ); |
104 | } | 102 | } |
105 | 103 | ||
106 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 104 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
107 | { | 105 | { |
108 | if ( input ) | 106 | if ( input ) |
109 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 107 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
110 | } | 108 | } |
111 | 109 | ||
112 | #ifndef QT_NO_COMPONENT | 110 | #ifndef QT_NO_COMPONENT |
113 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 111 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
114 | { | 112 | { |
115 | *iface = 0; | 113 | *iface = 0; |
116 | if ( uuid == IID_QUnknown ) | 114 | if ( uuid == IID_QUnknown ) |
117 | *iface = this; | 115 | *iface = this; |
118 | else if ( uuid == IID_InputMethod ) | 116 | else if ( uuid == IID_InputMethod ) |
119 | *iface = this; | 117 | *iface = this; |
120 | 118 | ||
121 | if ( *iface ) | 119 | if ( *iface ) |
122 | (*iface)->addRef(); | 120 | (*iface)->addRef(); |
123 | return QS_OK; | 121 | return QS_OK; |
124 | } | 122 | } |
125 | 123 | ||
126 | Q_EXPORT_INTERFACE() | 124 | Q_EXPORT_INTERFACE() |
127 | { | 125 | { |
128 | Q_CREATE_INSTANCE( KeyboardImpl ) | 126 | Q_CREATE_INSTANCE( KeyboardImpl ) |
129 | } | 127 | } |
130 | #endif | 128 | #endif |
diff --git a/inputmethods/keyboard/keyboardimpl.h b/inputmethods/keyboard/keyboardimpl.h index e756364..d33a822 100644 --- a/inputmethods/keyboard/keyboardimpl.h +++ b/inputmethods/keyboard/keyboardimpl.h | |||
@@ -1,51 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef KEYBOARDIMPL_H | 20 | #ifndef KEYBOARDIMPL_H |
21 | #define KEYBOARDIMPL_H | 21 | #define KEYBOARDIMPL_H |
22 | 22 | ||
23 | #include <qpe/inputmethodinterface.h> | 23 | #include <qpe/inputmethodinterface.h> |
24 | 24 | ||
25 | class Keyboard; | 25 | namespace KeyboardInput |
26 | { | ||
27 | class Keyboard; | ||
28 | } | ||
29 | |||
26 | class QPixmap; | 30 | class QPixmap; |
27 | 31 | ||
32 | namespace | ||
33 | { | ||
34 | |||
28 | class KeyboardImpl : public InputMethodInterface | 35 | class KeyboardImpl : public InputMethodInterface |
29 | { | 36 | { |
30 | public: | 37 | public: |
31 | KeyboardImpl(); | 38 | KeyboardImpl(); |
32 | virtual ~KeyboardImpl(); | 39 | virtual ~KeyboardImpl(); |
33 | 40 | ||
34 | #ifndef QT_NO_COMPONENT | 41 | #ifndef QT_NO_COMPONENT |
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
36 | Q_REFCOUNT | 43 | Q_REFCOUNT |
37 | #endif | 44 | #endif |
38 | 45 | ||
39 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | 46 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); |
40 | virtual void resetState(); | 47 | virtual void resetState(); |
41 | virtual QPixmap *icon(); | 48 | virtual QPixmap *icon(); |
42 | virtual QString name(); | 49 | virtual QString name(); |
43 | virtual void onKeyPress( QObject *receiver, const char *slot ); | 50 | virtual void onKeyPress( QObject *receiver, const char *slot ); |
44 | 51 | ||
45 | private: | 52 | private: |
46 | Keyboard *input; | 53 | KeyboardInput::Keyboard *input; |
47 | QPixmap *icn; | 54 | QPixmap *icn; |
48 | ulong ref; | 55 | ulong ref; |
49 | }; | 56 | }; |
50 | 57 | ||
58 | } // anonymous namespace | ||
59 | |||
51 | #endif | 60 | #endif |
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 |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index 84c0c74..c22fbb1 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1659 +1,1660 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "keyboard.h" | 21 | #include "keyboard.h" |
22 | #include "configdlg.h" | 22 | #include "configdlg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
26 | 26 | ||
27 | #include <qwindowsystem_qws.h> | 27 | #include <qwindowsystem_qws.h> |
28 | #include <qpainter.h> | 28 | #include <qpainter.h> |
29 | #include <qfontmetrics.h> | 29 | #include <qfontmetrics.h> |
30 | #include <qtimer.h> | 30 | #include <qtimer.h> |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
33 | #include <ctype.h> | 33 | #include <ctype.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qstringlist.h> | 36 | #include <qstringlist.h> |
37 | 37 | ||
38 | #include <sys/utsname.h> | 38 | #include <sys/utsname.h> |
39 | 39 | ||
40 | using namespace MultiKey; | ||
40 | 41 | ||
41 | /* Keyboard::Keyboard {{{1 */ | 42 | /* Keyboard::Keyboard {{{1 */ |
42 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 43 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : |
43 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), | 44 | QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), |
44 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), | 45 | meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), |
45 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), | 46 | useLargeKeys(TRUE), usePicks(0), useRepeat(0), |
46 | pressedKeyRow(-1), pressedKeyCol(-1), | 47 | pressedKeyRow(-1), pressedKeyCol(-1), |
47 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), | 48 | unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), |
48 | configdlg(0) | 49 | configdlg(0) |
49 | 50 | ||
50 | { | 51 | { |
51 | 52 | ||
52 | // get the default font | 53 | // get the default font |
53 | Config *config = new Config( "qpe" ); | 54 | Config *config = new Config( "qpe" ); |
54 | config->setGroup( "Appearance" ); | 55 | config->setGroup( "Appearance" ); |
55 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); | 56 | QString familyStr = config->readEntry( "FontFamily", "fixed" ); |
56 | delete config; | 57 | delete config; |
57 | 58 | ||
58 | config = new Config("multikey"); | 59 | config = new Config("multikey"); |
59 | config->setGroup ("general"); | 60 | config->setGroup ("general"); |
60 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 61 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
61 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 62 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
62 | delete config; | 63 | delete config; |
63 | 64 | ||
64 | 65 | ||
65 | setFont( QFont( familyStr, 10 ) ); | 66 | setFont( QFont( familyStr, 10 ) ); |
66 | 67 | ||
67 | picks = new KeyboardPicks( this ); | 68 | picks = new KeyboardPicks( this ); |
68 | picks->setFont( QFont( familyStr, 10 ) ); | 69 | picks->setFont( QFont( familyStr, 10 ) ); |
69 | picks->initialise(); | 70 | picks->initialise(); |
70 | if (usePicks) { | 71 | if (usePicks) { |
71 | 72 | ||
72 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 73 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
73 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 74 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
74 | 75 | ||
75 | } else picks->hide(); | 76 | } else picks->hide(); |
76 | 77 | ||
77 | loadKeyboardColors(); | 78 | loadKeyboardColors(); |
78 | 79 | ||
79 | keys = new Keys(); | 80 | keys = new Keys(); |
80 | 81 | ||
81 | repeatTimer = new QTimer( this ); | 82 | repeatTimer = new QTimer( this ); |
82 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 83 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
83 | 84 | ||
84 | } | 85 | } |
85 | 86 | ||
86 | Keyboard::~Keyboard() { | 87 | Keyboard::~Keyboard() { |
87 | 88 | ||
88 | if ( configdlg ) { | 89 | if ( configdlg ) { |
89 | delete (ConfigDlg *) configdlg; | 90 | delete (ConfigDlg *) configdlg; |
90 | configdlg = 0; | 91 | configdlg = 0; |
91 | } | 92 | } |
92 | 93 | ||
93 | } | 94 | } |
94 | 95 | ||
95 | /* Keyboard::resizeEvent {{{1 */ | 96 | /* Keyboard::resizeEvent {{{1 */ |
96 | void Keyboard::resizeEvent(QResizeEvent*) | 97 | void Keyboard::resizeEvent(QResizeEvent*) |
97 | { | 98 | { |
98 | int ph = picks->sizeHint().height(); | 99 | int ph = picks->sizeHint().height(); |
99 | picks->setGeometry( 0, 0, width(), ph ); | 100 | picks->setGeometry( 0, 0, width(), ph ); |
100 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); | 101 | keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); |
101 | 102 | ||
102 | int nk; // number of keys? | 103 | int nk; // number of keys? |
103 | if ( useLargeKeys ) { | 104 | if ( useLargeKeys ) { |
104 | nk = 15; | 105 | nk = 15; |
105 | } else { | 106 | } else { |
106 | nk = 19; | 107 | nk = 19; |
107 | } | 108 | } |
108 | defaultKeyWidth = (width()/nk)/2; | 109 | defaultKeyWidth = (width()/nk)/2; |
109 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? | 110 | xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? |
110 | 111 | ||
111 | } | 112 | } |
112 | 113 | ||
113 | /* KeyboardPicks::initialize {{{1 */ | 114 | /* KeyboardPicks::initialize {{{1 */ |
114 | void KeyboardPicks::initialise() | 115 | void KeyboardPicks::initialise() |
115 | { | 116 | { |
116 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 117 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
117 | mode = 0; | 118 | mode = 0; |
118 | dc = new KeyboardConfig(this); | 119 | dc = new KeyboardConfig(this); |
119 | configs.append(dc); | 120 | configs.append(dc); |
120 | } | 121 | } |
121 | 122 | ||
122 | /* KeyboardPicks::sizeHint {{{1 */ | 123 | /* KeyboardPicks::sizeHint {{{1 */ |
123 | QSize KeyboardPicks::sizeHint() const | 124 | QSize KeyboardPicks::sizeHint() const |
124 | { | 125 | { |
125 | return QSize(240,fontMetrics().lineSpacing()); | 126 | return QSize(240,fontMetrics().lineSpacing()); |
126 | } | 127 | } |
127 | 128 | ||
128 | 129 | ||
129 | /* KeyboardConfig::generateText {{{1 */ | 130 | /* KeyboardConfig::generateText {{{1 */ |
130 | void KeyboardConfig::generateText(const QString &s) | 131 | void KeyboardConfig::generateText(const QString &s) |
131 | { | 132 | { |
132 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 133 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
133 | for (int i=0; i<(int)backspaces; i++) { | 134 | for (int i=0; i<(int)backspaces; i++) { |
134 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 135 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
135 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 136 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
136 | } | 137 | } |
137 | for (int i=0; i<(int)s.length(); i++) { | 138 | for (int i=0; i<(int)s.length(); i++) { |
138 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 139 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
139 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 140 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
140 | } | 141 | } |
141 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 142 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
142 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 143 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
143 | backspaces = 0; | 144 | backspaces = 0; |
144 | #endif | 145 | #endif |
145 | } | 146 | } |
146 | 147 | ||
147 | 148 | ||
148 | 149 | ||
149 | 150 | ||
150 | /* Keyboard::paintEvent {{{1 */ | 151 | /* Keyboard::paintEvent {{{1 */ |
151 | void Keyboard::paintEvent(QPaintEvent* e) | 152 | void Keyboard::paintEvent(QPaintEvent* e) |
152 | { | 153 | { |
153 | QPainter painter(this); | 154 | QPainter painter(this); |
154 | painter.setClipRect(e->rect()); | 155 | painter.setClipRect(e->rect()); |
155 | drawKeyboard( painter ); | 156 | drawKeyboard( painter ); |
156 | picks->dc->draw( &painter ); | 157 | picks->dc->draw( &painter ); |
157 | } | 158 | } |
158 | 159 | ||
159 | 160 | ||
160 | /* Keyboard::drawKeyboard {{{1 */ | 161 | /* Keyboard::drawKeyboard {{{1 */ |
161 | 162 | ||
162 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 163 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) |
163 | { | 164 | { |
164 | 165 | ||
165 | 166 | ||
166 | if (row != -1 && col != -1) { //just redraw one key | 167 | if (row != -1 && col != -1) { //just redraw one key |
167 | 168 | ||
168 | int x = 0; | 169 | int x = 0; |
169 | for (int i = 0; i < col; i++) { | 170 | for (int i = 0; i < col; i++) { |
170 | 171 | ||
171 | x += keys->width(row, i) * defaultKeyWidth; | 172 | x += keys->width(row, i) * defaultKeyWidth; |
172 | } | 173 | } |
173 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 174 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
174 | 175 | ||
175 | int keyWidth = keys->width(row, col); | 176 | int keyWidth = keys->width(row, col); |
176 | 177 | ||
177 | p.fillRect(x + 1, y + 1, | 178 | p.fillRect(x + 1, y + 1, |
178 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, | 179 | keyWidth * defaultKeyWidth - 1, keyHeight - 1, |
179 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); | 180 | pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); |
180 | 181 | ||
181 | QImage *pix = keys->pix(row,col); | 182 | QImage *pix = keys->pix(row,col); |
182 | 183 | ||
183 | ushort c = keys->uni(row, col); | 184 | ushort c = keys->uni(row, col); |
184 | 185 | ||
185 | p.setPen(textcolor); | 186 | p.setPen(textcolor); |
186 | if (!pix) { | 187 | if (!pix) { |
187 | if ((shift || lock) && keys->shift(c)) | 188 | if ((shift || lock) && keys->shift(c)) |
188 | 189 | ||
189 | if (circumflex && keys->circumflex(keys->shift(c))) | 190 | if (circumflex && keys->circumflex(keys->shift(c))) |
190 | c = keys->circumflex(keys->shift(c)); | 191 | c = keys->circumflex(keys->shift(c)); |
191 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 192 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
192 | c = keys->diaeresis(keys->shift(c)); | 193 | c = keys->diaeresis(keys->shift(c)); |
193 | else if (baccent && keys->baccent(keys->shift(c))) | 194 | else if (baccent && keys->baccent(keys->shift(c))) |
194 | c = keys->baccent(keys->shift(c)); | 195 | c = keys->baccent(keys->shift(c)); |
195 | else if (accent && keys->accent(keys->shift(c))) | 196 | else if (accent && keys->accent(keys->shift(c))) |
196 | c = keys->accent(keys->shift(c)); | 197 | c = keys->accent(keys->shift(c)); |
197 | else if (meta && keys->meta(keys->shift(c))) | 198 | else if (meta && keys->meta(keys->shift(c))) |
198 | c = keys->meta(keys->shift(c)); | 199 | c = keys->meta(keys->shift(c)); |
199 | else | 200 | else |
200 | c = keys->shift(c); | 201 | c = keys->shift(c); |
201 | 202 | ||
202 | else if (meta && keys->meta(c)) | 203 | else if (meta && keys->meta(c)) |
203 | c = keys->meta(c); | 204 | c = keys->meta(c); |
204 | else if (circumflex && keys->circumflex(c)) | 205 | else if (circumflex && keys->circumflex(c)) |
205 | c = keys->circumflex(c); | 206 | c = keys->circumflex(c); |
206 | else if (baccent && keys->baccent(c)) | 207 | else if (baccent && keys->baccent(c)) |
207 | c = keys->baccent(c); | 208 | c = keys->baccent(c); |
208 | else if (accent && keys->accent(c)) | 209 | else if (accent && keys->accent(c)) |
209 | c = keys->accent(c); | 210 | c = keys->accent(c); |
210 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 211 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
211 | 212 | ||
212 | // the diaeresis key itself has to be in the diaeresisMap, | 213 | // the diaeresis key itself has to be in the diaeresisMap, |
213 | // or just do this to make it display the diaeresis char. | 214 | // or just do this to make it display the diaeresis char. |
214 | 215 | ||
215 | if (c == 0x2c6) | 216 | if (c == 0x2c6) |
216 | c = 0xa8; | 217 | c = 0xa8; |
217 | else | 218 | else |
218 | c = keys->diaeresis(c); | 219 | c = keys->diaeresis(c); |
219 | } | 220 | } |
220 | 221 | ||
221 | p.drawText(x, y, | 222 | p.drawText(x, y, |
222 | defaultKeyWidth * keyWidth + 3, keyHeight, | 223 | defaultKeyWidth * keyWidth + 3, keyHeight, |
223 | AlignCenter, (QChar)c); | 224 | AlignCenter, (QChar)c); |
224 | } | 225 | } |
225 | else | 226 | else |
226 | // center the image in the middle of the key | 227 | // center the image in the middle of the key |
227 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, | 228 | p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, |
228 | y + (keyHeight - pix->height())/2 + 1, | 229 | y + (keyHeight - pix->height())/2 + 1, |
229 | *pix ); | 230 | *pix ); |
230 | 231 | ||
231 | // this fixes the problem that the very right end of the board's vertical line | 232 | // this fixes the problem that the very right end of the board's vertical line |
232 | // gets painted over, because it's one pixel shorter than all other keys | 233 | // gets painted over, because it's one pixel shorter than all other keys |
233 | p.setPen(keycolor_lines); | 234 | p.setPen(keycolor_lines); |
234 | p.drawLine(width() - 1, 0, width() - 1, height()); | 235 | p.drawLine(width() - 1, 0, width() - 1, height()); |
235 | 236 | ||
236 | } else { | 237 | } else { |
237 | 238 | ||
238 | 239 | ||
239 | p.fillRect(0, 0, width(), height(), keycolor); | 240 | p.fillRect(0, 0, width(), height(), keycolor); |
240 | 241 | ||
241 | for (row = 1; row <= keys->rows(); row++) { | 242 | for (row = 1; row <= keys->rows(); row++) { |
242 | 243 | ||
243 | int x = 0; | 244 | int x = 0; |
244 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); | 245 | int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); |
245 | 246 | ||
246 | p.setPen(keycolor_lines); | 247 | p.setPen(keycolor_lines); |
247 | p.drawLine(x, y, x + width(), y); | 248 | p.drawLine(x, y, x + width(), y); |
248 | 249 | ||
249 | for (int col = 0; col < keys->numKeys(row); col++) { | 250 | for (int col = 0; col < keys->numKeys(row); col++) { |
250 | 251 | ||
251 | QImage *pix = keys->pix(row, col); | 252 | QImage *pix = keys->pix(row, col); |
252 | int keyWidth = keys->width(row, col); | 253 | int keyWidth = keys->width(row, col); |
253 | 254 | ||
254 | 255 | ||
255 | int keyWidthPix = defaultKeyWidth * keyWidth; | 256 | int keyWidthPix = defaultKeyWidth * keyWidth; |
256 | 257 | ||
257 | if (keys->pressed(row, col)) | 258 | if (keys->pressed(row, col)) |
258 | p.fillRect(x+1, y+1, keyWidthPix - 1, | 259 | p.fillRect(x+1, y+1, keyWidthPix - 1, |
259 | keyHeight - 1, keycolor_pressed); | 260 | keyHeight - 1, keycolor_pressed); |
260 | 261 | ||
261 | ushort c = keys->uni(row, col); | 262 | ushort c = keys->uni(row, col); |
262 | 263 | ||
263 | p.setPen(textcolor); | 264 | p.setPen(textcolor); |
264 | if (!pix) { | 265 | if (!pix) { |
265 | if ((shift || lock) && keys->shift(c)) | 266 | if ((shift || lock) && keys->shift(c)) |
266 | 267 | ||
267 | if (circumflex && keys->circumflex(keys->shift(c))) | 268 | if (circumflex && keys->circumflex(keys->shift(c))) |
268 | c = keys->circumflex(keys->shift(c)); | 269 | c = keys->circumflex(keys->shift(c)); |
269 | else if (diaeresis && keys->diaeresis(keys->shift(c))) | 270 | else if (diaeresis && keys->diaeresis(keys->shift(c))) |
270 | c = keys->diaeresis(keys->shift(c)); | 271 | c = keys->diaeresis(keys->shift(c)); |
271 | else if (baccent && keys->baccent(keys->shift(c))) | 272 | else if (baccent && keys->baccent(keys->shift(c))) |
272 | c = keys->baccent(keys->shift(c)); | 273 | c = keys->baccent(keys->shift(c)); |
273 | else if (accent && keys->accent(keys->shift(c))) | 274 | else if (accent && keys->accent(keys->shift(c))) |
274 | c = keys->accent(keys->shift(c)); | 275 | c = keys->accent(keys->shift(c)); |
275 | else if (meta && keys->meta(keys->shift(c))) | 276 | else if (meta && keys->meta(keys->shift(c))) |
276 | c = keys->meta(keys->shift(c)); | 277 | c = keys->meta(keys->shift(c)); |
277 | else | 278 | else |
278 | c = keys->shift(c); | 279 | c = keys->shift(c); |
279 | 280 | ||
280 | else if (meta && keys->meta(c)) | 281 | else if (meta && keys->meta(c)) |
281 | c = keys->meta(c); | 282 | c = keys->meta(c); |
282 | else if (circumflex && keys->circumflex(c)) | 283 | else if (circumflex && keys->circumflex(c)) |
283 | c = keys->circumflex(c); | 284 | c = keys->circumflex(c); |
284 | else if (baccent && keys->baccent(c)) | 285 | else if (baccent && keys->baccent(c)) |
285 | c = keys->baccent(c); | 286 | c = keys->baccent(c); |
286 | else if (accent && keys->accent(c)) | 287 | else if (accent && keys->accent(c)) |
287 | c = keys->accent(c); | 288 | c = keys->accent(c); |
288 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { | 289 | else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { |
289 | 290 | ||
290 | if (c == 0x2c6) | 291 | if (c == 0x2c6) |
291 | c = 0xa8; | 292 | c = 0xa8; |
292 | else | 293 | else |
293 | c = keys->diaeresis(c); | 294 | c = keys->diaeresis(c); |
294 | } | 295 | } |
295 | 296 | ||
296 | p.drawText(x, y, | 297 | p.drawText(x, y, |
297 | keyWidthPix + 3, keyHeight, | 298 | keyWidthPix + 3, keyHeight, |
298 | AlignCenter, (QChar)c); | 299 | AlignCenter, (QChar)c); |
299 | } | 300 | } |
300 | else { | 301 | else { |
301 | // center the image in the middle of the key | 302 | // center the image in the middle of the key |
302 | pix->setColor(1, textcolor.rgb()); | 303 | pix->setColor(1, textcolor.rgb()); |
303 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, | 304 | p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, |
304 | y + (keyHeight - pix->height())/2 + 1, | 305 | y + (keyHeight - pix->height())/2 + 1, |
305 | QImage(*pix) ); | 306 | QImage(*pix) ); |
306 | } | 307 | } |
307 | 308 | ||
308 | p.setPen(keycolor_lines); | 309 | p.setPen(keycolor_lines); |
309 | p.drawLine(x, y, x, y + keyHeight); | 310 | p.drawLine(x, y, x, y + keyHeight); |
310 | 311 | ||
311 | x += keyWidthPix; | 312 | x += keyWidthPix; |
312 | } | 313 | } |
313 | 314 | ||
314 | 315 | ||
315 | } | 316 | } |
316 | p.setPen(keycolor_lines); | 317 | p.setPen(keycolor_lines); |
317 | p.drawLine(0, height() - 1, width(), height() - 1); | 318 | p.drawLine(0, height() - 1, width(), height() - 1); |
318 | p.drawLine(width() - 1, 0, width() - 1, height()); | 319 | p.drawLine(width() - 1, 0, width() - 1, height()); |
319 | } | 320 | } |
320 | 321 | ||
321 | } | 322 | } |
322 | 323 | ||
323 | 324 | ||
324 | /* Keyboard::mousePressEvent {{{1 */ | 325 | /* Keyboard::mousePressEvent {{{1 */ |
325 | void Keyboard::mousePressEvent(QMouseEvent *e) | 326 | void Keyboard::mousePressEvent(QMouseEvent *e) |
326 | { | 327 | { |
327 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; | 328 | int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; |
328 | if (row > 5) row = 5; | 329 | if (row > 5) row = 5; |
329 | 330 | ||
330 | // figure out the column | 331 | // figure out the column |
331 | int col = 0; | 332 | int col = 0; |
332 | for (int w = 0; e->x() >= w; col++) | 333 | for (int w = 0; e->x() >= w; col++) |
333 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys | 334 | if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys |
334 | w += keys->width(row,col) * defaultKeyWidth; | 335 | w += keys->width(row,col) * defaultKeyWidth; |
335 | else break; | 336 | else break; |
336 | 337 | ||
337 | if (col <= 0) return; | 338 | if (col <= 0) return; |
338 | 339 | ||
339 | col --; // rewind one... | 340 | col --; // rewind one... |
340 | 341 | ||
341 | qkeycode = keys->qcode(row, col); | 342 | qkeycode = keys->qcode(row, col); |
342 | unicode = keys->uni(row, col); | 343 | unicode = keys->uni(row, col); |
343 | 344 | ||
344 | // might need to repaint if two or more of the same keys. | 345 | // might need to repaint if two or more of the same keys. |
345 | // should be faster if just paint one key even though multiple keys exist. | 346 | // should be faster if just paint one key even though multiple keys exist. |
346 | bool need_repaint = FALSE; | 347 | bool need_repaint = FALSE; |
347 | 348 | ||
348 | // circumflex and diaeresis support | 349 | // circumflex and diaeresis support |
349 | // messy to have this here, but too hard to implement any other method | 350 | // messy to have this here, but too hard to implement any other method |
350 | if (unicode == 0x2c6) { | 351 | if (unicode == 0x2c6) { |
351 | 352 | ||
352 | unicode = 0; | 353 | unicode = 0; |
353 | if (shift || lock) { | 354 | if (shift || lock) { |
354 | 355 | ||
355 | // diaeresis | 356 | // diaeresis |
356 | qkeycode = 0x2001; | 357 | qkeycode = 0x2001; |
357 | } | 358 | } |
358 | else { | 359 | else { |
359 | 360 | ||
360 | // circumflex | 361 | // circumflex |
361 | qkeycode = 0x2000; | 362 | qkeycode = 0x2000; |
362 | } | 363 | } |
363 | } | 364 | } |
364 | 365 | ||
365 | // Back accent character support | 366 | // Back accent character support |
366 | 367 | ||
367 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one | 368 | // the keys from 2c6 ~ 2cf should be used instead of the ascii one |
368 | if (unicode == 0x2cb) { | 369 | if (unicode == 0x2cb) { |
369 | 370 | ||
370 | unicode = 0; | 371 | unicode = 0; |
371 | if (shift || lock) { | 372 | if (shift || lock) { |
372 | 373 | ||
373 | // circumblex | 374 | // circumblex |
374 | qkeycode = 0x2000; | 375 | qkeycode = 0x2000; |
375 | } | 376 | } |
376 | else { | 377 | else { |
377 | 378 | ||
378 | // back accent | 379 | // back accent |
379 | qkeycode = 0x2002; | 380 | qkeycode = 0x2002; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | 383 | ||
383 | // Accent character support | 384 | // Accent character support |
384 | 385 | ||
385 | if (unicode == 0x2ca) { | 386 | if (unicode == 0x2ca) { |
386 | 387 | ||
387 | unicode = 0; | 388 | unicode = 0; |
388 | if (shift || lock) { | 389 | if (shift || lock) { |
389 | 390 | ||
390 | // diaeresis | 391 | // diaeresis |
391 | qkeycode = 0x2001; | 392 | qkeycode = 0x2001; |
392 | } | 393 | } |
393 | else { | 394 | else { |
394 | 395 | ||
395 | // accent | 396 | // accent |
396 | qkeycode = 0x2003; | 397 | qkeycode = 0x2003; |
397 | } | 398 | } |
398 | } | 399 | } |
399 | 400 | ||
400 | 401 | ||
401 | if (unicode == 0) { // either Qt char, or nothing | 402 | if (unicode == 0) { // either Qt char, or nothing |
402 | 403 | ||
403 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard | 404 | if (qkeycode == Qt::Key_F1) { // toggle the pickboard |
404 | 405 | ||
405 | if ( configdlg ) { | 406 | if ( configdlg ) { |
406 | 407 | ||
407 | delete (ConfigDlg *) configdlg; | 408 | delete (ConfigDlg *) configdlg; |
408 | configdlg = 0; | 409 | configdlg = 0; |
409 | } | 410 | } |
410 | else { | 411 | else { |
411 | configdlg = new ConfigDlg (); | 412 | configdlg = new ConfigDlg (); |
412 | connect(configdlg, SIGNAL(setMapToDefault()), | 413 | connect(configdlg, SIGNAL(setMapToDefault()), |
413 | this, SLOT(setMapToDefault())); | 414 | this, SLOT(setMapToDefault())); |
414 | connect(configdlg, SIGNAL(setMapToFile(QString)), | 415 | connect(configdlg, SIGNAL(setMapToFile(QString)), |
415 | this, SLOT(setMapToFile(QString))); | 416 | this, SLOT(setMapToFile(QString))); |
416 | connect(configdlg, SIGNAL(pickboardToggled(bool)), | 417 | connect(configdlg, SIGNAL(pickboardToggled(bool)), |
417 | this, SLOT(togglePickboard(bool))); | 418 | this, SLOT(togglePickboard(bool))); |
418 | connect(configdlg, SIGNAL(repeatToggled(bool)), | 419 | connect(configdlg, SIGNAL(repeatToggled(bool)), |
419 | this, SLOT(toggleRepeat(bool))); | 420 | this, SLOT(toggleRepeat(bool))); |
420 | connect(configdlg, SIGNAL(reloadKeyboard()), | 421 | connect(configdlg, SIGNAL(reloadKeyboard()), |
421 | this, SLOT(reloadKeyboard())); | 422 | this, SLOT(reloadKeyboard())); |
422 | connect(configdlg, SIGNAL(configDlgClosed()), | 423 | connect(configdlg, SIGNAL(configDlgClosed()), |
423 | this, SLOT(cleanupConfigDlg())); | 424 | this, SLOT(cleanupConfigDlg())); |
424 | configdlg->showMaximized(); | 425 | configdlg->showMaximized(); |
425 | configdlg->show(); | 426 | configdlg->show(); |
426 | configdlg->raise(); | 427 | configdlg->raise(); |
427 | } | 428 | } |
428 | 429 | ||
429 | } else if (qkeycode == Qt::Key_Control) { | 430 | } else if (qkeycode == Qt::Key_Control) { |
430 | need_repaint = TRUE; | 431 | need_repaint = TRUE; |
431 | 432 | ||
432 | if (ctrl) { | 433 | if (ctrl) { |
433 | 434 | ||
434 | *ctrl = 0; | 435 | *ctrl = 0; |
435 | ctrl = 0; | 436 | ctrl = 0; |
436 | 437 | ||
437 | } else { | 438 | } else { |
438 | 439 | ||
439 | ctrl = keys->pressedPtr(row, col); | 440 | ctrl = keys->pressedPtr(row, col); |
440 | need_repaint = TRUE; | 441 | need_repaint = TRUE; |
441 | *ctrl = !keys->pressed(row, col); | 442 | *ctrl = !keys->pressed(row, col); |
442 | 443 | ||
443 | } | 444 | } |
444 | 445 | ||
445 | } else if (qkeycode == Qt::Key_Alt) { | 446 | } else if (qkeycode == Qt::Key_Alt) { |
446 | need_repaint = TRUE; | 447 | need_repaint = TRUE; |
447 | 448 | ||
448 | if (alt) { | 449 | if (alt) { |
449 | *alt = 0; | 450 | *alt = 0; |
450 | alt = 0; | 451 | alt = 0; |
451 | 452 | ||
452 | } else { | 453 | } else { |
453 | 454 | ||
454 | alt = keys->pressedPtr(row, col); | 455 | alt = keys->pressedPtr(row, col); |
455 | need_repaint = TRUE; | 456 | need_repaint = TRUE; |
456 | *alt = !keys->pressed(row, col); | 457 | *alt = !keys->pressed(row, col); |
457 | } | 458 | } |
458 | 459 | ||
459 | } else if (qkeycode == Qt::Key_Shift) { | 460 | } else if (qkeycode == Qt::Key_Shift) { |
460 | need_repaint = TRUE; | 461 | need_repaint = TRUE; |
461 | 462 | ||
462 | if (shift) { | 463 | if (shift) { |
463 | *shift = 0; | 464 | *shift = 0; |
464 | shift = 0; | 465 | shift = 0; |
465 | } | 466 | } |
466 | else { | 467 | else { |
467 | shift = keys->pressedPtr(row, col); | 468 | shift = keys->pressedPtr(row, col); |
468 | *shift = 1; | 469 | *shift = 1; |
469 | if (lock) { | 470 | if (lock) { |
470 | *lock = 0; | 471 | *lock = 0; |
471 | lock = 0; | 472 | lock = 0; |
472 | } | 473 | } |
473 | } | 474 | } |
474 | 475 | ||
475 | 476 | ||
476 | /* | 477 | /* |
477 | * want to be able to hit circumflex/diaeresis -> shift | 478 | * want to be able to hit circumflex/diaeresis -> shift |
478 | * to type in shifted circumflex/diaeresis chars. | 479 | * to type in shifted circumflex/diaeresis chars. |
479 | * same thing with meta | 480 | * same thing with meta |
480 | 481 | ||
481 | if (meta) { *meta = 0; meta = 0; } | 482 | if (meta) { *meta = 0; meta = 0; } |
482 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 483 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
483 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 484 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
484 | 485 | ||
485 | */ | 486 | */ |
486 | 487 | ||
487 | } else if (qkeycode == Qt::Key_CapsLock) { | 488 | } else if (qkeycode == Qt::Key_CapsLock) { |
488 | need_repaint = TRUE; | 489 | need_repaint = TRUE; |
489 | 490 | ||
490 | if (lock) { | 491 | if (lock) { |
491 | *lock = 0; | 492 | *lock = 0; |
492 | lock = 0; | 493 | lock = 0; |
493 | } | 494 | } |
494 | else { | 495 | else { |
495 | lock = keys->pressedPtr(row, col);; | 496 | lock = keys->pressedPtr(row, col);; |
496 | *lock = true;; | 497 | *lock = true;; |
497 | if (shift) { | 498 | if (shift) { |
498 | *shift = 0; | 499 | *shift = 0; |
499 | shift = 0; | 500 | shift = 0; |
500 | } | 501 | } |
501 | } | 502 | } |
502 | 503 | ||
503 | /* | 504 | /* |
504 | if (meta) { *meta = 0; meta = 0; } | 505 | if (meta) { *meta = 0; meta = 0; } |
505 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 506 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
506 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 507 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
507 | */ | 508 | */ |
508 | 509 | ||
509 | } else if (qkeycode == Qt::Key_Meta) { | 510 | } else if (qkeycode == Qt::Key_Meta) { |
510 | need_repaint = TRUE; | 511 | need_repaint = TRUE; |
511 | 512 | ||
512 | if (meta) { | 513 | if (meta) { |
513 | *meta = 0; | 514 | *meta = 0; |
514 | meta = 0; | 515 | meta = 0; |
515 | 516 | ||
516 | } else { | 517 | } else { |
517 | 518 | ||
518 | meta = keys->pressedPtr(row, col); | 519 | meta = keys->pressedPtr(row, col); |
519 | *meta = true; | 520 | *meta = true; |
520 | } | 521 | } |
521 | 522 | ||
522 | // reset all the other keys | 523 | // reset all the other keys |
523 | if (shift) { *shift = 0; shift = 0; } | 524 | if (shift) { *shift = 0; shift = 0; } |
524 | if (lock) { *lock = 0; lock = 0; } | 525 | if (lock) { *lock = 0; lock = 0; } |
525 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 526 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
526 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 527 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
527 | if (baccent) { *baccent = 0; baccent = 0; } | 528 | if (baccent) { *baccent = 0; baccent = 0; } |
528 | if (accent) { *accent = 0; accent = 0; } | 529 | if (accent) { *accent = 0; accent = 0; } |
529 | 530 | ||
530 | // dont need to emit this key... acts same as alt | 531 | // dont need to emit this key... acts same as alt |
531 | qkeycode = 0; | 532 | qkeycode = 0; |
532 | 533 | ||
533 | // circumflex | 534 | // circumflex |
534 | } else if (qkeycode == 0x2000) { | 535 | } else if (qkeycode == 0x2000) { |
535 | need_repaint = TRUE; | 536 | need_repaint = TRUE; |
536 | 537 | ||
537 | if (circumflex) { | 538 | if (circumflex) { |
538 | 539 | ||
539 | *circumflex = 0; | 540 | *circumflex = 0; |
540 | circumflex = 0; | 541 | circumflex = 0; |
541 | 542 | ||
542 | } else { | 543 | } else { |
543 | 544 | ||
544 | circumflex = keys->pressedPtr(row, col); | 545 | circumflex = keys->pressedPtr(row, col); |
545 | *circumflex = true; | 546 | *circumflex = true; |
546 | } | 547 | } |
547 | 548 | ||
548 | /* no need to turn off shift or lock if circumflex | 549 | /* no need to turn off shift or lock if circumflex |
549 | * keys are pressed | 550 | * keys are pressed |
550 | 551 | ||
551 | if (shift) { *shift = 0; shift = 0; } | 552 | if (shift) { *shift = 0; shift = 0; } |
552 | if (lock) { *lock = 0; lock = 0; } | 553 | if (lock) { *lock = 0; lock = 0; } |
553 | 554 | ||
554 | */ | 555 | */ |
555 | 556 | ||
556 | // have to reset all the other keys | 557 | // have to reset all the other keys |
557 | if (meta) { *meta = 0; meta = 0; } | 558 | if (meta) { *meta = 0; meta = 0; } |
558 | if (diaeresis) { | 559 | if (diaeresis) { |
559 | 560 | ||
560 | // *diaeresis and *circumflex point to the same thing | 561 | // *diaeresis and *circumflex point to the same thing |
561 | // when diaeresis is enabled and you hit the circumflex | 562 | // when diaeresis is enabled and you hit the circumflex |
562 | // since they are the same key, it should turn off the | 563 | // since they are the same key, it should turn off the |
563 | // key | 564 | // key |
564 | 565 | ||
565 | *diaeresis = 0; | 566 | *diaeresis = 0; |
566 | diaeresis = 0; | 567 | diaeresis = 0; |
567 | circumflex = 0; | 568 | circumflex = 0; |
568 | } | 569 | } |
569 | 570 | ||
570 | qkeycode = 0; | 571 | qkeycode = 0; |
571 | 572 | ||
572 | // diaeresis | 573 | // diaeresis |
573 | } else if (qkeycode == 0x2001) { | 574 | } else if (qkeycode == 0x2001) { |
574 | need_repaint = TRUE; | 575 | need_repaint = TRUE; |
575 | 576 | ||
576 | if (diaeresis) { | 577 | if (diaeresis) { |
577 | 578 | ||
578 | *diaeresis = 0; | 579 | *diaeresis = 0; |
579 | diaeresis = 0; | 580 | diaeresis = 0; |
580 | 581 | ||
581 | } else { | 582 | } else { |
582 | 583 | ||
583 | diaeresis = keys->pressedPtr(row, col); | 584 | diaeresis = keys->pressedPtr(row, col); |
584 | *diaeresis = true; | 585 | *diaeresis = true; |
585 | } | 586 | } |
586 | 587 | ||
587 | 588 | ||
588 | if (shift) { *shift = 0; shift = 0; } | 589 | if (shift) { *shift = 0; shift = 0; } |
589 | 590 | ||
590 | /* | 591 | /* |
591 | * | 592 | * |
592 | if (lock) { *lock = 0; lock = 0; } | 593 | if (lock) { *lock = 0; lock = 0; } |
593 | * | 594 | * |
594 | */ | 595 | */ |
595 | 596 | ||
596 | if (meta) { *meta = 0; meta = 0; } | 597 | if (meta) { *meta = 0; meta = 0; } |
597 | if (circumflex) { | 598 | if (circumflex) { |
598 | 599 | ||
599 | // *circumflex = 0; | 600 | // *circumflex = 0; |
600 | // | 601 | // |
601 | // same thing the diaeresis pointer points too | 602 | // same thing the diaeresis pointer points too |
602 | 603 | ||
603 | circumflex = 0; | 604 | circumflex = 0; |
604 | } | 605 | } |
605 | 606 | ||
606 | 607 | ||
607 | qkeycode = 0; | 608 | qkeycode = 0; |
608 | 609 | ||
609 | // Back accent | 610 | // Back accent |
610 | } else if (qkeycode == 0x2002) { | 611 | } else if (qkeycode == 0x2002) { |
611 | need_repaint = TRUE; | 612 | need_repaint = TRUE; |
612 | 613 | ||
613 | if (baccent) { | 614 | if (baccent) { |
614 | 615 | ||
615 | *baccent = 0; | 616 | *baccent = 0; |
616 | baccent = 0; | 617 | baccent = 0; |
617 | 618 | ||
618 | } else { | 619 | } else { |
619 | 620 | ||
620 | baccent = keys->pressedPtr(row, col); | 621 | baccent = keys->pressedPtr(row, col); |
621 | *baccent = true; | 622 | *baccent = true; |
622 | } | 623 | } |
623 | 624 | ||
624 | 625 | ||
625 | if (shift) { *shift = 0; shift = 0; } | 626 | if (shift) { *shift = 0; shift = 0; } |
626 | if (meta) { *meta = 0; meta = 0; } | 627 | if (meta) { *meta = 0; meta = 0; } |
627 | if (accent) { *accent = 0; accent = 0; } | 628 | if (accent) { *accent = 0; accent = 0; } |
628 | 629 | ||
629 | qkeycode = 0; | 630 | qkeycode = 0; |
630 | 631 | ||
631 | // Accent | 632 | // Accent |
632 | } else if (qkeycode == 0x2003) { | 633 | } else if (qkeycode == 0x2003) { |
633 | need_repaint = TRUE; | 634 | need_repaint = TRUE; |
634 | 635 | ||
635 | if (accent) { | 636 | if (accent) { |
636 | 637 | ||
637 | *accent = 0; | 638 | *accent = 0; |
638 | accent = 0; | 639 | accent = 0; |
639 | 640 | ||
640 | } else { | 641 | } else { |
641 | 642 | ||
642 | accent = keys->pressedPtr(row, col); | 643 | accent = keys->pressedPtr(row, col); |
643 | *accent = true; | 644 | *accent = true; |
644 | } | 645 | } |
645 | 646 | ||
646 | 647 | ||
647 | if (shift) { *shift = 0; shift = 0; } | 648 | if (shift) { *shift = 0; shift = 0; } |
648 | if (meta) { *meta = 0; meta = 0; } | 649 | if (meta) { *meta = 0; meta = 0; } |
649 | if (baccent) { *baccent = 0; } | 650 | if (baccent) { *baccent = 0; } |
650 | 651 | ||
651 | qkeycode = 0; | 652 | qkeycode = 0; |
652 | } | 653 | } |
653 | 654 | ||
654 | } | 655 | } |
655 | else { // normal char | 656 | else { // normal char |
656 | if ((shift || lock) && keys->shift(unicode)) { | 657 | if ((shift || lock) && keys->shift(unicode)) { |
657 | 658 | ||
658 | // make diaeresis/circumflex -> shift input shifted | 659 | // make diaeresis/circumflex -> shift input shifted |
659 | // diaeresis/circumflex chars | 660 | // diaeresis/circumflex chars |
660 | 661 | ||
661 | if (circumflex && keys->circumflex(keys->shift(unicode))) | 662 | if (circumflex && keys->circumflex(keys->shift(unicode))) |
662 | unicode = keys->circumflex(keys->shift(unicode)); | 663 | unicode = keys->circumflex(keys->shift(unicode)); |
663 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) | 664 | else if (diaeresis && keys->diaeresis(keys->shift(unicode))) |
664 | unicode = keys->diaeresis(keys->shift(unicode)); | 665 | unicode = keys->diaeresis(keys->shift(unicode)); |
665 | else if (baccent && keys->baccent(keys->shift(unicode))) | 666 | else if (baccent && keys->baccent(keys->shift(unicode))) |
666 | unicode = keys->baccent(keys->shift(unicode)); | 667 | unicode = keys->baccent(keys->shift(unicode)); |
667 | else if (accent && keys->accent(keys->shift(unicode))) | 668 | else if (accent && keys->accent(keys->shift(unicode))) |
668 | unicode = keys->accent(keys->shift(unicode)); | 669 | unicode = keys->accent(keys->shift(unicode)); |
669 | else if (meta && keys->meta(keys->shift(unicode))) | 670 | else if (meta && keys->meta(keys->shift(unicode))) |
670 | unicode = keys->meta(keys->shift(unicode)); | 671 | unicode = keys->meta(keys->shift(unicode)); |
671 | else | 672 | else |
672 | unicode = keys->shift(unicode); | 673 | unicode = keys->shift(unicode); |
673 | } | 674 | } |
674 | else if (meta && keys->meta(unicode)) { | 675 | else if (meta && keys->meta(unicode)) { |
675 | unicode = keys->meta(unicode); | 676 | unicode = keys->meta(unicode); |
676 | } | 677 | } |
677 | else if (circumflex && keys->circumflex(unicode)) { | 678 | else if (circumflex && keys->circumflex(unicode)) { |
678 | unicode = keys->circumflex(unicode); | 679 | unicode = keys->circumflex(unicode); |
679 | } | 680 | } |
680 | else if (diaeresis && keys->diaeresis(unicode)) { | 681 | else if (diaeresis && keys->diaeresis(unicode)) { |
681 | 682 | ||
682 | unicode = keys->diaeresis(unicode); | 683 | unicode = keys->diaeresis(unicode); |
683 | } | 684 | } |
684 | else if (baccent && keys->baccent(unicode)) { | 685 | else if (baccent && keys->baccent(unicode)) { |
685 | unicode = keys->baccent(unicode); | 686 | unicode = keys->baccent(unicode); |
686 | } | 687 | } |
687 | else if (accent && keys->accent(unicode)) { | 688 | else if (accent && keys->accent(unicode)) { |
688 | unicode = keys->accent(unicode); | 689 | unicode = keys->accent(unicode); |
689 | } | 690 | } |
690 | } | 691 | } |
691 | 692 | ||
692 | // korean parsing | 693 | // korean parsing |
693 | if (keys->lang == "ko") { | 694 | if (keys->lang == "ko") { |
694 | 695 | ||
695 | unicode = parseKoreanInput(unicode); | 696 | unicode = parseKoreanInput(unicode); |
696 | } | 697 | } |
697 | 698 | ||
698 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); | 699 | modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); |
699 | 700 | ||
700 | if ('A' <= unicode && unicode <= 'z' && modifiers) { | 701 | if ('A' <= unicode && unicode <= 'z' && modifiers) { |
701 | 702 | ||
702 | qkeycode = QChar(unicode).upper(); | 703 | qkeycode = QChar(unicode).upper(); |
703 | unicode = qkeycode - '@'; | 704 | unicode = qkeycode - '@'; |
704 | } | 705 | } |
705 | 706 | ||
706 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); | 707 | QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); |
707 | 708 | ||
708 | // pickboard stuff | 709 | // pickboard stuff |
709 | if (usePicks) { | 710 | if (usePicks) { |
710 | 711 | ||
711 | KeyboardConfig *dc = picks->dc; | 712 | KeyboardConfig *dc = picks->dc; |
712 | 713 | ||
713 | if (dc) { | 714 | if (dc) { |
714 | if (qkeycode == Qt::Key_Backspace) { | 715 | if (qkeycode == Qt::Key_Backspace) { |
715 | dc->input.remove(dc->input.last()); // remove last input | 716 | dc->input.remove(dc->input.last()); // remove last input |
716 | dc->decBackspaces(); | 717 | dc->decBackspaces(); |
717 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { | 718 | } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { |
718 | dc->input.clear(); | 719 | dc->input.clear(); |
719 | dc->resetBackspaces(); | 720 | dc->resetBackspaces(); |
720 | } else { | 721 | } else { |
721 | dc->add(QString(QChar(unicode))); | 722 | dc->add(QString(QChar(unicode))); |
722 | dc->incBackspaces(); | 723 | dc->incBackspaces(); |
723 | } | 724 | } |
724 | } | 725 | } |
725 | picks->repaint(); | 726 | picks->repaint(); |
726 | } | 727 | } |
727 | 728 | ||
728 | 729 | ||
729 | // painting | 730 | // painting |
730 | pressed = TRUE; | 731 | pressed = TRUE; |
731 | 732 | ||
732 | pressedKeyRow = row; | 733 | pressedKeyRow = row; |
733 | pressedKeyCol = col; | 734 | pressedKeyCol = col; |
734 | 735 | ||
735 | if (need_repaint) repaint(FALSE); | 736 | if (need_repaint) repaint(FALSE); |
736 | else { // just paint the one key pressed | 737 | else { // just paint the one key pressed |
737 | 738 | ||
738 | 739 | ||
739 | 740 | ||
740 | QPainter p(this); | 741 | QPainter p(this); |
741 | drawKeyboard(p, row, col); | 742 | drawKeyboard(p, row, col); |
742 | 743 | ||
743 | } | 744 | } |
744 | 745 | ||
745 | if (useRepeat) repeatTimer->start( 800 ); | 746 | if (useRepeat) repeatTimer->start( 800 ); |
746 | //pressTid = startTimer(80); | 747 | //pressTid = startTimer(80); |
747 | 748 | ||
748 | } | 749 | } |
749 | 750 | ||
750 | 751 | ||
751 | /* Keyboard::mouseReleaseEvent {{{1 */ | 752 | /* Keyboard::mouseReleaseEvent {{{1 */ |
752 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 753 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
753 | { | 754 | { |
754 | pressed = FALSE; | 755 | pressed = FALSE; |
755 | //if ( pressTid == 0 ) | 756 | //if ( pressTid == 0 ) |
756 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 757 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
757 | if ( unicode != -1 ) { | 758 | if ( unicode != -1 ) { |
758 | emit key( unicode, qkeycode, modifiers, false, false ); | 759 | emit key( unicode, qkeycode, modifiers, false, false ); |
759 | repeatTimer->stop(); | 760 | repeatTimer->stop(); |
760 | } | 761 | } |
761 | #endif | 762 | #endif |
762 | if (shift && unicode != 0) { | 763 | if (shift && unicode != 0) { |
763 | 764 | ||
764 | 765 | ||
765 | *shift = 0; // unpress shift key | 766 | *shift = 0; // unpress shift key |
766 | shift = 0; // reset the shift pointer | 767 | shift = 0; // reset the shift pointer |
767 | repaint(FALSE); | 768 | repaint(FALSE); |
768 | 769 | ||
769 | } | 770 | } |
770 | if (ctrl && unicode != 0) { | 771 | if (ctrl && unicode != 0) { |
771 | 772 | ||
772 | *ctrl = 0; | 773 | *ctrl = 0; |
773 | ctrl = 0; | 774 | ctrl = 0; |
774 | repaint(FALSE); | 775 | repaint(FALSE); |
775 | 776 | ||
776 | } | 777 | } |
777 | if (alt && alt != 0) { | 778 | if (alt && alt != 0) { |
778 | 779 | ||
779 | *alt = 0; | 780 | *alt = 0; |
780 | alt = 0; | 781 | alt = 0; |
781 | repaint(FALSE); | 782 | repaint(FALSE); |
782 | 783 | ||
783 | } | 784 | } |
784 | 785 | ||
785 | /* | 786 | /* |
786 | * do not make the meta key release after being pressed | 787 | * do not make the meta key release after being pressed |
787 | * | 788 | * |
788 | 789 | ||
789 | else if (meta && unicode != 0) { | 790 | else if (meta && unicode != 0) { |
790 | 791 | ||
791 | *meta = 0; | 792 | *meta = 0; |
792 | meta = 0; | 793 | meta = 0; |
793 | repaint(FALSE); | 794 | repaint(FALSE); |
794 | } | 795 | } |
795 | 796 | ||
796 | */ | 797 | */ |
797 | 798 | ||
798 | else clearHighlight(); | 799 | else clearHighlight(); |
799 | } | 800 | } |
800 | 801 | ||
801 | /* Keyboard::timerEvent {{{1 */ | 802 | /* Keyboard::timerEvent {{{1 */ |
802 | 803 | ||
803 | /* dont know what this does, but i think it is here so that if your screen | 804 | /* dont know what this does, but i think it is here so that if your screen |
804 | * sticks (like on an ipaq) then it will stop repeating if you click another | 805 | * sticks (like on an ipaq) then it will stop repeating if you click another |
805 | * key... but who knows what anything does in this thing anyway? | 806 | * key... but who knows what anything does in this thing anyway? |
806 | 807 | ||
807 | void Keyboard::timerEvent(QTimerEvent* e) | 808 | void Keyboard::timerEvent(QTimerEvent* e) |
808 | { | 809 | { |
809 | if ( e->timerId() == pressTid ) { | 810 | if ( e->timerId() == pressTid ) { |
810 | killTimer(pressTid); | 811 | killTimer(pressTid); |
811 | pressTid = 0; | 812 | pressTid = 0; |
812 | if ( !pressed ) | 813 | if ( !pressed ) |
813 | cout << "calling clearHighlight from timerEvent\n"; | 814 | cout << "calling clearHighlight from timerEvent\n"; |
814 | //clearHighlight(); | 815 | //clearHighlight(); |
815 | } | 816 | } |
816 | } | 817 | } |
817 | */ | 818 | */ |
818 | 819 | ||
819 | void Keyboard::repeat() | 820 | void Keyboard::repeat() |
820 | { | 821 | { |
821 | 822 | ||
822 | repeatTimer->start( 200 ); | 823 | repeatTimer->start( 200 ); |
823 | emit key( unicode, qkeycode, modifiers, true, true ); | 824 | emit key( unicode, qkeycode, modifiers, true, true ); |
824 | } | 825 | } |
825 | 826 | ||
826 | void Keyboard::clearHighlight() | 827 | void Keyboard::clearHighlight() |
827 | { | 828 | { |
828 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { | 829 | if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { |
829 | int tmpRow = pressedKeyRow; | 830 | int tmpRow = pressedKeyRow; |
830 | int tmpCol = pressedKeyCol; | 831 | int tmpCol = pressedKeyCol; |
831 | 832 | ||
832 | pressedKeyRow = -1; | 833 | pressedKeyRow = -1; |
833 | pressedKeyCol = -1; | 834 | pressedKeyCol = -1; |
834 | 835 | ||
835 | QPainter p(this); | 836 | QPainter p(this); |
836 | drawKeyboard(p, tmpRow, tmpCol); | 837 | drawKeyboard(p, tmpRow, tmpCol); |
837 | } | 838 | } |
838 | } | 839 | } |
839 | 840 | ||
840 | 841 | ||
841 | /* Keyboard::sizeHint {{{1 */ | 842 | /* Keyboard::sizeHint {{{1 */ |
842 | QSize Keyboard::sizeHint() const | 843 | QSize Keyboard::sizeHint() const |
843 | { | 844 | { |
844 | QFontMetrics fm=fontMetrics(); | 845 | QFontMetrics fm=fontMetrics(); |
845 | int keyHeight = fm.lineSpacing() + 2; | 846 | int keyHeight = fm.lineSpacing() + 2; |
846 | 847 | ||
847 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); | 848 | return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); |
848 | } | 849 | } |
849 | 850 | ||
850 | 851 | ||
851 | void Keyboard::resetState() | 852 | void Keyboard::resetState() |
852 | { | 853 | { |
853 | if (shift) { *shift = 0; shift = 0; } | 854 | if (shift) { *shift = 0; shift = 0; } |
854 | if (lock) {*lock = 0; lock = 0; } | 855 | if (lock) {*lock = 0; lock = 0; } |
855 | if (meta) { *meta = 0; meta = 0; } | 856 | if (meta) { *meta = 0; meta = 0; } |
856 | if (circumflex) { *circumflex = 0; circumflex = 0; } | 857 | if (circumflex) { *circumflex = 0; circumflex = 0; } |
857 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } | 858 | if (diaeresis) { *diaeresis = 0; diaeresis = 0; } |
858 | if (baccent) { *baccent = 0; baccent = 0; } | 859 | if (baccent) { *baccent = 0; baccent = 0; } |
859 | if (accent) { *accent = 0; accent = 0; } | 860 | if (accent) { *accent = 0; accent = 0; } |
860 | 861 | ||
861 | schar = mchar = echar = 0; | 862 | schar = mchar = echar = 0; |
862 | picks->resetState(); | 863 | picks->resetState(); |
863 | } | 864 | } |
864 | 865 | ||
865 | /* Keyboard::togglePickboard {{{1 */ | 866 | /* Keyboard::togglePickboard {{{1 */ |
866 | void Keyboard::togglePickboard(bool on_off) | 867 | void Keyboard::togglePickboard(bool on_off) |
867 | { | 868 | { |
868 | usePicks = on_off; | 869 | usePicks = on_off; |
869 | if (usePicks) { | 870 | if (usePicks) { |
870 | picks->show(); | 871 | picks->show(); |
871 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send | 872 | //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send |
872 | //adjustSize(); | 873 | //adjustSize(); |
873 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 874 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
874 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 875 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
875 | } else { | 876 | } else { |
876 | 877 | ||
877 | picks->hide(); | 878 | picks->hide(); |
878 | picks->resetState(); | 879 | picks->resetState(); |
879 | //move(x(), y() + picks->height()); | 880 | //move(x(), y() + picks->height()); |
880 | //adjustSize(); | 881 | //adjustSize(); |
881 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 882 | QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
882 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 883 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
883 | 884 | ||
884 | } | 885 | } |
885 | /* | 886 | /* |
886 | * this closes && opens the input method | 887 | * this closes && opens the input method |
887 | */ | 888 | */ |
888 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 889 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
889 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 890 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
890 | } | 891 | } |
891 | 892 | ||
892 | void Keyboard::toggleRepeat(bool on) { | 893 | void Keyboard::toggleRepeat(bool on) { |
893 | 894 | ||
894 | useRepeat = on; | 895 | useRepeat = on; |
895 | //cout << "setting useRepeat to: " << useRepeat << "\n"; | 896 | //cout << "setting useRepeat to: " << useRepeat << "\n"; |
896 | } | 897 | } |
897 | 898 | ||
898 | void Keyboard::cleanupConfigDlg() { | 899 | void Keyboard::cleanupConfigDlg() { |
899 | 900 | ||
900 | if ( configdlg ) { | 901 | if ( configdlg ) { |
901 | delete (ConfigDlg *) configdlg; | 902 | delete (ConfigDlg *) configdlg; |
902 | configdlg = 0; | 903 | configdlg = 0; |
903 | } | 904 | } |
904 | } | 905 | } |
905 | 906 | ||
906 | /* Keyboard::setMapTo ... {{{1 */ | 907 | /* Keyboard::setMapTo ... {{{1 */ |
907 | void Keyboard::setMapToDefault() { | 908 | void Keyboard::setMapToDefault() { |
908 | 909 | ||
909 | 910 | ||
910 | /* load current locale language map */ | 911 | /* load current locale language map */ |
911 | Config *config = new Config("locale"); | 912 | Config *config = new Config("locale"); |
912 | config->setGroup( "Language" ); | 913 | config->setGroup( "Language" ); |
913 | QString l = config->readEntry( "Language" , "en" ); | 914 | QString l = config->readEntry( "Language" , "en" ); |
914 | delete config; | 915 | delete config; |
915 | 916 | ||
916 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" | 917 | QString key_map = QPEApplication::qpeDir() + "share/multikey/" |
917 | + l + ".keymap"; | 918 | + l + ".keymap"; |
918 | 919 | ||
919 | /* save change to multikey config file */ | 920 | /* save change to multikey config file */ |
920 | config = new Config("multikey"); | 921 | config = new Config("multikey"); |
921 | config->setGroup ("keymaps"); | 922 | config->setGroup ("keymaps"); |
922 | config->writeEntry ("current", key_map); // default closed | 923 | config->writeEntry ("current", key_map); // default closed |
923 | delete config; | 924 | delete config; |
924 | 925 | ||
925 | int prevRows = keys->rows(); | 926 | int prevRows = keys->rows(); |
926 | 927 | ||
927 | delete keys; | 928 | delete keys; |
928 | keys = new Keys(key_map); | 929 | keys = new Keys(key_map); |
929 | 930 | ||
930 | // have to repaint the keyboard | 931 | // have to repaint the keyboard |
931 | if (prevRows != keys->rows()) { | 932 | if (prevRows != keys->rows()) { |
932 | 933 | ||
933 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 934 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
934 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 935 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
935 | 936 | ||
936 | } else repaint(FALSE); | 937 | } else repaint(FALSE); |
937 | 938 | ||
938 | resetState(); | 939 | resetState(); |
939 | } | 940 | } |
940 | 941 | ||
941 | void Keyboard::setMapToFile(QString map) { | 942 | void Keyboard::setMapToFile(QString map) { |
942 | 943 | ||
943 | /* save change to multikey config file */ | 944 | /* save change to multikey config file */ |
944 | Config *config = new Config("multikey"); | 945 | Config *config = new Config("multikey"); |
945 | config->setGroup ("keymaps"); | 946 | config->setGroup ("keymaps"); |
946 | config->writeEntry ("current", map); // default closed | 947 | config->writeEntry ("current", map); // default closed |
947 | 948 | ||
948 | delete config; | 949 | delete config; |
949 | 950 | ||
950 | int prevRows = keys->rows(); | 951 | int prevRows = keys->rows(); |
951 | 952 | ||
952 | delete keys; | 953 | delete keys; |
953 | if (QFile(map).exists()) | 954 | if (QFile(map).exists()) |
954 | keys = new Keys(map); | 955 | keys = new Keys(map); |
955 | else | 956 | else |
956 | keys = new Keys(); | 957 | keys = new Keys(); |
957 | 958 | ||
958 | if (keys->rows() != prevRows) { | 959 | if (keys->rows() != prevRows) { |
959 | 960 | ||
960 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); | 961 | QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); |
961 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); | 962 | QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); |
962 | } | 963 | } |
963 | else repaint(FALSE); | 964 | else repaint(FALSE); |
964 | 965 | ||
965 | resetState(); | 966 | resetState(); |
966 | } | 967 | } |
967 | 968 | ||
968 | /* Keybaord::reloadKeyboard {{{1 */ | 969 | /* Keybaord::reloadKeyboard {{{1 */ |
969 | void Keyboard::reloadKeyboard() { | 970 | void Keyboard::reloadKeyboard() { |
970 | 971 | ||
971 | // reload colors and redraw | 972 | // reload colors and redraw |
972 | loadKeyboardColors(); | 973 | loadKeyboardColors(); |
973 | repaint(); | 974 | repaint(); |
974 | 975 | ||
975 | } | 976 | } |
976 | 977 | ||
977 | void Keyboard::loadKeyboardColors() { | 978 | void Keyboard::loadKeyboardColors() { |
978 | 979 | ||
979 | Config config ("multikey"); | 980 | Config config ("multikey"); |
980 | config.setGroup("colors"); | 981 | config.setGroup("colors"); |
981 | 982 | ||
982 | QStringList color; | 983 | QStringList color; |
983 | color = config.readListEntry("keycolor", QChar(',')); | 984 | color = config.readListEntry("keycolor", QChar(',')); |
984 | if (color.isEmpty()) { | 985 | if (color.isEmpty()) { |
985 | color = QStringList::split(",", "240,240,240"); | 986 | color = QStringList::split(",", "240,240,240"); |
986 | config.writeEntry("keycolor", color.join(",")); | 987 | config.writeEntry("keycolor", color.join(",")); |
987 | 988 | ||
988 | } | 989 | } |
989 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 990 | keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
990 | 991 | ||
991 | color = config.readListEntry("keycolor_pressed", QChar(',')); | 992 | color = config.readListEntry("keycolor_pressed", QChar(',')); |
992 | if (color.isEmpty()) { | 993 | if (color.isEmpty()) { |
993 | color = QStringList::split(",", "171,183,198"); | 994 | color = QStringList::split(",", "171,183,198"); |
994 | config.writeEntry("keycolor_pressed", color.join(",")); | 995 | config.writeEntry("keycolor_pressed", color.join(",")); |
995 | 996 | ||
996 | } | 997 | } |
997 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 998 | keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
998 | 999 | ||
999 | color = config.readListEntry("keycolor_lines", QChar(',')); | 1000 | color = config.readListEntry("keycolor_lines", QChar(',')); |
1000 | if (color.isEmpty()) { | 1001 | if (color.isEmpty()) { |
1001 | color = QStringList::split(",", "138,148,160"); | 1002 | color = QStringList::split(",", "138,148,160"); |
1002 | config.writeEntry("keycolor_lines", color.join(",")); | 1003 | config.writeEntry("keycolor_lines", color.join(",")); |
1003 | 1004 | ||
1004 | } | 1005 | } |
1005 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1006 | keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1006 | 1007 | ||
1007 | color = config.readListEntry("textcolor", QChar(',')); | 1008 | color = config.readListEntry("textcolor", QChar(',')); |
1008 | if (color.isEmpty()) { | 1009 | if (color.isEmpty()) { |
1009 | color = QStringList::split(",", "43,54,68"); | 1010 | color = QStringList::split(",", "43,54,68"); |
1010 | config.writeEntry("textcolor", color.join(",")); | 1011 | config.writeEntry("textcolor", color.join(",")); |
1011 | 1012 | ||
1012 | } | 1013 | } |
1013 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); | 1014 | textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); |
1014 | 1015 | ||
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | /* korean input functions {{{1 | 1018 | /* korean input functions {{{1 |
1018 | * | 1019 | * |
1019 | * TODO | 1020 | * TODO |
1020 | * one major problem with this implementation is that you can't move the | 1021 | * one major problem with this implementation is that you can't move the |
1021 | * cursor after inputing korean chars, otherwise it will eat up and replace | 1022 | * cursor after inputing korean chars, otherwise it will eat up and replace |
1022 | * the char before the cursor you move to. fix that | 1023 | * the char before the cursor you move to. fix that |
1023 | * | 1024 | * |
1024 | * make backspace delete one single char, not the whole thing if still | 1025 | * make backspace delete one single char, not the whole thing if still |
1025 | * editing. | 1026 | * editing. |
1026 | * | 1027 | * |
1027 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | 1028 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
1028 | * | 1029 | * |
1029 | * how korean input works | 1030 | * how korean input works |
1030 | * | 1031 | * |
1031 | * all following chars means unicode char value and are in hex | 1032 | * all following chars means unicode char value and are in hex |
1032 | * | 1033 | * |
1033 | * 초음 = schar (start char) | 1034 | * 초음 = schar (start char) |
1034 | * 중음 = mchar (middle char) | 1035 | * 중음 = mchar (middle char) |
1035 | * 끝음 = echar (end char) | 1036 | * 끝음 = echar (end char) |
1036 | * | 1037 | * |
1037 | * there are 19 schars. unicode position is at 1100 - 1112 | 1038 | * there are 19 schars. unicode position is at 1100 - 1112 |
1038 | * there are 21 mchars. unicode position is at 1161 - 1175 | 1039 | * there are 21 mchars. unicode position is at 1161 - 1175 |
1039 | * there are 27 echars. unicode position is at 11a8 - 11c2 | 1040 | * there are 27 echars. unicode position is at 11a8 - 11c2 |
1040 | * | 1041 | * |
1041 | * the map with everything combined is at ac00 - d7a3 | 1042 | * the map with everything combined is at ac00 - d7a3 |
1042 | * | 1043 | * |
1043 | */ | 1044 | */ |
1044 | 1045 | ||
1045 | ushort Keyboard::parseKoreanInput (ushort c) { | 1046 | ushort Keyboard::parseKoreanInput (ushort c) { |
1046 | 1047 | ||
1047 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) | 1048 | if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) |
1048 | || | 1049 | || |
1049 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode | 1050 | (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode |
1050 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { | 1051 | && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { |
1051 | 1052 | ||
1052 | schar = 0, mchar = 0, echar = 0; | 1053 | schar = 0, mchar = 0, echar = 0; |
1053 | return c; | 1054 | return c; |
1054 | } | 1055 | } |
1055 | 1056 | ||
1056 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input | 1057 | if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input |
1057 | 1058 | ||
1058 | if (schar == 0 || (schar != 0 && mchar == 0)) { | 1059 | if (schar == 0 || (schar != 0 && mchar == 0)) { |
1059 | schar = c; mchar = 0; echar = 0; | 1060 | schar = c; mchar = 0; echar = 0; |
1060 | return c; | 1061 | return c; |
1061 | } | 1062 | } |
1062 | else if (mchar != 0) { | 1063 | else if (mchar != 0) { |
1063 | 1064 | ||
1064 | if (echar == 0) { | 1065 | if (echar == 0) { |
1065 | 1066 | ||
1066 | if (!(echar = constoe(c))) { | 1067 | if (!(echar = constoe(c))) { |
1067 | 1068 | ||
1068 | schar = c; mchar = 0; echar = 0; | 1069 | schar = c; mchar = 0; echar = 0; |
1069 | return c; | 1070 | return c; |
1070 | } | 1071 | } |
1071 | 1072 | ||
1072 | } | 1073 | } |
1073 | else { // must figure out what the echar is | 1074 | else { // must figure out what the echar is |
1074 | 1075 | ||
1075 | if (echar == 0x11a8) { // ㄱ | 1076 | if (echar == 0x11a8) { // ㄱ |
1076 | 1077 | ||
1077 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ | 1078 | if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ |
1078 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ | 1079 | else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ |
1079 | else { | 1080 | else { |
1080 | schar = c; mchar = 0; echar = 0; | 1081 | schar = c; mchar = 0; echar = 0; |
1081 | return c; | 1082 | return c; |
1082 | } | 1083 | } |
1083 | 1084 | ||
1084 | } else if (echar == 0x11ab) { // ㄴ | 1085 | } else if (echar == 0x11ab) { // ㄴ |
1085 | 1086 | ||
1086 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ | 1087 | if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ |
1087 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ | 1088 | else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ |
1088 | else { | 1089 | else { |
1089 | schar = c; mchar = 0; echar = 0; | 1090 | schar = c; mchar = 0; echar = 0; |
1090 | return c; | 1091 | return c; |
1091 | } | 1092 | } |
1092 | 1093 | ||
1093 | } else if (echar == 0x11af) { // ㄹ | 1094 | } else if (echar == 0x11af) { // ㄹ |
1094 | 1095 | ||
1095 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ | 1096 | if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ |
1096 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ | 1097 | else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ |
1097 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ | 1098 | else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ |
1098 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ | 1099 | else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ |
1099 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ | 1100 | else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ |
1100 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ | 1101 | else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ |
1101 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ | 1102 | else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ |
1102 | else { | 1103 | else { |
1103 | schar = c; mchar = 0; echar = 0; | 1104 | schar = c; mchar = 0; echar = 0; |
1104 | return c; | 1105 | return c; |
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | } else if (echar == 0x11b8) { // ㅂ | 1108 | } else if (echar == 0x11b8) { // ㅂ |
1108 | 1109 | ||
1109 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ | 1110 | if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ |
1110 | else { | 1111 | else { |
1111 | schar = c; mchar = 0; echar = 0; | 1112 | schar = c; mchar = 0; echar = 0; |
1112 | return c; | 1113 | return c; |
1113 | } | 1114 | } |
1114 | 1115 | ||
1115 | } else if (echar == 0x11ba) { // ㅅ | 1116 | } else if (echar == 0x11ba) { // ㅅ |
1116 | 1117 | ||
1117 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ | 1118 | if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ |
1118 | else { | 1119 | else { |
1119 | schar = c; mchar = 0; echar = 0; | 1120 | schar = c; mchar = 0; echar = 0; |
1120 | return c; | 1121 | return c; |
1121 | } | 1122 | } |
1122 | 1123 | ||
1123 | } else { // if any other char, cannot combine chars | 1124 | } else { // if any other char, cannot combine chars |
1124 | 1125 | ||
1125 | schar = c; mchar = 0; echar = 0; | 1126 | schar = c; mchar = 0; echar = 0; |
1126 | return c; | 1127 | return c; |
1127 | } | 1128 | } |
1128 | 1129 | ||
1129 | unicode = echar; | 1130 | unicode = echar; |
1130 | } | 1131 | } |
1131 | } | 1132 | } |
1132 | 1133 | ||
1133 | } | 1134 | } |
1134 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input | 1135 | else if (0x1161 <= c && c <= 0x1175) { // mchar was input |
1135 | 1136 | ||
1136 | if (schar != 0 && mchar == 0) { mchar = c; } | 1137 | if (schar != 0 && mchar == 0) { mchar = c; } |
1137 | 1138 | ||
1138 | else if (schar != 0 && mchar != 0 && echar == 0) { | 1139 | else if (schar != 0 && mchar != 0 && echar == 0) { |
1139 | 1140 | ||
1140 | switch (mchar) { | 1141 | switch (mchar) { |
1141 | case 0x1169: | 1142 | case 0x1169: |
1142 | if (c == 0x1161) mchar = 0x116a; | 1143 | if (c == 0x1161) mchar = 0x116a; |
1143 | else if (c == 0x1162) mchar = 0x116b; | 1144 | else if (c == 0x1162) mchar = 0x116b; |
1144 | else if (c == 0x1175) mchar = 0x116c; | 1145 | else if (c == 0x1175) mchar = 0x116c; |
1145 | else { | 1146 | else { |
1146 | schar = 0; mchar = 0; echar = 0; | 1147 | schar = 0; mchar = 0; echar = 0; |
1147 | return c; | 1148 | return c; |
1148 | } | 1149 | } |
1149 | break; | 1150 | break; |
1150 | case 0x116e: | 1151 | case 0x116e: |
1151 | if (c == 0x1165) mchar = 0x116f; | 1152 | if (c == 0x1165) mchar = 0x116f; |
1152 | else if (c == 0x1166) mchar = 0x1170; | 1153 | else if (c == 0x1166) mchar = 0x1170; |
1153 | else if (c == 0x1175) mchar = 0x1171; | 1154 | else if (c == 0x1175) mchar = 0x1171; |
1154 | else { | 1155 | else { |
1155 | schar = 0; mchar = 0; echar = 0; | 1156 | schar = 0; mchar = 0; echar = 0; |
1156 | return c; | 1157 | return c; |
1157 | } | 1158 | } |
1158 | break; | 1159 | break; |
1159 | case 0x1173: | 1160 | case 0x1173: |
1160 | if (c == 0x1175) mchar = 0x1174; | 1161 | if (c == 0x1175) mchar = 0x1174; |
1161 | else { | 1162 | else { |
1162 | schar = 0; mchar = 0; echar = 0; | 1163 | schar = 0; mchar = 0; echar = 0; |
1163 | return c; | 1164 | return c; |
1164 | } | 1165 | } |
1165 | break; | 1166 | break; |
1166 | default: | 1167 | default: |
1167 | schar = 0; mchar = 0; echar = 0; | 1168 | schar = 0; mchar = 0; echar = 0; |
1168 | return c; | 1169 | return c; |
1169 | } | 1170 | } |
1170 | } | 1171 | } |
1171 | else if (schar != 0 && mchar != 0 && echar != 0) { | 1172 | else if (schar != 0 && mchar != 0 && echar != 0) { |
1172 | 1173 | ||
1173 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1174 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1174 | 1175 | ||
1175 | ushort prev = 0; | 1176 | ushort prev = 0; |
1176 | switch (echar) { | 1177 | switch (echar) { |
1177 | /* | 1178 | /* |
1178 | case 0x11a9: | 1179 | case 0x11a9: |
1179 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1180 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1180 | schar = 0x1100; | 1181 | schar = 0x1100; |
1181 | break; | 1182 | break; |
1182 | */ | 1183 | */ |
1183 | case 0x11aa: | 1184 | case 0x11aa: |
1184 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1185 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1185 | schar = 0x1109; | 1186 | schar = 0x1109; |
1186 | break; | 1187 | break; |
1187 | case 0x11ac: | 1188 | case 0x11ac: |
1188 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1189 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1189 | schar = 0x110c; | 1190 | schar = 0x110c; |
1190 | break; | 1191 | break; |
1191 | case 0x11ad: | 1192 | case 0x11ad: |
1192 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1193 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1193 | schar = 0x1112; | 1194 | schar = 0x1112; |
1194 | break; | 1195 | break; |
1195 | case 0x11b0: | 1196 | case 0x11b0: |
1196 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1197 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1197 | schar = 0x1100; | 1198 | schar = 0x1100; |
1198 | break; | 1199 | break; |
1199 | case 0x11b1: | 1200 | case 0x11b1: |
1200 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1201 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1201 | schar = 0x1106; | 1202 | schar = 0x1106; |
1202 | break; | 1203 | break; |
1203 | case 0x11b2: | 1204 | case 0x11b2: |
1204 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1205 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1205 | schar = 0x1107; | 1206 | schar = 0x1107; |
1206 | break; | 1207 | break; |
1207 | case 0x11b3: | 1208 | case 0x11b3: |
1208 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1209 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1209 | schar = 0x1109; | 1210 | schar = 0x1109; |
1210 | break; | 1211 | break; |
1211 | case 0x11b4: | 1212 | case 0x11b4: |
1212 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1213 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1213 | schar = 0x1110; | 1214 | schar = 0x1110; |
1214 | break; | 1215 | break; |
1215 | case 0x11b9: | 1216 | case 0x11b9: |
1216 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 1217 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
1217 | schar = 0x1109; | 1218 | schar = 0x1109; |
1218 | break; | 1219 | break; |
1219 | /* | 1220 | /* |
1220 | case 0x11bb: | 1221 | case 0x11bb: |
1221 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 1222 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
1222 | schar = 0x1109; | 1223 | schar = 0x1109; |
1223 | break; | 1224 | break; |
1224 | */ | 1225 | */ |
1225 | default: | 1226 | default: |
1226 | 1227 | ||
1227 | if (constoe(echar)) { | 1228 | if (constoe(echar)) { |
1228 | 1229 | ||
1229 | prev = combineKoreanChars(schar, mchar, 0); | 1230 | prev = combineKoreanChars(schar, mchar, 0); |
1230 | schar = constoe(echar); | 1231 | schar = constoe(echar); |
1231 | } | 1232 | } |
1232 | break; | 1233 | break; |
1233 | } | 1234 | } |
1234 | 1235 | ||
1235 | emit key( prev, prev, 0, true, false ); | 1236 | emit key( prev, prev, 0, true, false ); |
1236 | 1237 | ||
1237 | mchar = c; echar = 0; | 1238 | mchar = c; echar = 0; |
1238 | 1239 | ||
1239 | return combineKoreanChars(schar, mchar, 0); | 1240 | return combineKoreanChars(schar, mchar, 0); |
1240 | 1241 | ||
1241 | } | 1242 | } |
1242 | else { | 1243 | else { |
1243 | schar = 0; mchar = 0; echar = 0; | 1244 | schar = 0; mchar = 0; echar = 0; |
1244 | return c; | 1245 | return c; |
1245 | } | 1246 | } |
1246 | 1247 | ||
1247 | } | 1248 | } |
1248 | else /*if (c == ' ')*/ return c; | 1249 | else /*if (c == ' ')*/ return c; |
1249 | 1250 | ||
1250 | 1251 | ||
1251 | // and now... finally delete previous char, and return new char | 1252 | // and now... finally delete previous char, and return new char |
1252 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1253 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1253 | 1254 | ||
1254 | 1255 | ||
1255 | return combineKoreanChars( schar, mchar, echar); | 1256 | return combineKoreanChars( schar, mchar, echar); |
1256 | 1257 | ||
1257 | } | 1258 | } |
1258 | 1259 | ||
1259 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1260 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1260 | 1261 | ||
1261 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1262 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1262 | 1263 | ||
1263 | } | 1264 | } |
1264 | 1265 | ||
1265 | ushort Keyboard::constoe(const ushort c) { | 1266 | ushort Keyboard::constoe(const ushort c) { |
1266 | 1267 | ||
1267 | // converts schars to echars if possible | 1268 | // converts schars to echars if possible |
1268 | 1269 | ||
1269 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1270 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1270 | 1271 | ||
1271 | switch (c) { | 1272 | switch (c) { |
1272 | case 0x1100: return 0x11a8; | 1273 | case 0x1100: return 0x11a8; |
1273 | case 0x1101: return 0x11a9; | 1274 | case 0x1101: return 0x11a9; |
1274 | case 0x1102: return 0x11ab; | 1275 | case 0x1102: return 0x11ab; |
1275 | case 0x1103: return 0x11ae; | 1276 | case 0x1103: return 0x11ae; |
1276 | case 0x1105: return 0x11af; | 1277 | case 0x1105: return 0x11af; |
1277 | case 0x1106: return 0x11b7; | 1278 | case 0x1106: return 0x11b7; |
1278 | case 0x1107: return 0x11b8; | 1279 | case 0x1107: return 0x11b8; |
1279 | case 0x1109: return 0x11ba; | 1280 | case 0x1109: return 0x11ba; |
1280 | case 0x110a: return 0x11bb; | 1281 | case 0x110a: return 0x11bb; |
1281 | case 0x110b: return 0x11bc; | 1282 | case 0x110b: return 0x11bc; |
1282 | case 0x110c: return 0x11bd; | 1283 | case 0x110c: return 0x11bd; |
1283 | case 0x110e: return 0x11be; | 1284 | case 0x110e: return 0x11be; |
1284 | case 0x110f: return 0x11bf; | 1285 | case 0x110f: return 0x11bf; |
1285 | case 0x1110: return 0x11c0; | 1286 | case 0x1110: return 0x11c0; |
1286 | case 0x1111: return 0x11c1; | 1287 | case 0x1111: return 0x11c1; |
1287 | case 0x1112: return 0x11c2; | 1288 | case 0x1112: return 0x11c2; |
1288 | default: return 0; | 1289 | default: return 0; |
1289 | 1290 | ||
1290 | } | 1291 | } |
1291 | 1292 | ||
1292 | } else { //echar to schar | 1293 | } else { //echar to schar |
1293 | 1294 | ||
1294 | switch (c) { | 1295 | switch (c) { |
1295 | case 0x11a8: return 0x1100; | 1296 | case 0x11a8: return 0x1100; |
1296 | case 0x11a9: return 0x1101; | 1297 | case 0x11a9: return 0x1101; |
1297 | case 0x11ab: return 0x1102; | 1298 | case 0x11ab: return 0x1102; |
1298 | case 0x11ae: return 0x1103; | 1299 | case 0x11ae: return 0x1103; |
1299 | case 0x11af: return 0x1105; | 1300 | case 0x11af: return 0x1105; |
1300 | case 0x11b7: return 0x1106; | 1301 | case 0x11b7: return 0x1106; |
1301 | case 0x11b8: return 0x1107; | 1302 | case 0x11b8: return 0x1107; |
1302 | case 0x11ba: return 0x1109; | 1303 | case 0x11ba: return 0x1109; |
1303 | case 0x11bb: return 0x110a; | 1304 | case 0x11bb: return 0x110a; |
1304 | case 0x11bc: return 0x110b; | 1305 | case 0x11bc: return 0x110b; |
1305 | case 0x11bd: return 0x110c; | 1306 | case 0x11bd: return 0x110c; |
1306 | case 0x11be: return 0x110e; | 1307 | case 0x11be: return 0x110e; |
1307 | case 0x11bf: return 0x110f; | 1308 | case 0x11bf: return 0x110f; |
1308 | case 0x11c0: return 0x1110; | 1309 | case 0x11c0: return 0x1110; |
1309 | case 0x11c1: return 0x1111; | 1310 | case 0x11c1: return 0x1111; |
1310 | case 0x11c2: return 0x1112; | 1311 | case 0x11c2: return 0x1112; |
1311 | default: return 0; | 1312 | default: return 0; |
1312 | 1313 | ||
1313 | } | 1314 | } |
1314 | 1315 | ||
1315 | } | 1316 | } |
1316 | } | 1317 | } |
1317 | 1318 | ||
1318 | 1319 | ||
1319 | // Keys::Keys {{{1 | 1320 | // Keys::Keys {{{1 |
1320 | 1321 | ||
1321 | Keys::Keys() { | 1322 | Keys::Keys() { |
1322 | 1323 | ||
1323 | Config *config = new Config ("multikey"); | 1324 | Config *config = new Config ("multikey"); |
1324 | config->setGroup( "keymaps" ); | 1325 | config->setGroup( "keymaps" ); |
1325 | QString map = config->readEntry( "current" ); | 1326 | QString map = config->readEntry( "current" ); |
1326 | delete config; | 1327 | delete config; |
1327 | 1328 | ||
1328 | if (map.isNull() || !(QFile(map).exists())) { | 1329 | if (map.isNull() || !(QFile(map).exists())) { |
1329 | 1330 | ||
1330 | Config *config = new Config("locale"); | 1331 | Config *config = new Config("locale"); |
1331 | config->setGroup( "Language" ); | 1332 | config->setGroup( "Language" ); |
1332 | QString l = config->readEntry( "Language" , "en" ); | 1333 | QString l = config->readEntry( "Language" , "en" ); |
1333 | delete config; | 1334 | delete config; |
1334 | 1335 | ||
1335 | map = QPEApplication::qpeDir() + "/share/multikey/" | 1336 | map = QPEApplication::qpeDir() + "/share/multikey/" |
1336 | + l + ".keymap"; | 1337 | + l + ".keymap"; |
1337 | 1338 | ||
1338 | } | 1339 | } |
1339 | if (map.isNull() || !(QFile(map).exists())) { | 1340 | if (map.isNull() || !(QFile(map).exists())) { |
1340 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; | 1341 | map = QPEApplication::qpeDir() + "/share/multikey/en.keymap"; |
1341 | } | 1342 | } |
1342 | 1343 | ||
1343 | setKeysFromFile(map); | 1344 | setKeysFromFile(map); |
1344 | } | 1345 | } |
1345 | 1346 | ||
1346 | Keys::Keys(const char * filename) { | 1347 | Keys::Keys(const char * filename) { |
1347 | 1348 | ||
1348 | setKeysFromFile(filename); | 1349 | setKeysFromFile(filename); |
1349 | } | 1350 | } |
1350 | 1351 | ||
1351 | // Keys::setKeysFromFile {{{2 | 1352 | // Keys::setKeysFromFile {{{2 |
1352 | void Keys::setKeysFromFile(const char * filename) { | 1353 | void Keys::setKeysFromFile(const char * filename) { |
1353 | 1354 | ||
1354 | QFile f(filename); | 1355 | QFile f(filename); |
1355 | 1356 | ||
1356 | if (f.open(IO_ReadOnly)) { | 1357 | if (f.open(IO_ReadOnly)) { |
1357 | 1358 | ||
1358 | QTextStream t(&f); | 1359 | QTextStream t(&f); |
1359 | int row; | 1360 | int row; |
1360 | int qcode; | 1361 | int qcode; |
1361 | ushort unicode; | 1362 | ushort unicode; |
1362 | int width; | 1363 | int width; |
1363 | QString buf; | 1364 | QString buf; |
1364 | QString comment; | 1365 | QString comment; |
1365 | char * xpm[256]; //couldnt be larger than that... could it? | 1366 | char * xpm[256]; //couldnt be larger than that... could it? |
1366 | QImage *xpm2pix = 0; | 1367 | QImage *xpm2pix = 0; |
1367 | 1368 | ||
1368 | buf = t.readLine(); | 1369 | buf = t.readLine(); |
1369 | while (buf) { | 1370 | while (buf) { |
1370 | 1371 | ||
1371 | // get rid of comments | 1372 | // get rid of comments |
1372 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1373 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1373 | 1374 | ||
1374 | // key definition | 1375 | // key definition |
1375 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1376 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1376 | // no $1 type referencing!!! this implementation of regexp sucks | 1377 | // no $1 type referencing!!! this implementation of regexp sucks |
1377 | 1378 | ||
1378 | // dont know of any sscanf() type funcs in Qt lib | 1379 | // dont know of any sscanf() type funcs in Qt lib |
1379 | QTextStream tmp (buf, IO_ReadOnly); | 1380 | QTextStream tmp (buf, IO_ReadOnly); |
1380 | tmp >> row >> qcode >> unicode >> width >> comment; | 1381 | tmp >> row >> qcode >> unicode >> width >> comment; |
1381 | 1382 | ||
1382 | buf = t.readLine(); | 1383 | buf = t.readLine(); |
1383 | int xpmLineCount = 0; | 1384 | int xpmLineCount = 0; |
1384 | xpm2pix = 0; | 1385 | xpm2pix = 0; |
1385 | 1386 | ||
1386 | // erase blank space | 1387 | // erase blank space |
1387 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1388 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1388 | 1389 | ||
1389 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1390 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1390 | 1391 | ||
1391 | QString xpmBuf = buf.stripWhiteSpace(); | 1392 | QString xpmBuf = buf.stripWhiteSpace(); |
1392 | 1393 | ||
1393 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1394 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1394 | 1395 | ||
1395 | int j = 0; | 1396 | int j = 0; |
1396 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1397 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1397 | if (xpmBuf[i].latin1() != '"') { | 1398 | if (xpmBuf[i].latin1() != '"') { |
1398 | 1399 | ||
1399 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1400 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1400 | j++; | 1401 | j++; |
1401 | } | 1402 | } |
1402 | 1403 | ||
1403 | } | 1404 | } |
1404 | // have to close that facker up | 1405 | // have to close that facker up |
1405 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1406 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1406 | 1407 | ||
1407 | xpmLineCount++; | 1408 | xpmLineCount++; |
1408 | buf = t.readLine(); | 1409 | buf = t.readLine(); |
1409 | } | 1410 | } |
1410 | if (xpmLineCount) { | 1411 | if (xpmLineCount) { |
1411 | 1412 | ||
1412 | xpm2pix = new QImage((const char **)xpm); | 1413 | xpm2pix = new QImage((const char **)xpm); |
1413 | for (int i = 0; i < xpmLineCount; i++) | 1414 | for (int i = 0; i < xpmLineCount; i++) |
1414 | 1415 | ||
1415 | delete [] (xpm[i]); | 1416 | delete [] (xpm[i]); |
1416 | 1417 | ||
1417 | } | 1418 | } |
1418 | setKey(row, qcode, unicode, width, xpm2pix); | 1419 | setKey(row, qcode, unicode, width, xpm2pix); |
1419 | } | 1420 | } |
1420 | 1421 | ||
1421 | // shift map | 1422 | // shift map |
1422 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1423 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1423 | 1424 | ||
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1425 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | ushort lower, shift; | 1426 | ushort lower, shift; |
1426 | tmp >> lower >> shift; | 1427 | tmp >> lower >> shift; |
1427 | 1428 | ||
1428 | shiftMap.insert(lower, shift); | 1429 | shiftMap.insert(lower, shift); |
1429 | 1430 | ||
1430 | buf = t.readLine(); | 1431 | buf = t.readLine(); |
1431 | } | 1432 | } |
1432 | 1433 | ||
1433 | // meta key map | 1434 | // meta key map |
1434 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1435 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1435 | 1436 | ||
1436 | QTextStream tmp (buf, IO_ReadOnly); | 1437 | QTextStream tmp (buf, IO_ReadOnly); |
1437 | ushort lower, shift; | 1438 | ushort lower, shift; |
1438 | QChar m; | 1439 | QChar m; |
1439 | tmp >> m >> lower >> shift; | 1440 | tmp >> m >> lower >> shift; |
1440 | 1441 | ||
1441 | metaMap.insert(lower, shift); | 1442 | metaMap.insert(lower, shift); |
1442 | 1443 | ||
1443 | buf = t.readLine(); | 1444 | buf = t.readLine(); |
1444 | } | 1445 | } |
1445 | 1446 | ||
1446 | // circumflex | 1447 | // circumflex |
1447 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1448 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1448 | 1449 | ||
1449 | QTextStream tmp (buf, IO_ReadOnly); | 1450 | QTextStream tmp (buf, IO_ReadOnly); |
1450 | ushort lower, shift; | 1451 | ushort lower, shift; |
1451 | QChar c; | 1452 | QChar c; |
1452 | tmp >> c >> lower >> shift; | 1453 | tmp >> c >> lower >> shift; |
1453 | 1454 | ||
1454 | circumflexMap.insert(lower, shift); | 1455 | circumflexMap.insert(lower, shift); |
1455 | 1456 | ||
1456 | buf = t.readLine(); | 1457 | buf = t.readLine(); |
1457 | } | 1458 | } |
1458 | // diaeresis | 1459 | // diaeresis |
1459 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1460 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1460 | 1461 | ||
1461 | QTextStream tmp (buf, IO_ReadOnly); | 1462 | QTextStream tmp (buf, IO_ReadOnly); |
1462 | ushort lower, shift; | 1463 | ushort lower, shift; |
1463 | QChar d; | 1464 | QChar d; |
1464 | tmp >> d >> lower >> shift; | 1465 | tmp >> d >> lower >> shift; |
1465 | 1466 | ||
1466 | diaeresisMap.insert(lower, shift); | 1467 | diaeresisMap.insert(lower, shift); |
1467 | 1468 | ||
1468 | buf = t.readLine(); | 1469 | buf = t.readLine(); |
1469 | } | 1470 | } |
1470 | // back accent | 1471 | // back accent |
1471 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1472 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1472 | 1473 | ||
1473 | QTextStream tmp (buf, IO_ReadOnly); | 1474 | QTextStream tmp (buf, IO_ReadOnly); |
1474 | ushort lower, shift; | 1475 | ushort lower, shift; |
1475 | QChar d; | 1476 | QChar d; |
1476 | tmp >> d >> lower >> shift; | 1477 | tmp >> d >> lower >> shift; |
1477 | 1478 | ||
1478 | baccentMap.insert(lower, shift); | 1479 | baccentMap.insert(lower, shift); |
1479 | 1480 | ||
1480 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1481 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1481 | buf = t.readLine(); | 1482 | buf = t.readLine(); |
1482 | } | 1483 | } |
1483 | // accent | 1484 | // accent |
1484 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1485 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1485 | 1486 | ||
1486 | QTextStream tmp (buf, IO_ReadOnly); | 1487 | QTextStream tmp (buf, IO_ReadOnly); |
1487 | ushort lower, shift; | 1488 | ushort lower, shift; |
1488 | QChar d; | 1489 | QChar d; |
1489 | tmp >> d >> lower >> shift; | 1490 | tmp >> d >> lower >> shift; |
1490 | 1491 | ||
1491 | accentMap.insert(lower, shift); | 1492 | accentMap.insert(lower, shift); |
1492 | 1493 | ||
1493 | buf = t.readLine(); | 1494 | buf = t.readLine(); |
1494 | } | 1495 | } |
1495 | 1496 | ||
1496 | // other variables like lang & title | 1497 | // other variables like lang & title |
1497 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1498 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1498 | 1499 | ||
1499 | QTextStream tmp (buf, IO_ReadOnly); | 1500 | QTextStream tmp (buf, IO_ReadOnly); |
1500 | QString name, equals, value; | 1501 | QString name, equals, value; |
1501 | 1502 | ||
1502 | tmp >> name >> equals >> value; | 1503 | tmp >> name >> equals >> value; |
1503 | 1504 | ||
1504 | if (name == "lang") { | 1505 | if (name == "lang") { |
1505 | 1506 | ||
1506 | lang = value; | 1507 | lang = value; |
1507 | 1508 | ||
1508 | } | 1509 | } |
1509 | 1510 | ||
1510 | buf = t.readLine(); | 1511 | buf = t.readLine(); |
1511 | } | 1512 | } |
1512 | // comments | 1513 | // comments |
1513 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1514 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1514 | 1515 | ||
1515 | buf = t.readLine(); | 1516 | buf = t.readLine(); |
1516 | 1517 | ||
1517 | } else { // blank line, or garbage | 1518 | } else { // blank line, or garbage |
1518 | 1519 | ||
1519 | buf = t.readLine(); | 1520 | buf = t.readLine(); |
1520 | 1521 | ||
1521 | } | 1522 | } |
1522 | 1523 | ||
1523 | } | 1524 | } |
1524 | f.close(); | 1525 | f.close(); |
1525 | } | 1526 | } |
1526 | 1527 | ||
1527 | } | 1528 | } |
1528 | 1529 | ||
1529 | // Keys::setKey {{{2 | 1530 | // Keys::setKey {{{2 |
1530 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1531 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1531 | const int width, QImage *pix) { | 1532 | const int width, QImage *pix) { |
1532 | 1533 | ||
1533 | Key * key; | 1534 | Key * key; |
1534 | key = new Key; | 1535 | key = new Key; |
1535 | key->qcode = qcode; | 1536 | key->qcode = qcode; |
1536 | key->unicode = unicode; | 1537 | key->unicode = unicode; |
1537 | key->width = width; | 1538 | key->width = width; |
1538 | 1539 | ||
1539 | // share key->pressed between same keys | 1540 | // share key->pressed between same keys |
1540 | bool found = 0; | 1541 | bool found = 0; |
1541 | for (int i = 1; i <= 5; i++) { | 1542 | for (int i = 1; i <= 5; i++) { |
1542 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1543 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1543 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1544 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1544 | 1545 | ||
1545 | key->pressed = keys[i].at(j)->pressed; | 1546 | key->pressed = keys[i].at(j)->pressed; |
1546 | found = 1; | 1547 | found = 1; |
1547 | } | 1548 | } |
1548 | 1549 | ||
1549 | } | 1550 | } |
1550 | if (!found) { | 1551 | if (!found) { |
1551 | 1552 | ||
1552 | key->pressed = new bool; | 1553 | key->pressed = new bool; |
1553 | *(key->pressed) = 0; | 1554 | *(key->pressed) = 0; |
1554 | } | 1555 | } |
1555 | 1556 | ||
1556 | key->pix = pix; | 1557 | key->pix = pix; |
1557 | 1558 | ||
1558 | 1559 | ||
1559 | keys[row].append(key); | 1560 | keys[row].append(key); |
1560 | } | 1561 | } |
1561 | 1562 | ||
1562 | // Keys::~Keys {{{2 | 1563 | // Keys::~Keys {{{2 |
1563 | Keys::~Keys() { | 1564 | Keys::~Keys() { |
1564 | 1565 | ||
1565 | for (int i = 1; i <= 5; i++) | 1566 | for (int i = 1; i <= 5; i++) |
1566 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1567 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1567 | delete keys[i].at(j); | 1568 | delete keys[i].at(j); |
1568 | 1569 | ||
1569 | } | 1570 | } |
1570 | 1571 | ||
1571 | // Keys:: other functions {{{2 | 1572 | // Keys:: other functions {{{2 |
1572 | int Keys::width(const int row, const int col) { | 1573 | int Keys::width(const int row, const int col) { |
1573 | 1574 | ||
1574 | return keys[row].at(col)->width; | 1575 | return keys[row].at(col)->width; |
1575 | 1576 | ||
1576 | } | 1577 | } |
1577 | 1578 | ||
1578 | int Keys::rows() { | 1579 | int Keys::rows() { |
1579 | 1580 | ||
1580 | for (int i = 1; i <= 5; i++) { | 1581 | for (int i = 1; i <= 5; i++) { |
1581 | 1582 | ||
1582 | if (keys[i].count() == 0) | 1583 | if (keys[i].count() == 0) |
1583 | return i - 1; | 1584 | return i - 1; |
1584 | 1585 | ||
1585 | } | 1586 | } |
1586 | return 5; | 1587 | return 5; |
1587 | } | 1588 | } |
1588 | 1589 | ||
1589 | ushort Keys::uni(const int row, const int col) { | 1590 | ushort Keys::uni(const int row, const int col) { |
1590 | 1591 | ||
1591 | return keys[row].at(col)->unicode; | 1592 | return keys[row].at(col)->unicode; |
1592 | 1593 | ||
1593 | } | 1594 | } |
1594 | 1595 | ||
1595 | int Keys::qcode(const int row, const int col) { | 1596 | int Keys::qcode(const int row, const int col) { |
1596 | 1597 | ||
1597 | return keys[row].at(col)->qcode; | 1598 | return keys[row].at(col)->qcode; |
1598 | } | 1599 | } |
1599 | 1600 | ||
1600 | QImage *Keys::pix(const int row, const int col) { | 1601 | QImage *Keys::pix(const int row, const int col) { |
1601 | 1602 | ||
1602 | return keys[row].at(col)->pix; | 1603 | return keys[row].at(col)->pix; |
1603 | 1604 | ||
1604 | } | 1605 | } |
1605 | bool Keys::pressed(const int row, const int col) { | 1606 | bool Keys::pressed(const int row, const int col) { |
1606 | 1607 | ||
1607 | return *(keys[row].at(col)->pressed); | 1608 | return *(keys[row].at(col)->pressed); |
1608 | } | 1609 | } |
1609 | 1610 | ||
1610 | int Keys::numKeys(const int row) { | 1611 | int Keys::numKeys(const int row) { |
1611 | 1612 | ||
1612 | return keys[row].count(); | 1613 | return keys[row].count(); |
1613 | } | 1614 | } |
1614 | 1615 | ||
1615 | void Keys::setPressed(const int row, const int col, const bool pressed) { | 1616 | void Keys::setPressed(const int row, const int col, const bool pressed) { |
1616 | 1617 | ||
1617 | *(keys[row].at(col)->pressed) = pressed; | 1618 | *(keys[row].at(col)->pressed) = pressed; |
1618 | } | 1619 | } |
1619 | 1620 | ||
1620 | ushort Keys::shift(const ushort uni) { | 1621 | ushort Keys::shift(const ushort uni) { |
1621 | 1622 | ||
1622 | if (shiftMap[uni]) return shiftMap[uni]; | 1623 | if (shiftMap[uni]) return shiftMap[uni]; |
1623 | else return 0; | 1624 | else return 0; |
1624 | } | 1625 | } |
1625 | 1626 | ||
1626 | ushort Keys::meta(const ushort uni) { | 1627 | ushort Keys::meta(const ushort uni) { |
1627 | 1628 | ||
1628 | if (metaMap[uni]) return metaMap[uni]; | 1629 | if (metaMap[uni]) return metaMap[uni]; |
1629 | else return 0; | 1630 | else return 0; |
1630 | } | 1631 | } |
1631 | 1632 | ||
1632 | ushort Keys::circumflex(const ushort uni) { | 1633 | ushort Keys::circumflex(const ushort uni) { |
1633 | 1634 | ||
1634 | if (circumflexMap[uni]) return circumflexMap[uni]; | 1635 | if (circumflexMap[uni]) return circumflexMap[uni]; |
1635 | else return 0; | 1636 | else return 0; |
1636 | } | 1637 | } |
1637 | 1638 | ||
1638 | ushort Keys::diaeresis(const ushort uni) { | 1639 | ushort Keys::diaeresis(const ushort uni) { |
1639 | 1640 | ||
1640 | if(diaeresisMap[uni]) return diaeresisMap[uni]; | 1641 | if(diaeresisMap[uni]) return diaeresisMap[uni]; |
1641 | else return 0; | 1642 | else return 0; |
1642 | } | 1643 | } |
1643 | 1644 | ||
1644 | ushort Keys::baccent(const ushort uni) { | 1645 | ushort Keys::baccent(const ushort uni) { |
1645 | 1646 | ||
1646 | if(baccentMap[uni]) return baccentMap[uni]; | 1647 | if(baccentMap[uni]) return baccentMap[uni]; |
1647 | else return 0; | 1648 | else return 0; |
1648 | } | 1649 | } |
1649 | 1650 | ||
1650 | ushort Keys::accent(const ushort uni) { | 1651 | ushort Keys::accent(const ushort uni) { |
1651 | 1652 | ||
1652 | if(accentMap[uni]) return accentMap[uni]; | 1653 | if(accentMap[uni]) return accentMap[uni]; |
1653 | else return 0; | 1654 | else return 0; |
1654 | } | 1655 | } |
1655 | 1656 | ||
1656 | bool *Keys::pressedPtr(const int row, const int col) { | 1657 | bool *Keys::pressedPtr(const int row, const int col) { |
1657 | 1658 | ||
1658 | return keys[row].at(col)->pressed; | 1659 | return keys[row].at(col)->pressed; |
1659 | } | 1660 | } |
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h index bc74e71..20c5cee 100644 --- a/inputmethods/multikey/keyboard.h +++ b/inputmethods/multikey/keyboard.h | |||
@@ -1,188 +1,191 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qframe.h> | 20 | #include <qframe.h> |
21 | #include <qmap.h> | 21 | #include <qmap.h> |
22 | #include "../pickboard/pickboardcfg.h" | 22 | #include "../pickboard/pickboardcfg.h" |
23 | #include "../pickboard/pickboardpicks.h" | 23 | #include "../pickboard/pickboardpicks.h" |
24 | #include "configdlg.h" | 24 | #include "configdlg.h" |
25 | 25 | ||
26 | class QTimer; | 26 | class QTimer; |
27 | 27 | ||
28 | namespace MultiKey | ||
29 | { | ||
30 | |||
28 | class KeyboardConfig : public DictFilterConfig | 31 | class KeyboardConfig : public DictFilterConfig |
29 | { | 32 | { |
30 | public: | 33 | public: |
31 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } | 34 | KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } |
32 | virtual void generateText(const QString &s); | 35 | virtual void generateText(const QString &s); |
33 | void decBackspaces() { if (backspaces) backspaces--; } | 36 | void decBackspaces() { if (backspaces) backspaces--; } |
34 | void incBackspaces() { backspaces++; } | 37 | void incBackspaces() { backspaces++; } |
35 | void resetBackspaces() { backspaces = 0; } | 38 | void resetBackspaces() { backspaces = 0; } |
36 | private: | 39 | private: |
37 | int backspaces; | 40 | int backspaces; |
38 | }; | 41 | }; |
39 | 42 | ||
40 | 43 | ||
41 | class KeyboardPicks : public PickboardPicks | 44 | class KeyboardPicks : public PickboardPicks |
42 | { | 45 | { |
43 | Q_OBJECT | 46 | Q_OBJECT |
44 | public: | 47 | public: |
45 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) | 48 | KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) |
46 | : PickboardPicks(parent, name, f) { } | 49 | : PickboardPicks(parent, name, f) { } |
47 | void initialise(); | 50 | void initialise(); |
48 | virtual QSize sizeHint() const; | 51 | virtual QSize sizeHint() const; |
49 | KeyboardConfig *dc; | 52 | KeyboardConfig *dc; |
50 | }; | 53 | }; |
51 | 54 | ||
52 | 55 | ||
53 | class Keys { | 56 | class Keys { |
54 | public: | 57 | public: |
55 | 58 | ||
56 | Keys(); | 59 | Keys(); |
57 | Keys(const char * filename); | 60 | Keys(const char * filename); |
58 | ~Keys(); | 61 | ~Keys(); |
59 | int width(const int row, const int col); | 62 | int width(const int row, const int col); |
60 | int rows(); | 63 | int rows(); |
61 | ushort uni(const int row, const int col); | 64 | ushort uni(const int row, const int col); |
62 | int qcode(const int row, const int col); | 65 | int qcode(const int row, const int col); |
63 | bool pressed(const int row, const int col); | 66 | bool pressed(const int row, const int col); |
64 | bool *pressedPtr(const int row, const int col); | 67 | bool *pressedPtr(const int row, const int col); |
65 | ushort shift(const ushort); | 68 | ushort shift(const ushort); |
66 | ushort meta(const ushort); | 69 | ushort meta(const ushort); |
67 | ushort circumflex(const ushort); | 70 | ushort circumflex(const ushort); |
68 | ushort diaeresis(const ushort); | 71 | ushort diaeresis(const ushort); |
69 | ushort baccent(const ushort); | 72 | ushort baccent(const ushort); |
70 | ushort accent(const ushort); | 73 | ushort accent(const ushort); |
71 | QImage *pix(const int row, const int col); | 74 | QImage *pix(const int row, const int col); |
72 | int numKeys(const int row); | 75 | int numKeys(const int row); |
73 | void setKeysFromFile(const char *filename); | 76 | void setKeysFromFile(const char *filename); |
74 | void setKey(const int row, const int qcode, const ushort unicode, | 77 | void setKey(const int row, const int qcode, const ushort unicode, |
75 | const int width, QImage *pix); | 78 | const int width, QImage *pix); |
76 | void setPressed(const int row, const int col, const bool pressed); | 79 | void setPressed(const int row, const int col, const bool pressed); |
77 | QString lang; | 80 | QString lang; |
78 | QString label; | 81 | QString label; |
79 | 82 | ||
80 | private: | 83 | private: |
81 | 84 | ||
82 | typedef struct Key { | 85 | typedef struct Key { |
83 | int qcode; // are qt key codes just unicode values? | 86 | int qcode; // are qt key codes just unicode values? |
84 | ushort unicode; | 87 | ushort unicode; |
85 | int width; // not pixels but relative key width. normal key is 2 | 88 | int width; // not pixels but relative key width. normal key is 2 |
86 | 89 | ||
87 | // only needed for keys like ctrl that can have multiple keys pressed at once | 90 | // only needed for keys like ctrl that can have multiple keys pressed at once |
88 | bool *pressed; | 91 | bool *pressed; |
89 | QImage *pix; | 92 | QImage *pix; |
90 | }; | 93 | }; |
91 | 94 | ||
92 | QList<Key> keys[6]; | 95 | QList<Key> keys[6]; |
93 | QMap<ushort,ushort> shiftMap; | 96 | QMap<ushort,ushort> shiftMap; |
94 | QMap<ushort,ushort> metaMap; | 97 | QMap<ushort,ushort> metaMap; |
95 | QMap<ushort,ushort> circumflexMap; | 98 | QMap<ushort,ushort> circumflexMap; |
96 | QMap<ushort,ushort> diaeresisMap; | 99 | QMap<ushort,ushort> diaeresisMap; |
97 | QMap<ushort,ushort> baccentMap; | 100 | QMap<ushort,ushort> baccentMap; |
98 | QMap<ushort,ushort> accentMap; | 101 | QMap<ushort,ushort> accentMap; |
99 | 102 | ||
100 | }; | 103 | }; |
101 | 104 | ||
102 | class Keyboard : public QFrame | 105 | class Keyboard : public QFrame |
103 | { | 106 | { |
104 | Q_OBJECT | 107 | Q_OBJECT |
105 | public: | 108 | public: |
106 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); | 109 | Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); |
107 | ~Keyboard(); | 110 | ~Keyboard(); |
108 | 111 | ||
109 | void resetState(); | 112 | void resetState(); |
110 | 113 | ||
111 | void mousePressEvent(QMouseEvent*); | 114 | void mousePressEvent(QMouseEvent*); |
112 | void mouseReleaseEvent(QMouseEvent*); | 115 | void mouseReleaseEvent(QMouseEvent*); |
113 | void resizeEvent(QResizeEvent*); | 116 | void resizeEvent(QResizeEvent*); |
114 | void paintEvent(QPaintEvent* e); | 117 | void paintEvent(QPaintEvent* e); |
115 | //void timerEvent(QTimerEvent* e); | 118 | //void timerEvent(QTimerEvent* e); |
116 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); | 119 | void drawKeyboard( QPainter &p, int row = -1, int col = -1); |
117 | 120 | ||
118 | QSize sizeHint() const; | 121 | QSize sizeHint() const; |
119 | 122 | ||
120 | signals: | 123 | signals: |
121 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); | 124 | void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); |
122 | 125 | ||
123 | private slots: | 126 | private slots: |
124 | void repeat(); | 127 | void repeat(); |
125 | void togglePickboard(bool on_off); | 128 | void togglePickboard(bool on_off); |
126 | void toggleRepeat(bool on_off); | 129 | void toggleRepeat(bool on_off); |
127 | void setMapToDefault(); | 130 | void setMapToDefault(); |
128 | void setMapToFile(QString map); | 131 | void setMapToFile(QString map); |
129 | void cleanupConfigDlg(); | 132 | void cleanupConfigDlg(); |
130 | 133 | ||
131 | // used to redraw keyboard after edited colors | 134 | // used to redraw keyboard after edited colors |
132 | void reloadKeyboard(); | 135 | void reloadKeyboard(); |
133 | 136 | ||
134 | private: | 137 | private: |
135 | int getKey( int &w, int j = -1 ); | 138 | int getKey( int &w, int j = -1 ); |
136 | void clearHighlight(); | 139 | void clearHighlight(); |
137 | 140 | ||
138 | bool *shift; | 141 | bool *shift; |
139 | bool *lock; | 142 | bool *lock; |
140 | bool *ctrl; | 143 | bool *ctrl; |
141 | bool *alt; | 144 | bool *alt; |
142 | bool *meta; | 145 | bool *meta; |
143 | bool *circumflex; | 146 | bool *circumflex; |
144 | bool *diaeresis; | 147 | bool *diaeresis; |
145 | bool *baccent; | 148 | bool *baccent; |
146 | bool *accent; | 149 | bool *accent; |
147 | 150 | ||
148 | uint useLargeKeys:1; | 151 | uint useLargeKeys:1; |
149 | uint usePicks:1; | 152 | uint usePicks:1; |
150 | uint useRepeat:1; | 153 | uint useRepeat:1; |
151 | 154 | ||
152 | int pressedKeyRow; | 155 | int pressedKeyRow; |
153 | int pressedKeyCol; | 156 | int pressedKeyCol; |
154 | 157 | ||
155 | KeyboardPicks *picks; | 158 | KeyboardPicks *picks; |
156 | 159 | ||
157 | int keyHeight; | 160 | int keyHeight; |
158 | int defaultKeyWidth; | 161 | int defaultKeyWidth; |
159 | int xoffs; | 162 | int xoffs; |
160 | 163 | ||
161 | int unicode; | 164 | int unicode; |
162 | int qkeycode; | 165 | int qkeycode; |
163 | int modifiers; | 166 | int modifiers; |
164 | 167 | ||
165 | int pressTid; | 168 | int pressTid; |
166 | bool pressed; | 169 | bool pressed; |
167 | 170 | ||
168 | Keys *keys; | 171 | Keys *keys; |
169 | 172 | ||
170 | /* for korean input */ | 173 | /* for korean input */ |
171 | ushort schar, mchar, echar; | 174 | ushort schar, mchar, echar; |
172 | ushort parseKoreanInput(ushort c); | 175 | ushort parseKoreanInput(ushort c); |
173 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); | 176 | ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); |
174 | ushort constoe(const ushort c); | 177 | ushort constoe(const ushort c); |
175 | 178 | ||
176 | QTimer *repeatTimer; | 179 | QTimer *repeatTimer; |
177 | 180 | ||
178 | /* colors */ | 181 | /* colors */ |
179 | void loadKeyboardColors(); | 182 | void loadKeyboardColors(); |
180 | QColor keycolor; | 183 | QColor keycolor; |
181 | QColor keycolor_pressed; | 184 | QColor keycolor_pressed; |
182 | QColor keycolor_lines; | 185 | QColor keycolor_lines; |
183 | QColor textcolor; | 186 | QColor textcolor; |
184 | 187 | ||
185 | ConfigDlg *configdlg; | 188 | ConfigDlg *configdlg; |
186 | }; | 189 | }; |
187 | 190 | ||
188 | 191 | } // namespace MultiKey | |
diff --git a/inputmethods/multikey/keyboardimpl.cpp b/inputmethods/multikey/keyboardimpl.cpp index cebd43d..4cfbcd5 100644 --- a/inputmethods/multikey/keyboardimpl.cpp +++ b/inputmethods/multikey/keyboardimpl.cpp | |||
@@ -1,107 +1,107 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include <qapplication.h> | 20 | #include <qapplication.h> |
21 | #include <qpixmap.h> | 21 | #include <qpixmap.h> |
22 | #include "keyboard.h" | 22 | #include "keyboard.h" |
23 | #include "keyboardimpl.h" | 23 | #include "keyboardimpl.h" |
24 | 24 | ||
25 | /* XPM */ | 25 | /* XPM */ |
26 | static const char * kb_xpm[] = { | 26 | static const char * const kb_xpm[] = { |
27 | "28 13 4 1", | 27 | "28 13 4 1", |
28 | " c None", | 28 | " c None", |
29 | ". c #4C4C4C", | 29 | ". c #4C4C4C", |
30 | "+ c #FFF7DD", | 30 | "+ c #FFF7DD", |
31 | "@ c #D6CFBA", | 31 | "@ c #D6CFBA", |
32 | " .......................... ", | 32 | " .......................... ", |
33 | " .+++.+++.+++.+++.+++.++++. ", | 33 | " .+++.+++.+++.+++.+++.++++. ", |
34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", | 34 | " .+@@.+@@.+@@.+@@.+@@.+@@@. ", |
35 | " .......................... ", | 35 | " .......................... ", |
36 | " .+++++.+++.+++.+++.++++++. ", | 36 | " .+++++.+++.+++.+++.++++++. ", |
37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", | 37 | " .+@@@@.+@@.+@@.+@@.+@@@@@. ", |
38 | " .......................... ", | 38 | " .......................... ", |
39 | " .++++++.+++.+++.+++.+++++. ", | 39 | " .++++++.+++.+++.+++.+++++. ", |
40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", | 40 | " .+@@@@@.+@@.+@@.+@@.+@@@@. ", |
41 | " .......................... ", | 41 | " .......................... ", |
42 | " .++++.++++++++++++++.++++. ", | 42 | " .++++.++++++++++++++.++++. ", |
43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", | 43 | " .+@@@.+@@@@@@@@@@@@@.+@@@. ", |
44 | " .......................... "}; | 44 | " .......................... "}; |
45 | 45 | ||
46 | 46 | ||
47 | KeyboardImpl::KeyboardImpl() | 47 | KeyboardImpl::KeyboardImpl() |
48 | : input(0), icn(0), ref(0) | 48 | : input(0), icn(0), ref(0) |
49 | { | 49 | { |
50 | } | 50 | } |
51 | 51 | ||
52 | KeyboardImpl::~KeyboardImpl() | 52 | KeyboardImpl::~KeyboardImpl() |
53 | { | 53 | { |
54 | delete input; | 54 | delete input; |
55 | delete icn; | 55 | delete icn; |
56 | } | 56 | } |
57 | 57 | ||
58 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 58 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
59 | { | 59 | { |
60 | if ( !input ) | 60 | if ( !input ) |
61 | input = new Keyboard( parent, "Keyboard", f ); | 61 | input = new MultiKey::Keyboard( parent, "Keyboard", f ); |
62 | return input; | 62 | return input; |
63 | } | 63 | } |
64 | 64 | ||
65 | void KeyboardImpl::resetState() | 65 | void KeyboardImpl::resetState() |
66 | { | 66 | { |
67 | if ( input ) | 67 | if ( input ) |
68 | input->resetState(); | 68 | input->resetState(); |
69 | } | 69 | } |
70 | 70 | ||
71 | QPixmap *KeyboardImpl::icon() | 71 | QPixmap *KeyboardImpl::icon() |
72 | { | 72 | { |
73 | if ( !icn ) | 73 | if ( !icn ) |
74 | icn = new QPixmap( (const char **)kb_xpm ); | 74 | icn = new QPixmap( (const char **)kb_xpm ); |
75 | return icn; | 75 | return icn; |
76 | } | 76 | } |
77 | 77 | ||
78 | QString KeyboardImpl::name() | 78 | QString KeyboardImpl::name() |
79 | { | 79 | { |
80 | return qApp->translate( "InputMethods", "Multikey" ); | 80 | return qApp->translate( "InputMethods", "Multikey" ); |
81 | } | 81 | } |
82 | 82 | ||
83 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 83 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
84 | { | 84 | { |
85 | if ( input ) | 85 | if ( input ) |
86 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 86 | QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
87 | } | 87 | } |
88 | 88 | ||
89 | #ifndef QT_NO_COMPONENT | 89 | #ifndef QT_NO_COMPONENT |
90 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 90 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
91 | { | 91 | { |
92 | *iface = 0; | 92 | *iface = 0; |
93 | if ( uuid == IID_QUnknown ) | 93 | if ( uuid == IID_QUnknown ) |
94 | *iface = this; | 94 | *iface = this; |
95 | else if ( uuid == IID_InputMethod ) | 95 | else if ( uuid == IID_InputMethod ) |
96 | *iface = this; | 96 | *iface = this; |
97 | 97 | ||
98 | if ( *iface ) | 98 | if ( *iface ) |
99 | (*iface)->addRef(); | 99 | (*iface)->addRef(); |
100 | return QS_OK; | 100 | return QS_OK; |
101 | } | 101 | } |
102 | 102 | ||
103 | Q_EXPORT_INTERFACE() | 103 | Q_EXPORT_INTERFACE() |
104 | { | 104 | { |
105 | Q_CREATE_INSTANCE( KeyboardImpl ) | 105 | Q_CREATE_INSTANCE( KeyboardImpl ) |
106 | } | 106 | } |
107 | #endif | 107 | #endif |
diff --git a/inputmethods/multikey/keyboardimpl.h b/inputmethods/multikey/keyboardimpl.h index e756364..76a2955 100644 --- a/inputmethods/multikey/keyboardimpl.h +++ b/inputmethods/multikey/keyboardimpl.h | |||
@@ -1,51 +1,60 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef KEYBOARDIMPL_H | 20 | #ifndef KEYBOARDIMPL_H |
21 | #define KEYBOARDIMPL_H | 21 | #define KEYBOARDIMPL_H |
22 | 22 | ||
23 | #include <qpe/inputmethodinterface.h> | 23 | #include <qpe/inputmethodinterface.h> |
24 | 24 | ||
25 | class Keyboard; | 25 | namespace MultiKey |
26 | { | ||
27 | class Keyboard; | ||
28 | } | ||
29 | |||
26 | class QPixmap; | 30 | class QPixmap; |
27 | 31 | ||
32 | namespace | ||
33 | { | ||
34 | |||
28 | class KeyboardImpl : public InputMethodInterface | 35 | class KeyboardImpl : public InputMethodInterface |
29 | { | 36 | { |
30 | public: | 37 | public: |
31 | KeyboardImpl(); | 38 | KeyboardImpl(); |
32 | virtual ~KeyboardImpl(); | 39 | virtual ~KeyboardImpl(); |
33 | 40 | ||
34 | #ifndef QT_NO_COMPONENT | 41 | #ifndef QT_NO_COMPONENT |
35 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); | 42 | QRESULT queryInterface( const QUuid&, QUnknownInterface** ); |
36 | Q_REFCOUNT | 43 | Q_REFCOUNT |
37 | #endif | 44 | #endif |
38 | 45 | ||
39 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); | 46 | virtual QWidget *inputMethod( QWidget *parent, Qt::WFlags f ); |
40 | virtual void resetState(); | 47 | virtual void resetState(); |
41 | virtual QPixmap *icon(); | 48 | virtual QPixmap *icon(); |
42 | virtual QString name(); | 49 | virtual QString name(); |
43 | virtual void onKeyPress( QObject *receiver, const char *slot ); | 50 | virtual void onKeyPress( QObject *receiver, const char *slot ); |
44 | 51 | ||
45 | private: | 52 | private: |
46 | Keyboard *input; | 53 | MultiKey::Keyboard *input; |
47 | QPixmap *icn; | 54 | QPixmap *icn; |
48 | ulong ref; | 55 | ulong ref; |
49 | }; | 56 | }; |
50 | 57 | ||
58 | } // anonymous namespace | ||
59 | |||
51 | #endif | 60 | #endif |