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,288 +1,289 @@
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..",
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