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