summaryrefslogtreecommitdiff
authorhash <hash>2002-08-15 11:22:39 (UTC)
committer hash <hash>2002-08-15 11:22:39 (UTC)
commitdd6319831448313a03f2a80e08d5e170a511c676 (patch) (unidiff)
treec938b187e621fb03e3769198762a556a2f8cb676
parent04a632ea5dd5e5f5a696e53b9c7870247ccaa83c (diff)
downloadopie-dd6319831448313a03f2a80e08d5e170a511c676.zip
opie-dd6319831448313a03f2a80e08d5e170a511c676.tar.gz
opie-dd6319831448313a03f2a80e08d5e170a511c676.tar.bz2
made the keysize a little larger and the fonts too
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index b793391..2a80f1e 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,321 +1,321 @@
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 20
21#include "keyboard.h" 21#include "keyboard.h"
22#include "configdlg.h" 22#include "configdlg.h"
23 23
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <iostream.h> 36#include <iostream.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40 40
41#define USE_SMALL_BACKSPACE 41#define USE_SMALL_BACKSPACE
42 42
43/* Keyboard::Keyboard {{{1 */ 43/* Keyboard::Keyboard {{{1 */
44Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 44Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
45 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), 45 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0),
46 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1), 46 alt(0), useLargeKeys(TRUE), usePicks(0), pressedKeyRow(-1), pressedKeyCol(-1),
47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 47 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
48 configdlg(0) 48 configdlg(0)
49 49
50{ 50{
51 // get the default font 51 // get the default font
52 Config *config = new Config( "qpe" ); 52 Config *config = new Config( "qpe" );
53 config->setGroup( "Appearance" ); 53 config->setGroup( "Appearance" );
54 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 54 QString familyStr = config->readEntry( "FontFamily", "fixed" );
55 delete config; 55 delete config;
56 56
57 config = new Config("multikey"); 57 config = new Config("multikey");
58 config->setGroup ("pickboard"); 58 config->setGroup ("pickboard");
59 usePicks = config->readBoolEntry ("open", "0"); // default closed 59 usePicks = config->readBoolEntry ("open", "0"); // default closed
60 delete config; 60 delete config;
61 61
62 setFont( QFont( familyStr, 8 ) ); 62 setFont( QFont( familyStr, 10 ) );
63 63
64 picks = new KeyboardPicks( this ); 64 picks = new KeyboardPicks( this );
65 picks->setFont( QFont( familyStr, 8 ) ); 65 picks->setFont( QFont( familyStr, 10 ) );
66 picks->initialise(); 66 picks->initialise();
67 if (usePicks) { 67 if (usePicks) {
68 68
69 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 69 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
70 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 70 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
71 71
72 } else picks->hide(); 72 } else picks->hide();
73 73
74 keys = new Keys(); 74 keys = new Keys();
75 75
76 repeatTimer = new QTimer( this ); 76 repeatTimer = new QTimer( this );
77 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 77 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
78 78
79} 79}
80 80
81/* Keyboard::resizeEvent {{{1 */ 81/* Keyboard::resizeEvent {{{1 */
82void Keyboard::resizeEvent(QResizeEvent*) 82void Keyboard::resizeEvent(QResizeEvent*)
83{ 83{
84 int ph = picks->sizeHint().height(); 84 int ph = picks->sizeHint().height();
85 picks->setGeometry( 0, 0, width(), ph ); 85 picks->setGeometry( 0, 0, width(), ph );
86 keyHeight = (height()-(usePicks ? ph : 0))/5; 86 keyHeight = (height()-(usePicks ? ph : 0))/5;
87 87
88 int nk; // number of keys? 88 int nk; // number of keys?
89 if ( useLargeKeys ) { 89 if ( useLargeKeys ) {
90 nk = 15; 90 nk = 15;
91 } else { 91 } else {
92 nk = 19; 92 nk = 19;
93 } 93 }
94 defaultKeyWidth = (width()/nk)/2; 94 defaultKeyWidth = (width()/nk)/2;
95 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 95 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
96 96
97} 97}
98 98
99/* KeyboardPicks::initialize {{{1 */ 99/* KeyboardPicks::initialize {{{1 */
100void KeyboardPicks::initialise() 100void KeyboardPicks::initialise()
101{ 101{
102 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 102 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
103 mode = 0; 103 mode = 0;
104 dc = new KeyboardConfig(this); 104 dc = new KeyboardConfig(this);
105 configs.append(dc); 105 configs.append(dc);
106} 106}
107 107
108/* KeyboardPicks::sizeHint {{{1 */ 108/* KeyboardPicks::sizeHint {{{1 */
109QSize KeyboardPicks::sizeHint() const 109QSize KeyboardPicks::sizeHint() const
110{ 110{
111 return QSize(240,fontMetrics().lineSpacing()); 111 return QSize(240,fontMetrics().lineSpacing());
112} 112}
113 113
114 114
115/* KeyboardConfig::generateText {{{1 */ 115/* KeyboardConfig::generateText {{{1 */
116void KeyboardConfig::generateText(const QString &s) 116void KeyboardConfig::generateText(const QString &s)
117{ 117{
118#if defined(Q_WS_QWS) || defined(_WS_QWS_) 118#if defined(Q_WS_QWS) || defined(_WS_QWS_)
119 for (int i=0; i<(int)backspaces; i++) { 119 for (int i=0; i<(int)backspaces; i++) {
120 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 120 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
121 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 121 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
122 } 122 }
123 for (int i=0; i<(int)s.length(); i++) { 123 for (int i=0; i<(int)s.length(); i++) {
124 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 124 parent->emitKey( s[i].unicode(), 0, 0, true, false );
125 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 125 parent->emitKey( s[i].unicode(), 0, 0, false, false );
126 } 126 }
127 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 127 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
128 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 128 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
129 backspaces = 0; 129 backspaces = 0;
130#endif 130#endif
131} 131}
132 132
133 133
134 134
135 135
136/* Keyboard::paintEvent {{{1 */ 136/* Keyboard::paintEvent {{{1 */
137void Keyboard::paintEvent(QPaintEvent* e) 137void Keyboard::paintEvent(QPaintEvent* e)
138{ 138{
139 QPainter painter(this); 139 QPainter painter(this);
140 painter.setClipRect(e->rect()); 140 painter.setClipRect(e->rect());
141 drawKeyboard( painter ); 141 drawKeyboard( painter );
142 picks->dc->draw( &painter ); 142 picks->dc->draw( &painter );
143} 143}
144 144
145 145
146/* Keyboard::drawKeyboard {{{1 */ 146/* Keyboard::drawKeyboard {{{1 */
147 147
148void Keyboard::drawKeyboard(QPainter &p, int row, int col) 148void Keyboard::drawKeyboard(QPainter &p, int row, int col)
149{ 149{
150 QColor keycolor = 150 QColor keycolor =
151 QColor(240,240,240); 151 QColor(240,240,240);
152 QColor keycolor_pressed = QColor(171,183,198); 152 QColor keycolor_pressed = QColor(171,183,198);
153 QColor keycolor_lines = QColor(138,148,160); 153 QColor keycolor_lines = QColor(138,148,160);
154 QColor textcolor = QColor(43,54,68); 154 QColor textcolor = QColor(43,54,68);
155 155
156 156
157 if (row != -1 && col != -1) { //just redraw one key 157 if (row != -1 && col != -1) { //just redraw one key
158 158
159 int x = 0; 159 int x = 0;
160 for (int i = 0; i < col; i++) { 160 for (int i = 0; i < col; i++) {
161 161
162 x += keys->width(row, i) * defaultKeyWidth; 162 x += keys->width(row, i) * defaultKeyWidth;
163 } 163 }
164 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 164 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
165 165
166 int keyWidth = keys->width(row, col); 166 int keyWidth = keys->width(row, col);
167 167
168 p.fillRect(x + 1, y + 1, 168 p.fillRect(x + 1, y + 1,
169 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 169 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
170 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 170 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
171 171
172 QPixmap *pix = keys->pix(row,col); 172 QPixmap *pix = keys->pix(row,col);
173 173
174 ushort c = keys->uni(row, col); 174 ushort c = keys->uni(row, col);
175 175
176 if (!pix) { 176 if (!pix) {
177 p.setPen(textcolor); 177 p.setPen(textcolor);
178 p.drawText(x, y, 178 p.drawText(x, y,
179 defaultKeyWidth * keyWidth, keyHeight, 179 defaultKeyWidth * keyWidth, keyHeight,
180 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); 180 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
181 } 181 }
182 else 182 else
183 // center the image in the middle of the key 183 // center the image in the middle of the key
184 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 184 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
185 y + (keyHeight - pix->height())/2 + 1, 185 y + (keyHeight - pix->height())/2 + 1,
186 *pix ); 186 *pix );
187 187
188 // this fixes the problem that the very right end of the board's vertical line 188 // this fixes the problem that the very right end of the board's vertical line
189 // gets painted over, because it's one pixel shorter than all other keys 189 // gets painted over, because it's one pixel shorter than all other keys
190 p.setPen(keycolor_lines); 190 p.setPen(keycolor_lines);
191 p.drawLine(width() - 1, 0, width() - 1, height()); 191 p.drawLine(width() - 1, 0, width() - 1, height());
192 192
193 } else { 193 } else {
194 194
195 195
196 p.fillRect(0, 0, width(), height(), keycolor); 196 p.fillRect(0, 0, width(), height(), keycolor);
197 197
198 for (row = 1; row <= 5; row++) { 198 for (row = 1; row <= 5; row++) {
199 199
200 int x = 0; 200 int x = 0;
201 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 201 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
202 202
203 p.setPen(keycolor_lines); 203 p.setPen(keycolor_lines);
204 p.drawLine(x, y, x + width(), y); 204 p.drawLine(x, y, x + width(), y);
205 205
206 for (int col = 0; col < keys->numKeys(row); col++) { 206 for (int col = 0; col < keys->numKeys(row); col++) {
207 207
208 QPixmap *pix = keys->pix(row, col); 208 QPixmap *pix = keys->pix(row, col);
209 int keyWidth = keys->width(row, col); 209 int keyWidth = keys->width(row, col);
210 210
211 211
212 int keyWidthPix = defaultKeyWidth * keyWidth; 212 int keyWidthPix = defaultKeyWidth * keyWidth;
213 213
214 if (keys->pressed(row, col)) 214 if (keys->pressed(row, col))
215 p.fillRect(x+1, y+1, keyWidthPix - 1, 215 p.fillRect(x+1, y+1, keyWidthPix - 1,
216 keyHeight - 1, keycolor_pressed); 216 keyHeight - 1, keycolor_pressed);
217 217
218 ushort c = keys->uni(row, col); 218 ushort c = keys->uni(row, col);
219 219
220 if (!pix) { 220 if (!pix) {
221 p.setPen(textcolor); 221 p.setPen(textcolor);
222 p.drawText(x, y, 222 p.drawText(x, y,
223 keyWidthPix, keyHeight, 223 keyWidthPix, keyHeight,
224 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c); 224 AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
225 } 225 }
226 else { 226 else {
227 // center the image in the middle of the key 227 // center the image in the middle of the key
228 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 228 p.drawPixmap( x + (keyWidthPix - pix->width())/2,
229 y + (keyHeight - pix->height())/2 + 1, 229 y + (keyHeight - pix->height())/2 + 1,
230 QPixmap(*pix) ); 230 QPixmap(*pix) );
231 } 231 }
232 232
233 p.setPen(keycolor_lines); 233 p.setPen(keycolor_lines);
234 p.drawLine(x, y, x, y + keyHeight); 234 p.drawLine(x, y, x, y + keyHeight);
235 235
236 x += keyWidthPix; 236 x += keyWidthPix;
237 } 237 }
238 238
239 239
240 } 240 }
241 p.drawLine(0, height() - 1, width(), height() - 1); 241 p.drawLine(0, height() - 1, width(), height() - 1);
242 p.drawLine(width() - 1, 0, width() - 1, height()); 242 p.drawLine(width() - 1, 0, width() - 1, height());
243 } 243 }
244 244
245} 245}
246 246
247 247
248/* Keyboard::mousePressEvent {{{1 */ 248/* Keyboard::mousePressEvent {{{1 */
249void Keyboard::mousePressEvent(QMouseEvent *e) 249void Keyboard::mousePressEvent(QMouseEvent *e)
250{ 250{
251 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 251 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
252 if (row > 5) row = 5; 252 if (row > 5) row = 5;
253 253
254 // figure out the column 254 // figure out the column
255 int col = 0; 255 int col = 0;
256 for (int w = 0; e->x() >= w; col++) 256 for (int w = 0; e->x() >= w; col++)
257 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 257 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
258 w += keys->width(row,col) * defaultKeyWidth; 258 w += keys->width(row,col) * defaultKeyWidth;
259 else break; 259 else break;
260 260
261 col --; // rewind one... 261 col --; // rewind one...
262 262
263 qkeycode = keys->qcode(row, col); 263 qkeycode = keys->qcode(row, col);
264 unicode = keys->uni(row, col); 264 unicode = keys->uni(row, col);
265 265
266 // might need to repaint if two or more of the same keys. 266 // might need to repaint if two or more of the same keys.
267 // should be faster if just paint one key even though multiple keys exist. 267 // should be faster if just paint one key even though multiple keys exist.
268 bool need_repaint = FALSE; 268 bool need_repaint = FALSE;
269 269
270 if (unicode == 0) { // either Qt char, or nothing 270 if (unicode == 0) { // either Qt char, or nothing
271 271
272 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 272 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
273 273
274 if ( configdlg ) { 274 if ( configdlg ) {
275 delete (ConfigDlg *) configdlg; 275 delete (ConfigDlg *) configdlg;
276 configdlg = 0; 276 configdlg = 0;
277 } 277 }
278 else { 278 else {
279 configdlg = new ConfigDlg (); 279 configdlg = new ConfigDlg ();
280 connect(configdlg, SIGNAL(pickboardToggled(bool)), 280 connect(configdlg, SIGNAL(pickboardToggled(bool)),
281 this, SLOT(togglePickboard(bool))); 281 this, SLOT(togglePickboard(bool)));
282 connect(configdlg, SIGNAL(setMapToDefault()), 282 connect(configdlg, SIGNAL(setMapToDefault()),
283 this, SLOT(setMapToDefault())); 283 this, SLOT(setMapToDefault()));
284 connect(configdlg, SIGNAL(setMapToFile(QString)), 284 connect(configdlg, SIGNAL(setMapToFile(QString)),
285 this, SLOT(setMapToFile(QString))); 285 this, SLOT(setMapToFile(QString)));
286 configdlg->showMaximized(); 286 configdlg->showMaximized();
287 configdlg->show(); 287 configdlg->show();
288 configdlg->raise(); 288 configdlg->raise();
289 } 289 }
290 290
291 } else if (qkeycode == Qt::Key_Control) { 291 } else if (qkeycode == Qt::Key_Control) {
292 ctrl = keys->pressedPtr(row, col); 292 ctrl = keys->pressedPtr(row, col);
293 need_repaint = TRUE; 293 need_repaint = TRUE;
294 *ctrl = !keys->pressed(row, col); 294 *ctrl = !keys->pressed(row, col);
295 295
296 } else if (qkeycode == Qt::Key_Alt) { 296 } else if (qkeycode == Qt::Key_Alt) {
297 alt = keys->pressedPtr(row, col); 297 alt = keys->pressedPtr(row, col);
298 need_repaint = TRUE; 298 need_repaint = TRUE;
299 *alt = !keys->pressed(row, col); 299 *alt = !keys->pressed(row, col);
300 300
301 } else if (qkeycode == Qt::Key_Shift) { 301 } else if (qkeycode == Qt::Key_Shift) {
302 need_repaint = TRUE; 302 need_repaint = TRUE;
303 303
304 if (shift) { 304 if (shift) {
305 *shift = 0; 305 *shift = 0;
306 shift = 0; 306 shift = 0;
307 } 307 }
308 else { 308 else {
309 shift = keys->pressedPtr(row, col); 309 shift = keys->pressedPtr(row, col);
310 *shift = 1; 310 *shift = 1;
311 if (lock) { 311 if (lock) {
312 *lock = 0; 312 *lock = 0;
313 lock = 0; 313 lock = 0;
314 } 314 }
315 } 315 }
316 316
317 } else if (qkeycode == Qt::Key_CapsLock) { 317 } else if (qkeycode == Qt::Key_CapsLock) {
318 need_repaint = TRUE; 318 need_repaint = TRUE;
319 319
320 if (lock) { 320 if (lock) {
321 *lock = 0; 321 *lock = 0;