summaryrefslogtreecommitdiff
path: root/inputmethods/jumpx/keyboard.cpp
Unidiff
Diffstat (limited to 'inputmethods/jumpx/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/jumpx/keyboard.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/inputmethods/jumpx/keyboard.cpp b/inputmethods/jumpx/keyboard.cpp
index 0b8fc14..0cfb4be 100644
--- a/inputmethods/jumpx/keyboard.cpp
+++ b/inputmethods/jumpx/keyboard.cpp
@@ -31,192 +31,193 @@ static const int letterh = 14;
31static const int num1x1 = 130; 31static const int num1x1 = 130;
32static const int num1x2 = 137; 32static const int num1x2 = 137;
33static const int num1w = num1x2 - num1x1; 33static const int num1w = num1x2 - num1x1;
34 34
35static const int specialx1 = 138; 35static const int specialx1 = 138;
36static const int specialx2 = 170; 36static const int specialx2 = 170;
37static const int specialw = 16; 37static const int specialw = 16;
38 38
39static const int num2x1 = 171; 39static const int num2x1 = 171;
40static const int num2x2 = 178; 40static const int num2x2 = 178;
41static const int num2w = num2x2 - num2x1; 41static const int num2w = num2x2 - num2x1;
42 42
43static const int mod2x1 = 179; 43static const int mod2x1 = 179;
44static const int mod2x2 = 203; 44static const int mod2x2 = 203;
45static const int mod2w = mod2x2 - mod2x1; 45static const int mod2w = mod2x2 - mod2x1;
46 46
47static const int cursorx1 = 207; 47static const int cursorx1 = 207;
48static const int cursorw = 16; 48static const int cursorw = 16;
49 49
50static const int myParenID = -10; 50static const int myParenID = -10;
51 51
52 52
53typedef struct mapElement 53typedef struct mapElement
54{ 54{
55 int qcode; 55 int qcode;
56 ushort unicode; 56 ushort unicode;
57}; 57};
58 58
59static const mapElement mod1Map[] = { 59static const mapElement mod1Map[] = {
60 { Qt::Key_Escape, 27 }, 60 { Qt::Key_Escape, 27 },
61 { Qt::Key_Tab, 9 }, 61 { Qt::Key_Tab, 9 },
62 { Qt::Key_Return, 13 }, 62 { Qt::Key_Return, 13 },
63 { Qt::Key_Alt, 0 }, 63 { Qt::Key_Alt, 0 },
64 { Qt::Key_Control, 0 }, 64 { Qt::Key_Control, 0 },
65}; 65};
66 66
67static const uchar *const letterMap[] = { 67static const uchar *const letterMap[] = {
68 (const uchar *const)"zvchwk", 68 (const uchar *const)"zvchwk",
69 (const uchar *const)"fitaly", 69 (const uchar *const)"fitaly",
70 (const uchar *const)" ne ", 70 (const uchar *const)" ne ",
71 (const uchar *const)"gdorsb", 71 (const uchar *const)"gdorsb",
72 (const uchar *const)"qjumpx", 72 (const uchar *const)"qjumpx",
73}; 73};
74 74
75static const uchar *const letterMapShift[] = { 75static const uchar *const letterMapShift[] = {
76 (const uchar *const)"ZVCHWK", 76 (const uchar *const)"ZVCHWK",
77 (const uchar *const)"FITALY", 77 (const uchar *const)"FITALY",
78 (const uchar *const)" NE ", 78 (const uchar *const)" NE ",
79 (const uchar *const)"GDORSB", 79 (const uchar *const)"GDORSB",
80 (const uchar *const)"QJUMPX", 80 (const uchar *const)"QJUMPX",
81}; 81};
82 82
83static const uchar *const num1Map = (const uchar *const)"12345"; 83static const uchar *const num1Map = (const uchar *const)"12345";
84 84
85static const uchar *const specialMap[] = { 85static const uchar *const specialMap[] = {
86 (const uchar *const)"-+", 86 (const uchar *const)"-+",
87 (const uchar *const)"*!", 87 (const uchar *const)"*!",
88 (const uchar *const)",'", 88 (const uchar *const)",'",
89 (const uchar *const)".%", 89 (const uchar *const)".%",
90 (const uchar *const)"/$", 90 (const uchar *const)"/$",
91}; 91};
92 92
93static const uchar *const specialMapShift[] = { 93static const uchar *const specialMapShift[] = {
94 (const uchar *const)"_=", 94 (const uchar *const)"_=",
95 (const uchar *const)"#?", 95 (const uchar *const)"#?",
96 (const uchar *const)";\"", 96 (const uchar *const)";\"",
97 (const uchar *const)":|", 97 (const uchar *const)":|",
98 (const uchar *const)"\\&", 98 (const uchar *const)"\\&",
99}; 99};
100 100
101static const uchar *const specialMapParen[] = { 101static const uchar *const specialMapParen[] = {
102 (const uchar *const)"()", 102 (const uchar *const)"()",
103 (const uchar *const)"[]", 103 (const uchar *const)"[]",
104 (const uchar *const)"{}", 104 (const uchar *const)"{}",
105 (const uchar *const)"<>", 105 (const uchar *const)"<>",
106 (const uchar *const)"@~", 106 (const uchar *const)"@~",
107}; 107};
108 108
109static const uchar *const num2Map = (const uchar *const)"67890"; 109static const uchar *const num2Map = (const uchar *const)"67890";
110 110
111static const mapElement mod2Map[] = { 111static const mapElement mod2Map[] = {
112 { Qt::Key_Backspace, 8 }, 112 { Qt::Key_Backspace, 8 },
113 { Qt::Key_Delete, 0 }, 113 { Qt::Key_Delete, 0 },
114 { Qt::Key_Return, 13 }, 114 { Qt::Key_Return, 13 },
115 { Qt::Key_Shift, 0 }, 115 { Qt::Key_Shift, 0 },
116 { myParenID, 0 }, 116 { myParenID, 0 },
117}; 117};
118 118
119static const int cursorMap[][2] = { 119static const int cursorMap[][2] = {
120 { Qt::Key_Home, Qt::Key_PageUp }, 120 { Qt::Key_Home, Qt::Key_PageUp },
121 { Qt::Key_End, Qt::Key_PageDown }, 121 { Qt::Key_End, Qt::Key_PageDown },
122 { Qt::Key_Up, Qt::Key_Up }, 122 { Qt::Key_Up, Qt::Key_Up },
123 { Qt::Key_Left, Qt::Key_Right }, 123 { Qt::Key_Left, Qt::Key_Right },
124 { Qt::Key_Down, Qt::Key_Down }, 124 { Qt::Key_Down, Qt::Key_Down },
125}; 125};
126 126
127using namespace JumpX;
127 128
128Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : 129Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) :
129 QFrame(parent, name, f), 130 QFrame(parent, name, f),
130 shift(0), paren(0), ctrl(0), alt(0), 131 shift(0), paren(0), ctrl(0), alt(0),
131 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), 132 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0),
132 isnoncont(false), 133 isnoncont(false),
133 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), 134 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0),
134 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), 135 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL),
135 releasedPix(NULL), pressedPix(NULL) 136 releasedPix(NULL), pressedPix(NULL)
136{ 137{
137 //setPalette(QPalette(QColor(240,240,230))); // Beige! 138 //setPalette(QPalette(QColor(240,240,230))); // Beige!
138 139
139 releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("jumpx/released"); 140 releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("jumpx/released");
140 pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("jumpx/pressed"); 141 pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("jumpx/pressed");
141 pressedDigit = Resource::loadPixmap("jumpx/pressed"); 142 pressedDigit = Resource::loadPixmap("jumpx/pressed");
142 143
143 QPixmap tmp; 144 QPixmap tmp;
144 145
145 tmp = Resource::loadPixmap("jumpx/releasedShift"); 146 tmp = Resource::loadPixmap("jumpx/releasedShift");
146 bitBlt(&releasedShift, letterx1, 0, &tmp); 147 bitBlt(&releasedShift, letterx1, 0, &tmp);
147 148
148 tmp = Resource::loadPixmap("jumpx/releasedParen"); 149 tmp = Resource::loadPixmap("jumpx/releasedParen");
149 bitBlt(&releasedParen, specialx1, 0, &tmp); 150 bitBlt(&releasedParen, specialx1, 0, &tmp);
150 151
151 tmp = Resource::loadPixmap("jumpx/pressedShift"); 152 tmp = Resource::loadPixmap("jumpx/pressedShift");
152 bitBlt(&pressedShift, letterx1, 0, &tmp); 153 bitBlt(&pressedShift, letterx1, 0, &tmp);
153 154
154 tmp = Resource::loadPixmap("jumpx/pressedParen"); 155 tmp = Resource::loadPixmap("jumpx/pressedParen");
155 bitBlt(&pressedParen, specialx1, 0, &tmp); 156 bitBlt(&pressedParen, specialx1, 0, &tmp);
156 157
157 tmp = Resource::loadPixmap("jumpx/pressedDigit"); 158 tmp = Resource::loadPixmap("jumpx/pressedDigit");
158 bitBlt(&pressedDigit, specialx1, 0, &tmp); 159 bitBlt(&pressedDigit, specialx1, 0, &tmp);
159 160
160 offscreen = QPixmap( releasedPlain ); 161 offscreen = QPixmap( releasedPlain );
161 162
162 releasedPix = &releasedPlain; 163 releasedPix = &releasedPlain;
163 pressedPix = &pressedPlain; 164 pressedPix = &pressedPlain;
164 slidePix = &pressedPlain; 165 slidePix = &pressedPlain;
165 166
166 delayTimer = new QTimer(this); 167 delayTimer = new QTimer(this);
167 rateTimer = new QTimer(this); 168 rateTimer = new QTimer(this);
168 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); 169 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) );
169 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); 170 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) );
170} 171}
171 172
172void Keyboard::resizeEvent(QResizeEvent*) 173void Keyboard::resizeEvent(QResizeEvent*)
173{ 174{
174 //cout << "resizeEvent()" << endl; 175 //cout << "resizeEvent()" << endl;
175} 176}
176 177
177void Keyboard::paintEvent(QPaintEvent*) 178void Keyboard::paintEvent(QPaintEvent*)
178{ 179{
179 bitBlt(this, 0, 0, &offscreen); 180 bitBlt(this, 0, 0, &offscreen);
180} 181}
181 182
182void Keyboard::mousePressEvent(QMouseEvent *e) 183void Keyboard::mousePressEvent(QMouseEvent *e)
183{ 184{
184 pressedx = -1; 185 pressedx = -1;
185 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; 186 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0;
186 187
187 int x = e->x(); 188 int x = e->x();
188 int y = e->y(); 189 int y = e->y();
189 190
190 int row = (y - 1) / letterh; 191 int row = (y - 1) / letterh;
191 192
192 if ( x <= mod1x2 ) // mod1 193 if ( x <= mod1x2 ) // mod1
193 { 194 {
194 pressedx = mod1x1; 195 pressedx = mod1x1;
195 pressedy = row * letterh; 196 pressedy = row * letterh;
196 pressedw = mod1w + 1; 197 pressedw = mod1w + 1;
197 pressedh = letterh + 1; 198 pressedh = letterh + 1;
198 if ( row == 2 ) // return 199 if ( row == 2 ) // return
199 { 200 {
200 pressed2x = mod2x1; 201 pressed2x = mod2x1;
201 pressed2y = 2 * letterh; 202 pressed2y = 2 * letterh;
202 pressed2w = mod2w + 1; 203 pressed2w = mod2w + 1;
203 pressed2h = letterh + 1; 204 pressed2h = letterh + 1;
204 isnoncont = true; 205 isnoncont = true;
205 } 206 }
206 else if ( row == 3 ) // alt 207 else if ( row == 3 ) // alt
207 alt = 1; 208 alt = 1;
208 else if ( row == 4 ) // ctrl 209 else if ( row == 4 ) // ctrl
209 ctrl = 1; 210 ctrl = 1;
210 pressedKeyUnicode = mod1Map[row].unicode; 211 pressedKeyUnicode = mod1Map[row].unicode;
211 pressedKeyQcode = mod1Map[row].qcode; 212 pressedKeyQcode = mod1Map[row].qcode;
212 } 213 }
213 else if ( x >= letterx1 && x <= letterx2 ) // letter 214 else if ( x >= letterx1 && x <= letterx2 ) // letter
214 { 215 {
215 int column = (x - letterx1 - 1) / letterw; 216 int column = (x - letterx1 - 1) / letterw;
216 QChar temp; 217 QChar temp;
217 if ( shift ) 218 if ( shift )
218 temp = QChar( letterMapShift[row][column] ); 219 temp = QChar( letterMapShift[row][column] );
219 else 220 else
220 temp = QChar( letterMap[row][column] ); 221 temp = QChar( letterMap[row][column] );
221 if ( temp == ' ' ) // space 222 if ( temp == ' ' ) // space
222 { 223 {