Diffstat (limited to 'inputmethods/dvorak/dvorak.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | inputmethods/dvorak/dvorak.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/inputmethods/dvorak/dvorak.cpp b/inputmethods/dvorak/dvorak.cpp index 29b5bd0..97afa0a 100644 --- a/inputmethods/dvorak/dvorak.cpp +++ b/inputmethods/dvorak/dvorak.cpp | |||
@@ -1,129 +1,131 @@ | |||
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 "dvorak.h" | 21 | #include "dvorak.h" |
22 | 22 | ||
23 | #include <qpe/global.h> | 23 | #include <qpe/global.h> |
24 | 24 | ||
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | 31 | ||
32 | #define USE_SMALL_BACKSPACE | 32 | #define USE_SMALL_BACKSPACE |
33 | 33 | ||
34 | using namespace Dvorak; | ||
35 | |||
34 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 36 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
35 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), | 37 | QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), |
36 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), | 38 | alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), |
37 | unicode(-1), qkeycode(0), modifiers(0) | 39 | unicode(-1), qkeycode(0), modifiers(0) |
38 | { | 40 | { |
39 | // setPalette(QPalette(QColor(240,240,230))); // Beige! | 41 | // setPalette(QPalette(QColor(240,240,230))); // Beige! |
40 | // setFont( QFont( "Helvetica", 8 ) ); | 42 | // setFont( QFont( "Helvetica", 8 ) ); |
41 | // setPalette(QPalette(QColor(200,200,200))); // Gray | 43 | // setPalette(QPalette(QColor(200,200,200))); // Gray |
42 | setPalette(QPalette(QColor(220,220,220))); // Gray | 44 | setPalette(QPalette(QColor(220,220,220))); // Gray |
43 | 45 | ||
44 | picks = new KeyboardPicks( this ); | 46 | picks = new KeyboardPicks( this ); |
45 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 47 | picks->setFont( QFont( "smallsmooth", 9 ) ); |
46 | setFont( QFont( "smallsmooth", 9 ) ); | 48 | setFont( QFont( "smallsmooth", 9 ) ); |
47 | picks->initialise(); | 49 | picks->initialise(); |
48 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
49 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
50 | 52 | ||
51 | repeatTimer = new QTimer( this ); | 53 | repeatTimer = new QTimer( this ); |
52 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 54 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
53 | } | 55 | } |
54 | 56 | ||
55 | void Keyboard::resizeEvent(QResizeEvent*) | 57 | void Keyboard::resizeEvent(QResizeEvent*) |
56 | { | 58 | { |
57 | int ph = picks->sizeHint().height(); | 59 | int ph = picks->sizeHint().height(); |
58 | picks->setGeometry( 0, 0, width(), ph ); | 60 | picks->setGeometry( 0, 0, width(), ph ); |
59 | keyHeight = (height()-ph)/5; | 61 | keyHeight = (height()-ph)/5; |
60 | int nk; | 62 | int nk; |
61 | if ( useOptiKeys ) { | 63 | if ( useOptiKeys ) { |
62 | nk = 15; | 64 | nk = 15; |
63 | } else if ( useLargeKeys ) { | 65 | } else if ( useLargeKeys ) { |
64 | nk = 15; | 66 | nk = 15; |
65 | } else { | 67 | } else { |
66 | nk = 19; | 68 | nk = 19; |
67 | } | 69 | } |
68 | defaultKeyWidth = width()/nk; | 70 | defaultKeyWidth = width()/nk; |
69 | xoffs = (width()-defaultKeyWidth*nk)/2; | 71 | xoffs = (width()-defaultKeyWidth*nk)/2; |
70 | } | 72 | } |
71 | 73 | ||
72 | void KeyboardPicks::initialise() | 74 | void KeyboardPicks::initialise() |
73 | { | 75 | { |
74 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 76 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
75 | mode = 0; | 77 | mode = 0; |
76 | dc = new KeyboardConfig(this); | 78 | dc = new KeyboardConfig(this); |
77 | configs.append(dc); | 79 | configs.append(dc); |
78 | } | 80 | } |
79 | 81 | ||
80 | QSize KeyboardPicks::sizeHint() const | 82 | QSize KeyboardPicks::sizeHint() const |
81 | { | 83 | { |
82 | return QSize(240,fontMetrics().lineSpacing()); | 84 | return QSize(240,fontMetrics().lineSpacing()); |
83 | } | 85 | } |
84 | 86 | ||
85 | 87 | ||
86 | void KeyboardConfig::generateText(const QString &s) | 88 | void KeyboardConfig::generateText(const QString &s) |
87 | { | 89 | { |
88 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 90 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
89 | for (int i=0; i<(int)backspaces; i++) { | 91 | for (int i=0; i<(int)backspaces; i++) { |
90 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); | 92 | parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); |
91 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); | 93 | parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); |
92 | } | 94 | } |
93 | for (int i=0; i<(int)s.length(); i++) { | 95 | for (int i=0; i<(int)s.length(); i++) { |
94 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 96 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
95 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 97 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
96 | } | 98 | } |
97 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); | 99 | parent->emitKey( 0, Qt::Key_Space, 0, true, false ); |
98 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); | 100 | parent->emitKey( 0, Qt::Key_Space, 0, false, false ); |
99 | backspaces = 0; | 101 | backspaces = 0; |
100 | #endif | 102 | #endif |
101 | } | 103 | } |
102 | 104 | ||
103 | 105 | ||
104 | //PC keyboard layout and scancodes | 106 | //PC keyboard layout and scancodes |
105 | 107 | ||
106 | /* | 108 | /* |
107 | Format: length, code, length, code, ..., 0 | 109 | Format: length, code, length, code, ..., 0 |
108 | 110 | ||
109 | length is measured in half the width of a standard key. | 111 | length is measured in half the width of a standard key. |
110 | If code < 0x80 we have length/2 consecutive standard keys, | 112 | If code < 0x80 we have length/2 consecutive standard keys, |
111 | starting with scancode code. | 113 | starting with scancode code. |
112 | 114 | ||
113 | Special keys are hardcoded, one at a time, with length of key | 115 | Special keys are hardcoded, one at a time, with length of key |
114 | and code >= 0x80, these are NOT standard PC scancodes, but are looked | 116 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
115 | up in specialM[]. (The special keys are not keymappable.) | 117 | up in specialM[]. (The special keys are not keymappable.) |
116 | 118 | ||
117 | */ | 119 | */ |
118 | 120 | ||
119 | static const uchar * const keyboard_opti[5] = { | 121 | static const uchar * const keyboard_opti[5] = { |
120 | (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", | 122 | (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", |
121 | (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", | 123 | (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", |
122 | (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", | 124 | (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", |
123 | (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", | 125 | (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", |
124 | (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" | 126 | (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" |
125 | }; | 127 | }; |
126 | 128 | ||
127 | static const uchar * const keyboard_standard[5] = { | 129 | static const uchar * const keyboard_standard[5] = { |
128 | 130 | ||
129 | #ifdef USE_SMALL_BACKSPACE | 131 | #ifdef USE_SMALL_BACKSPACE |