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