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