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