summaryrefslogtreecommitdiff
path: root/inputmethods/keyboard
Unidiff
Diffstat (limited to 'inputmethods/keyboard') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/keyboard/keyboard.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp
index a85a7b1..fb88f2a 100644
--- a/inputmethods/keyboard/keyboard.cpp
+++ b/inputmethods/keyboard/keyboard.cpp
@@ -1,810 +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
33using namespace KeyboardInput; 33using namespace KeyboardInput;
34 34
35#define USE_SMALL_BACKSPACE 35#define USE_SMALL_BACKSPACE
36 36
37Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 37Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
38 QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), 38 QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE),
39 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), 39 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1),
40 unicode(-1), qkeycode(0), modifiers(0) 40 unicode(-1), qkeycode(0), modifiers(0)
41{ 41{
42 // setPalette(QPalette(QColor(240,240,230))); // Beige! 42 // setPalette(QPalette(QColor(240,240,230))); // Beige!
43 // setFont( QFont( "Helvetica", 8 ) ); 43 // setFont( QFont( "Helvetica", 8 ) );
44// setPalette(QPalette(QColor(200,200,200))); // Gray 44// setPalette(QPalette(QColor(200,200,200))); // Gray
45 setPalette(QPalette(QColor(220,220,220))); // Gray 45 setPalette(QPalette(QColor(220,220,220))); // Gray
46 46
47 picks = new KeyboardPicks( this ); 47 picks = new KeyboardPicks( this );
48 picks->setFont( QFont( "smallsmooth", 9 ) ); 48 picks->setFont( QFont( "smallsmooth", 9 ) );
49 setFont( QFont( "smallsmooth", 9 ) ); 49 setFont( QFont( "smallsmooth", 9 ) );
50 picks->initialise(); 50 picks->initialise();
51 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 51 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
52 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 52 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
53 53
54 repeatTimer = new QTimer( this ); 54 repeatTimer = new QTimer( this );
55 55
56 // temporary quick and dirty fix for the "sticky keyboard bug" 56 // temporary quick and dirty fix for the "sticky keyboard bug"
57 // on ipaq. 57 // on ipaq.
58// struct utsname name; 58// struct utsname name;
59// if (uname(&name) != -1) 59// if (uname(&name) != -1)
60 // { 60 // {
61 //QString release=name.release; 61 //QString release=name.release;
62 //qWarning("System release: %s\n", name.release); 62 //qWarning("System release: %s\n", name.release);
63 //if(release.find("embedix",0,TRUE) !=-1) 63 //if(release.find("embedix",0,TRUE) !=-1)
64 // { 64 // {
65 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 65 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
66 // } 66 // }
67 // } 67 // }
68} 68}
69 69
70void Keyboard::resizeEvent(QResizeEvent*) 70void Keyboard::resizeEvent(QResizeEvent*)
71{ 71{
72 int ph = picks->sizeHint().height(); 72 int ph = picks->sizeHint().height();
73 picks->setGeometry( 0, 0, width(), ph ); 73 picks->setGeometry( 0, 0, width(), ph );
74 keyHeight = (height()-ph)/5; 74 keyHeight = (height()-ph)/5;
75 int nk; 75 int nk;
76 if ( useOptiKeys ) { 76 if ( useOptiKeys ) {
77 nk = 15; 77 nk = 15;
78 } else if ( useLargeKeys ) { 78 } else if ( useLargeKeys ) {
79 nk = 15; 79 nk = 15;
80 } else { 80 } else {
81 nk = 19; 81 nk = 19;
82 } 82 }
83 defaultKeyWidth = width()/nk; 83 defaultKeyWidth = width()/nk;
84 xoffs = (width()-defaultKeyWidth*nk)/2; 84 xoffs = (width()-defaultKeyWidth*nk)/2;
85} 85}
86 86
87void KeyboardPicks::initialise() 87void KeyboardPicks::initialise()
88{ 88{
89 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 89 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
90 mode = 0; 90 mode = 0;
91 dc = new KeyboardConfig(this); 91 dc = new KeyboardConfig(this);
92 configs.append(dc); 92 configs.append(dc);
93} 93}
94 94
95QSize KeyboardPicks::sizeHint() const 95QSize KeyboardPicks::sizeHint() const
96{ 96{
97 return QSize(240,fontMetrics().lineSpacing()); 97 return QSize(240,fontMetrics().lineSpacing());
98} 98}
99 99
100 100
101void KeyboardConfig::generateText(const QString &s) 101void KeyboardConfig::generateText(const QString &s)
102{ 102{
103#if defined(Q_WS_QWS) || defined(_WS_QWS_) 103#if defined(Q_WS_QWS) || defined(_WS_QWS_)
104 for (int i=0; i<(int)backspaces; i++) { 104 for (int i=0; i<(int)backspaces; i++) {
105 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 105 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
106 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 106 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
107 } 107 }
108 for (int i=0; i<(int)s.length(); i++) { 108 for (int i=0; i<(int)s.length(); i++) {
109 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 109 parent->emitKey( s[i].unicode(), 0, 0, true, false );
110 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 110 parent->emitKey( s[i].unicode(), 0, 0, false, false );
111 } 111 }
112 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 112 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
113 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 113 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
114 backspaces = 0; 114 backspaces = 0;
115#endif 115#endif
116} 116}
117 117
118 118
119//PC keyboard layout and scancodes 119//PC keyboard layout and scancodes
120 120
121/* 121/*
122 Format: length, code, length, code, ..., 0 122 Format: length, code, length, code, ..., 0
123 123
124 length is measured in half the width of a standard key. 124 length is measured in half the width of a standard key.
125 If code < 0x80 we have length/2 consecutive standard keys, 125 If code < 0x80 we have length/2 consecutive standard keys,
126 starting with scancode code. 126 starting with scancode code.
127 127
128 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
129 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
130 up in specialM[]. (The special keys are not keymappable.) 130 up in specialM[]. (The special keys are not keymappable.)
131 131
132 */ 132 */
133 133
134static const uchar * const keyboard_opti[5] = { 134static const uchar * const keyboard_opti[5] = {
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\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",
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\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065",
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\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055",
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\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014",
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 (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"
140}; 140};
141 141
142 142
143static const uchar * const keyboard_standard[5] = { 143static const uchar * const keyboard_standard[5] = {
144 144
145#ifdef USE_SMALL_BACKSPACE 145#ifdef USE_SMALL_BACKSPACE
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 (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",
147#else 147#else
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 (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",
149#endif 149#endif
150 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP 150 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP
151 151
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 (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",
153 //TAB + qwerty.. + backslash //+ DEL + END + PGDN 153 //TAB + qwerty.. + backslash //+ DEL + END + PGDN
154 154
155 (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",
156 //CAPS + asdf.. + RETURN 156 //CAPS + asdf.. + RETURN
157 157
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 (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211",
159 //SHIFT + zxcv... //+ UP 159 //SHIFT + zxcv... //+ UP
160 160
161 (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"
162 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT 162 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT
163 163
164}; 164};
165 165
166 166
167struct ShiftMap { 167struct ShiftMap {
168 char normal; 168 char normal;
169 char shifted; 169 char shifted;
170}; 170};
171 171
172 172
173static const ShiftMap shiftMap[] = { 173static const ShiftMap shiftMap[] = {
174 { '`', '~' }, 174 { '`', '~' },
175 { '1', '!' }, 175 { '1', '!' },
176 { '2', '@' }, 176 { '2', '@' },
177 { '3', '#' }, 177 { '3', '#' },
178 { '4', '$' }, 178 { '4', '$' },
179 { '5', '%' }, 179 { '5', '%' },
180 { '6', '^' }, 180 { '6', '^' },
181 { '7', '&' }, 181 { '7', '&' },
182 { '8', '*' }, 182 { '8', '*' },
183 { '9', '(' }, 183 { '9', '(' },
184 { '0', ')' }, 184 { '0', ')' },
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
198/* XPM */ 198/* XPM */
199static const char * const uparrow_xpm[]={ 199static const char * const uparrow_xpm[]={
200"9 9 2 1", 200"9 9 2 1",
201"a c #000000", 201"a c #000000",
202". c None", 202". c None",
203".........", 203".........",
204"....a....", 204"....a....",
205"...aaa...", 205"...aaa...",
206"..aaaaa..", 206"..aaaaa..",
207"....a....", 207"....a....",
208"....a....", 208"....a....",
209"....a....", 209"....a....",
210"....a....", 210"....a....",
211"........."}; 211"........."};
212/* XPM */ 212/* XPM */
213static const char * const leftarrow_xpm[]={ 213static const char * const leftarrow_xpm[]={
214"9 9 2 1", 214"9 9 2 1",
215"a c #000000", 215"a c #000000",
216". c None", 216". c None",
217".........", 217".........",
218".........", 218".........",
219"...a.....", 219"...a.....",
220"..aa.....", 220"..aa.....",
221".aaaaaaa.", 221".aaaaaaa.",
222"..aa.....", 222"..aa.....",
223"...a.....", 223"...a.....",
224".........", 224".........",
225"........."}; 225"........."};
226/* XPM */ 226/* XPM */
227static const char * const downarrow_xpm[]={ 227static const char * const downarrow_xpm[]={
228"9 9 2 1", 228"9 9 2 1",
229"a c #000000", 229"a c #000000",
230". c None", 230". c None",
231".........", 231".........",
232"....a....", 232"....a....",
233"....a....", 233"....a....",
234"....a....", 234"....a....",
235"....a....", 235"....a....",
236"..aaaaa..", 236"..aaaaa..",
237"...aaa...", 237"...aaa...",
238"....a....", 238"....a....",
239"........."}; 239"........."};
240/* XPM */ 240/* XPM */
241static const char * const rightarrow_xpm[]={ 241static const char * const rightarrow_xpm[]={
242"9 9 2 1", 242"9 9 2 1",
243"a c #000000", 243"a c #000000",
244". c None", 244". c None",
245".........", 245".........",
246".........", 246".........",
247".....a...", 247".....a...",
248".....aa..", 248".....aa..",
249".aaaaaaa.", 249".aaaaaaa.",
250".....aa..", 250".....aa..",
251".....a...", 251".....a...",
252".........", 252".........",
253"........."}; 253"........."};
254/* XPM */ 254/* XPM */
255static const char * const insert_xpm[]={ 255static const char * const insert_xpm[]={
256"9 9 2 1", 256"9 9 2 1",
257"a c #000000", 257"a c #000000",
258". c None", 258". c None",
259".........", 259".........",
260"a........", 260"a........",
261"a.aaa.aaa", 261"a.aaa.aaa",
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...a",
265"a.a.a.aaa", 265"a.a.a.aaa",
266".........", 266".........",
267"........."}; 267"........."};
268/* XPM */ 268/* XPM */
269static const char * const delete_xpm[]={ 269static const char * const delete_xpm[]={
270"9 9 2 1", 270"9 9 2 1",
271"a c #000000", 271"a c #000000",
272". c None", 272". c None",
273".........", 273".........",
274"aa......a", 274"aa......a",
275"a.a.aaa.a", 275"a.a.aaa.a",
276"a.a.a.a.a", 276"a.a.a.a.a",
277"a.a.aaa.a.", 277"a.a.aaa.a.",
278"a.a.a...a", 278"a.a.a...a",
279"aaa.aaa.a", 279"aaa.aaa.a",
280".........", 280".........",
281"........."}; 281"........."};
282/* XPM */ 282/* XPM */
283static const char * const home_xpm[]={ 283static const char * const home_xpm[]={
284"9 9 2 1", 284"9 9 2 1",
285"a c #000000", 285"a c #000000",
286". c None", 286". c None",
287"....a....", 287"....a....",
288"...a.a...", 288"...a.a...",
289"..a...a..", 289"..a...a..",
290".a.....a.", 290".a.....a.",
291"aa.aaa.aa", 291"aa.aaa.aa",
292".a.a.a.a.", 292".a.a.a.a.",
293".a.a.a.a.", 293".a.a.a.a.",
294".aaaaaaa.", 294".aaaaaaa.",
295"........."}; 295"........."};
296/* XPM */ 296/* XPM */
297static const char * const end_xpm[]={ 297static const char * const end_xpm[]={
298"10 9 2 1", 298"10 9 2 1",
299"a c #000000", 299"a c #000000",
300". c None", 300". c None",
301"..........", 301"..........",
302"aa.......a", 302"aa.......a",
303"a..aaa.aaa", 303"a..aaa.aaa",
304"aa.a.a.a.a", 304"aa.a.a.a.a",
305"a..a.a.a.a", 305"a..a.a.a.a",
306"a..a.a.a.a", 306"a..a.a.a.a",
307"aa.a.a.aaa", 307"aa.a.a.aaa",
308"..........", 308"..........",
309".........."}; 309".........."};
310/* XPM */ 310/* XPM */
311static const char * const pageup_xpm[]={ 311static const char * const pageup_xpm[]={
312"9 9 2 1", 312"9 9 2 1",
313"a c #000000", 313"a c #000000",
314". c None", 314". c None",
315".aaa.aaa.", 315".aaa.aaa.",
316".a.a.a.a.", 316".a.a.a.a.",
317".aaa..aa.", 317".aaa..aa.",
318".a...aaa.", 318".a...aaa.",
319".........", 319".........",
320".a.a.aaa.", 320".a.a.aaa.",
321".a.a.a.a.", 321".a.a.a.a.",
322".aaa.aaa.", 322".aaa.aaa.",
323".....a..."}; 323".....a..."};
324/* XPM */ 324/* XPM */
325static const char * const pagedown_xpm[]={ 325static const char * const pagedown_xpm[]={
326"9 9 2 1", 326"9 9 2 1",
327"a c #000000", 327"a c #000000",
328". c None", 328". c None",
329".aaa.aaa.", 329".aaa.aaa.",
330".a.a.a.a.", 330".a.a.a.a.",
331".aaa..aa.", 331".aaa..aa.",
332".a...aaa.", 332".a...aaa.",
333".........", 333".........",
334"...a.....", 334"...a.....",
335".aaa.aaa.", 335".aaa.aaa.",
336".a.a.a.a.", 336".a.a.a.a.",
337".aaa.a.a."}; 337".aaa.a.a."};
338/* XPM */ 338/* XPM */
339static const char * const expand_xpm[]={ 339static const char * const expand_xpm[]={
340"4 9 2 1", 340"4 9 2 1",
341"a c #408040", 341"a c #408040",
342". c None", 342". c None",
343"a...", 343"a...",
344"aa..", 344"aa..",
345"aaa.", 345"aaa.",
346"aaaa", 346"aaaa",
347"aaaa", 347"aaaa",
348"aaaa", 348"aaaa",
349"aaa.", 349"aaa.",
350"aa..", 350"aa..",
351"a..."}; 351"a..."};
352/* XPM */ 352/* XPM */
353#ifdef USE_SMALL_BACKSPACE 353#ifdef USE_SMALL_BACKSPACE
354static const char * const backspace_xpm[]={ 354static const char * const backspace_xpm[]={
355"9 9 2 1", 355"9 9 2 1",
356"a c #000000", 356"a c #000000",
357". c None", 357". c None",
358".........", 358".........",
359".........", 359".........",
360"...a.....", 360"...a.....",
361"..aa.....", 361"..aa.....",
362".aaaaaaaa", 362".aaaaaaaa",
363"..aa.....", 363"..aa.....",
364"...a.....", 364"...a.....",
365".........", 365".........",
366"........."}; 366"........."};
367#else 367#else
368static const char * const backspace_xpm[]={ 368static const char * const backspace_xpm[]={
369"21 9 2 1", 369"21 9 2 1",
370"a c #000000", 370"a c #000000",
371". c None", 371". c None",
372".....................", 372".....................",
373".....................", 373".....................",
374".....aaa..a..........", 374".....aaa..a..........",
375".a...a..a.a.a.aaa.aaa", 375".a...a..a.a.a.aaa.aaa",
376"aaaa.aaa..aa..aa..a.a", 376"aaaa.aaa..aa..aa..a.a",
377".a...a..a.aaa..aa.a.a", 377".a...a..a.aaa..aa.a.a",
378".....aaaa.a.a.aaa.aa.", 378".....aaaa.a.a.aaa.aa.",
379"..................a..", 379"..................a..",
380"....................."}; 380"....................."};
381#endif 381#endif
382/* XPM */ 382/* XPM */
383static const char * const escape_xpm[]={ 383static const char * const escape_xpm[]={
384"9 9 2 1", 384"9 9 2 1",
385"a c #000000", 385"a c #000000",
386". c None", 386". c None",
387".........", 387".........",
388".........", 388".........",
389".aa.aa.aa", 389".aa.aa.aa",
390".a..a..a.", 390".a..a..a.",
391".aa.aa.a.", 391".aa.aa.a.",
392".a...a.a.", 392".a...a.a.",
393".aa.aa.aa", 393".aa.aa.aa",
394".........", 394".........",
395"........."}; 395"........."};
396 396
397 397
398enum { BSCode = 0x80, TabCode, CapsCode, RetCode, 398enum { BSCode = 0x80, TabCode, CapsCode, RetCode,
399 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, 399 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash,
400 UpCode, LeftCode, DownCode, RightCode, Blank, Expand, 400 UpCode, LeftCode, DownCode, RightCode, Blank, Expand,
401 Opti, ResetDict, 401 Opti, ResetDict,
402 Divide, Multiply, Add, Subtract, Decimal, Equal, 402 Divide, Multiply, Add, Subtract, Decimal, Equal,
403 Percent, Sqrt, Inverse, Escape }; 403 Percent, Sqrt, Inverse, Escape };
404 404
405typedef struct SpecialMap { 405typedef struct SpecialMap {
406 int qcode; 406 int qcode;
407 ushort unicode; 407 ushort unicode;
408 const char * label; 408 const char * label;
409 const char * const * xpm; 409 const char * const * xpm;
410}; 410};
411 411
412 412
413static const SpecialMap specialM[] = { 413static const SpecialMap specialM[] = {
414 { Qt::Key_Backspace, 8,"<", backspace_xpm }, 414 { Qt::Key_Backspace, 8,"<", backspace_xpm },
415 { Qt::Key_Tab, 9,"Tab", NULL }, 415 { Qt::Key_Tab, 9,"Tab", NULL },
416 { Qt::Key_CapsLock, 0,"Caps", NULL }, 416 { Qt::Key_CapsLock, 0,"Caps", NULL },
417 { Qt::Key_Return, 13,"Ret", NULL }, 417 { Qt::Key_Return, 13,"Ret", NULL },
418 { Qt::Key_Shift, 0,"Shift", NULL }, 418 { Qt::Key_Shift, 0,"Shift", NULL },
419 { Qt::Key_Control, 0,"Ctrl", NULL }, 419 { Qt::Key_Control, 0,"Ctrl", NULL },
420 { Qt::Key_Alt, 0,"Alt", NULL }, 420 { Qt::Key_Alt, 0,"Alt", NULL },
421 { Qt::Key_Space, ' ',"", NULL }, 421 { Qt::Key_Space, ' ',"", NULL },
422 { BackSlash, 43,"\\", NULL }, 422 { BackSlash, 43,"\\", NULL },
423 423
424 // Need images? 424 // Need images?
425 { Qt::Key_Up, 0,"^", uparrow_xpm }, 425 { Qt::Key_Up, 0,"^", uparrow_xpm },
426 { Qt::Key_Left, 0,"<", leftarrow_xpm }, 426 { Qt::Key_Left, 0,"<", leftarrow_xpm },
427 { Qt::Key_Down, 0,"v", downarrow_xpm }, 427 { Qt::Key_Down, 0,"v", downarrow_xpm },
428 { Qt::Key_Right, 0,">", rightarrow_xpm }, 428 { Qt::Key_Right, 0,">", rightarrow_xpm },
429 { Qt::Key_Insert, 0,"I", insert_xpm }, 429 { Qt::Key_Insert, 0,"I", insert_xpm },
430 { Qt::Key_Home, 0,"H", home_xpm }, 430 { Qt::Key_Home, 0,"H", home_xpm },
431 { Qt::Key_PageUp, 0,"U", pageup_xpm }, 431 { Qt::Key_PageUp, 0,"U", pageup_xpm },
432 { Qt::Key_End, 0,"E", end_xpm }, 432 { Qt::Key_End, 0,"E", end_xpm },
433 { Qt::Key_Delete, 0,"X", delete_xpm }, 433 { Qt::Key_Delete, 0,"X", delete_xpm },
434 { Qt::Key_PageDown, 0,"D", pagedown_xpm }, 434 { Qt::Key_PageDown, 0,"D", pagedown_xpm },
435 { Blank, 0," ", NULL }, 435 { Blank, 0," ", NULL },
436 { Expand, 0,"->", expand_xpm }, 436 { Expand, 0,"->", expand_xpm },
437 { Opti, 0,"#", NULL }, 437 { Opti, 0,"#", NULL },
438 { ResetDict, 0,"R", NULL }, 438 { ResetDict, 0,"R", NULL },
439 439
440 // number pad stuff 440 // number pad stuff
441 { Divide, 0,"/", NULL }, 441 { Divide, 0,"/", NULL },
442 { Multiply, 0,"*", NULL }, 442 { Multiply, 0,"*", NULL },
443 { Add, 0,"+", NULL }, 443 { Add, 0,"+", NULL },
444 { Subtract, 0,"-", NULL }, 444 { Subtract, 0,"-", NULL },
445 { Decimal, 0,".", NULL }, 445 { Decimal, 0,".", NULL },
446 { Equal, 0,"=", NULL }, 446 { Equal, 0,"=", NULL },
447 { Percent, 0,"%", NULL }, 447 { Percent, 0,"%", NULL },
448 { Sqrt, 0, "^1/2", NULL }, 448 { Sqrt, 0, "^1/2", NULL },
449 { Inverse, 0, "1/x", NULL }, 449 { Inverse, 0, "1/x", NULL },
450 450
451 { Escape, 27, "ESC", escape_xpm } 451 { Escape, 27, "ESC", escape_xpm }
452}; 452};
453 453
454 454
455static int keycode( int i2, int j, const uchar **keyboard ) 455static int keycode( int i2, int j, const uchar **keyboard )
456{ 456{
457 if ( j <0 || j >= 5 ) 457 if ( j <0 || j >= 5 )
458 return 0; 458 return 0;
459 459
460 const uchar *row = keyboard[j]; 460 const uchar *row = keyboard[j];
461 461
462 while ( *row && *row <= i2 ) { 462 while ( *row && *row <= i2 ) {
463 i2 -= *row; 463 i2 -= *row;
464 row += 2; 464 row += 2;
465 } 465 }
466 466
467 if ( !*row ) return 0; 467 if ( !*row ) return 0;
468 468
469 int k; 469 int k;
470 if ( row[1] >= 0x80 ) { 470 if ( row[1] >= 0x80 ) {
471 k = row[1]; 471 k = row[1];
472 } else { 472 } else {
473 k = row[1]+i2/2; 473 k = row[1]+i2/2;
474 } 474 }
475 475
476 return k; 476 return k;
477} 477}
478 478
479 479
480/* 480/*
481 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,
482 or next key on current row if \a j < 0. 482 or next key on current row if \a j < 0.
483 483
484*/ 484*/
485 485
486int Keyboard::getKey( int &w, int j ) { 486int Keyboard::getKey( int &w, int j ) {
487 static const uchar *row = 0; 487 static const uchar *row = 0;
488 static int key_i = 0; 488 static int key_i = 0;
489 static int scancode = 0; 489 static int scancode = 0;
490 static int half = 0; 490 static int half = 0;
491 491
492 if ( j >= 0 && j < 5 ) { 492 if ( j >= 0 && j < 5 ) {
493 if (useOptiKeys) 493 if (useOptiKeys)
494 row = keyboard_opti[j]; 494 row = keyboard_opti[j];
495 else 495 else
496 row = keyboard_standard[j]; 496 row = keyboard_standard[j];
497 half=0; 497 half=0;
498 } 498 }
499 499
500 if ( !row || !*row ) { 500 if ( !row || !*row ) {
501 return 0; 501 return 0;
502 } else if ( row[1] >= 0x80 ) { 502 } else if ( row[1] >= 0x80 ) {
503 scancode = row[1]; 503 scancode = row[1];
504 w = (row[0] * w + (half++&1)) / 2; 504 w = (row[0] * w + (half++&1)) / 2;
505 row += 2; 505 row += 2;
506 return scancode; 506 return scancode;
507 } else if ( key_i <= 0 ) { 507 } else if ( key_i <= 0 ) {
508 key_i = row[0]/2; 508 key_i = row[0]/2;
509 scancode = row[1]; 509 scancode = row[1];
510 } 510 }
511 key_i--; 511 key_i--;
512 if ( key_i <= 0 ) 512 if ( key_i <= 0 )
513 row += 2; 513 row += 2;
514 return scancode++; 514 return scancode++;
515} 515}
516 516
517 517
518void Keyboard::paintEvent(QPaintEvent* e) 518void Keyboard::paintEvent(QPaintEvent* e)
519{ 519{
520 QPainter painter(this); 520 QPainter painter(this);
521 painter.setClipRect(e->rect()); 521 painter.setClipRect(e->rect());
522 drawKeyboard( painter ); 522 drawKeyboard( painter );
523 picks->dc->draw( &painter ); 523 picks->dc->draw( &painter );
524} 524}
525 525
526 526
527/* 527/*
528 Draw the keyboard. 528 Draw the keyboard.
529 529
530 If key >= 0, only the specified key is drawn. 530 If key >= 0, only the specified key is drawn.
531*/ 531*/
532void Keyboard::drawKeyboard( QPainter &p, int key ) 532void Keyboard::drawKeyboard( QPainter &p, int key )
533{ 533{
534 const bool threeD = FALSE; 534 const bool threeD = FALSE;
535 const QColorGroup& cg = colorGroup(); 535 const QColorGroup& cg = colorGroup();
536 QColor keycolor = // cg.background(); 536 QColor keycolor = // cg.background();
537 QColor(240,240,230); // Beige! 537 QColor(240,240,230); // Beige!
538 QColor keycolor_pressed = cg.mid(); 538 QColor keycolor_pressed = cg.mid();
539 QColor keycolor_lo = cg.dark(); 539 QColor keycolor_lo = cg.dark();
540 QColor keycolor_hi = cg.light(); 540 QColor keycolor_hi = cg.light();
541 QColor textcolor = QColor(0,0,0); // cg.text(); 541 QColor textcolor = QColor(0,0,0); // cg.text();
542 542
543 int margin = threeD ? 1 : 0; 543 int margin = threeD ? 1 : 0;
544 544
545// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); 545// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed );
546 546
547 for ( int j = 0; j < 5; j++ ) { 547 for ( int j = 0; j < 5; j++ ) {
548 int y = j * keyHeight + picks->height() + 1; 548 int y = j * keyHeight + picks->height() + 1;
549 int x = xoffs; 549 int x = xoffs;
550 int kw = defaultKeyWidth; 550 int kw = defaultKeyWidth;
551 int k= getKey( kw, j ); 551 int k= getKey( kw, j );
552 while ( k ) { 552 while ( k ) {
553 if ( key < 0 || k == key ) { 553 if ( key < 0 || k == key ) {
554 QString s; 554 QString s;
555 bool pressed = (k == pressedKey); 555 bool pressed = (k == pressedKey);
556 bool blank = (k == 0223); 556 bool blank = (k == 0223);
557 const char * const * xpm = NULL; 557 const char * const * xpm = NULL;
558 558
559 if ( k >= 0x80 ) { 559 if ( k >= 0x80 ) {
560 s = specialM[k - 0x80].label; 560 s = specialM[k - 0x80].label;
561 561
562 xpm = specialM[k - 0x80].xpm; 562 xpm = specialM[k - 0x80].xpm;
563 563
564 if ( k == ShiftCode ) { 564 if ( k == ShiftCode ) {
565 pressed = shift; 565 pressed = shift;
566 } else if ( k == CapsCode ) { 566 } else if ( k == CapsCode ) {
567 pressed = lock; 567 pressed = lock;
568 } else if ( k == CtrlCode ) { 568 } else if ( k == CtrlCode ) {
569 pressed = ctrl; 569 pressed = ctrl;
570 } else if ( k == AltCode ) { 570 } else if ( k == AltCode ) {
571 pressed = alt; 571 pressed = alt;
572 } 572 }
573 } else { 573 } else {
574#if defined(Q_WS_QWS) || defined(_WS_QWS_) 574#if defined(Q_WS_QWS) || defined(_WS_QWS_)
575/* 575/*
576 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : 576 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode :
577 QWSServer::keyMap()[k].unicode); 577 QWSServer::keyMap()[k].unicode);
578*/ 578*/
579 // ### Fixme, bad code, needs improving, whole thing needs to 579 // ### Fixme, bad code, needs improving, whole thing needs to
580 // 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
581 char shifted = k; 581 char shifted = k;
582 if ( !isalpha( k ) ) { 582 if ( !isalpha( k ) ) {
583 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 583 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
584 if ( shiftMap[i].normal == k ) 584 if ( shiftMap[i].normal == k )
585 shifted = shiftMap[i].shifted; 585 shifted = shiftMap[i].shifted;
586 } else { 586 } else {
587 shifted = toupper( k ); 587 shifted = toupper( k );
588 } 588 }
589 s = QChar( shift^lock ? shifted : k ); 589 s = QChar( shift^lock ? shifted : k );
590#endif 590#endif
591 } 591 }
592 592
593 if (!blank) { 593 if (!blank) {
594 if ( pressed ) 594 if ( pressed )
595 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 );
596 else 596 else
597 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 );
598 598
599 if ( threeD ) { 599 if ( threeD ) {
600 p.setPen(pressed ? keycolor_lo : keycolor_hi); 600 p.setPen(pressed ? keycolor_lo : keycolor_hi);
601 p.drawLine( x, y+1, x, y+keyHeight-2 ); 601 p.drawLine( x, y+1, x, y+keyHeight-2 );
602 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); 602 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 );
603 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 );
604 } else if ( j == 0 ) { 604 } else if ( j == 0 ) {
605 p.setPen(pressed ? keycolor_hi : keycolor_lo); 605 p.setPen(pressed ? keycolor_hi : keycolor_lo);
606 p.drawLine( x, y, x+kw, y ); 606 p.drawLine( x, y, x+kw, y );
607 } 607 }
608 608
609 // right 609 // right
610 p.setPen(pressed ? keycolor_hi : keycolor_lo); 610 p.setPen(pressed ? keycolor_hi : keycolor_lo);
611 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 );
612 612
613 if ( threeD ) { 613 if ( threeD ) {
614 p.setPen(keycolor_lo.light()); 614 p.setPen(keycolor_lo.light());
615 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 );
616 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 );
617 } 617 }
618 618
619 if (xpm) { 619 if (xpm) {
620 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); 620 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) );
621 } else { 621 } else {
622 p.setPen(textcolor); 622 p.setPen(textcolor);
623 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); 623 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s );
624 } 624 }
625 625
626 if ( threeD ) { 626 if ( threeD ) {
627 p.setPen(keycolor_hi); 627 p.setPen(keycolor_hi);
628 p.drawLine( x, y, x+kw-1, y ); 628 p.drawLine( x, y, x+kw-1, y );
629 } 629 }
630 630
631 // bottom 631 // bottom
632 p.setPen(keycolor_lo); 632 p.setPen(keycolor_lo);
633 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 );
634 634
635 } else { 635 } else {
636 p.fillRect( x, y, kw, keyHeight, cg.background() ); 636 p.fillRect( x, y, kw, keyHeight, cg.background() );
637 } 637 }
638 } 638 }
639 639
640 x += kw; 640 x += kw;
641 kw = defaultKeyWidth; 641 kw = defaultKeyWidth;
642 k = getKey( kw ); 642 k = getKey( kw );
643 } 643 }
644 } 644 }
645} 645}
646 646
647 647
648void Keyboard::mousePressEvent(QMouseEvent *e) 648void Keyboard::mousePressEvent(QMouseEvent *e)
649{ 649{
650 clearHighlight(); // typing fast? 650 clearHighlight(); // typing fast?
651 651
652 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; 652 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth;
653 int j = (e->y() - picks->height()) / keyHeight; 653 int j = (e->y() - picks->height()) / keyHeight;
654 654
655 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) );
656 bool need_repaint = FALSE; 656 bool need_repaint = FALSE;
657 unicode = -1; 657 unicode = -1;
658 qkeycode = 0; 658 qkeycode = 0;
659 if ( k >= 0x80 ) { 659 if ( k >= 0x80 ) {
660 if ( k == ShiftCode ) { 660 if ( k == ShiftCode ) {
661 shift = !shift; 661 shift = !shift;
662 need_repaint = TRUE; 662 need_repaint = TRUE;
663 } else if ( k == AltCode ){ 663 } else if ( k == AltCode ){
664 alt = !alt; 664 alt = !alt;
665 need_repaint = TRUE; 665 need_repaint = TRUE;
666 } else if ( k == CapsCode ) { 666 } else if ( k == CapsCode ) {
667 lock = !lock; 667 lock = !lock;
668 need_repaint = TRUE; 668 need_repaint = TRUE;
669 } else if ( k == CtrlCode ) { 669 } else if ( k == CtrlCode ) {
670 ctrl = !ctrl; 670 ctrl = !ctrl;
671 need_repaint = TRUE; 671 need_repaint = TRUE;
672 } else if ( k == 0224 /* Expand */ ) { 672 } else if ( k == 0224 /* Expand */ ) {
673 useLargeKeys = !useLargeKeys; 673 useLargeKeys = !useLargeKeys;
674 resizeEvent(0); 674 resizeEvent(0);
675 repaint( TRUE ); // need it to clear first 675 repaint( TRUE ); // need it to clear first
676 } else if ( k == 0225 /* Opti/Toggle */ ) { 676 } else if ( k == 0225 /* Opti/Toggle */ ) {
677 useOptiKeys = !useOptiKeys; 677 useOptiKeys = !useOptiKeys;
678 resizeEvent(0); 678 resizeEvent(0);
679 repaint( TRUE ); // need it to clear first 679 repaint( TRUE ); // need it to clear first
680 } else { 680 } else {
681 qkeycode = specialM[ k - 0x80 ].qcode; 681 qkeycode = specialM[ k - 0x80 ].qcode;
682 unicode = specialM[ k - 0x80 ].unicode; 682 unicode = specialM[ k - 0x80 ].unicode;
683 } 683 }
684 } else { 684 } else {
685#if defined(Q_WS_QWS) || defined(_WS_QWS_) 685#if defined(Q_WS_QWS) || defined(_WS_QWS_)
686/* 686/*
687 qk = QWSServer::keyMap()[k].key_code; 687 qk = QWSServer::keyMap()[k].key_code;
688 if ( qk != Key_unknown ) { 688 if ( qk != Key_unknown ) {
689 if ( ctrl ) 689 if ( ctrl )
690 u = QWSServer::keyMap()[k].ctrl_unicode; 690 u = QWSServer::keyMap()[k].ctrl_unicode;
691 else if ( shift^lock ) 691 else if ( shift^lock )
692 u = QWSServer::keyMap()[k].shift_unicode; 692 u = QWSServer::keyMap()[k].shift_unicode;
693 else 693 else
694 u = QWSServer::keyMap()[k].unicode; 694 u = QWSServer::keyMap()[k].unicode;
695 } 695 }
696*/ 696*/
697 char shifted = k; 697 char shifted = k;
698 if ( !isalpha( k ) ) { 698 if ( !isalpha( k ) ) {
699 // ### Fixme, bad code, needs improving, whole thing needs to 699 // ### Fixme, bad code, needs improving, whole thing needs to
700 // 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
701 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 701 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
702 if ( shiftMap[i].normal == k ) 702 if ( shiftMap[i].normal == k )
703 shifted = shiftMap[i].shifted; 703 shifted = shiftMap[i].shifted;
704 } else { 704 } else {
705 shifted = toupper( k ); 705 shifted = toupper( k );
706 } 706 }
707 QChar tempChar( shift^lock ? shifted : k ); 707 QChar tempChar( shift^lock ? shifted : k );
708 unicode = tempChar.unicode(); 708 unicode = tempChar.unicode();
709#endif 709#endif
710 } 710 }
711 if ( unicode != -1 ) { 711 if ( unicode != -1 ) {
712 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | 712 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) |
713 (alt ? Qt::AltButton : 0); 713 (alt ? Qt::AltButton : 0);
714#if defined(Q_WS_QWS) || defined(_WS_QWS_) 714#if defined(Q_WS_QWS) || defined(_WS_QWS_)
715 emit key( unicode, qkeycode, modifiers, true, false ); 715 emit key( unicode, qkeycode, modifiers, true, false );
716 repeatTimer->start( 500 ); 716 repeatTimer->start( 500 );
717#endif 717#endif
718 need_repaint = shift || alt || ctrl; 718 need_repaint = shift || alt || ctrl;
719 shift = alt = ctrl = FALSE; 719 shift = alt = ctrl = FALSE;
720 //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 );
721 721
722 KeyboardConfig *dc = picks->dc; 722 KeyboardConfig *dc = picks->dc;
723 723
724 if (dc) { 724 if (dc) {
725 if (qkeycode == Qt::Key_Backspace) { 725 if (qkeycode == Qt::Key_Backspace) {
726 dc->input.remove(dc->input.last()); // remove last input 726 dc->input.remove(dc->input.last()); // remove last input
727 dc->decBackspaces(); 727 dc->decBackspaces();
728 } else if ( k == 0226 || qkeycode == Qt::Key_Return || 728 } else if ( k == 0226 || qkeycode == Qt::Key_Return ||
729 qkeycode == Qt::Key_Space || 729 qkeycode == Qt::Key_Space ||
730 QChar(unicode).isPunct() ) { 730 QChar(unicode).isPunct() ) {
731 dc->input.clear(); 731 dc->input.clear();
732 dc->resetBackspaces(); 732 dc->resetBackspaces();
733 } else { 733 } else {
734 dc->add(QString(QChar(unicode))); 734 dc->add(QString(QChar(unicode)));
735 dc->incBackspaces(); 735 dc->incBackspaces();
736 } 736 }
737 } 737 }
738 738
739 picks->repaint(); 739 picks->repaint();
740 740
741 } 741 }
742 pressedKey = k; 742 pressedKey = k;
743 if ( need_repaint ) { 743 if ( need_repaint ) {
744 repaint( FALSE ); 744 repaint( FALSE );
745 } else { 745 } else {
746 QPainter p(this); 746 QPainter p(this);
747 drawKeyboard( p, pressedKey ); 747 drawKeyboard( p, pressedKey );
748 } 748 }
749 pressTid = startTimer(80); 749 pressTid = startTimer(80);
750 pressed = TRUE; 750 pressed = TRUE;
751} 751}
752 752
753 753
754void Keyboard::mouseReleaseEvent(QMouseEvent*) 754void Keyboard::mouseReleaseEvent(QMouseEvent*)
755{ 755{
756 if ( pressTid == 0 ) 756 if ( pressTid == 0 )
757 clearHighlight(); 757 clearHighlight();
758#if defined(Q_WS_QWS) || defined(_WS_QWS_) 758#if defined(Q_WS_QWS) || defined(_WS_QWS_)
759 if ( unicode != -1 ) { 759 if ( unicode != -1 ) {
760 emit key( unicode, qkeycode, modifiers, false, false ); 760 emit key( unicode, qkeycode, modifiers, false, false );
761 repeatTimer->stop(); 761 repeatTimer->stop();
762 } 762 }
763#endif 763#endif
764 pressed = FALSE; 764 pressed = FALSE;
765} 765}
766 766
767void Keyboard::timerEvent(QTimerEvent* e) 767void Keyboard::timerEvent(QTimerEvent* e)
768{ 768{
769 if ( e->timerId() == pressTid ) { 769 if ( e->timerId() == pressTid ) {
770 killTimer(pressTid); 770 killTimer(pressTid);
771 pressTid = 0; 771 pressTid = 0;
772 if ( !pressed ) 772 if ( !pressed )
773 clearHighlight(); 773 clearHighlight();
774 } 774 }
775} 775}
776 776
777void Keyboard::repeat() 777void Keyboard::repeat()
778{ 778{
779 779
780 repeatTimer->start( 200 ); 780 repeatTimer->start( 200 );
781 emit key( unicode, qkeycode, modifiers, true, true ); 781 emit key( unicode, qkeycode, modifiers, true, true );
782} 782}
783 783
784void Keyboard::clearHighlight() 784void Keyboard::clearHighlight()
785{ 785{
786 if ( pressedKey >= 0 ) { 786 if ( pressedKey >= 0 ) {
787 int tmp = pressedKey; 787 int tmp = pressedKey;
788 pressedKey = -1; 788 pressedKey = -1;
789 QPainter p(this); 789 QPainter p(this);
790 drawKeyboard( p, tmp ); 790 drawKeyboard( p, tmp );
791 } 791 }
792} 792}
793 793
794 794
795QSize Keyboard::sizeHint() const 795QSize Keyboard::sizeHint() const
796{ 796{
797 QFontMetrics fm=fontMetrics(); 797 QFontMetrics fm=fontMetrics();
798 int keyHeight = fm.lineSpacing()+2; 798 int keyHeight = fm.lineSpacing()+2;
799 799
800 if (useOptiKeys) 800 if (useOptiKeys)
801 keyHeight += 1; 801 keyHeight += 1;
802 802
803 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); 803 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 );
804} 804}
805 805
806 806
807void Keyboard::resetState() 807void Keyboard::resetState()
808{ 808{
809 picks->resetState(); 809 picks->resetState();
810} 810}