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.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
new file mode 100644
index 0000000..b524195
--- a/dev/null
+++ b/inputmethods/multikey/keyboard.h
@@ -0,0 +1,148 @@
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 <qmap.h>
22#include "../pickboard/pickboardcfg.h"
23#include "../pickboard/pickboardpicks.h"
24
25class QTimer;
26
27class KeyboardConfig : public DictFilterConfig
28{
29public:
30 KeyboardConfig(PickboardPicks* p) : DictFilterConfig(p), backspaces(0) { nrows = 1; }
31 virtual void generateText(const QString &s);
32 void decBackspaces() { if (backspaces) backspaces--; }
33 void incBackspaces() { backspaces++; }
34 void resetBackspaces() { backspaces = 0; }
35private:
36 int backspaces;
37};
38
39
40class KeyboardPicks : public PickboardPicks
41{
42 Q_OBJECT
43public:
44 KeyboardPicks(QWidget* parent=0, const char* name=0, WFlags f=0)
45 : PickboardPicks(parent, name, f) { }
46 void initialise();
47 virtual QSize sizeHint() const;
48 KeyboardConfig *dc;
49};
50
51
52class Keys {
53public:
54
55 Keys();
56 Keys(const char * filename);
57 ushort uni(const int row, const int col);
58 int qcode(const int row, const int col);
59 int width(const int row, const int col);
60 bool pressed(const int row, const int col);
61 bool *pressedPtr(const int row, const int col);
62 ushort shift(const ushort);
63 QPixmap *pix(const int row, const int col);
64 int numKeys(const int row);
65 void setKeysFromFile(const char *filename);
66 void setKey(const int row, const int qcode, const ushort unicode,
67 const int width, QPixmap *pix);
68 void setPressed(const int row, const int col, const bool pressed);
69
70private:
71
72 typedef struct Key {
73 int qcode; // are qt key codes just unicode values?
74 ushort unicode;
75 int width; // not pixels but relative key width. normal key is 2
76
77 // only needed for keys like ctrl that can have multiple keys pressed at once
78 bool *pressed;
79 QPixmap *pix;
80 };
81
82 QList<Key> keys[6];
83 QMap<ushort,ushort> shiftMap;
84
85};
86
87class Keyboard : public QFrame
88{
89 Q_OBJECT
90public:
91 Keyboard( QWidget* parent=0, const char* name=0, WFlags f=0 );
92
93 void resetState();
94
95 void mousePressEvent(QMouseEvent*);
96 void mouseReleaseEvent(QMouseEvent*);
97 void resizeEvent(QResizeEvent*);
98 void paintEvent(QPaintEvent* e);
99 //void timerEvent(QTimerEvent* e);
100 void drawKeyboard( QPainter &p, int row = -1, int col = -1);
101
102 QSize sizeHint() const;
103
104signals:
105 void key( ushort scancode, ushort unicode, ushort modifiers, bool, bool );
106
107private slots:
108 void repeat();
109
110private:
111 int getKey( int &w, int j = -1 );
112 void clearHighlight();
113
114 bool *shift;
115 bool *lock;
116 bool *ctrl;
117 bool *alt;
118 uint useLargeKeys:1;
119 uint usePicks:1;
120
121 int pressedKeyRow;
122 int pressedKeyCol;
123
124 KeyboardPicks *picks;
125
126 int keyHeight;
127 int defaultKeyWidth;
128 int xoffs;
129
130 int unicode;
131 int qkeycode;
132 int modifiers;
133
134 int pressTid;
135 bool pressed;
136
137 Keys keys;
138 QString LANG;
139 /* for korean input */
140 ushort schar, mchar, echar;
141 ushort parseKoreanInput(ushort c);
142 ushort combineKoreanChars(const ushort s, const ushort m, const ushort e);
143 ushort constoe(const ushort c);
144
145 QTimer *repeatTimer;
146};
147
148