summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.h
Unidiff
Diffstat (limited to 'inputmethods/multikey/keyboard.h') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index bc74e71..20c5cee 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -1,188 +1,191 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qframe.h> 20#include <qframe.h>
21#include <qmap.h> 21#include <qmap.h>
22#include "../pickboard/pickboardcfg.h" 22#include "../pickboard/pickboardcfg.h"
23#include "../pickboard/pickboardpicks.h" 23#include "../pickboard/pickboardpicks.h"
24#include "configdlg.h" 24#include "configdlg.h"
25 25
26class QTimer; 26class QTimer;
27 27
28namespace MultiKey
29{
30
28class KeyboardConfig : public DictFilterConfig 31class KeyboardConfig : public DictFilterConfig
29{ 32{
30public: 33public:
31 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; } 34 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
32 virtual void generateText(const QString &s); 35 virtual void generateText(const QString &s);
33 void decBackspaces() { if (backspaces) backspaces--; } 36 void decBackspaces() { if (backspaces) backspaces--; }
34 void incBackspaces() { backspaces++; } 37 void incBackspaces() { backspaces++; }
35 void resetBackspaces() { backspaces = 0; } 38 void resetBackspaces() { backspaces = 0; }
36private: 39private:
37 int backspaces; 40 int backspaces;
38}; 41};
39 42
40 43
41class KeyboardPicks : public PickboardPicks 44class KeyboardPicks : public PickboardPicks
42{ 45{
43 Q_OBJECT 46 Q_OBJECT
44public: 47public:
45 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0) 48 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
46 : PickboardPicks(parent, name, f) { } 49 : PickboardPicks(parent, name, f) { }
47 void initialise(); 50 void initialise();
48 virtual QSize sizeHint() const; 51 virtual QSize sizeHint() const;
49 KeyboardConfig *dc; 52 KeyboardConfig *dc;
50}; 53};
51 54
52 55
53class Keys { 56class Keys {
54public: 57public:
55 58
56 Keys(); 59 Keys();
57 Keys(const char * filename); 60 Keys(const char * filename);
58 ~Keys(); 61 ~Keys();
59 int width(const int row, const int col); 62 int width(const int row, const int col);
60 int rows(); 63 int rows();
61 ushort uni(const int row, const int col); 64 ushort uni(const int row, const int col);
62 int qcode(const int row, const int col); 65 int qcode(const int row, const int col);
63 bool pressed(const int row, const int col); 66 bool pressed(const int row, const int col);
64 bool *pressedPtr(const int row, const int col); 67 bool *pressedPtr(const int row, const int col);
65 ushort shift(const ushort); 68 ushort shift(const ushort);
66 ushort meta(const ushort); 69 ushort meta(const ushort);
67 ushort circumflex(const ushort); 70 ushort circumflex(const ushort);
68 ushort diaeresis(const ushort); 71 ushort diaeresis(const ushort);
69 ushort baccent(const ushort); 72 ushort baccent(const ushort);
70 ushort accent(const ushort); 73 ushort accent(const ushort);
71 QImage *pix(const int row, const int col); 74 QImage *pix(const int row, const int col);
72 int numKeys(const int row); 75 int numKeys(const int row);
73 void setKeysFromFile(const char *filename); 76 void setKeysFromFile(const char *filename);
74 void setKey(const int row, const int qcode, const ushort unicode, 77 void setKey(const int row, const int qcode, const ushort unicode,
75 const int width, QImage *pix); 78 const int width, QImage *pix);
76 void setPressed(const int row, const int col, const bool pressed); 79 void setPressed(const int row, const int col, const bool pressed);
77 QString lang; 80 QString lang;
78 QString label; 81 QString label;
79 82
80private: 83private:
81 84
82 typedef struct Key { 85 typedef struct Key {
83 int qcode; // are qt key codes just unicode values? 86 int qcode; // are qt key codes just unicode values?
84 ushort unicode; 87 ushort unicode;
85 int width; // not pixels but relative key width. normal key is 2 88 int width; // not pixels but relative key width. normal key is 2
86 89
87 // only needed for keys like ctrl that can have multiple keys pressed at once 90 // only needed for keys like ctrl that can have multiple keys pressed at once
88 bool *pressed; 91 bool *pressed;
89 QImage *pix; 92 QImage *pix;
90 }; 93 };
91 94
92 QList<Key> keys[6]; 95 QList<Key> keys[6];
93 QMap<ushort,ushort> shiftMap; 96 QMap<ushort,ushort> shiftMap;
94 QMap<ushort,ushort> metaMap; 97 QMap<ushort,ushort> metaMap;
95 QMap<ushort,ushort> circumflexMap; 98 QMap<ushort,ushort> circumflexMap;
96 QMap<ushort,ushort> diaeresisMap; 99 QMap<ushort,ushort> diaeresisMap;
97 QMap<ushort,ushort> baccentMap; 100 QMap<ushort,ushort> baccentMap;
98 QMap<ushort,ushort> accentMap; 101 QMap<ushort,ushort> accentMap;
99 102
100}; 103};
101 104
102class Keyboard : public QFrame 105class Keyboard : public QFrame
103{ 106{
104 Q_OBJECT 107 Q_OBJECT
105public: 108public:
106 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 ); 109 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
107 ~Keyboard(); 110 ~Keyboard();
108 111
109 void resetState(); 112 void resetState();
110 113
111 void mousePressEvent(QMouseEvent*); 114 void mousePressEvent(QMouseEvent*);
112 void mouseReleaseEvent(QMouseEvent*); 115 void mouseReleaseEvent(QMouseEvent*);
113 void resizeEvent(QResizeEvent*); 116 void resizeEvent(QResizeEvent*);
114 void paintEvent(QPaintEvent* e); 117 void paintEvent(QPaintEvent* e);
115 //void timerEvent(QTimerEvent* e); 118 //void timerEvent(QTimerEvent* e);
116 void drawKeyboard( QPainter &p, int row = -1, int col = -1); 119 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
117 120
118 QSize sizeHint() const; 121 QSize sizeHint() const;
119 122
120signals: 123signals:
121 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool ); 124 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
122 125
123private slots: 126private slots:
124 void repeat(); 127 void repeat();
125 void togglePickboard(bool on_off); 128 void togglePickboard(bool on_off);
126 void toggleRepeat(bool on_off); 129 void toggleRepeat(bool on_off);
127 void setMapToDefault(); 130 void setMapToDefault();
128 void setMapToFile(QString map); 131 void setMapToFile(QString map);
129 void cleanupConfigDlg(); 132 void cleanupConfigDlg();
130 133
131 // used to redraw keyboard after edited colors 134 // used to redraw keyboard after edited colors
132 void reloadKeyboard(); 135 void reloadKeyboard();
133 136
134private: 137private:
135 int getKey( int &w, int j = -1 ); 138 int getKey( int &w, int j = -1 );
136 void clearHighlight(); 139 void clearHighlight();
137 140
138 bool *shift; 141 bool *shift;
139 bool *lock; 142 bool *lock;
140 bool *ctrl; 143 bool *ctrl;
141 bool *alt; 144 bool *alt;
142 bool *meta; 145 bool *meta;
143 bool *circumflex; 146 bool *circumflex;
144 bool *diaeresis; 147 bool *diaeresis;
145 bool *baccent; 148 bool *baccent;
146 bool *accent; 149 bool *accent;
147 150
148 uint useLargeKeys:1; 151 uint useLargeKeys:1;
149 uint usePicks:1; 152 uint usePicks:1;
150 uint useRepeat:1; 153 uint useRepeat:1;
151 154
152 int pressedKeyRow; 155 int pressedKeyRow;
153 int pressedKeyCol; 156 int pressedKeyCol;
154 157
155 KeyboardPicks *picks; 158 KeyboardPicks *picks;
156 159
157 int keyHeight; 160 int keyHeight;
158 int defaultKeyWidth; 161 int defaultKeyWidth;
159 int xoffs; 162 int xoffs;
160 163
161 int unicode; 164 int unicode;
162 int qkeycode; 165 int qkeycode;
163 int modifiers; 166 int modifiers;
164 167
165 int pressTid; 168 int pressTid;
166 bool pressed; 169 bool pressed;
167 170
168 Keys *keys; 171 Keys *keys;
169 172
170 /* for korean input */ 173 /* for korean input */
171 ushort schar, mchar, echar; 174 ushort schar, mchar, echar;
172 ushort parseKoreanInput(ushort c); 175 ushort parseKoreanInput(ushort c);
173 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e); 176 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
174 ushort constoe(const ushort c); 177 ushort constoe(const ushort c);
175 178
176 QTimer *repeatTimer; 179 QTimer *repeatTimer;
177 180
178 /* colors */ 181 /* colors */
179 void loadKeyboardColors(); 182 void loadKeyboardColors();
180 QColor keycolor; 183 QColor keycolor;
181 QColor keycolor_pressed; 184 QColor keycolor_pressed;
182 QColor keycolor_lines; 185 QColor keycolor_lines;
183 QColor textcolor; 186 QColor textcolor;
184 187
185 ConfigDlg *configdlg; 188 ConfigDlg *configdlg;
186}; 189};
187 190
188 191} // namespace MultiKey