Diffstat (limited to 'inputmethods/pickboard/pickboardcfg.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/pickboard/pickboardcfg.h | 213 |
1 files changed, 213 insertions, 0 deletions
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 | |||
32 | class PickboardPicks; | ||
33 | |||
34 | class LetterButton : public QPushButton { | ||
35 | Q_OBJECT | ||
36 | public: | ||
37 | LetterButton(const QChar& letter, QWidget* parent); | ||
38 | private slots: | ||
39 | void toggleCase(); | ||
40 | private: | ||
41 | bool skip; | ||
42 | }; | ||
43 | |||
44 | class LetterChoice : public QButtonGroup { | ||
45 | Q_OBJECT | ||
46 | public: | ||
47 | LetterChoice(QWidget* parent, const QString& set); | ||
48 | |||
49 | QChar choice() { return ch; } | ||
50 | |||
51 | signals: | ||
52 | void changed(); | ||
53 | |||
54 | private slots: | ||
55 | void change(); | ||
56 | |||
57 | private: | ||
58 | QChar ch; | ||
59 | }; | ||
60 | |||
61 | class PickboardAdd : public QDialog { | ||
62 | Q_OBJECT | ||
63 | public: | ||
64 | PickboardAdd(QWidget* owner, const QStringList& setlist); | ||
65 | ~PickboardAdd(); | ||
66 | |||
67 | QString word() const; | ||
68 | bool exec(); | ||
69 | |||
70 | private slots: | ||
71 | void checkAllDone(); | ||
72 | |||
73 | private: | ||
74 | QPushButton *yes; | ||
75 | LetterChoice **lc; | ||
76 | int nlc; | ||
77 | }; | ||
78 | |||
79 | class PickboardConfig : QObject { | ||
80 | public: | ||
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 | |||
88 | protected: | ||
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 | |||
99 | protected: | ||
100 | PickboardPicks* parent; | ||
101 | int nrows; | ||
102 | private: | ||
103 | int pressrow, pressx; | ||
104 | }; | ||
105 | |||
106 | class StringConfig : public PickboardConfig { | ||
107 | public: | ||
108 | StringConfig(PickboardPicks* p) : PickboardConfig(p) { } | ||
109 | |||
110 | void draw(QPainter* p); | ||
111 | |||
112 | protected: | ||
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 | |||
121 | class CharStringConfig : public StringConfig { | ||
122 | QString input; | ||
123 | QStringList chars; | ||
124 | public: | ||
125 | CharStringConfig(PickboardPicks* p) : StringConfig(p) { } | ||
126 | |||
127 | void addChar(const QString& s); | ||
128 | virtual void doMenu(int); | ||
129 | |||
130 | protected: | ||
131 | QString text(int r, int i); | ||
132 | bool spreadRow(int i); | ||
133 | void pick(bool press, int row, int item); | ||
134 | }; | ||
135 | |||
136 | class 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 | |||
146 | public: | ||
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 | |||
163 | protected: | ||
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 | |||
177 | class CharConfig : public StringConfig { | ||
178 | QStringList chars1; | ||
179 | QStringList chars2; | ||
180 | public: | ||
181 | CharConfig(PickboardPicks* p) : StringConfig(p) { } | ||
182 | void addChar(int r, const QString& s); | ||
183 | |||
184 | protected: | ||
185 | QString text(int r, int i); | ||
186 | bool spreadRow(int); | ||
187 | void pick(bool press, int row, int item); | ||
188 | }; | ||
189 | |||
190 | class 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 | |||
198 | public: | ||
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 | |||
205 | protected: | ||
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 | ||