summaryrefslogtreecommitdiff
path: root/inputmethods/pickboard
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /inputmethods/pickboard
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'inputmethods/pickboard') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/pickboard/.cvsignore3
-rw-r--r--inputmethods/pickboard/Makefile.in147
-rw-r--r--inputmethods/pickboard/pickboard.cpp89
-rw-r--r--inputmethods/pickboard/pickboard.h43
-rw-r--r--inputmethods/pickboard/pickboard.pro12
-rw-r--r--inputmethods/pickboard/pickboardcfg.cpp731
-rw-r--r--inputmethods/pickboard/pickboardcfg.h213
-rw-r--r--inputmethods/pickboard/pickboardimpl.cpp101
-rw-r--r--inputmethods/pickboard/pickboardimpl.h51
-rw-r--r--inputmethods/pickboard/pickboardpicks.cpp418
-rw-r--r--inputmethods/pickboard/pickboardpicks.h66
-rw-r--r--inputmethods/pickboard/qpe-pickboard.control9
-rwxr-xr-xinputmethods/pickboard/qpe-pickboard.postinst2
-rwxr-xr-xinputmethods/pickboard/qpe-pickboard.postrm2
14 files changed, 1887 insertions, 0 deletions
diff --git a/inputmethods/pickboard/.cvsignore b/inputmethods/pickboard/.cvsignore
new file mode 100644
index 0000000..edfa921
--- a/dev/null
+++ b/inputmethods/pickboard/.cvsignore
@@ -0,0 +1,3 @@
1moc_*
2*.moc
3Makefile
diff --git a/inputmethods/pickboard/Makefile.in b/inputmethods/pickboard/Makefile.in
new file mode 100644
index 0000000..d72e82d
--- a/dev/null
+++ b/inputmethods/pickboard/Makefile.in
@@ -0,0 +1,147 @@
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
17DESTDIR = ../../plugins/inputmethods/
18VER_MAJ = 1
19VER_MIN = 0
20VER_PATCH = 0
21 TARGET= qpickboard
22TARGET1 = lib$(TARGET).so.$(VER_MAJ)
23
24####### Files
25
26 HEADERS =pickboard.h \
27 pickboardcfg.h \
28 pickboardimpl.h \
29 pickboardpicks.h
30 SOURCES =pickboard.cpp \
31 pickboardcfg.cpp \
32 pickboardimpl.cpp \
33 pickboardpicks.cpp
34 OBJECTS =pickboard.o \
35 pickboardcfg.o \
36 pickboardimpl.o \
37 pickboardpicks.o
38INTERFACES =
39UICDECLS =
40UICIMPLS =
41 SRCMOC =moc_pickboard.cpp \
42 moc_pickboardcfg.cpp \
43 moc_pickboardpicks.cpp
44 OBJMOC =moc_pickboard.o \
45 moc_pickboardcfg.o \
46 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
71all: $(DESTDIR)$(SYSCONF_LINK_TARGET)
72
73$(DESTDIR)$(SYSCONF_LINK_TARGET): $(UICDECLS) $(OBJECTS) $(OBJMOC) $(SUBLIBS)
74 $(SYSCONF_LINK_LIB)
75
76moc: $(SRCMOC)
77
78tmake:
79 tmake pickboard.pro
80
81clean:
82 -rm -f $(OBJECTS) $(OBJMOC) $(SRCMOC) $(UICIMPLS) $(UICDECLS)
83 -rm -f *~ core
84 -rm -f allmoc.cpp
85
86####### Extension Modules
87
88listpromodules:
89 @echo
90
91listallmodules:
92 @echo
93
94listaddonpromodules:
95 @echo
96
97listaddonentmodules:
98 @echo
99
100
101REQUIRES=
102
103####### Sub-libraries
104
105
106###### Combined headers
107
108
109
110####### Compile
111
112pickboard.o: pickboard.cpp \
113 pickboard.h \
114 pickboardpicks.h \
115 pickboardcfg.h
116
117pickboardcfg.o: pickboardcfg.cpp \
118 pickboardcfg.h \
119 pickboardpicks.h
120
121pickboardimpl.o: pickboardimpl.cpp \
122 pickboard.h \
123 pickboardimpl.h
124
125pickboardpicks.o: pickboardpicks.cpp \
126 pickboardpicks.h \
127 pickboardcfg.h
128
129moc_pickboard.o: moc_pickboard.cpp \
130 pickboard.h
131
132moc_pickboardcfg.o: moc_pickboardcfg.cpp \
133 pickboardcfg.h
134
135moc_pickboardpicks.o: moc_pickboardpicks.cpp \
136 pickboardpicks.h
137
138moc_pickboard.cpp: pickboard.h
139 $(MOC) pickboard.h -o moc_pickboard.cpp
140
141moc_pickboardcfg.cpp: pickboardcfg.h
142 $(MOC) pickboardcfg.h -o moc_pickboardcfg.cpp
143
144moc_pickboardpicks.cpp: pickboardpicks.h
145 $(MOC) pickboardpicks.h -o moc_pickboardpicks.cpp
146
147
diff --git a/inputmethods/pickboard/pickboard.cpp b/inputmethods/pickboard/pickboard.cpp
new file mode 100644
index 0000000..087144e
--- a/dev/null
+++ b/inputmethods/pickboard/pickboard.cpp
@@ -0,0 +1,89 @@
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 "pickboard.h"
21#include "pickboardpicks.h"
22#include "pickboardcfg.h"
23
24#include <qpe/global.h>
25
26#include <qpainter.h>
27#include <qlist.h>
28#include <qbitmap.h>
29#include <qlayout.h>
30#include <qvbox.h>
31#include <qdialog.h>
32#include <qscrollview.h>
33#include <qpopupmenu.h>
34#include <qhbuttongroup.h>
35#include <qpushbutton.h>
36#include <qmessagebox.h>
37#include <qwindowsystem_qws.h>
38
39/* XPM */
40static const char * const menu_xpm[]={
41"9 9 2 1",
42"a c #000000",
43". c None",
44".........",
45".........",
46".........",
47"....a....",
48"...aaa...",
49"..aaaaa..",
50".aaaaaaa.",
51".........",
52"........."};
53
54class PickboardPrivate {
55public:
56 PickboardPrivate(Pickboard* parent)
57 {
58 picks = new PickboardPicks(parent);
59 picks->initialise();
60 menu = new QPushButton(parent);
61 menu->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding));
62 menu->setPixmap(QPixmap((const char **)menu_xpm));
63 QObject::connect(menu,SIGNAL(clicked()),picks,SLOT(doMenu()));
64 QObject::connect(picks,SIGNAL(key(ushort,ushort,ushort,bool,bool)),
65 parent,SIGNAL(key(ushort,ushort,ushort,bool,bool)));
66 }
67
68 PickboardPicks* picks;
69 QPushButton* menu;
70};
71
72Pickboard::Pickboard(QWidget* parent, const char* name, WFlags f) :
73 QFrame(parent,name,f)
74{
75 (new QHBoxLayout(this))->setAutoAdd(TRUE);
76 d = new PickboardPrivate(this);
77 setFont( QFont( "smallsmooth", 9 ) );
78}
79
80Pickboard::~Pickboard()
81{
82 delete d;
83}
84
85void Pickboard::resetState()
86{
87 d->picks->resetState();
88}
89
diff --git a/inputmethods/pickboard/pickboard.h b/inputmethods/pickboard/pickboard.h
new file mode 100644
index 0000000..5fff875
--- a/dev/null
+++ b/inputmethods/pickboard/pickboard.h
@@ -0,0 +1,43 @@
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 PICKBOARD_H
21#define PICKBOARD_H
22
23#include <qframe.h>
24
25class PickboardPrivate;
26
27class Pickboard : public QFrame
28{
29 Q_OBJECT
30public:
31 Pickboard(QWidget* parent=0, const char* name=0, WFlags f=0);
32 ~Pickboard();
33
34 void resetState();
35
36signals:
37 void key( ushort, ushort, ushort, bool, bool );
38
39private:
40 PickboardPrivate* d;
41};
42
43#endif
diff --git a/inputmethods/pickboard/pickboard.pro b/inputmethods/pickboard/pickboard.pro
new file mode 100644
index 0000000..50bc342
--- a/dev/null
+++ b/inputmethods/pickboard/pickboard.pro
@@ -0,0 +1,12 @@
1 TEMPLATE= lib
2 CONFIG += qt warn_on release
3 HEADERS= pickboard.h pickboardcfg.h pickboardimpl.h pickboardpicks.h
4 SOURCES= pickboard.cpp pickboardcfg.cpp pickboardimpl.cpp pickboardpicks.cpp
5 TARGET = qpickboard
6 DESTDIR = ../../plugins/inputmethods
7INCLUDEPATH += $(QPEDIR)/include
8DEPENDPATH += ../$(QPEDIR)/include ../../taskbar
9LIBS += -lqpe
10 VERSION = 1.0.0
11
12TRANSLATIONS += ../../i18n/de/libqpickboard.ts
diff --git a/inputmethods/pickboard/pickboardcfg.cpp b/inputmethods/pickboard/pickboardcfg.cpp
new file mode 100644
index 0000000..e8b47cb
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardcfg.cpp
@@ -0,0 +1,731 @@
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 "pickboardcfg.h"
22#include "pickboardpicks.h"
23
24#include <qpe/global.h>
25
26#include <qpainter.h>
27#include <qlist.h>
28#include <qbitmap.h>
29#include <qlayout.h>
30#include <qvbox.h>
31#include <qdialog.h>
32#include <qscrollview.h>
33#include <qpopupmenu.h>
34#include <qhbuttongroup.h>
35#include <qpushbutton.h>
36#include <qmessagebox.h>
37#include <qwindowsystem_qws.h>
38
39static const char * pickboard_help =
40 "<h1>The Pickboard</h1>"
41 "<i>The smallest and fastest way to type.</i>"
42 "<p>"
43 "Enter a word by tapping letter-groups and picking the word."
44 "<br>Enter spaces with \"Space\", or other keys through \"KEY\"."
45 "<br>Use \"Shift\" to capitalize words that are not normally capitalized."
46 "<br>Press \"Shift\" twice for an all-capitals word."
47 "<br>Add custom words by picking them, then selecting \"Add...\" from the menu on the right."
48 ;
49
50const int intermatchmargin=5;
51
52
53PickboardConfig::~PickboardConfig() { }
54
55void PickboardConfig::updateRows(int from, int to)
56{
57 if ( from != to ) { // (all)
58 parent->update();
59 } else {
60 QFontMetrics fm = parent->fontMetrics();
61 parent->update(QRect(0,1+fm.descent() + from * fm.lineSpacing(), parent->width(),
62 fm.lineSpacing()));
63 }
64}
65
66void PickboardConfig::updateItem(int r, int)
67{
68 updateRows(r,r);
69}
70
71void PickboardConfig::changeMode(int m)
72{
73 parent->setMode(m);
74}
75void PickboardConfig::generateText(const QString& s)
76{
77#if defined(Q_WS_QWS) || defined(_WS_QWS_)
78 for (int i=0; i<(int)s.length(); i++) {
79 parent->emitKey(s[i].unicode(), 0, 0, true, false);
80 parent->emitKey(s[i].unicode(), 0, 0, false, false);
81 }
82#endif
83}
84void PickboardConfig::generateKey( int k )
85{
86#if defined(Q_WS_QWS) || defined(_WS_QWS_)
87 parent->emitKey(0, k, 0, true, false);
88 parent->emitKey(0, k, 0, false, false);
89#endif
90}
91
92void PickboardConfig::pickPoint(const QPoint& p, bool press)
93{
94 if ( press ) {
95 int ls=parent->height()/nrows;
96 int y=0;
97 pressx = -1;
98 for (int r=0; r<nrows; r++) {
99 if ( p.y() >= y && p.y() < y+ls ) {
100 pressrow = r;
101 pressx = p.x();
102 pickInRow( pressrow, pressx, TRUE );
103 return;
104 }
105 y += ls;
106 }
107 } else if ( pressx >= 0 ) {
108 pickInRow( pressrow, pressx, FALSE );
109 pressx = -1;
110 }
111}
112
113void PickboardConfig::fillMenu(QPopupMenu& menu)
114{
115 menu.insertItem("Reset",100);
116 menu.insertSeparator();
117 menu.insertItem("Help",1);
118}
119
120void PickboardConfig::doMenu(int i)
121{
122 switch (i) {
123 case 100:
124 if ( parent->currentMode() ) {
125 changeMode(0);
126 updateRows(0,1);
127 }
128 break;
129 case 1: {
130 QMessageBox help("Pickboard Help", pickboard_help,
131 QMessageBox::NoIcon, 1, 0, 0);
132 help.showMaximized();
133 help.exec();
134 }
135 }
136}
137
138void StringConfig::draw(QPainter* p)
139{
140 QFontMetrics fm = p->fontMetrics();
141
142 for (int r=0; r<nrows; r++) {
143 p->translate(0,fm.lineSpacing());
144 p->setPen(rowColor(r));
145
146 int tw=0;
147 QString s;
148 int i=0;
149 for (; !(s=text(r,i)).isNull(); ++i) {
150 int w = fm.width(s);
151 tw += w;
152 }
153 bool spread = spreadRow(r);// && parent->width() > tw;
154 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
155 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
156
157 i=0;
158 for (; !(s=text(r,i)).isNull(); ++i) {
159 int w = fm.width(s)+xw;
160 if ( highlight(r,i) ) {
161 p->fillRect(x-xw/2,1+fm.descent()-fm.lineSpacing(),w,fm.lineSpacing(),Qt::black);
162 p->setPen(Qt::white);
163 }else{
164 p->setPen(Qt::black);
165 }
166 p->drawText(x,-fm.descent()-1,s);
167 x += w;
168 }
169 }
170}
171
172void StringConfig::pickInRow(int r, int xpos, bool press)
173{
174 QFontMetrics fm = parent->fontMetrics();
175
176 int tw=0;
177 QString s;
178 int i=0;
179 for (; !(s=text(r,i)).isNull(); ++i) {
180 int w = fm.width(s);
181 tw += w;
182 }
183 bool spread = spreadRow(r) && parent->width() > tw;
184 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
185 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
186
187 i=0;
188 for (; !(s=text(r,i)).isNull(); ++i) {
189 int x2 = x + fm.width(s)+xw;
190 if ( xpos >= x && xpos < x2 ) {
191 pick(press, r, i);
192 return;
193 }
194 x = x2;
195 }
196}
197
198void StringConfig::updateItem(int r, int item)
199{
200 QFontMetrics fm = parent->fontMetrics();
201
202 int y = r * fm.lineSpacing();
203
204 int tw=0;
205 QString s;
206 int i=0;
207 for (; !(s=text(r,i)).isNull(); ++i) {
208 int w = fm.width(s);
209 tw += w;
210 }
211 bool spread = spreadRow(r) && parent->width() > tw;
212 int xw = spread ? (parent->width()-tw)/(i-1) : 3;
213 int x = spread ? (parent->width()-tw-xw*(i-1))/2 : 2;
214
215 i=0;
216 for (; !(s=text(r,i)).isNull(); ++i) {
217 int w = fm.width(s)+xw;
218 if ( i == item ) {
219 parent->update(QRect(x-xw/2,y+1+fm.descent(),w,fm.lineSpacing()));
220 return;
221 }
222 x += w;
223 }
224}
225
226bool StringConfig::highlight(int,int) const
227{
228 return FALSE;
229}
230
231LetterButton::LetterButton(const QChar& letter, QWidget* parent) :
232 QPushButton(letter,parent)
233{
234 setToggleButton(TRUE);
235 setAutoDefault(FALSE);
236 connect(this,SIGNAL(clicked()),this,SLOT(toggleCase()));
237 skip=TRUE;
238}
239
240void LetterButton::toggleCase()
241{
242 if ( skip ) {
243 // Don't toggle case the first time
244 skip=FALSE;
245 return;
246 }
247
248 QChar ch = text()[0];
249 QChar nch = ch.lower();
250 if ( ch == nch )
251 nch = ch.upper();
252 setText(nch);
253}
254
255LetterChoice::LetterChoice(QWidget* parent, const QString& set) :
256 QButtonGroup(parent)
257{
258 QHBoxLayout *l = new QHBoxLayout(this);
259 setFrameStyle(0);
260 setExclusive(TRUE);
261 for (int i=0; i<(int)set.length(); i++) {
262 LetterButton* b = new LetterButton(set[i],this);
263 l->addWidget(b,1,AlignCenter);
264 connect(b,SIGNAL(clicked()),this,SLOT(change()));
265 }
266}
267
268void LetterChoice::change()
269{
270 LetterButton* b = (LetterButton*)sender();
271 ch = b->text()[0];
272 emit changed();
273}
274
275
276PickboardAdd::PickboardAdd(QWidget* owner, const QStringList& setlist) :
277 QDialog( owner, 0, TRUE )
278{
279 QVBoxLayout* l = new QVBoxLayout(this);
280 l->setAutoAdd(TRUE);
281
282 QScrollView *sv = new QScrollView(this);
283 sv->setResizePolicy(QScrollView::AutoOneFit);
284 setMaximumHeight(200); // ### QDialog shouldn't allow us to be bigger than the screen
285 QVBox *letters = new QVBox(sv);
286 letters->setSpacing(0);
287 lc = new LetterChoice*[setlist.count()];
288 nlc = (int)setlist.count();
289 for (int i=0; i<nlc; i++) {
290 lc[i] = new LetterChoice(letters,setlist[i]);
291 connect(lc[i],SIGNAL(changed()),this,SLOT(checkAllDone()));
292 }
293 sv->addChild(letters);
294 QHBox* hb = new QHBox(this);
295 hb->setSpacing(0);
296 yes = new QPushButton("OK",hb);
297 yes->setEnabled(FALSE);
298 QPushButton *no = new QPushButton("Cancel",hb);
299 connect(yes, SIGNAL(clicked()), this, SLOT(accept()));
300 connect(no, SIGNAL(clicked()), this, SLOT(reject()));
301}
302
303PickboardAdd::~PickboardAdd()
304{
305 delete [] lc;
306}
307
308QString PickboardAdd::word() const
309{
310 QString str;
311 for (int i=0; i<nlc; i++) {
312 str += lc[i]->choice();
313 }
314 return str;
315}
316
317bool PickboardAdd::exec()
318{
319 QPoint pos = parentWidget()->mapToGlobal(QPoint(0,0));
320 pos.ry() -= height();
321 if ( QDialog::exec() ) {
322 Global::addWords(QStringList(word()));
323 return TRUE;
324 } else {
325 return FALSE;
326 }
327}
328
329void PickboardAdd::checkAllDone()
330{
331 if ( !yes->isEnabled() ) {
332 for (int i=0; i<nlc; i++) {
333 if ( lc[i]->choice().isNull() )
334 return;
335 }
336 yes->setEnabled(TRUE);
337 }
338}
339
340
341void DictFilterConfig::doMenu(int i)
342{
343 switch (i) {
344 case 300:
345 if ( input.count() == 0 ) {
346 QMessageBox::information(0, "Adding Words",
347 "To add words, pick the letters,\nthen "
348 "open the Add dialog. In that\ndialog, tap "
349 "the correct letters\nfrom the list "
350 "(tap twice for\ncapitals).");
351 } else {
352 PickboardAdd add(parent,capitalize(input));
353 if ( add.exec() )
354 generateText(add.word());
355 input.clear();
356 matches.clear();
357 updateRows(0,0);
358 }
359 break;
360 case 100:
361 if ( !input.isEmpty() ) {
362 input.clear();
363 matches.clear();
364 StringConfig::doMenu(i);
365 updateRows(0,1);
366 break;
367 } // else fall through
368 default:
369 StringConfig::doMenu(i);
370 }
371 shift = 0;
372 lit0 = -1;
373}
374
375QString DictFilterConfig::text(int r, int i)
376{
377 QStringList l = r ? sets : input.isEmpty() ? othermodes : matches;
378 return i < (int)l.count() ?
379 (input.isEmpty() ? l[i] : capitalize(l[i]))
380 : QString::null;
381}
382
383bool DictFilterConfig::spreadRow(int r)
384{
385 return r ? TRUE : input.isEmpty() ? TRUE : FALSE;
386}
387
388QStringList DictFilterConfig::capitalize(const QStringList& l)
389{
390 switch ( shift ) {
391 case 1: {
392 QStringList r;
393 QStringList::ConstIterator it = l.begin();
394 r.append((*it).upper());
395 for (++it; it != l.end(); ++it)
396 r.append(*it);
397 return r;
398 } case 2: {
399 QStringList r;
400 for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it)
401 r.append((*it).upper());
402 return r;
403 }
404 }
405 return l;
406}
407
408QString DictFilterConfig::capitalize(const QString& s)
409{
410 switch ( shift ) {
411 case 1: {
412 QString u = s;
413 u[0] = u[0].upper();
414 return u;
415 break;
416 } case 2:
417 return s.upper();
418 break;
419 }
420 return s;
421}
422
423void DictFilterConfig::pick(bool press, int row, int item)
424{
425 if ( row == 0 ) {
426 if ( press ) {
427 if ( input.isEmpty() ) {
428 lit0 = item;
429 if ( othermodes[item] == "Space" ) {
430 updateItem(row,item);
431 generateText(" ");
432 } else if ( othermodes[item] == "Back" ) {
433 updateItem(row,item);
434 generateKey(Qt::Key_Backspace);
435 } else if ( othermodes[item] == "Enter" ) {
436 updateItem(row,item);
437 generateKey(Qt::Key_Return);
438 } else if ( othermodes[item] == "Shift" ) {
439 updateItem(row,item);
440 shift = (shift+1)%3;
441 }
442 }
443 } else {
444 if ( !input.isEmpty() ) {
445 input.clear();
446 if ( item>=0 ) {
447 generateText(capitalize(matches[item]));
448 }
449 shift = 0;
450 matches.clear();
451 updateRows(0,0);
452 } else if ( item < 3 ) {
453 lit0 = -1;
454 changeMode(item+1); // I'm mode 0! ####
455 updateRows(0,1);
456 }
457 if ( lit0 >= 0 ) {
458 if ( !shift || othermodes[lit0] != "Shift" ) {
459 updateItem(0,lit0);
460 lit0 = -1;
461 }
462 }
463 }
464 } else {
465 lit0 = -1;
466 if ( press && item >= 0 ) {
467 lit1 = item;
468 add(sets[item]);
469 updateItem(1,item);
470 updateRows(0,0);
471 } else {
472 updateItem(1,lit1);
473 lit1 = -1;
474 }
475 }
476}
477
478bool DictFilterConfig::scanMatch(const QString& set, const QChar& l) const
479{
480 return set == "?" || set == "*" || set.contains(l);
481}
482
483//static int visit=0;
484//static int lvisit=0;
485
486void DictFilterConfig::scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend)
487{
488 if ( n ) {
489 do {
490//visit++;
491 bool pastend = ipos >= (int)input.count();
492 if ( pastend && extend || !pastend && scanMatch(input[ipos],n->letter().lower()) ) {
493 if ( length>1 ) {
494 if ( !pastend && input[ipos] == "*" ) {
495 scan(n->jump(),ipos+1,str+n->letter(),length-1,FALSE);
496 scan(n->jump(),ipos,str+n->letter(),length,FALSE);
497 } else {
498 scan(n->jump(),ipos+1,str+n->letter(),length-1,extend);
499 }
500 } else {
501 if ( n->isWord() ) {
502 matches.append(str+n->letter());
503 }
504 }
505 }
506 n = n->next();
507 } while (n);
508 }
509}
510
511void DictFilterConfig::scanLengths(const QDawg::Node* n, int ipos, int& length_bitarray)
512{
513 if ( n ) {
514 do {
515//lvisit++;
516 bool pastend = ipos >= (int)input.count();
517 if ( pastend || scanMatch(input[ipos],n->letter().lower()) ) {
518 scanLengths(n->jump(),ipos+1,length_bitarray);
519 if ( n->isWord() )
520 length_bitarray |= (1<<(ipos+1));
521 }
522 n = n->next();
523 } while (n);
524 }
525}
526
527void DictFilterConfig::add(const QString& set)
528{
529 QFontMetrics fm = parent->fontMetrics();
530 input.append(set.lower());
531 matches.clear();
532//visit=0;
533//lvisit=0;
534 int length_bitarray = 0;
535 if ( input.count() > 4 ) {
536 scanLengths(Global::addedDawg().root(),0,length_bitarray);
537 scanLengths(Global::fixedDawg().root(),0,length_bitarray);
538 } else {
539 length_bitarray = 0xffffffff;
540 }
541 for (int len=input.count(); len<22 /* 32 */; ++len) {
542 if ( length_bitarray & (1<<len) ) {
543 scan(Global::addedDawg().root(),0,"",len,TRUE);
544 scan(Global::fixedDawg().root(),0,"",len,TRUE);
545 int x = 2;
546 for (QStringList::Iterator it=matches.begin(); it!=matches.end(); ++it) {
547 x += fm.width(*it)+intermatchmargin;
548 if ( x >= parent->width() ) {
549//qDebug("%d+%d visits",lvisit,visit);
550 return; // RETURN - No point finding more
551 }
552 }
553 }
554 if ( len == 1 && input.count() == 1 ) {
555 // Allow all single-characters to show as "matches"
556 for ( int i=0; i<(int)set.length(); i++ ) {
557 QChar ch = set[i].lower();
558 matches.append(ch);
559 }
560 }
561 }
562//qDebug("%d+%d visits",lvisit,visit);
563}
564
565bool DictFilterConfig::highlight(int r,int c) const
566{
567 return r == 0 ? c == lit0 : c == lit1;
568}
569
570
571void DictFilterConfig::addSet(const QString& s)
572{
573 sets.append(s);
574}
575
576void DictFilterConfig::addMode(const QString& s)
577{
578 othermodes.append(s);
579}
580
581void DictFilterConfig::fillMenu(QPopupMenu& menu)
582{
583 menu.insertItem("Add...",300);
584 StringConfig::fillMenu(menu);
585}
586
587QValueList<QPixmap> KeycodeConfig::row(int i)
588{
589 return i ? keypm2 : keypm1;
590}
591
592void KeycodeConfig::pickInRow(int r, int xpos, bool press)
593{
594 QValueList<QPixmap> pl = row(r);
595 QValueList<QPixmap>::Iterator it;
596 int item=0;
597 int x=xmarg;
598 for (it=pl.begin(); it!=pl.end(); ++it) {
599 int x2 = x + (*it).width();
600 if ( (*it).height() > 1 )
601 x2 += xw;
602 if ( xpos >= x && xpos < x2 ) {
603 pick(press, r, item);
604 return;
605 }
606 x = x2;
607 item++;
608 }
609}
610
611void KeycodeConfig::pick(bool press, int row, int item)
612{
613 if ( !press ) {
614 if ( item >= 0 ) {
615 int k = row == 0 ? keys1[item] : keys2[item];
616 if ( k )
617 generateKey(k);
618 }
619 changeMode(0);
620 updateRows(0,1);
621 }
622}
623
624void KeycodeConfig::draw(QPainter* p)
625{
626 int y=3;
627 QValueList<QPixmap>::Iterator it;
628 for (int r=0; r<nrows; r++) {
629 QValueList<QPixmap> pl = row(r);
630 int x = xmarg;
631 for (it=pl.begin(); it!=pl.end(); ++it) {
632 if ( (*it).height() == 1 ) {
633 // just a gap
634 x += (*it).width();
635 } else {
636 p->drawPixmap(x,y,*it);
637 x += (*it).width()+xw;
638 }
639 }
640 y += parent->height()/nrows;
641 }
642}
643
644
645void KeycodeConfig::addKey(int r, const QPixmap& pm, int code)
646{
647 if ( r == 0 ) {
648 keypm1.append(pm);
649 keys1.append(code);
650 } else {
651 keypm2.append(pm);
652 keys2.append(code);
653 }
654}
655void KeycodeConfig::addGap(int r, int w)
656{
657 QBitmap pm(w,1); // ick.
658 addKey(r,pm,0);
659}
660
661QString CharConfig::text(int r, int i)
662{
663 QStringList l = r ? chars2 : chars1;
664 return i < (int)l.count() ? l[i] : QString::null;
665}
666bool CharConfig::spreadRow(int)
667{
668 return TRUE;
669}
670
671void CharConfig::pick(bool press, int row, int item)
672{
673 if ( !press ) {
674 if ( item >= 0 ) {
675 generateText(row == 0 ? chars1[item] : chars2[item]);
676 }
677 changeMode(0);
678 updateRows(0,1);
679 }
680}
681
682void CharConfig::addChar(int r, const QString& s)
683{
684 if ( r ) chars2.append(s); else chars1.append(s);
685}
686
687QString CharStringConfig::text(int r, int i)
688{
689 QStringList l = r ? chars : QStringList(input);
690 return i < (int)l.count() ? l[i] : QString::null;
691}
692
693bool CharStringConfig::spreadRow(int i)
694{
695 return i ? TRUE : FALSE;
696}
697
698void CharStringConfig::pick(bool press, int row, int item)
699{
700 if ( row == 0 ) {
701 if ( !press ) {
702 if ( item>=0 ) {
703 generateText(input);
704 }
705 input = "";
706 changeMode(0);
707 updateRows(0,1);
708 }
709 } else {
710 if ( press && item >= 0 ) {
711 input.append(chars[item]);
712 updateRows(0,0);
713 }
714 }
715}
716
717void CharStringConfig::addChar(const QString& s)
718{
719 chars.append(s);
720}
721
722void CharStringConfig::doMenu(int i)
723{
724 if ( i == 100 ) {
725 input = "";
726 updateRows(0,0);
727 }
728
729 StringConfig::doMenu(i);
730}
731
diff --git a/inputmethods/pickboard/pickboardcfg.h b/inputmethods/pickboard/pickboardcfg.h
new file mode 100644
index 0000000..e0dc0dd
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardcfg.h
@@ -0,0 +1,213 @@
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 PICKBOARDCFG_H
21#define PICKBOARDCFG_H
22
23#include <qpe/qdawg.h>
24
25#include <qpushbutton.h>
26#include <qhbuttongroup.h>
27#include <qdialog.h>
28#include <qlist.h>
29
30// Internal stuff...
31
32class PickboardPicks;
33
34class LetterButton : public QPushButton {
35 Q_OBJECT
36public:
37 LetterButton(const QChar& letter, QWidget* parent);
38private slots:
39 void toggleCase();
40private:
41 bool skip;
42};
43
44class LetterChoice : public QButtonGroup {
45 Q_OBJECT
46public:
47 LetterChoice(QWidget* parent, const QString& set);
48
49 QChar choice() { return ch; }
50
51signals:
52 void changed();
53
54private slots:
55 void change();
56
57private:
58 QChar ch;
59};
60
61class PickboardAdd : public QDialog {
62 Q_OBJECT
63public:
64 PickboardAdd(QWidget* owner, const QStringList& setlist);
65 ~PickboardAdd();
66
67 QString word() const;
68 bool exec();
69
70private slots:
71 void checkAllDone();
72
73private:
74 QPushButton *yes;
75 LetterChoice **lc;
76 int nlc;
77};
78
79class PickboardConfig : QObject {
80public:
81 PickboardConfig(PickboardPicks* p) : parent(p), nrows(2), pressx(-1) { }
82 virtual ~PickboardConfig();
83 virtual void pickPoint(const QPoint& p, bool press);
84 virtual void draw(QPainter*)=0;
85 virtual void fillMenu(QPopupMenu&);
86 virtual void doMenu(int);
87
88protected:
89 void updateRows(int from, int to);
90 virtual void updateItem(int r, int i);
91 virtual void pickInRow(int r, int xpos, bool press)=0;
92
93 void changeMode(int m);
94 virtual void generateText(const QString& s);
95 void generateKey( int k );
96
97 virtual void pick(bool press, int row, int item)=0;
98
99protected:
100 PickboardPicks* parent;
101 int nrows;
102private:
103 int pressrow, pressx;
104};
105
106class StringConfig : public PickboardConfig {
107public:
108 StringConfig(PickboardPicks* p) : PickboardConfig(p) { }
109
110 void draw(QPainter* p);
111
112protected:
113 virtual QString text(int r, int i)=0;
114 virtual bool spreadRow(int i)=0;
115 virtual QColor rowColor(int) { return Qt::black; }
116 virtual void pickInRow(int r, int xpos, bool press);
117 virtual void updateItem(int r, int i);
118 virtual bool highlight(int,int) const;
119};
120
121class CharStringConfig : public StringConfig {
122 QString input;
123 QStringList chars;
124public:
125 CharStringConfig(PickboardPicks* p) : StringConfig(p) { }
126
127 void addChar(const QString& s);
128 virtual void doMenu(int);
129
130protected:
131 QString text(int r, int i);
132 bool spreadRow(int i);
133 void pick(bool press, int row, int item);
134};
135
136class DictFilterConfig : public StringConfig {
137 QStringList matches;
138 QStringList sets;
139 QStringList othermodes;
140 int lit0;
141 int lit1;
142 int shift;
143 QString capitalize(const QString& s);
144 QStringList capitalize(const QStringList& s);
145
146public:
147 QStringList input;
148 DictFilterConfig(PickboardPicks* p) : StringConfig(p)
149 {
150 shift = 0;
151 lit0 = -1;
152 lit1 = -1;
153 }
154
155 void addSet(const QString& s);
156 void addMode(const QString& s);
157
158 void fillMenu(QPopupMenu& menu);
159 void doMenu(int i);
160
161 void add(const QString& set);
162
163protected:
164 QString text(int r, int i);
165
166 bool spreadRow(int i);
167
168 void pick(bool press, int row, int item);
169
170 bool scanMatch(const QString& set, const QChar& l) const;
171 void scan(const QDawg::Node* n, int ipos, const QString& str, int length, bool extend);
172 void scanLengths(const QDawg::Node* n, int ipos, int& bitarray);
173
174 bool highlight(int r,int c) const;
175};
176
177class CharConfig : public StringConfig {
178 QStringList chars1;
179 QStringList chars2;
180public:
181 CharConfig(PickboardPicks* p) : StringConfig(p) { }
182 void addChar(int r, const QString& s);
183
184protected:
185 QString text(int r, int i);
186 bool spreadRow(int);
187 void pick(bool press, int row, int item);
188};
189
190class KeycodeConfig : public PickboardConfig {
191 QValueList<int> keys1;
192 QValueList<int> keys2;
193 QValueList<QPixmap> keypm1;
194 QValueList<QPixmap> keypm2;
195 static const int xw = 8;
196 static const int xmarg = 8;
197
198public:
199 KeycodeConfig(PickboardPicks* p) : PickboardConfig(p) { }
200 void addKey(int r, const QPixmap& pm, int code);
201 void addGap(int r, int w);
202
203 void draw(QPainter* p);
204
205protected:
206 void pickInRow(int r, int xpos, bool press);
207 QValueList<QPixmap> row(int i);
208
209 void pick(bool press, int row, int item);
210};
211
212
213#endif
diff --git a/inputmethods/pickboard/pickboardimpl.cpp b/inputmethods/pickboard/pickboardimpl.cpp
new file mode 100644
index 0000000..a4e8f02
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardimpl.cpp
@@ -0,0 +1,101 @@
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 <qobject.h>
22#include <qpixmap.h>
23#include "pickboard.h"
24#include "pickboardimpl.h"
25
26/* XPM */
27static const char * pb_xpm[]={
28"28 7 2 1",
29"# c #303030",
30" c None",
31" ########################## ",
32" # # # # # # # ",
33" # # # # # # # ",
34" ########################## ",
35" # # # # # # ",
36" # # # # # # ",
37" ########################## "};
38
39
40PickboardImpl::PickboardImpl()
41 : pickboard(0), icn(0), ref(0)
42{
43}
44
45PickboardImpl::~PickboardImpl()
46{
47 delete pickboard;
48 delete icn;
49}
50
51QWidget *PickboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
52{
53 if ( !pickboard )
54 pickboard = new Pickboard( parent, "pickboard", f );
55 return pickboard;
56}
57
58void PickboardImpl::resetState()
59{
60 if ( pickboard )
61 pickboard->resetState();
62}
63
64QPixmap *PickboardImpl::icon()
65{
66 if ( !icn )
67 icn = new QPixmap( (const char **)pb_xpm );
68 return icn;
69}
70
71QString PickboardImpl::name()
72{
73 return qApp->translate( "InputMethods", "Pickboard" );
74}
75
76void PickboardImpl::onKeyPress( QObject *receiver, const char *slot )
77{
78 if ( pickboard )
79 QObject::connect( pickboard, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
80}
81
82#ifndef QT_NO_COMPONENT
83QRESULT PickboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
84{
85 *iface = 0;
86 if ( uuid == IID_QUnknown )
87 *iface = this;
88 else if ( uuid == IID_InputMethod )
89 *iface = this;
90
91 if ( *iface )
92 (*iface)->addRef();
93 return QS_OK;
94}
95
96Q_EXPORT_INTERFACE()
97{
98 Q_CREATE_INSTANCE( PickboardImpl )
99}
100#endif
101
diff --git a/inputmethods/pickboard/pickboardimpl.h b/inputmethods/pickboard/pickboardimpl.h
new file mode 100644
index 0000000..4f23665
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardimpl.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 PICKBOARDIMPL_H
21#define PICKBOARDIMPL_H
22
23#include <qpe/inputmethodinterface.h>
24
25class Pickboard;
26class QPixmap;
27
28class PickboardImpl : public InputMethodInterface
29{
30public:
31 PickboardImpl();
32 virtual ~PickboardImpl();
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
45private:
46 Pickboard *pickboard;
47 QPixmap *icn;
48 ulong ref;
49};
50
51#endif
diff --git a/inputmethods/pickboard/pickboardpicks.cpp b/inputmethods/pickboard/pickboardpicks.cpp
new file mode 100644
index 0000000..a80bbf8
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardpicks.cpp
@@ -0,0 +1,418 @@
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 "pickboardpicks.h"
21#include "pickboardcfg.h"
22
23#include <qpe/global.h>
24
25#include <qpainter.h>
26#include <qlist.h>
27#include <qbitmap.h>
28#include <qlayout.h>
29#include <qvbox.h>
30#include <qdialog.h>
31#include <qscrollview.h>
32#include <qpopupmenu.h>
33#include <qhbuttongroup.h>
34#include <qpushbutton.h>
35#include <qmessagebox.h>
36#include <qwindowsystem_qws.h>
37
38void PickboardPicks::doMenu()
39{
40 QWidget* cause = (QWidget*)sender(); // evil
41
42 QPopupMenu popup(this);
43 config()->fillMenu(popup);
44
45 QPoint pos = cause->mapToGlobal(cause->rect().topRight());
46 QSize sz = popup.sizeHint();
47 pos.ry() -= sz.height();
48 pos.rx() -= sz.width();
49 popup.move(pos);
50 config()->doMenu(popup.exec());
51}
52
53static const char *BS_xpm[] = {
54"5 7 2 1",
55"a c #000000",
56". c None",
57"...aa",
58"..aaa",
59".aaaa",
60"aaaaa",
61".aaaa",
62"..aaa",
63"...aa",
64};
65static const char *Del_xpm[] = {
66"14 7 2 1",
67"a c #000000",
68". c None",
69"aaa..aaaa.a...",
70"a..a.a....a...",
71"a..a.a....a...",
72"a..a.aaa..a...",
73"a..a.a....a...",
74"a..a.a....a...",
75"aaa..aaaa.aaaa"
76};
77static const char *Home_xpm[] = {
78"20 7 2 1",
79"a c #000000",
80". c None",
81"a..a..aa..a...a.aaaa",
82"a..a.a..a.aa.aa.a...",
83"a..a.a..a.a.a.a.a...",
84"aaaa.a..a.a.a.a.aaa.",
85"a..a.a..a.a...a.a...",
86"a..a.a..a.a...a.a...",
87"a..a..aa..a...a.aaaa"
88};
89static const char *PgUp_xpm[] = {
90"20 7 2 1",
91"a c #000000",
92". c None",
93"aaa.......a..a......",
94"a..a......a..a......",
95"a..a.aa...a..a.aaa..",
96"aaa.a.....a..a.a..a.",
97"a...a.aa..a..a.aaa..",
98"a...a..a..a..a.a....",
99"a....aaa...aa..a...."
100};
101static const char *PgDn_xpm[] = {
102"20 7 2 1",
103"a c #000000",
104". c None",
105"aaa.......aaa.......",
106"a..a......a..a......",
107"a..a.aa...a..a.a..a.",
108"aaa.a.....a..a.aa.a.",
109"a...a.aa..a..a.a.aa.",
110"a...a..a..a..a.a..a.",
111"a....aaa..aaa..a..a."
112};
113static const char *End_xpm[] = {
114"14 7 2 1",
115"a c #000000",
116". c None",
117"aaaa.a..a.aaa.",
118"a....aa.a.a..a",
119"a....a.aa.a..a",
120"aaa..a..a.a..a",
121"a....a..a.a..a",
122"a....a..a.a..a",
123"aaaa.a..a.aaa."
124};
125static const char *Enter_xpm[] = {
126"14 7 2 1",
127"a c #000000",
128". c None",
129".............a",
130".............a",
131"..a..........a",
132".aa.........a.",
133"aaaaaaaaaaaa..",
134".aa...........",
135"..a..........."
136};
137static const char *Esc_xpm[] = {
138"14 7 2 1",
139"a c #000000",
140". c None",
141"aaaa..aa...aa.",
142"a....a..a.a..a",
143"a....a....a...",
144"aaa...aa..a...",
145"a.......a.a...",
146"a....a..a.a..a",
147"aaaa..aa...aa."
148};
149static const char *Ins_xpm[] = {
150"13 7 2 1",
151"a c #000000",
152". c None",
153"aaa.a..a..aa.",
154".a..aa.a.a..a",
155".a..a.aa.a...",
156".a..a..a..aa.",
157".a..a..a....a",
158".a..a..a.a..a",
159"aaa.a..a..aa."
160};
161static const char *Up_xpm[] = {
162"7 7 2 1",
163"a c #000000",
164". c None",
165"...a...",
166"..aaa..",
167".a.a.a.",
168"a..a..a",
169"...a...",
170"...a...",
171"...a..."
172};
173static const char *Left_xpm[] = {
174"7 7 2 1",
175"a c #000000",
176". c None",
177"...a...",
178"..a....",
179".a.....",
180"aaaaaaa",
181".a.....",
182"..a....",
183"...a..."
184};
185static const char *Down_xpm[] = {
186"7 7 2 1",
187"a c #000000",
188". c None",
189"...a...",
190"...a...",
191"...a...",
192"a..a..a",
193".a.a.a.",
194"..aaa..",
195"...a..."
196};
197static const char *Right_xpm[] = {
198"7 7 2 1",
199"a c #000000",
200". c None",
201"...a...",
202"....a..",
203".....a.",
204"aaaaaaa",
205".....a.",
206"....a..",
207"...a..."
208};
209static const char *BackTab_xpm[] = {
210"8 7 2 1",
211"a c #000000",
212". c None",
213"a.......",
214"a..a....",
215"a.aa....",
216"aaaaaaaa",
217"a.aa....",
218"a..a....",
219"a......."
220};
221static const char *Tab_xpm[] = {
222"8 7 2 1",
223"a c #000000",
224". c None",
225".......a",
226"....a..a",
227"....aa.a",
228"aaaaaaaa",
229"....aa.a",
230"....a..a",
231".......a"
232};
233static const char *Space_xpm[] = {
234"9 9 2 1",
235"a c #000000",
236". c None",
237"aaaaaaaaa",
238"a.......a",
239"a.......a",
240"a.......a",
241"a.......a",
242"a.......a",
243"a.......a",
244"a.......a",
245"aaaaaaaaa"
246};
247
248PickboardPicks::PickboardPicks(QWidget* parent, const char* name, WFlags f ) :
249 QFrame(parent,name,f)
250{
251}
252
253void PickboardPicks::initialise(void)
254{
255 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
256 mode = 0;
257
258 DictFilterConfig* dc = new DictFilterConfig(this);
259 dc->addSet("ABC");
260 dc->addSet("DEF");
261 dc->addSet("GHI");
262 dc->addSet("JKL");
263 dc->addSet("MNO");
264 dc->addSet("PQR");
265 dc->addSet("STU");
266 dc->addSet("VWX");
267 dc->addSet("YZ-'");
268 dc->addMode("123");
269 dc->addMode("@*!?");
270 dc->addMode("KEY");
271 dc->addMode("Space");
272 dc->addMode("Back");
273 dc->addMode("Enter");
274 dc->addMode("Shift");
275 configs.append(dc);
276
277 CharStringConfig* number = new CharStringConfig(this);
278 number->addChar("0");
279 number->addChar("1");
280 number->addChar("2");
281 number->addChar("3");
282 number->addChar("4");
283 number->addChar("5");
284 number->addChar("6");
285 number->addChar("7");
286 number->addChar("8");
287 number->addChar("9");
288 number->addChar("."); // #### or "," in some locales
289 configs.append(number);
290
291 CharConfig* punc = new CharConfig(this);
292
293 punc->addChar(0,"\"");
294 punc->addChar(0,"`");
295 punc->addChar(0,"'");
296 punc->addChar(0,"\253");
297 punc->addChar(0,"\273");
298 punc->addChar(0,"\277");
299 punc->addChar(1,"(");
300 punc->addChar(1,")");
301 punc->addChar(1,"[");
302 punc->addChar(1,"]");
303 punc->addChar(1,"{");
304 punc->addChar(1,"}");
305
306 punc->addChar(0,"+");
307 punc->addChar(0,"-");
308 punc->addChar(0,"*");
309 punc->addChar(0,"/");
310 punc->addChar(0,"=");
311 punc->addChar(0,"_");
312 punc->addChar(0,"$");
313 punc->addChar(0,"&");
314 punc->addChar(1,"|");
315 punc->addChar(1,"@");
316 punc->addChar(1,"\\");
317 punc->addChar(1,"#");
318 punc->addChar(1,"^");
319 punc->addChar(1,"~");
320 punc->addChar(1,"<");
321 punc->addChar(1,">");
322
323 punc->addChar(0,".");
324 punc->addChar(0,"?");
325 punc->addChar(0,"!");
326 punc->addChar(0,",");
327 punc->addChar(0,";");
328 punc->addChar(1,":");
329 punc->addChar(1,"\267");
330 punc->addChar(1,"\277");
331 punc->addChar(1,"\241");
332 punc->addChar(1,"\367");
333
334 punc->addChar(0,"$");
335 punc->addChar(0,"\242");
336 punc->addChar(0,"\245");
337 punc->addChar(1,"\243");
338 punc->addChar(1,"\244");
339 punc->addChar(1,"\260");
340
341 configs.append(punc);
342
343 KeycodeConfig* keys = new KeycodeConfig(this);
344 keys->addKey(0,QPixmap(Esc_xpm),Key_Escape);
345 keys->addKey(0,QPixmap(BS_xpm),Key_Backspace);
346 keys->addGap(0,10);
347
348 keys->addKey(0,QPixmap(Ins_xpm),Key_Insert);
349 keys->addKey(0,QPixmap(Home_xpm),Key_Home);
350 keys->addKey(0,QPixmap(PgUp_xpm),Key_PageUp);
351
352 keys->addGap(0,25);
353 keys->addKey(0,QPixmap(Up_xpm),Key_Up);
354 keys->addGap(0,15);
355
356 keys->addKey(1,QPixmap(BackTab_xpm),Key_Tab);
357 keys->addGap(1,3);
358 keys->addKey(1,QPixmap(Tab_xpm),Key_Tab);
359 keys->addGap(1,10);
360
361 keys->addKey(1,QPixmap(Del_xpm),Key_Delete);
362 keys->addGap(1,2);
363 keys->addKey(1,QPixmap(End_xpm),Key_End);
364 keys->addGap(1,3);
365 keys->addKey(1,QPixmap(PgDn_xpm),Key_PageDown);
366
367 keys->addGap(1,10);
368 keys->addKey(1,QPixmap(Left_xpm),Key_Left);
369 keys->addKey(1,QPixmap(Down_xpm),Key_Down);
370 keys->addKey(1,QPixmap(Right_xpm),Key_Right);
371
372 keys->addGap(1,13);
373 keys->addKey(1,QPixmap(Space_xpm),Key_Space);
374
375 keys->addGap(0,10);
376 keys->addKey(0,QPixmap(Enter_xpm),Key_Return);
377
378 configs.append(keys);
379}
380
381PickboardPicks::~PickboardPicks()
382{
383}
384
385QSize PickboardPicks::sizeHint() const
386{
387 return QSize(240,fontMetrics().lineSpacing()*2+3);
388}
389
390void PickboardPicks::drawContents(QPainter* p)
391{
392 config()->draw(p);
393}
394
395void PickboardPicks::mousePressEvent(QMouseEvent* e)
396{
397 config()->pickPoint(e->pos(),TRUE);
398}
399
400void PickboardPicks::mouseDoubleClickEvent(QMouseEvent* e)
401{
402 config()->pickPoint(e->pos(),TRUE);
403}
404
405void PickboardPicks::mouseReleaseEvent(QMouseEvent* e)
406{
407 config()->pickPoint(e->pos(),FALSE);
408}
409
410void PickboardPicks::setMode(int m)
411{
412 mode = m;
413}
414
415void PickboardPicks::resetState()
416{
417 config()->doMenu(100);
418}
diff --git a/inputmethods/pickboard/pickboardpicks.h b/inputmethods/pickboard/pickboardpicks.h
new file mode 100644
index 0000000..1881e92
--- a/dev/null
+++ b/inputmethods/pickboard/pickboardpicks.h
@@ -0,0 +1,66 @@
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 PICKBOARDPICKS_H
21#define PICKBOARDPICKS_H
22
23#include <qframe.h>
24#include <qlist.h>
25
26// Internal stuff...
27
28class PickboardConfig;
29
30class PickboardPicks : public QFrame {
31 Q_OBJECT
32public:
33 PickboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0);
34 ~PickboardPicks();
35 QSize sizeHint() const;
36 void initialise();
37 void setMode(int);
38 int currentMode() const { return mode; }
39
40 void mousePressEvent(QMouseEvent*);
41
42 void emitKey( ushort scan, ushort uni, ushort mod, bool press, bool repeat )
43 { key(scan,uni,mod,press, repeat); }
44 void resetState();
45
46signals:
47 void key( ushort scan, ushort uni, ushort mod, bool, bool );
48
49public slots:
50 void doMenu();
51
52protected:
53 void drawContents( QPainter * );
54 void mouseDoubleClickEvent(QMouseEvent*);
55 void mouseReleaseEvent(QMouseEvent*);
56
57protected:
58 int mode;
59 QList<PickboardConfig> configs;
60
61private:
62 PickboardConfig* config() { return configs.at(mode); }
63};
64
65
66#endif
diff --git a/inputmethods/pickboard/qpe-pickboard.control b/inputmethods/pickboard/qpe-pickboard.control
new file mode 100644
index 0000000..8d12181
--- a/dev/null
+++ b/inputmethods/pickboard/qpe-pickboard.control
@@ -0,0 +1,9 @@
1Files: plugins/inputmethods/libqpickboard.so*
2Priority: optional
3Section: qpe/inputmethods
4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm
6Version: $QPE_VERSION-3
7Depends: qpe-base ($QPE_VERSION)
8Description: Pickboard input method
9 Pickboard dictionary-based input method for the Qtopia environment.
diff --git a/inputmethods/pickboard/qpe-pickboard.postinst b/inputmethods/pickboard/qpe-pickboard.postinst
new file mode 100755
index 0000000..c254b01
--- a/dev/null
+++ b/inputmethods/pickboard/qpe-pickboard.postinst
@@ -0,0 +1,2 @@
1#!/bin/sh
2/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadInputMethods()"
diff --git a/inputmethods/pickboard/qpe-pickboard.postrm b/inputmethods/pickboard/qpe-pickboard.postrm
new file mode 100755
index 0000000..c254b01
--- a/dev/null
+++ b/inputmethods/pickboard/qpe-pickboard.postrm
@@ -0,0 +1,2 @@
1#!/bin/sh
2/opt/QtPalmtop/bin/qcop QPE/TaskBar "reloadInputMethods()"