summaryrefslogtreecommitdiff
path: root/inputmethods/keyboard/keyboard.cpp
authorharlekin <harlekin>2002-05-02 10:59:23 (UTC)
committer harlekin <harlekin>2002-05-02 10:59:23 (UTC)
commit3e4ce540942b6342a00c272dac171e729ae2b08b (patch) (unidiff)
tree9251a7389328a4d581b9e1c9848f8d6dc139a555 /inputmethods/keyboard/keyboard.cpp
parent9b22572f07ec954e9dda33e99f7fc681e3c50827 (diff)
downloadopie-3e4ce540942b6342a00c272dac171e729ae2b08b.zip
opie-3e4ce540942b6342a00c272dac171e729ae2b08b.tar.gz
opie-3e4ce540942b6342a00c272dac171e729ae2b08b.tar.bz2
removed the hack that limited the bad influence of the sticky bug on ipaq, since it is not needed any more. Sticky bug is fixed in 2.4.18-rmk3 hh6
Diffstat (limited to 'inputmethods/keyboard/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/keyboard/keyboard.cpp72
1 files changed, 36 insertions, 36 deletions
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp
index a04c45a..0f0b188 100644
--- a/inputmethods/keyboard/keyboard.cpp
+++ b/inputmethods/keyboard/keyboard.cpp
@@ -41,42 +41,42 @@ Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
41 // setPalette(QPalette(QColor(240,240,230))); // Beige! 41 // setPalette(QPalette(QColor(240,240,230))); // Beige!
42 // setFont( QFont( "Helvetica", 8 ) ); 42 // setFont( QFont( "Helvetica", 8 ) );
43// setPalette(QPalette(QColor(200,200,200))); // Gray 43// setPalette(QPalette(QColor(200,200,200))); // Gray
44 setPalette(QPalette(QColor(220,220,220))); // Gray 44 setPalette(QPalette(QColor(220,220,220))); // Gray
45 45
46 picks = new KeyboardPicks( this ); 46 picks = new KeyboardPicks( this );
47 picks->setFont( QFont( "smallsmooth", 9 ) ); 47 picks->setFont( QFont( "smallsmooth", 9 ) );
48 setFont( QFont( "smallsmooth", 9 ) ); 48 setFont( QFont( "smallsmooth", 9 ) );
49 picks->initialise(); 49 picks->initialise();
50 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 50 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
51 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 51 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
52 52
53 repeatTimer = new QTimer( this ); 53 repeatTimer = new QTimer( this );
54 54
55 // temporary quick and dirty fix for the "sticky keyboard bug" 55 // temporary quick and dirty fix for the "sticky keyboard bug"
56 // on ipaq. 56 // on ipaq.
57 struct utsname name; 57// struct utsname name;
58 if (uname(&name) != -1) 58// if (uname(&name) != -1)
59 { 59 // {
60 QString release=name.release; 60 //QString release=name.release;
61 qWarning("System release: %s\n", name.release); 61 //qWarning("System release: %s\n", name.release);
62 if(release.find("embedix",0,TRUE) !=-1) 62 //if(release.find("embedix",0,TRUE) !=-1)
63 { 63 // {
64 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 64 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
65 } 65 // }
66 } 66 // }
67} 67}
68 68
69void Keyboard::resizeEvent(QResizeEvent*) 69void Keyboard::resizeEvent(QResizeEvent*)
70{ 70{
71 int ph = picks->sizeHint().height(); 71 int ph = picks->sizeHint().height();
72 picks->setGeometry( 0, 0, width(), ph ); 72 picks->setGeometry( 0, 0, width(), ph );
73 keyHeight = (height()-ph)/5; 73 keyHeight = (height()-ph)/5;
74 int nk; 74 int nk;
75 if ( useOptiKeys ) { 75 if ( useOptiKeys ) {
76 nk = 15; 76 nk = 15;
77 } else if ( useLargeKeys ) { 77 } else if ( useLargeKeys ) {
78 nk = 15; 78 nk = 15;
79 } else { 79 } else {
80 nk = 19; 80 nk = 19;
81 } 81 }
82 defaultKeyWidth = width()/nk; 82 defaultKeyWidth = width()/nk;
@@ -106,73 +106,73 @@ void KeyboardConfig::generateText(const QString &s)
106 } 106 }
107 for (int i=0; i<(int)s.length(); i++) { 107 for (int i=0; i<(int)s.length(); i++) {
108 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 108 parent->emitKey( s[i].unicode(), 0, 0, true, false );
109 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 109 parent->emitKey( s[i].unicode(), 0, 0, false, false );
110 } 110 }
111 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 111 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
112 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 112 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
113 backspaces = 0; 113 backspaces = 0;
114#endif 114#endif
115} 115}
116 116
117 117
118//PC keyboard layout and scancodes 118//PC keyboard layout and scancodes
119 119
120/* 120/*
121 Format: length, code, length, code, ..., 0 121 Format: length, code, length, code, ..., 0
122 122
123 length is measured in half the width of a standard key. 123 length is measured in half the width of a standard key.
124 If code < 0x80 we have length/2 consecutive standard keys, 124 If code < 0x80 we have length/2 consecutive standard keys,
125 starting with scancode code. 125 starting with scancode code.
126 126
127 Special keys are hardcoded, one at a time, with length of key 127 Special keys are hardcoded, one at a time, with length of key
128 and code >= 0x80, these are NOT standard PC scancodes, but are looked 128 and code >= 0x80, these are NOT standard PC scancodes, but are looked
129 up in specialM[]. (The special keys are not keymappable.) 129 up in specialM[]. (The special keys are not keymappable.)
130 130
131 */ 131 */
132 132
133static const uchar * const keyboard_opti[5] = { 133static const uchar * const keyboard_opti[5] = {
134 (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236", 134 (const uchar *const) "\001\223\003\240\002\20\002\41\002\26\002\62\002\56\002\45\002\54\003\200\001\223\002\226\002\235\002\234\002\236",
135 (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065", 135 (const uchar *const) "\001\223\003\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065",
136 (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055", 136 (const uchar *const) "\001\223\003\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055",
137 (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014", 137 (const uchar *const) "\001\223\003\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014",
138 (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230" 138 (const uchar *const) "\001\223\003\206\002\44\002\31\002\57\002\42\002\46\002\25\002\207\003\204\001\223\002\013\002\064\002\015\002\230"
139}; 139};
140 140
141 141
142static const uchar * const keyboard_standard[5] = { 142static const uchar * const keyboard_standard[5] = {
143 143
144#ifdef USE_SMALL_BACKSPACE 144#ifdef USE_SMALL_BACKSPACE
145 (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\002\200\002\223\002\215\002\216\002\217", 145 (const uchar *const)"\002\240\002`\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\002\200\002\223\002\215\002\216\002\217",
146#else 146#else
147 (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217", 147 (const uchar *const)"\002\051\0021\0022\0023\0024\0025\0026\0027\0028\0029\0020\002-\002=\004\200\002\223\002\215\002\216\002\217",
148#endif 148#endif
149 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP 149 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP
150 150
151 (const uchar *const)"\003\201\002q\002w\002e\002r\002t\002y\002u\002i\002o\002p\002[\002]\002\\\001\224\002\223\002\221\002\220\002\222", 151 (const uchar *const)"\003\201\002q\002w\002e\002r\002t\002y\002u\002i\002o\002p\002[\002]\002\\\001\224\002\223\002\221\002\220\002\222",
152 //TAB + qwerty.. + backslash //+ DEL + END + PGDN 152 //TAB + qwerty.. + backslash //+ DEL + END + PGDN
153 153
154 (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", 154 (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203",
155 //CAPS + asdf.. + RETURN 155 //CAPS + asdf.. + RETURN
156 156
157 (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", 157 (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211",
158 //SHIFT + zxcv... //+ UP 158 //SHIFT + zxcv... //+ UP
159 159
160 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" 160 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214"
161 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT 161 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT
162 162
163}; 163};
164 164
165 165
166struct ShiftMap { 166struct ShiftMap {
167 char normal; 167 char normal;
168 char shifted; 168 char shifted;
169}; 169};
170 170
171 171
172static const ShiftMap shiftMap[] = { 172static const ShiftMap shiftMap[] = {
173 { '`', '~' }, 173 { '`', '~' },
174 { '1', '!' }, 174 { '1', '!' },
175 { '2', '@' }, 175 { '2', '@' },
176 { '3', '#' }, 176 { '3', '#' },
177 { '4', '$' }, 177 { '4', '$' },
178 { '5', '%' }, 178 { '5', '%' },
@@ -381,33 +381,33 @@ static const char * const backspace_xpm[]={
381/* XPM */ 381/* XPM */
382static const char * const escape_xpm[]={ 382static const char * const escape_xpm[]={
383"9 9 2 1", 383"9 9 2 1",
384"a c #000000", 384"a c #000000",
385". c None", 385". c None",
386".........", 386".........",
387".........", 387".........",
388".aa.aa.aa", 388".aa.aa.aa",
389".a..a..a.", 389".a..a..a.",
390".aa.aa.a.", 390".aa.aa.a.",
391".a...a.a.", 391".a...a.a.",
392".aa.aa.aa", 392".aa.aa.aa",
393".........", 393".........",
394"........."}; 394"........."};
395 395
396 396
397enum { BSCode = 0x80, TabCode, CapsCode, RetCode, 397enum { BSCode = 0x80, TabCode, CapsCode, RetCode,
398 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, 398 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash,
399 UpCode, LeftCode, DownCode, RightCode, Blank, Expand, 399 UpCode, LeftCode, DownCode, RightCode, Blank, Expand,
400 Opti, ResetDict, 400 Opti, ResetDict,
401 Divide, Multiply, Add, Subtract, Decimal, Equal, 401 Divide, Multiply, Add, Subtract, Decimal, Equal,
402 Percent, Sqrt, Inverse, Escape }; 402 Percent, Sqrt, Inverse, Escape };
403 403
404typedef struct SpecialMap { 404typedef struct SpecialMap {
405 int qcode; 405 int qcode;
406 ushort unicode; 406 ushort unicode;
407 const char * label; 407 const char * label;
408 const char * const * xpm; 408 const char * const * xpm;
409}; 409};
410 410
411 411
412static const SpecialMap specialM[] = { 412static const SpecialMap specialM[] = {
413 { Qt::Key_Backspace, 8,"<", backspace_xpm }, 413 { Qt::Key_Backspace, 8,"<", backspace_xpm },
@@ -422,170 +422,170 @@ static const SpecialMap specialM[] = {
422 422
423 // Need images? 423 // Need images?
424 { Qt::Key_Up, 0,"^", uparrow_xpm }, 424 { Qt::Key_Up, 0,"^", uparrow_xpm },
425 { Qt::Key_Left, 0,"<", leftarrow_xpm }, 425 { Qt::Key_Left, 0,"<", leftarrow_xpm },
426 { Qt::Key_Down, 0,"v", downarrow_xpm }, 426 { Qt::Key_Down, 0,"v", downarrow_xpm },
427 { Qt::Key_Right, 0,">", rightarrow_xpm }, 427 { Qt::Key_Right, 0,">", rightarrow_xpm },
428 { Qt::Key_Insert, 0,"I", insert_xpm }, 428 { Qt::Key_Insert, 0,"I", insert_xpm },
429 { Qt::Key_Home, 0,"H", home_xpm }, 429 { Qt::Key_Home, 0,"H", home_xpm },
430 { Qt::Key_PageUp, 0,"U", pageup_xpm }, 430 { Qt::Key_PageUp, 0,"U", pageup_xpm },
431 { Qt::Key_End, 0,"E", end_xpm }, 431 { Qt::Key_End, 0,"E", end_xpm },
432 { Qt::Key_Delete, 0,"X", delete_xpm }, 432 { Qt::Key_Delete, 0,"X", delete_xpm },
433 { Qt::Key_PageDown, 0,"D", pagedown_xpm }, 433 { Qt::Key_PageDown, 0,"D", pagedown_xpm },
434 { Blank, 0," ", NULL }, 434 { Blank, 0," ", NULL },
435 { Expand, 0,"->", expand_xpm }, 435 { Expand, 0,"->", expand_xpm },
436 { Opti, 0,"#", NULL }, 436 { Opti, 0,"#", NULL },
437 { ResetDict, 0,"R", NULL }, 437 { ResetDict, 0,"R", NULL },
438 438
439 // number pad stuff 439 // number pad stuff
440 { Divide, 0,"/", NULL }, 440 { Divide, 0,"/", NULL },
441 { Multiply, 0,"*", NULL }, 441 { Multiply, 0,"*", NULL },
442 { Add, 0,"+", NULL }, 442 { Add, 0,"+", NULL },
443 { Subtract, 0,"-", NULL }, 443 { Subtract, 0,"-", NULL },
444 { Decimal, 0,".", NULL }, 444 { Decimal, 0,".", NULL },
445 { Equal, 0,"=", NULL }, 445 { Equal, 0,"=", NULL },
446 { Percent, 0,"%", NULL }, 446 { Percent, 0,"%", NULL },
447 { Sqrt, 0, "^1/2", NULL }, 447 { Sqrt, 0, "^1/2", NULL },
448 { Inverse, 0, "1/x", NULL }, 448 { Inverse, 0, "1/x", NULL },
449 449
450 { Escape, 27, "ESC", escape_xpm } 450 { Escape, 27, "ESC", escape_xpm }
451}; 451};
452 452
453 453
454static int keycode( int i2, int j, const uchar **keyboard ) 454static int keycode( int i2, int j, const uchar **keyboard )
455{ 455{
456 if ( j <0 || j >= 5 ) 456 if ( j <0 || j >= 5 )
457 return 0; 457 return 0;
458 458
459 const uchar *row = keyboard[j]; 459 const uchar *row = keyboard[j];
460 460
461 while ( *row && *row <= i2 ) { 461 while ( *row && *row <= i2 ) {
462 i2 -= *row; 462 i2 -= *row;
463 row += 2; 463 row += 2;
464 } 464 }
465 465
466 if ( !*row ) return 0; 466 if ( !*row ) return 0;
467 467
468 int k; 468 int k;
469 if ( row[1] >= 0x80 ) { 469 if ( row[1] >= 0x80 ) {
470 k = row[1]; 470 k = row[1];
471 } else { 471 } else {
472 k = row[1]+i2/2; 472 k = row[1]+i2/2;
473 } 473 }
474 474
475 return k; 475 return k;
476} 476}
477 477
478 478
479/* 479/*
480 return scancode and width of first key in row \a j if \a j >= 0, 480 return scancode and width of first key in row \a j if \a j >= 0,
481 or next key on current row if \a j < 0. 481 or next key on current row if \a j < 0.
482 482
483*/ 483*/
484 484
485int Keyboard::getKey( int &w, int j ) { 485int Keyboard::getKey( int &w, int j ) {
486 static const uchar *row = 0; 486 static const uchar *row = 0;
487 static int key_i = 0; 487 static int key_i = 0;
488 static int scancode = 0; 488 static int scancode = 0;
489 static int half = 0; 489 static int half = 0;
490 490
491 if ( j >= 0 && j < 5 ) { 491 if ( j >= 0 && j < 5 ) {
492 if (useOptiKeys) 492 if (useOptiKeys)
493 row = keyboard_opti[j]; 493 row = keyboard_opti[j];
494 else 494 else
495 row = keyboard_standard[j]; 495 row = keyboard_standard[j];
496 half=0; 496 half=0;
497 } 497 }
498 498
499 if ( !row || !*row ) { 499 if ( !row || !*row ) {
500 return 0; 500 return 0;
501 } else if ( row[1] >= 0x80 ) { 501 } else if ( row[1] >= 0x80 ) {
502 scancode = row[1]; 502 scancode = row[1];
503 w = (row[0] * w + (half++&1)) / 2; 503 w = (row[0] * w + (half++&1)) / 2;
504 row += 2; 504 row += 2;
505 return scancode; 505 return scancode;
506 } else if ( key_i <= 0 ) { 506 } else if ( key_i <= 0 ) {
507 key_i = row[0]/2; 507 key_i = row[0]/2;
508 scancode = row[1]; 508 scancode = row[1];
509 } 509 }
510 key_i--; 510 key_i--;
511 if ( key_i <= 0 ) 511 if ( key_i <= 0 )
512 row += 2; 512 row += 2;
513 return scancode++; 513 return scancode++;
514} 514}
515 515
516 516
517void Keyboard::paintEvent(QPaintEvent* e) 517void Keyboard::paintEvent(QPaintEvent* e)
518{ 518{
519 QPainter painter(this); 519 QPainter painter(this);
520 painter.setClipRect(e->rect()); 520 painter.setClipRect(e->rect());
521 drawKeyboard( painter ); 521 drawKeyboard( painter );
522 picks->dc->draw( &painter ); 522 picks->dc->draw( &painter );
523} 523}
524 524
525 525
526/* 526/*
527 Draw the keyboard. 527 Draw the keyboard.
528 528
529 If key >= 0, only the specified key is drawn. 529 If key >= 0, only the specified key is drawn.
530*/ 530*/
531void Keyboard::drawKeyboard( QPainter &p, int key ) 531void Keyboard::drawKeyboard( QPainter &p, int key )
532{ 532{
533 const bool threeD = FALSE; 533 const bool threeD = FALSE;
534 const QColorGroup& cg = colorGroup(); 534 const QColorGroup& cg = colorGroup();
535 QColor keycolor = // cg.background(); 535 QColor keycolor = // cg.background();
536 QColor(240,240,230); // Beige! 536 QColor(240,240,230); // Beige!
537 QColor keycolor_pressed = cg.mid(); 537 QColor keycolor_pressed = cg.mid();
538 QColor keycolor_lo = cg.dark(); 538 QColor keycolor_lo = cg.dark();
539 QColor keycolor_hi = cg.light(); 539 QColor keycolor_hi = cg.light();
540 QColor textcolor = QColor(0,0,0); // cg.text(); 540 QColor textcolor = QColor(0,0,0); // cg.text();
541 541
542 int margin = threeD ? 1 : 0; 542 int margin = threeD ? 1 : 0;
543 543
544// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); 544// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed );
545 545
546 for ( int j = 0; j < 5; j++ ) { 546 for ( int j = 0; j < 5; j++ ) {
547 int y = j * keyHeight + picks->height() + 1; 547 int y = j * keyHeight + picks->height() + 1;
548 int x = xoffs; 548 int x = xoffs;
549 int kw = defaultKeyWidth; 549 int kw = defaultKeyWidth;
550 int k= getKey( kw, j ); 550 int k= getKey( kw, j );
551 while ( k ) { 551 while ( k ) {
552 if ( key < 0 || k == key ) { 552 if ( key < 0 || k == key ) {
553 QString s; 553 QString s;
554 bool pressed = (k == pressedKey); 554 bool pressed = (k == pressedKey);
555 bool blank = (k == 0223); 555 bool blank = (k == 0223);
556 const char * const * xpm = NULL; 556 const char * const * xpm = NULL;
557 557
558 if ( k >= 0x80 ) { 558 if ( k >= 0x80 ) {
559 s = specialM[k - 0x80].label; 559 s = specialM[k - 0x80].label;
560 560
561 xpm = specialM[k - 0x80].xpm; 561 xpm = specialM[k - 0x80].xpm;
562 562
563 if ( k == ShiftCode ) { 563 if ( k == ShiftCode ) {
564 pressed = shift; 564 pressed = shift;
565 } else if ( k == CapsCode ) { 565 } else if ( k == CapsCode ) {
566 pressed = lock; 566 pressed = lock;
567 } else if ( k == CtrlCode ) { 567 } else if ( k == CtrlCode ) {
568 pressed = ctrl; 568 pressed = ctrl;
569 } else if ( k == AltCode ) { 569 } else if ( k == AltCode ) {
570 pressed = alt; 570 pressed = alt;
571 } 571 }
572 } else { 572 } else {
573#if defined(Q_WS_QWS) || defined(_WS_QWS_) 573#if defined(Q_WS_QWS) || defined(_WS_QWS_)
574/* 574/*
575 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : 575 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode :
576 QWSServer::keyMap()[k].unicode); 576 QWSServer::keyMap()[k].unicode);
577*/ 577*/
578 // ### Fixme, bad code, needs improving, whole thing needs to 578 // ### Fixme, bad code, needs improving, whole thing needs to
579 // be re-coded to get rid of the way it did things with scancodes etc 579 // be re-coded to get rid of the way it did things with scancodes etc
580 char shifted = k; 580 char shifted = k;
581 if ( !isalpha( k ) ) { 581 if ( !isalpha( k ) ) {
582 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 582 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
583 if ( shiftMap[i].normal == k ) 583 if ( shiftMap[i].normal == k )
584 shifted = shiftMap[i].shifted; 584 shifted = shiftMap[i].shifted;
585 } else { 585 } else {
586 shifted = toupper( k ); 586 shifted = toupper( k );
587 } 587 }
588 s = QChar( shift^lock ? shifted : k ); 588 s = QChar( shift^lock ? shifted : k );
589#endif 589#endif
590 } 590 }
591 591
@@ -608,42 +608,42 @@ void Keyboard::drawKeyboard( QPainter &p, int key )
608 // right 608 // right
609 p.setPen(pressed ? keycolor_hi : keycolor_lo); 609 p.setPen(pressed ? keycolor_hi : keycolor_lo);
610 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); 610 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 );
611 611
612 if ( threeD ) { 612 if ( threeD ) {
613 p.setPen(keycolor_lo.light()); 613 p.setPen(keycolor_lo.light());
614 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); 614 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 );
615 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); 615 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 );
616 } 616 }
617 617
618 if (xpm) { 618 if (xpm) {
619 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); 619 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) );
620 } else { 620 } else {
621 p.setPen(textcolor); 621 p.setPen(textcolor);
622 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); 622 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s );
623 } 623 }
624 624
625 if ( threeD ) { 625 if ( threeD ) {
626 p.setPen(keycolor_hi); 626 p.setPen(keycolor_hi);
627 p.drawLine( x, y, x+kw-1, y ); 627 p.drawLine( x, y, x+kw-1, y );
628 } 628 }
629 629
630 // bottom 630 // bottom
631 p.setPen(keycolor_lo); 631 p.setPen(keycolor_lo);
632 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); 632 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 );
633 633
634 } else { 634 } else {
635 p.fillRect( x, y, kw, keyHeight, cg.background() ); 635 p.fillRect( x, y, kw, keyHeight, cg.background() );
636 } 636 }
637 } 637 }
638 638
639 x += kw; 639 x += kw;
640 kw = defaultKeyWidth; 640 kw = defaultKeyWidth;
641 k = getKey( kw ); 641 k = getKey( kw );
642 } 642 }
643 } 643 }
644} 644}
645 645
646 646
647void Keyboard::mousePressEvent(QMouseEvent *e) 647void Keyboard::mousePressEvent(QMouseEvent *e)
648{ 648{
649 clearHighlight(); // typing fast? 649 clearHighlight(); // typing fast?
@@ -676,33 +676,33 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
676 useOptiKeys = !useOptiKeys; 676 useOptiKeys = !useOptiKeys;
677 resizeEvent(0); 677 resizeEvent(0);
678 repaint( TRUE ); // need it to clear first 678 repaint( TRUE ); // need it to clear first
679 } else { 679 } else {
680 qkeycode = specialM[ k - 0x80 ].qcode; 680 qkeycode = specialM[ k - 0x80 ].qcode;
681 unicode = specialM[ k - 0x80 ].unicode; 681 unicode = specialM[ k - 0x80 ].unicode;
682 } 682 }
683 } else { 683 } else {
684#if defined(Q_WS_QWS) || defined(_WS_QWS_) 684#if defined(Q_WS_QWS) || defined(_WS_QWS_)
685/* 685/*
686 qk = QWSServer::keyMap()[k].key_code; 686 qk = QWSServer::keyMap()[k].key_code;
687 if ( qk != Key_unknown ) { 687 if ( qk != Key_unknown ) {
688 if ( ctrl ) 688 if ( ctrl )
689 u = QWSServer::keyMap()[k].ctrl_unicode; 689 u = QWSServer::keyMap()[k].ctrl_unicode;
690 else if ( shift^lock ) 690 else if ( shift^lock )
691 u = QWSServer::keyMap()[k].shift_unicode; 691 u = QWSServer::keyMap()[k].shift_unicode;
692 else 692 else
693 u = QWSServer::keyMap()[k].unicode; 693 u = QWSServer::keyMap()[k].unicode;
694 } 694 }
695*/ 695*/
696 char shifted = k; 696 char shifted = k;
697 if ( !isalpha( k ) ) { 697 if ( !isalpha( k ) ) {
698 // ### Fixme, bad code, needs improving, whole thing needs to 698 // ### Fixme, bad code, needs improving, whole thing needs to
699 // be re-coded to get rid of the way it did things with scancodes etc 699 // be re-coded to get rid of the way it did things with scancodes etc
700 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 700 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
701 if ( shiftMap[i].normal == k ) 701 if ( shiftMap[i].normal == k )
702 shifted = shiftMap[i].shifted; 702 shifted = shiftMap[i].shifted;
703 } else { 703 } else {
704 shifted = toupper( k ); 704 shifted = toupper( k );
705 } 705 }
706 QChar tempChar( shift^lock ? shifted : k ); 706 QChar tempChar( shift^lock ? shifted : k );
707 unicode = tempChar.unicode(); 707 unicode = tempChar.unicode();
708#endif 708#endif
@@ -762,48 +762,48 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
762#endif 762#endif
763 pressed = FALSE; 763 pressed = FALSE;
764} 764}
765 765
766void Keyboard::timerEvent(QTimerEvent* e) 766void Keyboard::timerEvent(QTimerEvent* e)
767{ 767{
768 if ( e->timerId() == pressTid ) { 768 if ( e->timerId() == pressTid ) {
769 killTimer(pressTid); 769 killTimer(pressTid);
770 pressTid = 0; 770 pressTid = 0;
771 if ( !pressed ) 771 if ( !pressed )
772 clearHighlight(); 772 clearHighlight();
773 } 773 }
774} 774}
775 775
776void Keyboard::repeat() 776void Keyboard::repeat()
777{ 777{
778 778
779 repeatTimer->start( 200 ); 779 repeatTimer->start( 200 );
780 emit key( unicode, qkeycode, modifiers, true, true ); 780 emit key( unicode, qkeycode, modifiers, true, true );
781} 781}
782 782
783void Keyboard::clearHighlight() 783void Keyboard::clearHighlight()
784{ 784{
785 if ( pressedKey >= 0 ) { 785 if ( pressedKey >= 0 ) {
786 int tmp = pressedKey; 786 int tmp = pressedKey;
787 pressedKey = -1; 787 pressedKey = -1;
788 QPainter p(this); 788 QPainter p(this);
789 drawKeyboard( p, tmp ); 789 drawKeyboard( p, tmp );
790 } 790 }
791} 791}
792 792
793 793
794QSize Keyboard::sizeHint() const 794QSize Keyboard::sizeHint() const
795{ 795{
796 QFontMetrics fm=fontMetrics(); 796 QFontMetrics fm=fontMetrics();
797 int keyHeight = fm.lineSpacing()+2; 797 int keyHeight = fm.lineSpacing()+2;
798 798
799 if (useOptiKeys) 799 if (useOptiKeys)
800 keyHeight += 1; 800 keyHeight += 1;
801 801
802 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); 802 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 );
803} 803}
804 804
805 805
806void Keyboard::resetState() 806void Keyboard::resetState()
807{ 807{
808 picks->resetState(); 808 picks->resetState();
809} 809}