Diffstat (limited to 'inputmethods/jumpx/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | inputmethods/jumpx/keyboard.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/inputmethods/jumpx/keyboard.cpp b/inputmethods/jumpx/keyboard.cpp index 0cfb4be..79f0d5d 100644 --- a/inputmethods/jumpx/keyboard.cpp +++ b/inputmethods/jumpx/keyboard.cpp | |||
@@ -1,62 +1,62 @@ | |||
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 <opie2/oresource.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 }, |
@@ -92,115 +92,115 @@ static const uchar *const specialMap[] = { | |||
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 | using namespace JumpX; |
128 | 128 | ||
129 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 129 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
130 | QFrame(parent, name, f), | 130 | QFrame(parent, name, f), |
131 | shift(0), paren(0), ctrl(0), alt(0), | 131 | shift(0), paren(0), ctrl(0), alt(0), |
132 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), | 132 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), |
133 | isnoncont(false), | 133 | isnoncont(false), |
134 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), | 134 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), |
135 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), | 135 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), |
136 | releasedPix(NULL), pressedPix(NULL) | 136 | releasedPix(NULL), pressedPix(NULL) |
137 | { | 137 | { |
138 | //setPalette(QPalette(QColor(240,240,230))); // Beige! | 138 | //setPalette(QPalette(QColor(240,240,230))); // Beige! |
139 | 139 | ||
140 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("jumpx/released"); | 140 | releasedPlain = releasedShift = releasedParen = Opie::Core::OResource::loadPixmap("jumpx/released"); |
141 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("jumpx/pressed"); | 141 | pressedPlain = pressedShift = pressedParen = Opie::Core::OResource::loadPixmap("jumpx/pressed"); |
142 | pressedDigit = Resource::loadPixmap("jumpx/pressed"); | 142 | pressedDigit = Opie::Core::OResource::loadPixmap("jumpx/pressed"); |
143 | 143 | ||
144 | QPixmap tmp; | 144 | QPixmap tmp; |
145 | 145 | ||
146 | tmp = Resource::loadPixmap("jumpx/releasedShift"); | 146 | tmp = Opie::Core::OResource::loadPixmap("jumpx/releasedShift"); |
147 | bitBlt(&releasedShift, letterx1, 0, &tmp); | 147 | bitBlt(&releasedShift, letterx1, 0, &tmp); |
148 | 148 | ||
149 | tmp = Resource::loadPixmap("jumpx/releasedParen"); | 149 | tmp = Opie::Core::OResource::loadPixmap("jumpx/releasedParen"); |
150 | bitBlt(&releasedParen, specialx1, 0, &tmp); | 150 | bitBlt(&releasedParen, specialx1, 0, &tmp); |
151 | 151 | ||
152 | tmp = Resource::loadPixmap("jumpx/pressedShift"); | 152 | tmp = Opie::Core::OResource::loadPixmap("jumpx/pressedShift"); |
153 | bitBlt(&pressedShift, letterx1, 0, &tmp); | 153 | bitBlt(&pressedShift, letterx1, 0, &tmp); |
154 | 154 | ||
155 | tmp = Resource::loadPixmap("jumpx/pressedParen"); | 155 | tmp = Opie::Core::OResource::loadPixmap("jumpx/pressedParen"); |
156 | bitBlt(&pressedParen, specialx1, 0, &tmp); | 156 | bitBlt(&pressedParen, specialx1, 0, &tmp); |
157 | 157 | ||
158 | tmp = Resource::loadPixmap("jumpx/pressedDigit"); | 158 | tmp = Opie::Core::OResource::loadPixmap("jumpx/pressedDigit"); |
159 | bitBlt(&pressedDigit, specialx1, 0, &tmp); | 159 | bitBlt(&pressedDigit, specialx1, 0, &tmp); |
160 | 160 | ||
161 | offscreen = QPixmap( releasedPlain ); | 161 | offscreen = QPixmap( releasedPlain ); |
162 | 162 | ||
163 | releasedPix = &releasedPlain; | 163 | releasedPix = &releasedPlain; |
164 | pressedPix = &pressedPlain; | 164 | pressedPix = &pressedPlain; |
165 | slidePix = &pressedPlain; | 165 | slidePix = &pressedPlain; |
166 | 166 | ||
167 | delayTimer = new QTimer(this); | 167 | delayTimer = new QTimer(this); |
168 | rateTimer = new QTimer(this); | 168 | rateTimer = new QTimer(this); |
169 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); | 169 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); |
170 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 170 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
171 | } | 171 | } |
172 | 172 | ||
173 | void Keyboard::resizeEvent(QResizeEvent*) | 173 | void Keyboard::resizeEvent(QResizeEvent*) |
174 | { | 174 | { |
175 | //cout << "resizeEvent()" << endl; | 175 | //cout << "resizeEvent()" << endl; |
176 | } | 176 | } |
177 | 177 | ||
178 | void Keyboard::paintEvent(QPaintEvent*) | 178 | void Keyboard::paintEvent(QPaintEvent*) |
179 | { | 179 | { |
180 | bitBlt(this, 0, 0, &offscreen); | 180 | bitBlt(this, 0, 0, &offscreen); |
181 | } | 181 | } |
182 | 182 | ||
183 | void Keyboard::mousePressEvent(QMouseEvent *e) | 183 | void Keyboard::mousePressEvent(QMouseEvent *e) |
184 | { | 184 | { |
185 | pressedx = -1; | 185 | pressedx = -1; |
186 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; | 186 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; |
187 | 187 | ||
188 | int x = e->x(); | 188 | int x = e->x(); |
189 | int y = e->y(); | 189 | int y = e->y(); |
190 | 190 | ||
191 | int row = (y - 1) / letterh; | 191 | int row = (y - 1) / letterh; |
192 | 192 | ||
193 | if ( x <= mod1x2 ) // mod1 | 193 | if ( x <= mod1x2 ) // mod1 |
194 | { | 194 | { |
195 | pressedx = mod1x1; | 195 | pressedx = mod1x1; |
196 | pressedy = row * letterh; | 196 | pressedy = row * letterh; |
197 | pressedw = mod1w + 1; | 197 | pressedw = mod1w + 1; |
198 | pressedh = letterh + 1; | 198 | pressedh = letterh + 1; |
199 | if ( row == 2 ) // return | 199 | if ( row == 2 ) // return |
200 | { | 200 | { |
201 | pressed2x = mod2x1; | 201 | pressed2x = mod2x1; |
202 | pressed2y = 2 * letterh; | 202 | pressed2y = 2 * letterh; |
203 | pressed2w = mod2w + 1; | 203 | pressed2w = mod2w + 1; |
204 | pressed2h = letterh + 1; | 204 | pressed2h = letterh + 1; |
205 | isnoncont = true; | 205 | isnoncont = true; |
206 | } | 206 | } |