summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/dasher/SettingsStore.cpp5
-rw-r--r--inputmethods/dasher/SettingsStore.h1
-rw-r--r--inputmethods/dvorak/dvorak.cpp8
-rw-r--r--inputmethods/keyboard/keyboard.cpp10
-rw-r--r--inputmethods/multikey/keyboard.cpp10
5 files changed, 20 insertions, 14 deletions
diff --git a/inputmethods/dasher/SettingsStore.cpp b/inputmethods/dasher/SettingsStore.cpp
index f7661bd..7e0fa58 100644
--- a/inputmethods/dasher/SettingsStore.cpp
+++ b/inputmethods/dasher/SettingsStore.cpp
@@ -1,135 +1,140 @@
1// SettingsStore.cpp 1// SettingsStore.cpp
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11 11
12#include "SettingsStore.h" 12#include "SettingsStore.h"
13 13
14using namespace std; 14using namespace std;
15 15
16/* TODO: Consider using Template functions to make this neater. */ 16/* TODO: Consider using Template functions to make this neater. */
17 17
18 18
19CSettingsStore::~CSettingsStore()
20{
21}
22
23
19bool CSettingsStore::GetBoolOption(const string& Key) 24bool CSettingsStore::GetBoolOption(const string& Key)
20{ 25{
21 if (BoolMap.find(Key)==BoolMap.end()) { 26 if (BoolMap.find(Key)==BoolMap.end()) {
22 bool Value = false; 27 bool Value = false;
23 LoadSetting(Key, &Value); 28 LoadSetting(Key, &Value);
24 BoolMap[Key] = Value; 29 BoolMap[Key] = Value;
25 } 30 }
26 31
27 return BoolMap[Key]; 32 return BoolMap[Key];
28} 33}
29 34
30 35
31long CSettingsStore::GetLongOption(const string& Key) 36long CSettingsStore::GetLongOption(const string& Key)
32{ 37{
33 if (LongMap.find(Key)==LongMap.end()) { 38 if (LongMap.find(Key)==LongMap.end()) {
34 long Value = 0l; 39 long Value = 0l;
35 LoadSetting(Key, &Value); 40 LoadSetting(Key, &Value);
36 LongMap[Key] = Value; 41 LongMap[Key] = Value;
37 } 42 }
38 43
39 return LongMap[Key]; 44 return LongMap[Key];
40} 45}
41 46
42 47
43string& CSettingsStore::GetStringOption(const string& Key) 48string& CSettingsStore::GetStringOption(const string& Key)
44{ 49{
45 if (StringMap.find(Key)==StringMap.end()) { 50 if (StringMap.find(Key)==StringMap.end()) {
46 string Value = ""; 51 string Value = "";
47 LoadSetting(Key, &Value); 52 LoadSetting(Key, &Value);
48 StringMap[Key] = Value; 53 StringMap[Key] = Value;
49 } 54 }
50 55
51 return StringMap[Key]; 56 return StringMap[Key];
52} 57}
53 58
54 59
55void CSettingsStore::SetBoolOption(const string& Key, bool Value) 60void CSettingsStore::SetBoolOption(const string& Key, bool Value)
56{ 61{
57 BoolMap[Key] = Value; 62 BoolMap[Key] = Value;
58 SaveSetting(Key, Value); 63 SaveSetting(Key, Value);
59} 64}
60 65
61 66
62void CSettingsStore::SetLongOption(const string& Key, long Value) 67void CSettingsStore::SetLongOption(const string& Key, long Value)
63{ 68{
64 LongMap[Key] = Value; 69 LongMap[Key] = Value;
65 SaveSetting(Key, Value); 70 SaveSetting(Key, Value);
66} 71}
67 72
68 73
69void CSettingsStore::SetStringOption(const string& Key, const string& Value) 74void CSettingsStore::SetStringOption(const string& Key, const string& Value)
70{ 75{
71 StringMap[Key] = Value; 76 StringMap[Key] = Value;
72 SaveSetting(Key, Value); 77 SaveSetting(Key, Value);
73} 78}
74 79
75 80
76void CSettingsStore::SetBoolDefault(const string& Key, bool Value) 81void CSettingsStore::SetBoolDefault(const string& Key, bool Value)
77{ 82{
78 bool TmpValue; 83 bool TmpValue;
79 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 84 if ( (BoolMap.find(Key)==BoolMap.end()) && (!LoadSetting(Key, &TmpValue)) )
80 SetBoolOption(Key, Value); 85 SetBoolOption(Key, Value);
81} 86}
82 87
83 88
84void CSettingsStore::SetLongDefault(const string& Key, long Value) 89void CSettingsStore::SetLongDefault(const string& Key, long Value)
85{ 90{
86 long TmpValue; 91 long TmpValue;
87 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 92 if ( (LongMap.find(Key)==LongMap.end()) && (!LoadSetting(Key, &TmpValue)) )
88 SetLongOption(Key, Value); 93 SetLongOption(Key, Value);
89} 94}
90 95
91 96
92void CSettingsStore::SetStringDefault(const string& Key, const string& Value) 97void CSettingsStore::SetStringDefault(const string& Key, const string& Value)
93{ 98{
94 string TmpValue; 99 string TmpValue;
95 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) ) 100 if ( (StringMap.find(Key)==StringMap.end()) && (!LoadSetting(Key, &TmpValue)) )
96 SetStringOption(Key, Value); 101 SetStringOption(Key, Value);
97} 102}
98 103
99 104
100/* Private functions -- Settings are not saved between sessions unless these 105/* Private functions -- Settings are not saved between sessions unless these
101functions are over-ridden. 106functions are over-ridden.
102--------------------------------------------------------------------------*/ 107--------------------------------------------------------------------------*/
103 108
104 109
105bool CSettingsStore::LoadSetting(const string& , bool* ) 110bool CSettingsStore::LoadSetting(const string& , bool* )
106{ 111{
107 return false; 112 return false;
108} 113}
109 114
110 115
111bool CSettingsStore::LoadSetting(const string& , long* ) 116bool CSettingsStore::LoadSetting(const string& , long* )
112{ 117{
113 return false; 118 return false;
114} 119}
115 120
116 121
117bool CSettingsStore::LoadSetting(const string& , string* ) 122bool CSettingsStore::LoadSetting(const string& , string* )
118{ 123{
119 return false; 124 return false;
120} 125}
121 126
122 127
123void CSettingsStore::SaveSetting(const string& , bool ) 128void CSettingsStore::SaveSetting(const string& , bool )
124{ 129{
125} 130}
126 131
127 132
128void CSettingsStore::SaveSetting(const string& , long ) 133void CSettingsStore::SaveSetting(const string& , long )
129{ 134{
130} 135}
131 136
132 137
133void CSettingsStore::SaveSetting(const string& , const string& ) 138void CSettingsStore::SaveSetting(const string& , const string& )
134{ 139{
135} 140}
diff --git a/inputmethods/dasher/SettingsStore.h b/inputmethods/dasher/SettingsStore.h
index 8ef9fcf..2ddf152 100644
--- a/inputmethods/dasher/SettingsStore.h
+++ b/inputmethods/dasher/SettingsStore.h
@@ -1,92 +1,93 @@
1// SettingsStore.h 1// SettingsStore.h
2// 2//
3///////////////////////////////////////////////////////////////////////////// 3/////////////////////////////////////////////////////////////////////////////
4// 4//
5// Copyright (c) 2002 Iain Murray 5// Copyright (c) 2002 Iain Murray
6// 6//
7///////////////////////////////////////////////////////////////////////////// 7/////////////////////////////////////////////////////////////////////////////
8 8
9 9
10 10
11#ifndef __SettingsStore_h__ 11#ifndef __SettingsStore_h__
12#define __SettingsStore_h__ 12#define __SettingsStore_h__
13 13
14 14
15#include "MSVC_Unannoy.h" 15#include "MSVC_Unannoy.h"
16#include <string> 16#include <string>
17#include <map> 17#include <map>
18 18
19 19
20/* 20/*
21 The public interface uses UTF-8 strings. All Keys should be 21 The public interface uses UTF-8 strings. All Keys should be
22 in American English and encodable in ASCII. However, 22 in American English and encodable in ASCII. However,
23 string Values may contain special characters where appropriate. 23 string Values may contain special characters where appropriate.
24*/ 24*/
25 25
26 26
27class CSettingsStore 27class CSettingsStore
28{ 28{
29public: 29public:
30 virtual ~CSettingsStore();
30 bool GetBoolOption(const std::string& Key); 31 bool GetBoolOption(const std::string& Key);
31 long GetLongOption(const std::string& Key); 32 long GetLongOption(const std::string& Key);
32 std::string& GetStringOption(const std::string& Key); 33 std::string& GetStringOption(const std::string& Key);
33 34
34 void SetBoolOption(const std::string& Key, bool Value); 35 void SetBoolOption(const std::string& Key, bool Value);
35 void SetLongOption(const std::string& Key, long Value); 36 void SetLongOption(const std::string& Key, long Value);
36 void SetStringOption(const std::string& Key, const std::string& Value); 37 void SetStringOption(const std::string& Key, const std::string& Value);
37 38
38 void SetBoolDefault(const std::string& Key, bool Value); 39 void SetBoolDefault(const std::string& Key, bool Value);
39 void SetLongDefault(const std::string& Key, long Value); 40 void SetLongDefault(const std::string& Key, long Value);
40 void SetStringDefault(const std::string& Key, const std::string& Value); 41 void SetStringDefault(const std::string& Key, const std::string& Value);
41private: 42private:
42 // Platform Specific settings file management 43 // Platform Specific settings file management
43 44
44 // LoadSetting changes Value only if it succeeds in loading the setting, 45 // LoadSetting changes Value only if it succeeds in loading the setting,
45 // in which case it also returns true. Failure is indicated by returning false. 46 // in which case it also returns true. Failure is indicated by returning false.
46 //! Load a setting with a boolean value 47 //! Load a setting with a boolean value
47 // 48 //
48 //! Load a setting with a boolean value. Return true if successful 49 //! Load a setting with a boolean value. Return true if successful
49 //! \param Key Name of the setting 50 //! \param Key Name of the setting
50 //! \param Value Value of the setting 51 //! \param Value Value of the setting
51 virtual bool LoadSetting(const std::string& Key, bool* Value); 52 virtual bool LoadSetting(const std::string& Key, bool* Value);
52 53
53 //! Load a setting with a long value 54 //! Load a setting with a long value
54 // 55 //
55 //! Load a setting with a long value. Return true if successful 56 //! Load a setting with a long value. Return true if successful
56 //! \param Key Name of the setting 57 //! \param Key Name of the setting
57 //! \param Value Value of the setting 58 //! \param Value Value of the setting
58 virtual bool LoadSetting(const std::string& Key, long* Value); 59 virtual bool LoadSetting(const std::string& Key, long* Value);
59 60
60 //! Load a setting with a string value 61 //! Load a setting with a string value
61 // 62 //
62 //! Load a setting with a string value. Return true if successful 63 //! Load a setting with a string value. Return true if successful
63 //! \param Key Name of the setting 64 //! \param Key Name of the setting
64 //! \param Value Value of the setting, UTF8 encoded 65 //! \param Value Value of the setting, UTF8 encoded
65 virtual bool LoadSetting(const std::string& Key, std::string* Value); 66 virtual bool LoadSetting(const std::string& Key, std::string* Value);
66 67
67 //! Save a setting with a boolean value 68 //! Save a setting with a boolean value
68 // 69 //
69 //! \param Key Name of the setting 70 //! \param Key Name of the setting
70 //! \param Value Value of the setting 71 //! \param Value Value of the setting
71 virtual void SaveSetting(const std::string& Key, bool Value); 72 virtual void SaveSetting(const std::string& Key, bool Value);
72 73
73 //! Save a setting with a long value 74 //! Save a setting with a long value
74 // 75 //
75 //! \param Key Name of the setting 76 //! \param Key Name of the setting
76 //! \param Value Value of the setting 77 //! \param Value Value of the setting
77 virtual void SaveSetting(const std::string& Key, long Value); 78 virtual void SaveSetting(const std::string& Key, long Value);
78 79
79 //! Save a setting with a string value 80 //! Save a setting with a string value
80 // 81 //
81 //! \param Key Name of the setting 82 //! \param Key Name of the setting
82 //! \param Value Value of the setting, UTF8 encoded 83 //! \param Value Value of the setting, UTF8 encoded
83 virtual void SaveSetting(const std::string& Key, const std::string& Value); 84 virtual void SaveSetting(const std::string& Key, const std::string& Value);
84 85
85 // Used to store settings in memory 86 // Used to store settings in memory
86 std::map<std::string, bool> BoolMap; 87 std::map<std::string, bool> BoolMap;
87 std::map<std::string, long> LongMap; 88 std::map<std::string, long> LongMap;
88 std::map<std::string, std::string> StringMap; 89 std::map<std::string, std::string> StringMap;
89}; 90};
90 91
91 92
92#endif /* #ifndef __SettingsStore_h__ */ 93#endif /* #ifndef __SettingsStore_h__ */
diff --git a/inputmethods/dvorak/dvorak.cpp b/inputmethods/dvorak/dvorak.cpp
index 97afa0a..2137f22 100644
--- a/inputmethods/dvorak/dvorak.cpp
+++ b/inputmethods/dvorak/dvorak.cpp
@@ -1,612 +1,612 @@
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
34using namespace Dvorak; 34using namespace Dvorak;
35 35
36Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : 36Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) :
37 QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), 37 QFrame(parent, name, f), shift(FALSE), lock(FALSE), ctrl(FALSE),
38 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), 38 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1),
39 unicode(-1), qkeycode(0), modifiers(0) 39 unicode(-1), qkeycode(0), modifiers(0)
40{ 40{
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 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 54 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
55} 55}
56 56
57void Keyboard::resizeEvent(QResizeEvent*) 57void Keyboard::resizeEvent(QResizeEvent*)
58{ 58{
59 int ph = picks->sizeHint().height(); 59 int ph = picks->sizeHint().height();
60 picks->setGeometry( 0, 0, width(), ph ); 60 picks->setGeometry( 0, 0, width(), ph );
61 keyHeight = (height()-ph)/5; 61 keyHeight = (height()-ph)/5;
62 int nk; 62 int nk;
63 if ( useOptiKeys ) { 63 if ( useOptiKeys ) {
64 nk = 15; 64 nk = 15;
65 } else if ( useLargeKeys ) { 65 } else if ( useLargeKeys ) {
66 nk = 15; 66 nk = 15;
67 } else { 67 } else {
68 nk = 19; 68 nk = 19;
69 } 69 }
70 defaultKeyWidth = width()/nk; 70 defaultKeyWidth = width()/nk;
71 xoffs = (width()-defaultKeyWidth*nk)/2; 71 xoffs = (width()-defaultKeyWidth*nk)/2;
72} 72}
73 73
74void KeyboardPicks::initialise() 74void KeyboardPicks::initialise()
75{ 75{
76 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 76 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
77 mode = 0; 77 mode = 0;
78 dc = new KeyboardConfig(this); 78 dc = new KeyboardConfig(this);
79 configs.append(dc); 79 configs.append(dc);
80} 80}
81 81
82QSize KeyboardPicks::sizeHint() const 82QSize KeyboardPicks::sizeHint() const
83{ 83{
84 return QSize(240,fontMetrics().lineSpacing()); 84 return QSize(240,fontMetrics().lineSpacing());
85} 85}
86 86
87 87
88void KeyboardConfig::generateText(const QString &s) 88void KeyboardConfig::generateText(const QString &s)
89{ 89{
90#if defined(Q_WS_QWS) || defined(_WS_QWS_) 90#if defined(Q_WS_QWS) || defined(_WS_QWS_)
91 for (int i=0; i<(int)backspaces; i++) { 91 for (int i=0; i<(int)backspaces; i++) {
92 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 92 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
93 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 93 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
94 } 94 }
95 for (int i=0; i<(int)s.length(); i++) { 95 for (int i=0; i<(int)s.length(); i++) {
96 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 96 parent->emitKey( s[i].unicode(), 0, 0, true, false );
97 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 97 parent->emitKey( s[i].unicode(), 0, 0, false, false );
98 } 98 }
99 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 99 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
100 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 100 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
101 backspaces = 0; 101 backspaces = 0;
102#endif 102#endif
103} 103}
104 104
105 105
106//PC keyboard layout and scancodes 106//PC keyboard layout and scancodes
107 107
108/* 108/*
109 Format: length, code, length, code, ..., 0 109 Format: length, code, length, code, ..., 0
110 110
111 length is measured in half the width of a standard key. 111 length is measured in half the width of a standard key.
112 If code < 0x80 we have length/2 consecutive standard keys, 112 If code < 0x80 we have length/2 consecutive standard keys,
113 starting with scancode code. 113 starting with scancode code.
114 114
115 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
116 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
117 up in specialM[]. (The special keys are not keymappable.) 117 up in specialM[]. (The special keys are not keymappable.)
118 118
119 */ 119 */
120 120
121static const uchar * const keyboard_opti[5] = { 121static const uchar * const keyboard_opti[5] = {
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", 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",
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", 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",
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", 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",
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", 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",
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" 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"
127}; 127};
128 128
129static const uchar * const keyboard_standard[5] = { 129static const uchar * const keyboard_standard[5] = {
130 130
131#ifdef USE_SMALL_BACKSPACE 131#ifdef USE_SMALL_BACKSPACE
132 (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", 132 (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",
133#else 133#else
134 (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", 134 (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",
135#endif 135#endif
136 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP 136 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP
137 137
138 (const uchar *const)"\003\201\002'\002,\002.\002p\002y\002f\002g\002c\002r\002l\002/\002=\002\\\001\224\002\223\002\221\002\220\002\222", 138 (const uchar *const)"\003\201\002'\002,\002.\002p\002y\002f\002g\002c\002r\002l\002/\002=\002\\\001\224\002\223\002\221\002\220\002\222",
139 //TAB + qwerty.. + backslash //+ DEL + END + PGDN 139 //TAB + qwerty.. + backslash //+ DEL + END + PGDN
140 140
141 (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203", 141 (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203",
142 //CAPS + asdf.. + RETURN 142 //CAPS + asdf.. + RETURN
143 143
144 (const uchar *const)"\005\204\002;\002q\002j\002k\002x\002b\002m\002w\002v\002z\005\204\002\223\002\223\002\211", 144 (const uchar *const)"\005\204\002;\002q\002j\002k\002x\002b\002m\002w\002v\002z\005\204\002\223\002\223\002\211",
145 //SHIFT + zxcv... //+ UP 145 //SHIFT + zxcv... //+ UP
146 146
147 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" 147 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214"
148 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT 148 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT
149 149
150}; 150};
151 151
152 152
153struct ShiftMap { 153struct ShiftMap {
154 char normal; 154 char normal;
155 char shifted; 155 char shifted;
156}; 156};
157 157
158 158
159static const ShiftMap shiftMap[] = { 159static const ShiftMap shiftMap[] = {
160 { '`', '~' }, 160 { '`', '~' },
161 { '1', '!' }, 161 { '1', '!' },
162 { '2', '@' }, 162 { '2', '@' },
163 { '3', '#' }, 163 { '3', '#' },
164 { '4', '$' }, 164 { '4', '$' },
165 { '5', '%' }, 165 { '5', '%' },
166 { '6', '^' }, 166 { '6', '^' },
167 { '7', '&' }, 167 { '7', '&' },
168 { '8', '*' }, 168 { '8', '*' },
169 { '9', '(' }, 169 { '9', '(' },
170 { '0', ')' }, 170 { '0', ')' },
171 { '-', '_' }, 171 { '-', '_' },
172 { '=', '+' }, 172 { '=', '+' },
173 { '\\', '|' }, 173 { '\\', '|' },
174 { '[', '{' }, 174 { '[', '{' },
175 { ']', '}' }, 175 { ']', '}' },
176 { ';', ':' }, 176 { ';', ':' },
177 { '\'', '"' }, 177 { '\'', '"' },
178 { ',', '<' }, 178 { ',', '<' },
179 { '.', '>' }, 179 { '.', '>' },
180 { '/', '?' } 180 { '/', '?' }
181}; 181};
182 182
183 183
184/* XPM */ 184/* XPM */
185static const char * const uparrow_xpm[]={ 185static const char * const uparrow_xpm[]={
186"9 9 2 1", 186"9 9 2 1",
187"a c #000000", 187"a c #000000",
188". c None", 188". c None",
189".........", 189".........",
190"....a....", 190"....a....",
191"...aaa...", 191"...aaa...",
192"..aaaaa..", 192"..aaaaa..",
193"....a....", 193"....a....",
194"....a....", 194"....a....",
195"....a....", 195"....a....",
196"....a....", 196"....a....",
197"........."}; 197"........."};
198/* XPM */ 198/* XPM */
199static const char * const leftarrow_xpm[]={ 199static const char * const leftarrow_xpm[]={
200"9 9 2 1", 200"9 9 2 1",
201"a c #000000", 201"a c #000000",
202". c None", 202". c None",
203".........", 203".........",
204".........", 204".........",
205"...a.....", 205"...a.....",
206"..aa.....", 206"..aa.....",
207".aaaaaaa.", 207".aaaaaaa.",
208"..aa.....", 208"..aa.....",
209"...a.....", 209"...a.....",
210".........", 210".........",
211"........."}; 211"........."};
212/* XPM */ 212/* XPM */
213static const char * const downarrow_xpm[]={ 213static const char * const downarrow_xpm[]={
214"9 9 2 1", 214"9 9 2 1",
215"a c #000000", 215"a c #000000",
216". c None", 216". c None",
217".........", 217".........",
218"....a....", 218"....a....",
219"....a....", 219"....a....",
220"....a....", 220"....a....",
221"....a....", 221"....a....",
222"..aaaaa..", 222"..aaaaa..",
223"...aaa...", 223"...aaa...",
224"....a....", 224"....a....",
225"........."}; 225"........."};
226/* XPM */ 226/* XPM */
227static const char * const rightarrow_xpm[]={ 227static const char * const rightarrow_xpm[]={
228"9 9 2 1", 228"9 9 2 1",
229"a c #000000", 229"a c #000000",
230". c None", 230". c None",
231".........", 231".........",
232".........", 232".........",
233".....a...", 233".....a...",
234".....aa..", 234".....aa..",
235".aaaaaaa.", 235".aaaaaaa.",
236".....aa..", 236".....aa..",
237".....a...", 237".....a...",
238".........", 238".........",
239"........."}; 239"........."};
240/* XPM */ 240/* XPM */
241static const char * const insert_xpm[]={ 241static const char * const insert_xpm[]={
242"9 9 2 1", 242"9 9 2 1",
243"a c #000000", 243"a c #000000",
244". c None", 244". c None",
245".........", 245".........",
246"a........", 246"a........",
247"a.aaa.aaa", 247"a.aaa.aaa",
248"a.a.a.a..", 248"a.a.a.a..",
249"a.a.a..a.", 249"a.a.a..a.",
250"a.a.a...a", 250"a.a.a...a",
251"a.a.a.aaa", 251"a.a.a.aaa",
252".........", 252".........",
253"........."}; 253"........."};
254/* XPM */ 254/* XPM */
255static const char * const delete_xpm[]={ 255static const char * const delete_xpm[]={
256"9 9 2 1", 256"9 9 2 1",
257"a c #000000", 257"a c #000000",
258". c None", 258". c None",
259".........", 259".........",
260"aa......a", 260"aa......a",
261"a.a.aaa.a", 261"a.a.aaa.a",
262"a.a.a.a.a", 262"a.a.a.a.a",
263"a.a.aaa.a.", 263"a.a.aaa.a.",
264"a.a.a...a", 264"a.a.a...a",
265"aaa.aaa.a", 265"aaa.aaa.a",
266".........", 266".........",
267"........."}; 267"........."};
268/* XPM */ 268/* XPM */
269static const char * const home_xpm[]={ 269static const char * const home_xpm[]={
270"9 9 2 1", 270"9 9 2 1",
271"a c #000000", 271"a c #000000",
272". c None", 272". c None",
273"....a....", 273"....a....",
274"...a.a...", 274"...a.a...",
275"..a...a..", 275"..a...a..",
276".a.....a.", 276".a.....a.",
277"aa.aaa.aa", 277"aa.aaa.aa",
278".a.a.a.a.", 278".a.a.a.a.",
279".a.a.a.a.", 279".a.a.a.a.",
280".aaaaaaa.", 280".aaaaaaa.",
281"........."}; 281"........."};
282/* XPM */ 282/* XPM */
283static const char * const end_xpm[]={ 283static const char * const end_xpm[]={
284"10 9 2 1", 284"10 9 2 1",
285"a c #000000", 285"a c #000000",
286". c None", 286". c None",
287"..........", 287"..........",
288"aa.......a", 288"aa.......a",
289"a..aaa.aaa", 289"a..aaa.aaa",
290"aa.a.a.a.a", 290"aa.a.a.a.a",
291"a..a.a.a.a", 291"a..a.a.a.a",
292"a..a.a.a.a", 292"a..a.a.a.a",
293"aa.a.a.aaa", 293"aa.a.a.aaa",
294"..........", 294"..........",
295".........."}; 295".........."};
296/* XPM */ 296/* XPM */
297static const char * const pageup_xpm[]={ 297static const char * const pageup_xpm[]={
298"9 9 2 1", 298"9 9 2 1",
299"a c #000000", 299"a c #000000",
300". c None", 300". c None",
301".aaa.aaa.", 301".aaa.aaa.",
302".a.a.a.a.", 302".a.a.a.a.",
303".aaa..aa.", 303".aaa..aa.",
304".a...aaa.", 304".a...aaa.",
305".........", 305".........",
306".a.a.aaa.", 306".a.a.aaa.",
307".a.a.a.a.", 307".a.a.a.a.",
308".aaa.aaa.", 308".aaa.aaa.",
309".....a..."}; 309".....a..."};
310/* XPM */ 310/* XPM */
311static const char * const pagedown_xpm[]={ 311static const char * const pagedown_xpm[]={
312"9 9 2 1", 312"9 9 2 1",
313"a c #000000", 313"a c #000000",
314". c None", 314". c None",
315".aaa.aaa.", 315".aaa.aaa.",
316".a.a.a.a.", 316".a.a.a.a.",
317".aaa..aa.", 317".aaa..aa.",
318".a...aaa.", 318".a...aaa.",
319".........", 319".........",
320"...a.....", 320"...a.....",
321".aaa.aaa.", 321".aaa.aaa.",
322".a.a.a.a.", 322".a.a.a.a.",
323".aaa.a.a."}; 323".aaa.a.a."};
324/* XPM */ 324/* XPM */
325static const char * const expand_xpm[]={ 325static const char * const expand_xpm[]={
326"4 9 2 1", 326"4 9 2 1",
327"a c #408040", 327"a c #408040",
328". c None", 328". c None",
329"a...", 329"a...",
330"aa..", 330"aa..",
331"aaa.", 331"aaa.",
332"aaaa", 332"aaaa",
333"aaaa", 333"aaaa",
334"aaaa", 334"aaaa",
335"aaa.", 335"aaa.",
336"aa..", 336"aa..",
337"a..."}; 337"a..."};
338/* XPM */ 338/* XPM */
339#ifdef USE_SMALL_BACKSPACE 339#ifdef USE_SMALL_BACKSPACE
340static const char * const backspace_xpm[]={ 340static const char * const backspace_xpm[]={
341"9 9 2 1", 341"9 9 2 1",
342"a c #000000", 342"a c #000000",
343". c None", 343". c None",
344".........", 344".........",
345".........", 345".........",
346"...a.....", 346"...a.....",
347"..aa.....", 347"..aa.....",
348".aaaaaaaa", 348".aaaaaaaa",
349"..aa.....", 349"..aa.....",
350"...a.....", 350"...a.....",
351".........", 351".........",
352"........."}; 352"........."};
353#else 353#else
354static const char * const backspace_xpm[]={ 354static const char * const backspace_xpm[]={
355"21 9 2 1", 355"21 9 2 1",
356"a c #000000", 356"a c #000000",
357". c None", 357". c None",
358".....................", 358".....................",
359".....................", 359".....................",
360".....aaa..a..........", 360".....aaa..a..........",
361".a...a..a.a.a.aaa.aaa", 361".a...a..a.a.a.aaa.aaa",
362"aaaa.aaa..aa..aa..a.a", 362"aaaa.aaa..aa..aa..a.a",
363".a...a..a.aaa..aa.a.a", 363".a...a..a.aaa..aa.a.a",
364".....aaaa.a.a.aaa.aa.", 364".....aaaa.a.a.aaa.aa.",
365"..................a..", 365"..................a..",
366"....................."}; 366"....................."};
367#endif 367#endif
368/* XPM */ 368/* XPM */
369static const char * const escape_xpm[]={ 369static const char * const escape_xpm[]={
370"9 9 2 1", 370"9 9 2 1",
371"a c #000000", 371"a c #000000",
372". c None", 372". c None",
373".........", 373".........",
374".........", 374".........",
375".aa.aa.aa", 375".aa.aa.aa",
376".a..a..a.", 376".a..a..a.",
377".aa.aa.a.", 377".aa.aa.a.",
378".a...a.a.", 378".a...a.a.",
379".aa.aa.aa", 379".aa.aa.aa",
380".........", 380".........",
381"........."}; 381"........."};
382 382
383 383
384enum { BSCode = 0x80, TabCode, CapsCode, RetCode, 384enum { BSCode = 0x80, TabCode, CapsCode, RetCode,
385 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, 385 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash,
386 UpCode, LeftCode, DownCode, RightCode, Blank, Expand, 386 UpCode, LeftCode, DownCode, RightCode, Blank, Expand,
387 Opti, ResetDict, 387 Opti, ResetDict,
388 Divide, Multiply, Add, Subtract, Decimal, Equal, 388 Divide, Multiply, Add, Subtract, Decimal, Equal,
389 Percent, Sqrt, Inverse, Escape }; 389 Percent, Sqrt, Inverse, Escape };
390 390
391typedef struct SpecialMap { 391typedef struct SpecialMap {
392 int qcode; 392 int qcode;
393 ushort unicode; 393 ushort unicode;
394 const char * label; 394 const char * label;
395 const char * const * xpm; 395 const char * const * xpm;
396}; 396};
397 397
398 398
399static const SpecialMap specialM[] = { 399static const SpecialMap specialM[] = {
400 { Qt::Key_Backspace, 8,"<", backspace_xpm }, 400 { Qt::Key_Backspace, 8,"<", backspace_xpm },
401 { Qt::Key_Tab, 9,"Tab", NULL }, 401 { Qt::Key_Tab, 9,"Tab", NULL },
402 { Qt::Key_CapsLock, 0,"Caps", NULL }, 402 { Qt::Key_CapsLock, 0,"Caps", NULL },
403 { Qt::Key_Return, 13,"Ret", NULL }, 403 { Qt::Key_Return, 13,"Ret", NULL },
404 { Qt::Key_Shift, 0,"Shift", NULL }, 404 { Qt::Key_Shift, 0,"Shift", NULL },
405 { Qt::Key_Control, 0,"Ctrl", NULL }, 405 { Qt::Key_Control, 0,"Ctrl", NULL },
406 { Qt::Key_Alt, 0,"Alt", NULL }, 406 { Qt::Key_Alt, 0,"Alt", NULL },
407 { Qt::Key_Space, ' ',"", NULL }, 407 { Qt::Key_Space, ' ',"", NULL },
408 { BackSlash, 43,"\\", NULL }, 408 { BackSlash, 43,"\\", NULL },
409 409
410 // Need images? 410 // Need images?
411 { Qt::Key_Up, 0,"^", uparrow_xpm }, 411 { Qt::Key_Up, 0,"^", uparrow_xpm },
412 { Qt::Key_Left, 0,"<", leftarrow_xpm }, 412 { Qt::Key_Left, 0,"<", leftarrow_xpm },
413 { Qt::Key_Down, 0,"v", downarrow_xpm }, 413 { Qt::Key_Down, 0,"v", downarrow_xpm },
414 { Qt::Key_Right, 0,">", rightarrow_xpm }, 414 { Qt::Key_Right, 0,">", rightarrow_xpm },
415 { Qt::Key_Insert, 0,"I", insert_xpm }, 415 { Qt::Key_Insert, 0,"I", insert_xpm },
416 { Qt::Key_Home, 0,"H", home_xpm }, 416 { Qt::Key_Home, 0,"H", home_xpm },
417 { Qt::Key_PageUp, 0,"U", pageup_xpm }, 417 { Qt::Key_PageUp, 0,"U", pageup_xpm },
418 { Qt::Key_End, 0,"E", end_xpm }, 418 { Qt::Key_End, 0,"E", end_xpm },
419 { Qt::Key_Delete, 0,"X", delete_xpm }, 419 { Qt::Key_Delete, 0,"X", delete_xpm },
420 { Qt::Key_PageDown, 0,"D", pagedown_xpm }, 420 { Qt::Key_PageDown, 0,"D", pagedown_xpm },
421 { Blank, 0," ", NULL }, 421 { Blank, 0," ", NULL },
422 { Expand, 0,"->", expand_xpm }, 422 { Expand, 0,"->", expand_xpm },
423 { Opti, 0,"#", NULL }, 423 { Opti, 0,"#", NULL },
424 { ResetDict, 0,"R", NULL }, 424 { ResetDict, 0,"R", NULL },
425 425
426 // number pad stuff 426 // number pad stuff
427 { Divide, 0,"/", NULL }, 427 { Divide, 0,"/", NULL },
428 { Multiply, 0,"*", NULL }, 428 { Multiply, 0,"*", NULL },
429 { Add, 0,"+", NULL }, 429 { Add, 0,"+", NULL },
430 { Subtract, 0,"-", NULL }, 430 { Subtract, 0,"-", NULL },
431 { Decimal, 0,".", NULL }, 431 { Decimal, 0,".", NULL },
432 { Equal, 0,"=", NULL }, 432 { Equal, 0,"=", NULL },
433 { Percent, 0,"%", NULL }, 433 { Percent, 0,"%", NULL },
434 { Sqrt, 0, "^1/2", NULL }, 434 { Sqrt, 0, "^1/2", NULL },
435 { Inverse, 0, "1/x", NULL }, 435 { Inverse, 0, "1/x", NULL },
436 436
437 { Escape, 27, "ESC", escape_xpm } 437 { Escape, 27, "ESC", escape_xpm }
438}; 438};
439 439
440 440
441static int keycode( int i2, int j, const uchar **keyboard ) 441static int keycode( int i2, int j, const uchar **keyboard )
442{ 442{
443 if ( j <0 || j >= 5 ) 443 if ( j <0 || j >= 5 )
444 return 0; 444 return 0;
445 445
446 const uchar *row = keyboard[j]; 446 const uchar *row = keyboard[j];
447 447
448 while ( *row && *row <= i2 ) { 448 while ( *row && *row <= i2 ) {
449 i2 -= *row; 449 i2 -= *row;
450 row += 2; 450 row += 2;
451 } 451 }
452 452
453 if ( !*row ) return 0; 453 if ( !*row ) return 0;
454 454
455 int k; 455 int k;
456 if ( row[1] >= 0x80 ) { 456 if ( row[1] >= 0x80 ) {
457 k = row[1]; 457 k = row[1];
458 } else { 458 } else {
459 k = row[1]+i2/2; 459 k = row[1]+i2/2;
460 } 460 }
461 461
462 return k; 462 return k;
463} 463}
464 464
465 465
466/* 466/*
467 return scancode and width of first key in row \a j if \a j >= 0, 467 return scancode and width of first key in row \a j if \a j >= 0,
468 or next key on current row if \a j < 0. 468 or next key on current row if \a j < 0.
469 469
470*/ 470*/
471 471
472int Keyboard::getKey( int &w, int j ) { 472int Keyboard::getKey( int &w, int j ) {
473 static const uchar *row = 0; 473 static const uchar *row = 0;
474 static int key_i = 0; 474 static int key_i = 0;
475 static int scancode = 0; 475 static int scancode = 0;
476 static int half = 0; 476 static int half = 0;
477 477
478 if ( j >= 0 && j < 5 ) { 478 if ( j >= 0 && j < 5 ) {
479 if (useOptiKeys) 479 if (useOptiKeys)
480 row = keyboard_opti[j]; 480 row = keyboard_opti[j];
481 else 481 else
482 row = keyboard_standard[j]; 482 row = keyboard_standard[j];
483 half=0; 483 half=0;
484 } 484 }
485 485
486 if ( !row || !*row ) { 486 if ( !row || !*row ) {
487 return 0; 487 return 0;
488 } else if ( row[1] >= 0x80 ) { 488 } else if ( row[1] >= 0x80 ) {
489 scancode = row[1]; 489 scancode = row[1];
490 w = (row[0] * w + (half++&1)) / 2; 490 w = (row[0] * w + (half++&1)) / 2;
491 row += 2; 491 row += 2;
492 return scancode; 492 return scancode;
493 } else if ( key_i <= 0 ) { 493 } else if ( key_i <= 0 ) {
494 key_i = row[0]/2; 494 key_i = row[0]/2;
495 scancode = row[1]; 495 scancode = row[1];
496 } 496 }
497 key_i--; 497 key_i--;
498 if ( key_i <= 0 ) 498 if ( key_i <= 0 )
499 row += 2; 499 row += 2;
500 return scancode++; 500 return scancode++;
501} 501}
502 502
503 503
504void Keyboard::paintEvent(QPaintEvent* e) 504void Keyboard::paintEvent(QPaintEvent* e)
505{ 505{
506 QPainter painter(this); 506 QPainter painter(this);
507 painter.setClipRect(e->rect()); 507 painter.setClipRect(e->rect());
508 drawKeyboard( painter ); 508 drawKeyboard( painter );
509 picks->dc->draw( &painter ); 509 picks->dc->draw( &painter );
510} 510}
511 511
512 512
513/* 513/*
514 Draw the keyboard. 514 Draw the keyboard.
515 515
516 If key >= 0, only the specified key is drawn. 516 If key >= 0, only the specified key is drawn.
517*/ 517*/
518void Keyboard::drawKeyboard( QPainter &p, int key ) 518void Keyboard::drawKeyboard( QPainter &p, int key )
519{ 519{
520 const bool threeD = FALSE; 520 const bool threeD = FALSE;
521 const QColorGroup& cg = colorGroup(); 521 const QColorGroup& cg = colorGroup();
522 QColor keycolor = // cg.background(); 522 QColor keycolor = // cg.background();
523 QColor(240,240,230); // Beige! 523 QColor(240,240,230); // Beige!
524 QColor keycolor_pressed = cg.mid(); 524 QColor keycolor_pressed = cg.mid();
525 QColor keycolor_lo = cg.dark(); 525 QColor keycolor_lo = cg.dark();
526 QColor keycolor_hi = cg.light(); 526 QColor keycolor_hi = cg.light();
527 QColor textcolor = QColor(0,0,0); // cg.text(); 527 QColor textcolor = QColor(0,0,0); // cg.text();
528 528
529 int margin = threeD ? 1 : 0; 529 int margin = threeD ? 1 : 0;
530 530
531// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); 531// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed );
532 532
533 for ( int j = 0; j < 5; j++ ) { 533 for ( int j = 0; j < 5; j++ ) {
534 int y = j * keyHeight + picks->height() + 1; 534 int y = j * keyHeight + picks->height() + 1;
535 int x = xoffs; 535 int x = xoffs;
536 int kw = defaultKeyWidth; 536 int kw = defaultKeyWidth;
537 int k= getKey( kw, j ); 537 int k= getKey( kw, j );
538 while ( k ) { 538 while ( k ) {
539 if ( key < 0 || k == key ) { 539 if ( key < 0 || k == key ) {
540 QString s; 540 QString s;
541 bool pressed = (k == pressedKey); 541 bool pressed = (k == pressedKey);
542 bool blank = (k == 0223); 542 bool blank = (k == 0223);
543 const char * const * xpm = NULL; 543 const char * const * xpm = NULL;
544 544
545 if ( k >= 0x80 ) { 545 if ( k >= 0x80 ) {
546 s = specialM[k - 0x80].label; 546 s = specialM[k - 0x80].label;
547 547
548 xpm = specialM[k - 0x80].xpm; 548 xpm = specialM[k - 0x80].xpm;
549 549
550 if ( k == ShiftCode ) { 550 if ( k == ShiftCode ) {
551 pressed = shift; 551 pressed = shift;
552 } else if ( k == CapsCode ) { 552 } else if ( k == CapsCode ) {
553 pressed = lock; 553 pressed = lock;
554 } else if ( k == CtrlCode ) { 554 } else if ( k == CtrlCode ) {
555 pressed = ctrl; 555 pressed = ctrl;
556 } else if ( k == AltCode ) { 556 } else if ( k == AltCode ) {
557 pressed = alt; 557 pressed = alt;
558 } 558 }
559 } else { 559 } else {
560#if defined(Q_WS_QWS) || defined(_WS_QWS_) 560#if defined(Q_WS_QWS) || defined(_WS_QWS_)
561/* 561/*
562 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : 562 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode :
563 QWSServer::keyMap()[k].unicode); 563 QWSServer::keyMap()[k].unicode);
564*/ 564*/
565 // ### Fixme, bad code, needs improving, whole thing needs to 565 // ### Fixme, bad code, needs improving, whole thing needs to
566 // be re-coded to get rid of the way it did things with scancodes etc 566 // be re-coded to get rid of the way it did things with scancodes etc
567 char shifted = k; 567 char shifted = k;
568 if ( !isalpha( k ) ) { 568 if ( !isalpha( k ) ) {
569 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 569 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
570 if ( shiftMap[i].normal == k ) 570 if ( shiftMap[i].normal == k )
571 shifted = shiftMap[i].shifted; 571 shifted = shiftMap[i].shifted;
572 } else { 572 } else {
573 shifted = toupper( k ); 573 shifted = toupper( k );
574 } 574 }
575 s = QChar( shift^lock ? shifted : k ); 575 s = QChar( shift^lock ? shifted : k );
576#endif 576#endif
577 } 577 }
578 578
579 if (!blank) { 579 if (!blank) {
580 if ( pressed ) 580 if ( pressed )
581 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); 581 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed );
582 else 582 else
583 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); 583 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor );
584 584
585 if ( threeD ) { 585 if ( threeD ) {
586 p.setPen(pressed ? keycolor_lo : keycolor_hi); 586 p.setPen(pressed ? keycolor_lo : keycolor_hi);
587 p.drawLine( x, y+1, x, y+keyHeight-2 ); 587 p.drawLine( x, y+1, x, y+keyHeight-2 );
588 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); 588 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 );
589 p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); 589 p.drawLine( x+1, y+1, x+1+kw-2, y+1 );
590 } else if ( j == 0 ) { 590 } else if ( j == 0 ) {
591 p.setPen(pressed ? keycolor_hi : keycolor_lo); 591 p.setPen(pressed ? keycolor_hi : keycolor_lo);
592 p.drawLine( x, y, x+kw, y ); 592 p.drawLine( x, y, x+kw, y );
593 } 593 }
594 594
595 // right 595 // right
596 p.setPen(pressed ? keycolor_hi : keycolor_lo); 596 p.setPen(pressed ? keycolor_hi : keycolor_lo);
597 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); 597 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 );
598 598
599 if ( threeD ) { 599 if ( threeD ) {
600 p.setPen(keycolor_lo.light()); 600 p.setPen(keycolor_lo.light());
601 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); 601 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 );
602 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); 602 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 );
603 } 603 }
604 604
605 if (xpm) { 605 if (xpm) {
606 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); 606 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) );
607 } else { 607 } else {
608 p.setPen(textcolor); 608 p.setPen(textcolor);
609 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); 609 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s );
610 } 610 }
611 611
612 if ( threeD ) { 612 if ( threeD ) {
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp
index a85a7b1..fb88f2a 100644
--- a/inputmethods/keyboard/keyboard.cpp
+++ b/inputmethods/keyboard/keyboard.cpp
@@ -1,625 +1,625 @@
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 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#include <sys/utsname.h> 31#include <sys/utsname.h>
32 32
33using namespace KeyboardInput; 33using namespace KeyboardInput;
34 34
35#define USE_SMALL_BACKSPACE 35#define USE_SMALL_BACKSPACE
36 36
37Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 37Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
38 QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE), 38 QFrame(parent, _name, f), shift(FALSE), lock(FALSE), ctrl(FALSE),
39 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1), 39 alt(FALSE), useLargeKeys(TRUE), useOptiKeys(0), pressedKey(-1),
40 unicode(-1), qkeycode(0), modifiers(0) 40 unicode(-1), qkeycode(0), modifiers(0)
41{ 41{
42 // setPalette(QPalette(QColor(240,240,230))); // Beige! 42 // setPalette(QPalette(QColor(240,240,230))); // Beige!
43 // setFont( QFont( "Helvetica", 8 ) ); 43 // setFont( QFont( "Helvetica", 8 ) );
44// setPalette(QPalette(QColor(200,200,200))); // Gray 44// setPalette(QPalette(QColor(200,200,200))); // Gray
45 setPalette(QPalette(QColor(220,220,220))); // Gray 45 setPalette(QPalette(QColor(220,220,220))); // Gray
46 46
47 picks = new KeyboardPicks( this ); 47 picks = new KeyboardPicks( this );
48 picks->setFont( QFont( "smallsmooth", 9 ) ); 48 picks->setFont( QFont( "smallsmooth", 9 ) );
49 setFont( QFont( "smallsmooth", 9 ) ); 49 setFont( QFont( "smallsmooth", 9 ) );
50 picks->initialise(); 50 picks->initialise();
51 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 51 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
52 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 52 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
53 53
54 repeatTimer = new QTimer( this ); 54 repeatTimer = new QTimer( this );
55 55
56 // temporary quick and dirty fix for the "sticky keyboard bug" 56 // temporary quick and dirty fix for the "sticky keyboard bug"
57 // on ipaq. 57 // on ipaq.
58// struct utsname name; 58// struct utsname name;
59// if (uname(&name) != -1) 59// if (uname(&name) != -1)
60 // { 60 // {
61 //QString release=name.release; 61 //QString release=name.release;
62 //qWarning("System release: %s\n", name.release); 62 //qWarning("System release: %s\n", name.release);
63 //if(release.find("embedix",0,TRUE) !=-1) 63 //if(release.find("embedix",0,TRUE) !=-1)
64 // { 64 // {
65 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 65 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
66 // } 66 // }
67 // } 67 // }
68} 68}
69 69
70void Keyboard::resizeEvent(QResizeEvent*) 70void Keyboard::resizeEvent(QResizeEvent*)
71{ 71{
72 int ph = picks->sizeHint().height(); 72 int ph = picks->sizeHint().height();
73 picks->setGeometry( 0, 0, width(), ph ); 73 picks->setGeometry( 0, 0, width(), ph );
74 keyHeight = (height()-ph)/5; 74 keyHeight = (height()-ph)/5;
75 int nk; 75 int nk;
76 if ( useOptiKeys ) { 76 if ( useOptiKeys ) {
77 nk = 15; 77 nk = 15;
78 } else if ( useLargeKeys ) { 78 } else if ( useLargeKeys ) {
79 nk = 15; 79 nk = 15;
80 } else { 80 } else {
81 nk = 19; 81 nk = 19;
82 } 82 }
83 defaultKeyWidth = width()/nk; 83 defaultKeyWidth = width()/nk;
84 xoffs = (width()-defaultKeyWidth*nk)/2; 84 xoffs = (width()-defaultKeyWidth*nk)/2;
85} 85}
86 86
87void KeyboardPicks::initialise() 87void KeyboardPicks::initialise()
88{ 88{
89 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 89 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
90 mode = 0; 90 mode = 0;
91 dc = new KeyboardConfig(this); 91 dc = new KeyboardConfig(this);
92 configs.append(dc); 92 configs.append(dc);
93} 93}
94 94
95QSize KeyboardPicks::sizeHint() const 95QSize KeyboardPicks::sizeHint() const
96{ 96{
97 return QSize(240,fontMetrics().lineSpacing()); 97 return QSize(240,fontMetrics().lineSpacing());
98} 98}
99 99
100 100
101void KeyboardConfig::generateText(const QString &s) 101void KeyboardConfig::generateText(const QString &s)
102{ 102{
103#if defined(Q_WS_QWS) || defined(_WS_QWS_) 103#if defined(Q_WS_QWS) || defined(_WS_QWS_)
104 for (int i=0; i<(int)backspaces; i++) { 104 for (int i=0; i<(int)backspaces; i++) {
105 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 105 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
106 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 106 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
107 } 107 }
108 for (int i=0; i<(int)s.length(); i++) { 108 for (int i=0; i<(int)s.length(); i++) {
109 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 109 parent->emitKey( s[i].unicode(), 0, 0, true, false );
110 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 110 parent->emitKey( s[i].unicode(), 0, 0, false, false );
111 } 111 }
112 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 112 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
113 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 113 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
114 backspaces = 0; 114 backspaces = 0;
115#endif 115#endif
116} 116}
117 117
118 118
119//PC keyboard layout and scancodes 119//PC keyboard layout and scancodes
120 120
121/* 121/*
122 Format: length, code, length, code, ..., 0 122 Format: length, code, length, code, ..., 0
123 123
124 length is measured in half the width of a standard key. 124 length is measured in half the width of a standard key.
125 If code < 0x80 we have length/2 consecutive standard keys, 125 If code < 0x80 we have length/2 consecutive standard keys,
126 starting with scancode code. 126 starting with scancode code.
127 127
128 Special keys are hardcoded, one at a time, with length of key 128 Special keys are hardcoded, one at a time, with length of key
129 and code >= 0x80, these are NOT standard PC scancodes, but are looked 129 and code >= 0x80, these are NOT standard PC scancodes, but are looked
130 up in specialM[]. (The special keys are not keymappable.) 130 up in specialM[]. (The special keys are not keymappable.)
131 131
132 */ 132 */
133 133
134static const uchar * const keyboard_opti[5] = { 134static const uchar * const keyboard_opti[5] = {
135 (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\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",
136 (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\201\004\207\002\30\002\24\002\43\004\207\003\203\001\223\006\002\002\065",
137 (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\202\002\60\002\37\002\23\002\22\002\36\002\21\002\55\003\203\001\223\006\005\002\055",
138 (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\205\004\207\002\27\002\61\002\40\004\207\003\204\001\223\006\010\002\014",
139 (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 (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"
140}; 140};
141 141
142 142
143static const uchar * const keyboard_standard[5] = { 143static const uchar * const keyboard_standard[5] = {
144 144
145#ifdef USE_SMALL_BACKSPACE 145#ifdef USE_SMALL_BACKSPACE
146 (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 (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",
147#else 147#else
148 (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 (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",
149#endif 149#endif
150 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP 150 //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP
151 151
152 (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 (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",
153 //TAB + qwerty.. + backslash //+ DEL + END + PGDN 153 //TAB + qwerty.. + backslash //+ DEL + END + PGDN
154 154
155 (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", 155 (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203",
156 //CAPS + asdf.. + RETURN 156 //CAPS + asdf.. + RETURN
157 157
158 (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", 158 (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211",
159 //SHIFT + zxcv... //+ UP 159 //SHIFT + zxcv... //+ UP
160 160
161 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" 161 (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214"
162 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT 162 //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT
163 163
164}; 164};
165 165
166 166
167struct ShiftMap { 167struct ShiftMap {
168 char normal; 168 char normal;
169 char shifted; 169 char shifted;
170}; 170};
171 171
172 172
173static const ShiftMap shiftMap[] = { 173static const ShiftMap shiftMap[] = {
174 { '`', '~' }, 174 { '`', '~' },
175 { '1', '!' }, 175 { '1', '!' },
176 { '2', '@' }, 176 { '2', '@' },
177 { '3', '#' }, 177 { '3', '#' },
178 { '4', '$' }, 178 { '4', '$' },
179 { '5', '%' }, 179 { '5', '%' },
180 { '6', '^' }, 180 { '6', '^' },
181 { '7', '&' }, 181 { '7', '&' },
182 { '8', '*' }, 182 { '8', '*' },
183 { '9', '(' }, 183 { '9', '(' },
184 { '0', ')' }, 184 { '0', ')' },
185 { '-', '_' }, 185 { '-', '_' },
186 { '=', '+' }, 186 { '=', '+' },
187 { '\\', '|' }, 187 { '\\', '|' },
188 { '[', '{' }, 188 { '[', '{' },
189 { ']', '}' }, 189 { ']', '}' },
190 { ';', ':' }, 190 { ';', ':' },
191 { '\'', '"' }, 191 { '\'', '"' },
192 { ',', '<' }, 192 { ',', '<' },
193 { '.', '>' }, 193 { '.', '>' },
194 { '/', '?' } 194 { '/', '?' }
195}; 195};
196 196
197 197
198/* XPM */ 198/* XPM */
199static const char * const uparrow_xpm[]={ 199static const char * const uparrow_xpm[]={
200"9 9 2 1", 200"9 9 2 1",
201"a c #000000", 201"a c #000000",
202". c None", 202". c None",
203".........", 203".........",
204"....a....", 204"....a....",
205"...aaa...", 205"...aaa...",
206"..aaaaa..", 206"..aaaaa..",
207"....a....", 207"....a....",
208"....a....", 208"....a....",
209"....a....", 209"....a....",
210"....a....", 210"....a....",
211"........."}; 211"........."};
212/* XPM */ 212/* XPM */
213static const char * const leftarrow_xpm[]={ 213static const char * const leftarrow_xpm[]={
214"9 9 2 1", 214"9 9 2 1",
215"a c #000000", 215"a c #000000",
216". c None", 216". c None",
217".........", 217".........",
218".........", 218".........",
219"...a.....", 219"...a.....",
220"..aa.....", 220"..aa.....",
221".aaaaaaa.", 221".aaaaaaa.",
222"..aa.....", 222"..aa.....",
223"...a.....", 223"...a.....",
224".........", 224".........",
225"........."}; 225"........."};
226/* XPM */ 226/* XPM */
227static const char * const downarrow_xpm[]={ 227static const char * const downarrow_xpm[]={
228"9 9 2 1", 228"9 9 2 1",
229"a c #000000", 229"a c #000000",
230". c None", 230". c None",
231".........", 231".........",
232"....a....", 232"....a....",
233"....a....", 233"....a....",
234"....a....", 234"....a....",
235"....a....", 235"....a....",
236"..aaaaa..", 236"..aaaaa..",
237"...aaa...", 237"...aaa...",
238"....a....", 238"....a....",
239"........."}; 239"........."};
240/* XPM */ 240/* XPM */
241static const char * const rightarrow_xpm[]={ 241static const char * const rightarrow_xpm[]={
242"9 9 2 1", 242"9 9 2 1",
243"a c #000000", 243"a c #000000",
244". c None", 244". c None",
245".........", 245".........",
246".........", 246".........",
247".....a...", 247".....a...",
248".....aa..", 248".....aa..",
249".aaaaaaa.", 249".aaaaaaa.",
250".....aa..", 250".....aa..",
251".....a...", 251".....a...",
252".........", 252".........",
253"........."}; 253"........."};
254/* XPM */ 254/* XPM */
255static const char * const insert_xpm[]={ 255static const char * const insert_xpm[]={
256"9 9 2 1", 256"9 9 2 1",
257"a c #000000", 257"a c #000000",
258". c None", 258". c None",
259".........", 259".........",
260"a........", 260"a........",
261"a.aaa.aaa", 261"a.aaa.aaa",
262"a.a.a.a..", 262"a.a.a.a..",
263"a.a.a..a.", 263"a.a.a..a.",
264"a.a.a...a", 264"a.a.a...a",
265"a.a.a.aaa", 265"a.a.a.aaa",
266".........", 266".........",
267"........."}; 267"........."};
268/* XPM */ 268/* XPM */
269static const char * const delete_xpm[]={ 269static const char * const delete_xpm[]={
270"9 9 2 1", 270"9 9 2 1",
271"a c #000000", 271"a c #000000",
272". c None", 272". c None",
273".........", 273".........",
274"aa......a", 274"aa......a",
275"a.a.aaa.a", 275"a.a.aaa.a",
276"a.a.a.a.a", 276"a.a.a.a.a",
277"a.a.aaa.a.", 277"a.a.aaa.a.",
278"a.a.a...a", 278"a.a.a...a",
279"aaa.aaa.a", 279"aaa.aaa.a",
280".........", 280".........",
281"........."}; 281"........."};
282/* XPM */ 282/* XPM */
283static const char * const home_xpm[]={ 283static const char * const home_xpm[]={
284"9 9 2 1", 284"9 9 2 1",
285"a c #000000", 285"a c #000000",
286". c None", 286". c None",
287"....a....", 287"....a....",
288"...a.a...", 288"...a.a...",
289"..a...a..", 289"..a...a..",
290".a.....a.", 290".a.....a.",
291"aa.aaa.aa", 291"aa.aaa.aa",
292".a.a.a.a.", 292".a.a.a.a.",
293".a.a.a.a.", 293".a.a.a.a.",
294".aaaaaaa.", 294".aaaaaaa.",
295"........."}; 295"........."};
296/* XPM */ 296/* XPM */
297static const char * const end_xpm[]={ 297static const char * const end_xpm[]={
298"10 9 2 1", 298"10 9 2 1",
299"a c #000000", 299"a c #000000",
300". c None", 300". c None",
301"..........", 301"..........",
302"aa.......a", 302"aa.......a",
303"a..aaa.aaa", 303"a..aaa.aaa",
304"aa.a.a.a.a", 304"aa.a.a.a.a",
305"a..a.a.a.a", 305"a..a.a.a.a",
306"a..a.a.a.a", 306"a..a.a.a.a",
307"aa.a.a.aaa", 307"aa.a.a.aaa",
308"..........", 308"..........",
309".........."}; 309".........."};
310/* XPM */ 310/* XPM */
311static const char * const pageup_xpm[]={ 311static const char * const pageup_xpm[]={
312"9 9 2 1", 312"9 9 2 1",
313"a c #000000", 313"a c #000000",
314". c None", 314". c None",
315".aaa.aaa.", 315".aaa.aaa.",
316".a.a.a.a.", 316".a.a.a.a.",
317".aaa..aa.", 317".aaa..aa.",
318".a...aaa.", 318".a...aaa.",
319".........", 319".........",
320".a.a.aaa.", 320".a.a.aaa.",
321".a.a.a.a.", 321".a.a.a.a.",
322".aaa.aaa.", 322".aaa.aaa.",
323".....a..."}; 323".....a..."};
324/* XPM */ 324/* XPM */
325static const char * const pagedown_xpm[]={ 325static const char * const pagedown_xpm[]={
326"9 9 2 1", 326"9 9 2 1",
327"a c #000000", 327"a c #000000",
328". c None", 328". c None",
329".aaa.aaa.", 329".aaa.aaa.",
330".a.a.a.a.", 330".a.a.a.a.",
331".aaa..aa.", 331".aaa..aa.",
332".a...aaa.", 332".a...aaa.",
333".........", 333".........",
334"...a.....", 334"...a.....",
335".aaa.aaa.", 335".aaa.aaa.",
336".a.a.a.a.", 336".a.a.a.a.",
337".aaa.a.a."}; 337".aaa.a.a."};
338/* XPM */ 338/* XPM */
339static const char * const expand_xpm[]={ 339static const char * const expand_xpm[]={
340"4 9 2 1", 340"4 9 2 1",
341"a c #408040", 341"a c #408040",
342". c None", 342". c None",
343"a...", 343"a...",
344"aa..", 344"aa..",
345"aaa.", 345"aaa.",
346"aaaa", 346"aaaa",
347"aaaa", 347"aaaa",
348"aaaa", 348"aaaa",
349"aaa.", 349"aaa.",
350"aa..", 350"aa..",
351"a..."}; 351"a..."};
352/* XPM */ 352/* XPM */
353#ifdef USE_SMALL_BACKSPACE 353#ifdef USE_SMALL_BACKSPACE
354static const char * const backspace_xpm[]={ 354static const char * const backspace_xpm[]={
355"9 9 2 1", 355"9 9 2 1",
356"a c #000000", 356"a c #000000",
357". c None", 357". c None",
358".........", 358".........",
359".........", 359".........",
360"...a.....", 360"...a.....",
361"..aa.....", 361"..aa.....",
362".aaaaaaaa", 362".aaaaaaaa",
363"..aa.....", 363"..aa.....",
364"...a.....", 364"...a.....",
365".........", 365".........",
366"........."}; 366"........."};
367#else 367#else
368static const char * const backspace_xpm[]={ 368static const char * const backspace_xpm[]={
369"21 9 2 1", 369"21 9 2 1",
370"a c #000000", 370"a c #000000",
371". c None", 371". c None",
372".....................", 372".....................",
373".....................", 373".....................",
374".....aaa..a..........", 374".....aaa..a..........",
375".a...a..a.a.a.aaa.aaa", 375".a...a..a.a.a.aaa.aaa",
376"aaaa.aaa..aa..aa..a.a", 376"aaaa.aaa..aa..aa..a.a",
377".a...a..a.aaa..aa.a.a", 377".a...a..a.aaa..aa.a.a",
378".....aaaa.a.a.aaa.aa.", 378".....aaaa.a.a.aaa.aa.",
379"..................a..", 379"..................a..",
380"....................."}; 380"....................."};
381#endif 381#endif
382/* XPM */ 382/* XPM */
383static const char * const escape_xpm[]={ 383static const char * const escape_xpm[]={
384"9 9 2 1", 384"9 9 2 1",
385"a c #000000", 385"a c #000000",
386". c None", 386". c None",
387".........", 387".........",
388".........", 388".........",
389".aa.aa.aa", 389".aa.aa.aa",
390".a..a..a.", 390".a..a..a.",
391".aa.aa.a.", 391".aa.aa.a.",
392".a...a.a.", 392".a...a.a.",
393".aa.aa.aa", 393".aa.aa.aa",
394".........", 394".........",
395"........."}; 395"........."};
396 396
397 397
398enum { BSCode = 0x80, TabCode, CapsCode, RetCode, 398enum { BSCode = 0x80, TabCode, CapsCode, RetCode,
399 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, 399 ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash,
400 UpCode, LeftCode, DownCode, RightCode, Blank, Expand, 400 UpCode, LeftCode, DownCode, RightCode, Blank, Expand,
401 Opti, ResetDict, 401 Opti, ResetDict,
402 Divide, Multiply, Add, Subtract, Decimal, Equal, 402 Divide, Multiply, Add, Subtract, Decimal, Equal,
403 Percent, Sqrt, Inverse, Escape }; 403 Percent, Sqrt, Inverse, Escape };
404 404
405typedef struct SpecialMap { 405typedef struct SpecialMap {
406 int qcode; 406 int qcode;
407 ushort unicode; 407 ushort unicode;
408 const char * label; 408 const char * label;
409 const char * const * xpm; 409 const char * const * xpm;
410}; 410};
411 411
412 412
413static const SpecialMap specialM[] = { 413static const SpecialMap specialM[] = {
414 { Qt::Key_Backspace, 8,"<", backspace_xpm }, 414 { Qt::Key_Backspace, 8,"<", backspace_xpm },
415 { Qt::Key_Tab, 9,"Tab", NULL }, 415 { Qt::Key_Tab, 9,"Tab", NULL },
416 { Qt::Key_CapsLock, 0,"Caps", NULL }, 416 { Qt::Key_CapsLock, 0,"Caps", NULL },
417 { Qt::Key_Return, 13,"Ret", NULL }, 417 { Qt::Key_Return, 13,"Ret", NULL },
418 { Qt::Key_Shift, 0,"Shift", NULL }, 418 { Qt::Key_Shift, 0,"Shift", NULL },
419 { Qt::Key_Control, 0,"Ctrl", NULL }, 419 { Qt::Key_Control, 0,"Ctrl", NULL },
420 { Qt::Key_Alt, 0,"Alt", NULL }, 420 { Qt::Key_Alt, 0,"Alt", NULL },
421 { Qt::Key_Space, ' ',"", NULL }, 421 { Qt::Key_Space, ' ',"", NULL },
422 { BackSlash, 43,"\\", NULL }, 422 { BackSlash, 43,"\\", NULL },
423 423
424 // Need images? 424 // Need images?
425 { Qt::Key_Up, 0,"^", uparrow_xpm }, 425 { Qt::Key_Up, 0,"^", uparrow_xpm },
426 { Qt::Key_Left, 0,"<", leftarrow_xpm }, 426 { Qt::Key_Left, 0,"<", leftarrow_xpm },
427 { Qt::Key_Down, 0,"v", downarrow_xpm }, 427 { Qt::Key_Down, 0,"v", downarrow_xpm },
428 { Qt::Key_Right, 0,">", rightarrow_xpm }, 428 { Qt::Key_Right, 0,">", rightarrow_xpm },
429 { Qt::Key_Insert, 0,"I", insert_xpm }, 429 { Qt::Key_Insert, 0,"I", insert_xpm },
430 { Qt::Key_Home, 0,"H", home_xpm }, 430 { Qt::Key_Home, 0,"H", home_xpm },
431 { Qt::Key_PageUp, 0,"U", pageup_xpm }, 431 { Qt::Key_PageUp, 0,"U", pageup_xpm },
432 { Qt::Key_End, 0,"E", end_xpm }, 432 { Qt::Key_End, 0,"E", end_xpm },
433 { Qt::Key_Delete, 0,"X", delete_xpm }, 433 { Qt::Key_Delete, 0,"X", delete_xpm },
434 { Qt::Key_PageDown, 0,"D", pagedown_xpm }, 434 { Qt::Key_PageDown, 0,"D", pagedown_xpm },
435 { Blank, 0," ", NULL }, 435 { Blank, 0," ", NULL },
436 { Expand, 0,"->", expand_xpm }, 436 { Expand, 0,"->", expand_xpm },
437 { Opti, 0,"#", NULL }, 437 { Opti, 0,"#", NULL },
438 { ResetDict, 0,"R", NULL }, 438 { ResetDict, 0,"R", NULL },
439 439
440 // number pad stuff 440 // number pad stuff
441 { Divide, 0,"/", NULL }, 441 { Divide, 0,"/", NULL },
442 { Multiply, 0,"*", NULL }, 442 { Multiply, 0,"*", NULL },
443 { Add, 0,"+", NULL }, 443 { Add, 0,"+", NULL },
444 { Subtract, 0,"-", NULL }, 444 { Subtract, 0,"-", NULL },
445 { Decimal, 0,".", NULL }, 445 { Decimal, 0,".", NULL },
446 { Equal, 0,"=", NULL }, 446 { Equal, 0,"=", NULL },
447 { Percent, 0,"%", NULL }, 447 { Percent, 0,"%", NULL },
448 { Sqrt, 0, "^1/2", NULL }, 448 { Sqrt, 0, "^1/2", NULL },
449 { Inverse, 0, "1/x", NULL }, 449 { Inverse, 0, "1/x", NULL },
450 450
451 { Escape, 27, "ESC", escape_xpm } 451 { Escape, 27, "ESC", escape_xpm }
452}; 452};
453 453
454 454
455static int keycode( int i2, int j, const uchar **keyboard ) 455static int keycode( int i2, int j, const uchar **keyboard )
456{ 456{
457 if ( j <0 || j >= 5 ) 457 if ( j <0 || j >= 5 )
458 return 0; 458 return 0;
459 459
460 const uchar *row = keyboard[j]; 460 const uchar *row = keyboard[j];
461 461
462 while ( *row && *row <= i2 ) { 462 while ( *row && *row <= i2 ) {
463 i2 -= *row; 463 i2 -= *row;
464 row += 2; 464 row += 2;
465 } 465 }
466 466
467 if ( !*row ) return 0; 467 if ( !*row ) return 0;
468 468
469 int k; 469 int k;
470 if ( row[1] >= 0x80 ) { 470 if ( row[1] >= 0x80 ) {
471 k = row[1]; 471 k = row[1];
472 } else { 472 } else {
473 k = row[1]+i2/2; 473 k = row[1]+i2/2;
474 } 474 }
475 475
476 return k; 476 return k;
477} 477}
478 478
479 479
480/* 480/*
481 return scancode and width of first key in row \a j if \a j >= 0, 481 return scancode and width of first key in row \a j if \a j >= 0,
482 or next key on current row if \a j < 0. 482 or next key on current row if \a j < 0.
483 483
484*/ 484*/
485 485
486int Keyboard::getKey( int &w, int j ) { 486int Keyboard::getKey( int &w, int j ) {
487 static const uchar *row = 0; 487 static const uchar *row = 0;
488 static int key_i = 0; 488 static int key_i = 0;
489 static int scancode = 0; 489 static int scancode = 0;
490 static int half = 0; 490 static int half = 0;
491 491
492 if ( j >= 0 && j < 5 ) { 492 if ( j >= 0 && j < 5 ) {
493 if (useOptiKeys) 493 if (useOptiKeys)
494 row = keyboard_opti[j]; 494 row = keyboard_opti[j];
495 else 495 else
496 row = keyboard_standard[j]; 496 row = keyboard_standard[j];
497 half=0; 497 half=0;
498 } 498 }
499 499
500 if ( !row || !*row ) { 500 if ( !row || !*row ) {
501 return 0; 501 return 0;
502 } else if ( row[1] >= 0x80 ) { 502 } else if ( row[1] >= 0x80 ) {
503 scancode = row[1]; 503 scancode = row[1];
504 w = (row[0] * w + (half++&1)) / 2; 504 w = (row[0] * w + (half++&1)) / 2;
505 row += 2; 505 row += 2;
506 return scancode; 506 return scancode;
507 } else if ( key_i <= 0 ) { 507 } else if ( key_i <= 0 ) {
508 key_i = row[0]/2; 508 key_i = row[0]/2;
509 scancode = row[1]; 509 scancode = row[1];
510 } 510 }
511 key_i--; 511 key_i--;
512 if ( key_i <= 0 ) 512 if ( key_i <= 0 )
513 row += 2; 513 row += 2;
514 return scancode++; 514 return scancode++;
515} 515}
516 516
517 517
518void Keyboard::paintEvent(QPaintEvent* e) 518void Keyboard::paintEvent(QPaintEvent* e)
519{ 519{
520 QPainter painter(this); 520 QPainter painter(this);
521 painter.setClipRect(e->rect()); 521 painter.setClipRect(e->rect());
522 drawKeyboard( painter ); 522 drawKeyboard( painter );
523 picks->dc->draw( &painter ); 523 picks->dc->draw( &painter );
524} 524}
525 525
526 526
527/* 527/*
528 Draw the keyboard. 528 Draw the keyboard.
529 529
530 If key >= 0, only the specified key is drawn. 530 If key >= 0, only the specified key is drawn.
531*/ 531*/
532void Keyboard::drawKeyboard( QPainter &p, int key ) 532void Keyboard::drawKeyboard( QPainter &p, int key )
533{ 533{
534 const bool threeD = FALSE; 534 const bool threeD = FALSE;
535 const QColorGroup& cg = colorGroup(); 535 const QColorGroup& cg = colorGroup();
536 QColor keycolor = // cg.background(); 536 QColor keycolor = // cg.background();
537 QColor(240,240,230); // Beige! 537 QColor(240,240,230); // Beige!
538 QColor keycolor_pressed = cg.mid(); 538 QColor keycolor_pressed = cg.mid();
539 QColor keycolor_lo = cg.dark(); 539 QColor keycolor_lo = cg.dark();
540 QColor keycolor_hi = cg.light(); 540 QColor keycolor_hi = cg.light();
541 QColor textcolor = QColor(0,0,0); // cg.text(); 541 QColor textcolor = QColor(0,0,0); // cg.text();
542 542
543 int margin = threeD ? 1 : 0; 543 int margin = threeD ? 1 : 0;
544 544
545// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); 545// p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed );
546 546
547 for ( int j = 0; j < 5; j++ ) { 547 for ( int j = 0; j < 5; j++ ) {
548 int y = j * keyHeight + picks->height() + 1; 548 int y = j * keyHeight + picks->height() + 1;
549 int x = xoffs; 549 int x = xoffs;
550 int kw = defaultKeyWidth; 550 int kw = defaultKeyWidth;
551 int k= getKey( kw, j ); 551 int k= getKey( kw, j );
552 while ( k ) { 552 while ( k ) {
553 if ( key < 0 || k == key ) { 553 if ( key < 0 || k == key ) {
554 QString s; 554 QString s;
555 bool pressed = (k == pressedKey); 555 bool pressed = (k == pressedKey);
556 bool blank = (k == 0223); 556 bool blank = (k == 0223);
557 const char * const * xpm = NULL; 557 const char * const * xpm = NULL;
558 558
559 if ( k >= 0x80 ) { 559 if ( k >= 0x80 ) {
560 s = specialM[k - 0x80].label; 560 s = specialM[k - 0x80].label;
561 561
562 xpm = specialM[k - 0x80].xpm; 562 xpm = specialM[k - 0x80].xpm;
563 563
564 if ( k == ShiftCode ) { 564 if ( k == ShiftCode ) {
565 pressed = shift; 565 pressed = shift;
566 } else if ( k == CapsCode ) { 566 } else if ( k == CapsCode ) {
567 pressed = lock; 567 pressed = lock;
568 } else if ( k == CtrlCode ) { 568 } else if ( k == CtrlCode ) {
569 pressed = ctrl; 569 pressed = ctrl;
570 } else if ( k == AltCode ) { 570 } else if ( k == AltCode ) {
571 pressed = alt; 571 pressed = alt;
572 } 572 }
573 } else { 573 } else {
574#if defined(Q_WS_QWS) || defined(_WS_QWS_) 574#if defined(Q_WS_QWS) || defined(_WS_QWS_)
575/* 575/*
576 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : 576 s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode :
577 QWSServer::keyMap()[k].unicode); 577 QWSServer::keyMap()[k].unicode);
578*/ 578*/
579 // ### Fixme, bad code, needs improving, whole thing needs to 579 // ### Fixme, bad code, needs improving, whole thing needs to
580 // be re-coded to get rid of the way it did things with scancodes etc 580 // be re-coded to get rid of the way it did things with scancodes etc
581 char shifted = k; 581 char shifted = k;
582 if ( !isalpha( k ) ) { 582 if ( !isalpha( k ) ) {
583 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 583 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
584 if ( shiftMap[i].normal == k ) 584 if ( shiftMap[i].normal == k )
585 shifted = shiftMap[i].shifted; 585 shifted = shiftMap[i].shifted;
586 } else { 586 } else {
587 shifted = toupper( k ); 587 shifted = toupper( k );
588 } 588 }
589 s = QChar( shift^lock ? shifted : k ); 589 s = QChar( shift^lock ? shifted : k );
590#endif 590#endif
591 } 591 }
592 592
593 if (!blank) { 593 if (!blank) {
594 if ( pressed ) 594 if ( pressed )
595 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); 595 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed );
596 else 596 else
597 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); 597 p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor );
598 598
599 if ( threeD ) { 599 if ( threeD ) {
600 p.setPen(pressed ? keycolor_lo : keycolor_hi); 600 p.setPen(pressed ? keycolor_lo : keycolor_hi);
601 p.drawLine( x, y+1, x, y+keyHeight-2 ); 601 p.drawLine( x, y+1, x, y+keyHeight-2 );
602 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); 602 p.drawLine( x+1, y+1, x+1, y+keyHeight-3 );
603 p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); 603 p.drawLine( x+1, y+1, x+1+kw-2, y+1 );
604 } else if ( j == 0 ) { 604 } else if ( j == 0 ) {
605 p.setPen(pressed ? keycolor_hi : keycolor_lo); 605 p.setPen(pressed ? keycolor_hi : keycolor_lo);
606 p.drawLine( x, y, x+kw, y ); 606 p.drawLine( x, y, x+kw, y );
607 } 607 }
608 608
609 // right 609 // right
610 p.setPen(pressed ? keycolor_hi : keycolor_lo); 610 p.setPen(pressed ? keycolor_hi : keycolor_lo);
611 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); 611 p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 );
612 612
613 if ( threeD ) { 613 if ( threeD ) {
614 p.setPen(keycolor_lo.light()); 614 p.setPen(keycolor_lo.light());
615 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); 615 p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 );
616 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); 616 p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 );
617 } 617 }
618 618
619 if (xpm) { 619 if (xpm) {
620 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); 620 p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) );
621 } else { 621 } else {
622 p.setPen(textcolor); 622 p.setPen(textcolor);
623 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); 623 p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s );
624 } 624 }
625 625
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4f4f25f..7ddfd3e 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -1,670 +1,670 @@
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 <qdir.h> 34#include <qdir.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37 37
38#include <sys/utsname.h> 38#include <sys/utsname.h>
39 39
40using namespace MultiKey; 40using namespace MultiKey;
41 41
42static const char * const kb_config_xpm[] = { 42static const char * const kb_config_xpm[] = {
43"13 7 2 1", 43"13 7 2 1",
44" c None", 44" c None",
45". c #000000", 45". c #000000",
46" ", 46" ",
47" . ", 47" . ",
48" ... ", 48" ... ",
49" ..... ", 49" ..... ",
50" . ", 50" . ",
51" . ", 51" . ",
52" "}; 52" "};
53 53
54/* Keyboard::Keyboard {{{1 */ 54/* Keyboard::Keyboard {{{1 */
55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 55Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), 56 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0), 57 meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
58 useLargeKeys(TRUE), usePicks(0), useRepeat(0), 58 useLargeKeys(TRUE), usePicks(0), useRepeat(0),
59 pressedKeyRow(-1), pressedKeyCol(-1), 59 pressedKeyRow(-1), pressedKeyCol(-1),
60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 60 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
61 configdlg(0) 61 configdlg(0)
62 62
63{ 63{
64 64
65 // get the default font 65 // get the default font
66 Config *config = new Config( "qpe" ); 66 Config *config = new Config( "qpe" );
67 config->setGroup( "Appearance" ); 67 config->setGroup( "Appearance" );
68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); 68 QString familyStr = config->readEntry( "FontFamily", "smallsmooth" );
69 delete config; 69 delete config;
70 70
71 config = new Config("multikey"); 71 config = new Config("multikey");
72 config->setGroup ("general"); 72 config->setGroup ("general");
73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed 73 usePicks = config->readBoolEntry ("usePickboard", 0); // default closed
74 useRepeat = config->readBoolEntry ("useRepeat", 1); 74 useRepeat = config->readBoolEntry ("useRepeat", 1);
75 delete config; 75 delete config;
76 76
77 77
78 setFont( QFont( familyStr, 10 ) ); 78 setFont( QFont( familyStr, 10 ) );
79 79
80 picks = new KeyboardPicks( this ); 80 picks = new KeyboardPicks( this );
81 picks->setFont( QFont( familyStr, 10 ) ); 81 picks->setFont( QFont( familyStr, 10 ) );
82 picks->initialise(); 82 picks->initialise();
83 if (usePicks) { 83 if (usePicks) {
84 84
85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 85 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 86 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
87 87
88 } else picks->hide(); 88 } else picks->hide();
89 89
90 loadKeyboardColors(); 90 loadKeyboardColors();
91 91
92 keys = new Keys(); 92 keys = new Keys();
93 93
94 repeatTimer = new QTimer( this ); 94 repeatTimer = new QTimer( this );
95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 95 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
96 96
97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this); 97 QCopChannel* kbdChannel = new QCopChannel("MultiKey/Keyboard", this);
98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)), 98 connect(kbdChannel, SIGNAL(received(const QCString&,const QByteArray&)),
99 this, SLOT(receive(const QCString&,const QByteArray&))); 99 this, SLOT(receive(const QCString&,const QByteArray&)));
100} 100}
101 101
102Keyboard::~Keyboard() { 102Keyboard::~Keyboard() {
103 103
104 if ( configdlg ) { 104 if ( configdlg ) {
105 delete configdlg; 105 delete configdlg;
106 configdlg = 0; 106 configdlg = 0;
107 } 107 }
108 108
109} 109}
110 110
111/* Keyboard::resizeEvent {{{1 */ 111/* Keyboard::resizeEvent {{{1 */
112void Keyboard::resizeEvent(QResizeEvent*) 112void Keyboard::resizeEvent(QResizeEvent*)
113{ 113{
114 int ph = picks->sizeHint().height(); 114 int ph = picks->sizeHint().height();
115 picks->setGeometry( 0, 0, width(), ph ); 115 picks->setGeometry( 0, 0, width(), ph );
116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1); 116 keyHeight = (height()-(usePicks ? ph : 0))/(keys->rows()?keys->rows():1);
117 117
118 int nk; // number of keys? 118 int nk; // number of keys?
119 if ( useLargeKeys ) { 119 if ( useLargeKeys ) {
120 nk = 15; 120 nk = 15;
121 } else { 121 } else {
122 nk = 19; 122 nk = 19;
123 } 123 }
124 defaultKeyWidth = (width()/nk)/2; 124 defaultKeyWidth = (width()/nk)/2;
125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 125 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
126 126
127} 127}
128 128
129/* KeyboardPicks::initialize {{{1 */ 129/* KeyboardPicks::initialize {{{1 */
130void KeyboardPicks::initialise() 130void KeyboardPicks::initialise()
131{ 131{
132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 132 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
133 mode = 0; 133 mode = 0;
134 dc = new KeyboardConfig(this); 134 dc = new KeyboardConfig(this);
135 configs.append(dc); 135 configs.append(dc);
136} 136}
137 137
138/* KeyboardPicks::sizeHint {{{1 */ 138/* KeyboardPicks::sizeHint {{{1 */
139QSize KeyboardPicks::sizeHint() const 139QSize KeyboardPicks::sizeHint() const
140{ 140{
141 return QSize(240,fontMetrics().lineSpacing()); 141 return QSize(240,fontMetrics().lineSpacing());
142} 142}
143 143
144 144
145/* KeyboardConfig::generateText {{{1 */ 145/* KeyboardConfig::generateText {{{1 */
146void KeyboardConfig::generateText(const QString &s) 146void KeyboardConfig::generateText(const QString &s)
147{ 147{
148#if defined(Q_WS_QWS) || defined(_WS_QWS_) 148#if defined(Q_WS_QWS) || defined(_WS_QWS_)
149 for (int i=0; i<(int)backspaces; i++) { 149 for (int i=0; i<(int)backspaces; i++) {
150 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 150 parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false );
151 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 151 parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false );
152 } 152 }
153 for (int i=0; i<(int)s.length(); i++) { 153 for (int i=0; i<(int)s.length(); i++) {
154 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 154 parent->emitKey( s[i].unicode(), 0, 0, true, false );
155 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 155 parent->emitKey( s[i].unicode(), 0, 0, false, false );
156 } 156 }
157 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 157 parent->emitKey( 0, ::Qt::Key_Space, 0, true, false );
158 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 158 parent->emitKey( 0, ::Qt::Key_Space, 0, false, false );
159 backspaces = 0; 159 backspaces = 0;
160#endif 160#endif
161} 161}
162 162
163 163
164 164
165 165
166/* Keyboard::paintEvent {{{1 */ 166/* Keyboard::paintEvent {{{1 */
167void Keyboard::paintEvent(QPaintEvent* e) 167void Keyboard::paintEvent(QPaintEvent* e)
168{ 168{
169 QPainter painter(this); 169 QPainter painter(this);
170 painter.setClipRect(e->rect()); 170 painter.setClipRect(e->rect());
171 drawKeyboard( painter ); 171 drawKeyboard( painter );
172 picks->dc->draw( &painter ); 172 picks->dc->draw( &painter );
173} 173}
174 174
175 175
176/* Keyboard::drawKeyboard {{{1 */ 176/* Keyboard::drawKeyboard {{{1 */
177 177
178void Keyboard::drawKeyboard(QPainter &p, int row, int col) 178void Keyboard::drawKeyboard(QPainter &p, int row, int col)
179{ 179{
180 180
181 181
182 if (row != -1 && col != -1) { //just redraw one key 182 if (row != -1 && col != -1) { //just redraw one key
183 183
184 int x = 0; 184 int x = 0;
185 for (int i = 0; i < col; i++) { 185 for (int i = 0; i < col; i++) {
186 186
187 x += keys->width(row, i) * defaultKeyWidth; 187 x += keys->width(row, i) * defaultKeyWidth;
188 } 188 }
189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 189 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
190 190
191 int keyWidth = keys->width(row, col); 191 int keyWidth = keys->width(row, col);
192 192
193 p.fillRect(x + 1, y + 1, 193 p.fillRect(x + 1, y + 1,
194 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 194 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 195 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
196 196
197 QImage *pix = keys->pix(row,col); 197 QImage *pix = keys->pix(row,col);
198 198
199 ushort c = keys->uni(row, col); 199 ushort c = keys->uni(row, col);
200 200
201 p.setPen(textcolor); 201 p.setPen(textcolor);
202 if (!pix) { 202 if (!pix) {
203 if ((shift || lock) && keys->shift(c)) 203 if ((shift || lock) && keys->shift(c))
204 204
205 if (circumflex && keys->circumflex(keys->shift(c))) 205 if (circumflex && keys->circumflex(keys->shift(c)))
206 c = keys->circumflex(keys->shift(c)); 206 c = keys->circumflex(keys->shift(c));
207 else if (diaeresis && keys->diaeresis(keys->shift(c))) 207 else if (diaeresis && keys->diaeresis(keys->shift(c)))
208 c = keys->diaeresis(keys->shift(c)); 208 c = keys->diaeresis(keys->shift(c));
209 else if (baccent && keys->baccent(keys->shift(c))) 209 else if (baccent && keys->baccent(keys->shift(c)))
210 c = keys->baccent(keys->shift(c)); 210 c = keys->baccent(keys->shift(c));
211 else if (accent && keys->accent(keys->shift(c))) 211 else if (accent && keys->accent(keys->shift(c)))
212 c = keys->accent(keys->shift(c)); 212 c = keys->accent(keys->shift(c));
213 else if (meta && keys->meta(keys->shift(c))) 213 else if (meta && keys->meta(keys->shift(c)))
214 c = keys->meta(keys->shift(c)); 214 c = keys->meta(keys->shift(c));
215 else 215 else
216 c = keys->shift(c); 216 c = keys->shift(c);
217 217
218 else if (meta && keys->meta(c)) 218 else if (meta && keys->meta(c))
219 c = keys->meta(c); 219 c = keys->meta(c);
220 else if (circumflex && keys->circumflex(c)) 220 else if (circumflex && keys->circumflex(c))
221 c = keys->circumflex(c); 221 c = keys->circumflex(c);
222 else if (baccent && keys->baccent(c)) 222 else if (baccent && keys->baccent(c))
223 c = keys->baccent(c); 223 c = keys->baccent(c);
224 else if (accent && keys->accent(c)) 224 else if (accent && keys->accent(c))
225 c = keys->accent(c); 225 c = keys->accent(c);
226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 226 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
227 227
228 // the diaeresis key itself has to be in the diaeresisMap, 228 // the diaeresis key itself has to be in the diaeresisMap,
229 // or just do this to make it display the diaeresis char. 229 // or just do this to make it display the diaeresis char.
230 230
231 if (c == 0x2c6) 231 if (c == 0x2c6)
232 c = 0xa8; 232 c = 0xa8;
233 else 233 else
234 c = keys->diaeresis(c); 234 c = keys->diaeresis(c);
235 } 235 }
236 236
237 p.drawText(x, y, 237 p.drawText(x, y,
238 defaultKeyWidth * keyWidth + 3, keyHeight, 238 defaultKeyWidth * keyWidth + 3, keyHeight,
239 AlignCenter, (QChar)c); 239 AlignCenter, (QChar)c);
240 } 240 }
241 else 241 else
242 // center the image in the middle of the key 242 // center the image in the middle of the key
243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1, 243 p.drawImage( x + (defaultKeyWidth * keyWidth - pix->width())/2 + 1,
244 y + (keyHeight - pix->height())/2 + 1, 244 y + (keyHeight - pix->height())/2 + 1,
245 *pix ); 245 *pix );
246 246
247 // this fixes the problem that the very right end of the board's vertical line 247 // this fixes the problem that the very right end of the board's vertical line
248 // gets painted over, because it's one pixel shorter than all other keys 248 // gets painted over, because it's one pixel shorter than all other keys
249 p.setPen(keycolor_lines); 249 p.setPen(keycolor_lines);
250 p.drawLine(width() - 1, 0, width() - 1, height()); 250 p.drawLine(width() - 1, 0, width() - 1, height());
251 251
252 } else { 252 } else {
253 253
254 254
255 p.fillRect(0, 0, width(), height(), keycolor); 255 p.fillRect(0, 0, width(), height(), keycolor);
256 256
257 for (row = 1; row <= keys->rows(); row++) { 257 for (row = 1; row <= keys->rows(); row++) {
258 258
259 int x = 0; 259 int x = 0;
260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 260 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
261 261
262 p.setPen(keycolor_lines); 262 p.setPen(keycolor_lines);
263 p.drawLine(x, y, x + width(), y); 263 p.drawLine(x, y, x + width(), y);
264 264
265 for (int col = 0; col < keys->numKeys(row); col++) { 265 for (int col = 0; col < keys->numKeys(row); col++) {
266 266
267 QImage *pix = keys->pix(row, col); 267 QImage *pix = keys->pix(row, col);
268 int keyWidth = keys->width(row, col); 268 int keyWidth = keys->width(row, col);
269 269
270 270
271 int keyWidthPix = defaultKeyWidth * keyWidth; 271 int keyWidthPix = defaultKeyWidth * keyWidth;
272 272
273 if (keys->pressed(row, col)) 273 if (keys->pressed(row, col))
274 p.fillRect(x+1, y+1, keyWidthPix - 1, 274 p.fillRect(x+1, y+1, keyWidthPix - 1,
275 keyHeight - 1, keycolor_pressed); 275 keyHeight - 1, keycolor_pressed);
276 276
277 ushort c = keys->uni(row, col); 277 ushort c = keys->uni(row, col);
278 278
279 p.setPen(textcolor); 279 p.setPen(textcolor);
280 if (!pix) { 280 if (!pix) {
281 if ((shift || lock) && keys->shift(c)) 281 if ((shift || lock) && keys->shift(c))
282 282
283 if (circumflex && keys->circumflex(keys->shift(c))) 283 if (circumflex && keys->circumflex(keys->shift(c)))
284 c = keys->circumflex(keys->shift(c)); 284 c = keys->circumflex(keys->shift(c));
285 else if (diaeresis && keys->diaeresis(keys->shift(c))) 285 else if (diaeresis && keys->diaeresis(keys->shift(c)))
286 c = keys->diaeresis(keys->shift(c)); 286 c = keys->diaeresis(keys->shift(c));
287 else if (baccent && keys->baccent(keys->shift(c))) 287 else if (baccent && keys->baccent(keys->shift(c)))
288 c = keys->baccent(keys->shift(c)); 288 c = keys->baccent(keys->shift(c));
289 else if (accent && keys->accent(keys->shift(c))) 289 else if (accent && keys->accent(keys->shift(c)))
290 c = keys->accent(keys->shift(c)); 290 c = keys->accent(keys->shift(c));
291 else if (meta && keys->meta(keys->shift(c))) 291 else if (meta && keys->meta(keys->shift(c)))
292 c = keys->meta(keys->shift(c)); 292 c = keys->meta(keys->shift(c));
293 else 293 else
294 c = keys->shift(c); 294 c = keys->shift(c);
295 295
296 else if (meta && keys->meta(c)) 296 else if (meta && keys->meta(c))
297 c = keys->meta(c); 297 c = keys->meta(c);
298 else if (circumflex && keys->circumflex(c)) 298 else if (circumflex && keys->circumflex(c))
299 c = keys->circumflex(c); 299 c = keys->circumflex(c);
300 else if (baccent && keys->baccent(c)) 300 else if (baccent && keys->baccent(c))
301 c = keys->baccent(c); 301 c = keys->baccent(c);
302 else if (accent && keys->accent(c)) 302 else if (accent && keys->accent(c))
303 c = keys->accent(c); 303 c = keys->accent(c);
304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) { 304 else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
305 305
306 if (c == 0x2c6) 306 if (c == 0x2c6)
307 c = 0xa8; 307 c = 0xa8;
308 else 308 else
309 c = keys->diaeresis(c); 309 c = keys->diaeresis(c);
310 } 310 }
311 311
312 p.drawText(x, y, 312 p.drawText(x, y,
313 keyWidthPix + 3, keyHeight, 313 keyWidthPix + 3, keyHeight,
314 AlignCenter, (QChar)c); 314 AlignCenter, (QChar)c);
315 } 315 }
316 else { 316 else {
317 // center the image in the middle of the key 317 // center the image in the middle of the key
318 pix->setColor(1, textcolor.rgb()); 318 pix->setColor(1, textcolor.rgb());
319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1, 319 p.drawImage( x + (keyWidthPix - pix->width())/2 + 1,
320 y + (keyHeight - pix->height())/2 + 1, 320 y + (keyHeight - pix->height())/2 + 1,
321 QImage(*pix) ); 321 QImage(*pix) );
322 } 322 }
323 323
324 p.setPen(keycolor_lines); 324 p.setPen(keycolor_lines);
325 p.drawLine(x, y, x, y + keyHeight); 325 p.drawLine(x, y, x, y + keyHeight);
326 326
327 x += keyWidthPix; 327 x += keyWidthPix;
328 } 328 }
329 329
330 330
331 } 331 }
332 p.setPen(keycolor_lines); 332 p.setPen(keycolor_lines);
333 p.drawLine(0, height() - 1, width(), height() - 1); 333 p.drawLine(0, height() - 1, width(), height() - 1);
334 p.drawLine(width() - 1, 0, width() - 1, height()); 334 p.drawLine(width() - 1, 0, width() - 1, height());
335 } 335 }
336 336
337} 337}
338 338
339 339
340/* Keyboard::mousePressEvent {{{1 */ 340/* Keyboard::mousePressEvent {{{1 */
341void Keyboard::mousePressEvent(QMouseEvent *e) 341void Keyboard::mousePressEvent(QMouseEvent *e)
342{ 342{
343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 343 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
344 if (row > 5) row = 5; 344 if (row > 5) row = 5;
345 345
346 // figure out the column 346 // figure out the column
347 int col = 0; 347 int col = 0;
348 for (int w = 0; e->x() >= w; col++) 348 for (int w = 0; e->x() >= w; col++)
349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 349 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
350 w += keys->width(row,col) * defaultKeyWidth; 350 w += keys->width(row,col) * defaultKeyWidth;
351 else break; 351 else break;
352 352
353 if (col <= 0) return; 353 if (col <= 0) return;
354 354
355 col --; // rewind one... 355 col --; // rewind one...
356 356
357 qkeycode = keys->qcode(row, col); 357 qkeycode = keys->qcode(row, col);
358 unicode = keys->uni(row, col); 358 unicode = keys->uni(row, col);
359 359
360 // might need to repaint if two or more of the same keys. 360 // might need to repaint if two or more of the same keys.
361 // should be faster if just paint one key even though multiple keys exist. 361 // should be faster if just paint one key even though multiple keys exist.
362 bool need_repaint = FALSE; 362 bool need_repaint = FALSE;
363 363
364 // circumflex and diaeresis support 364 // circumflex and diaeresis support
365 // messy to have this here, but too hard to implement any other method 365 // messy to have this here, but too hard to implement any other method
366 if (unicode == 0x2c6) { 366 if (unicode == 0x2c6) {
367 367
368 unicode = 0; 368 unicode = 0;
369 if (shift || lock) { 369 if (shift || lock) {
370 370
371 // diaeresis 371 // diaeresis
372 qkeycode = 0x2001; 372 qkeycode = 0x2001;
373 } 373 }
374 else { 374 else {
375 375
376 // circumflex 376 // circumflex
377 qkeycode = 0x2000; 377 qkeycode = 0x2000;
378 } 378 }
379 } 379 }
380 380
381 // Back accent character support 381 // Back accent character support
382 382
383 // the keys from 2c6 ~ 2cf should be used instead of the ascii one 383 // the keys from 2c6 ~ 2cf should be used instead of the ascii one
384 if (unicode == 0x2cb) { 384 if (unicode == 0x2cb) {
385 385
386 unicode = 0; 386 unicode = 0;
387 if (shift || lock) { 387 if (shift || lock) {
388 388
389 // circumblex 389 // circumblex
390 qkeycode = 0x2000; 390 qkeycode = 0x2000;
391 } 391 }
392 else { 392 else {
393 393
394 // back accent 394 // back accent
395 qkeycode = 0x2002; 395 qkeycode = 0x2002;
396 } 396 }
397 } 397 }
398 398
399 // Accent character support 399 // Accent character support
400 400
401 if (unicode == 0x2ca) { 401 if (unicode == 0x2ca) {
402 402
403 unicode = 0; 403 unicode = 0;
404 if (shift || lock) { 404 if (shift || lock) {
405 405
406 // diaeresis 406 // diaeresis
407 qkeycode = 0x2001; 407 qkeycode = 0x2001;
408 } 408 }
409 else { 409 else {
410 410
411 // accent 411 // accent
412 qkeycode = 0x2003; 412 qkeycode = 0x2003;
413 } 413 }
414 } 414 }
415 415
416 416
417 if (unicode == 0) { // either Qt char, or nothing 417 if (unicode == 0) { // either Qt char, or nothing
418 418
419 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 419 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
420 420
421 if ( configdlg ) { 421 if ( configdlg ) {
422 422
423 delete configdlg; 423 delete configdlg;
424 configdlg = 0; 424 configdlg = 0;
425 } 425 }
426 else { 426 else {
427 configdlg = new ConfigDlg (); 427 configdlg = new ConfigDlg ();
428 connect(configdlg, SIGNAL(setMapToDefault()), 428 connect(configdlg, SIGNAL(setMapToDefault()),
429 this, SLOT(setMapToDefault())); 429 this, SLOT(setMapToDefault()));
430 connect(configdlg, SIGNAL(setMapToFile(QString)), 430 connect(configdlg, SIGNAL(setMapToFile(QString)),
431 this, SLOT(setMapToFile(QString))); 431 this, SLOT(setMapToFile(QString)));
432 connect(configdlg, SIGNAL(pickboardToggled(bool)), 432 connect(configdlg, SIGNAL(pickboardToggled(bool)),
433 this, SLOT(togglePickboard(bool))); 433 this, SLOT(togglePickboard(bool)));
434 connect(configdlg, SIGNAL(repeatToggled(bool)), 434 connect(configdlg, SIGNAL(repeatToggled(bool)),
435 this, SLOT(toggleRepeat(bool))); 435 this, SLOT(toggleRepeat(bool)));
436 connect(configdlg, SIGNAL(reloadKeyboard()), 436 connect(configdlg, SIGNAL(reloadKeyboard()),
437 this, SLOT(reloadKeyboard())); 437 this, SLOT(reloadKeyboard()));
438 connect(configdlg, SIGNAL(configDlgClosed()), 438 connect(configdlg, SIGNAL(configDlgClosed()),
439 this, SLOT(cleanupConfigDlg())); 439 this, SLOT(cleanupConfigDlg()));
440 connect(configdlg, SIGNAL(reloadSw()), 440 connect(configdlg, SIGNAL(reloadSw()),
441 this, SLOT(reloadSw())); 441 this, SLOT(reloadSw()));
442 configdlg->showMaximized(); 442 configdlg->showMaximized();
443 configdlg->show(); 443 configdlg->show();
444 configdlg->raise(); 444 configdlg->raise();
445 } 445 }
446 446
447 } else if (qkeycode == Qt::Key_Control) { 447 } else if (qkeycode == Qt::Key_Control) {
448 need_repaint = TRUE; 448 need_repaint = TRUE;
449 449
450 if (ctrl) { 450 if (ctrl) {
451 451
452 *ctrl = 0; 452 *ctrl = 0;
453 ctrl = 0; 453 ctrl = 0;
454 454
455 } else { 455 } else {
456 456
457 ctrl = keys->pressedPtr(row, col); 457 ctrl = keys->pressedPtr(row, col);
458 need_repaint = TRUE; 458 need_repaint = TRUE;
459 *ctrl = !keys->pressed(row, col); 459 *ctrl = !keys->pressed(row, col);
460 460
461 } 461 }
462 462
463 } else if (qkeycode == Qt::Key_Alt) { 463 } else if (qkeycode == Qt::Key_Alt) {
464 need_repaint = TRUE; 464 need_repaint = TRUE;
465 465
466 if (alt) { 466 if (alt) {
467 *alt = 0; 467 *alt = 0;
468 alt = 0; 468 alt = 0;
469 469
470 } else { 470 } else {
471 471
472 alt = keys->pressedPtr(row, col); 472 alt = keys->pressedPtr(row, col);
473 need_repaint = TRUE; 473 need_repaint = TRUE;
474 *alt = !keys->pressed(row, col); 474 *alt = !keys->pressed(row, col);
475 } 475 }
476 476
477 } else if (qkeycode == Qt::Key_Shift) { 477 } else if (qkeycode == Qt::Key_Shift) {
478 need_repaint = TRUE; 478 need_repaint = TRUE;
479 479
480 if (shift) { 480 if (shift) {
481 *shift = 0; 481 *shift = 0;
482 shift = 0; 482 shift = 0;
483 } 483 }
484 else { 484 else {
485 shift = keys->pressedPtr(row, col); 485 shift = keys->pressedPtr(row, col);
486 *shift = 1; 486 *shift = 1;
487 if (lock) { 487 if (lock) {
488 *lock = 0; 488 *lock = 0;
489 lock = 0; 489 lock = 0;
490 } 490 }
491 } 491 }
492 492
493 493
494 /* 494 /*
495 * want to be able to hit circumflex/diaeresis -> shift 495 * want to be able to hit circumflex/diaeresis -> shift
496 * to type in shifted circumflex/diaeresis chars. 496 * to type in shifted circumflex/diaeresis chars.
497 * same thing with meta 497 * same thing with meta
498 498
499 if (meta) { *meta = 0; meta = 0; } 499 if (meta) { *meta = 0; meta = 0; }
500 if (circumflex) { *circumflex = 0; circumflex = 0; } 500 if (circumflex) { *circumflex = 0; circumflex = 0; }
501 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 501 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
502 502
503 */ 503 */
504 504
505 } else if (qkeycode == Qt::Key_CapsLock) { 505 } else if (qkeycode == Qt::Key_CapsLock) {
506 need_repaint = TRUE; 506 need_repaint = TRUE;
507 507
508 if (lock) { 508 if (lock) {
509 *lock = 0; 509 *lock = 0;
510 lock = 0; 510 lock = 0;
511 } 511 }
512 else { 512 else {
513 lock = keys->pressedPtr(row, col);; 513 lock = keys->pressedPtr(row, col);;
514 *lock = true;; 514 *lock = true;;
515 if (shift) { 515 if (shift) {
516 *shift = 0; 516 *shift = 0;
517 shift = 0; 517 shift = 0;
518 } 518 }
519 } 519 }
520 520
521 /* 521 /*
522 if (meta) { *meta = 0; meta = 0; } 522 if (meta) { *meta = 0; meta = 0; }
523 if (circumflex) { *circumflex = 0; circumflex = 0; } 523 if (circumflex) { *circumflex = 0; circumflex = 0; }
524 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 524 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
525 */ 525 */
526 526
527 } else if (qkeycode == Qt::Key_Meta) { 527 } else if (qkeycode == Qt::Key_Meta) {
528 need_repaint = TRUE; 528 need_repaint = TRUE;
529 529
530 if (meta) { 530 if (meta) {
531 *meta = 0; 531 *meta = 0;
532 meta = 0; 532 meta = 0;
533 533
534 } else { 534 } else {
535 535
536 meta = keys->pressedPtr(row, col); 536 meta = keys->pressedPtr(row, col);
537 *meta = true; 537 *meta = true;
538 } 538 }
539 539
540 // reset all the other keys 540 // reset all the other keys
541 if (shift) { *shift = 0; shift = 0; } 541 if (shift) { *shift = 0; shift = 0; }
542 if (lock) { *lock = 0; lock = 0; } 542 if (lock) { *lock = 0; lock = 0; }
543 if (circumflex) { *circumflex = 0; circumflex = 0; } 543 if (circumflex) { *circumflex = 0; circumflex = 0; }
544 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 544 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
545 if (baccent) { *baccent = 0; baccent = 0; } 545 if (baccent) { *baccent = 0; baccent = 0; }
546 if (accent) { *accent = 0; accent = 0; } 546 if (accent) { *accent = 0; accent = 0; }
547 547
548 // dont need to emit this key... acts same as alt 548 // dont need to emit this key... acts same as alt
549 qkeycode = 0; 549 qkeycode = 0;
550 550
551 // circumflex 551 // circumflex
552 } else if (qkeycode == 0x2000) { 552 } else if (qkeycode == 0x2000) {
553 need_repaint = TRUE; 553 need_repaint = TRUE;
554 554
555 if (circumflex) { 555 if (circumflex) {
556 556
557 *circumflex = 0; 557 *circumflex = 0;
558 circumflex = 0; 558 circumflex = 0;
559 559
560 } else { 560 } else {
561 561
562 circumflex = keys->pressedPtr(row, col); 562 circumflex = keys->pressedPtr(row, col);
563 *circumflex = true; 563 *circumflex = true;
564 } 564 }
565 565
566 /* no need to turn off shift or lock if circumflex 566 /* no need to turn off shift or lock if circumflex
567 * keys are pressed 567 * keys are pressed
568 568
569 if (shift) { *shift = 0; shift = 0; } 569 if (shift) { *shift = 0; shift = 0; }
570 if (lock) { *lock = 0; lock = 0; } 570 if (lock) { *lock = 0; lock = 0; }
571 571
572 */ 572 */
573 573
574 // have to reset all the other keys 574 // have to reset all the other keys
575 if (meta) { *meta = 0; meta = 0; } 575 if (meta) { *meta = 0; meta = 0; }
576 if (diaeresis) { 576 if (diaeresis) {
577 577
578 // *diaeresis and *circumflex point to the same thing 578 // *diaeresis and *circumflex point to the same thing
579 // when diaeresis is enabled and you hit the circumflex 579 // when diaeresis is enabled and you hit the circumflex
580 // since they are the same key, it should turn off the 580 // since they are the same key, it should turn off the
581 // key 581 // key
582 582
583 *diaeresis = 0; 583 *diaeresis = 0;
584 diaeresis = 0; 584 diaeresis = 0;
585 circumflex = 0; 585 circumflex = 0;
586 } 586 }
587 587
588 qkeycode = 0; 588 qkeycode = 0;
589 589
590 // diaeresis 590 // diaeresis
591 } else if (qkeycode == 0x2001) { 591 } else if (qkeycode == 0x2001) {
592 need_repaint = TRUE; 592 need_repaint = TRUE;
593 593
594 if (diaeresis) { 594 if (diaeresis) {
595 595
596 *diaeresis = 0; 596 *diaeresis = 0;
597 diaeresis = 0; 597 diaeresis = 0;
598 598
599 } else { 599 } else {
600 600
601 diaeresis = keys->pressedPtr(row, col); 601 diaeresis = keys->pressedPtr(row, col);
602 *diaeresis = true; 602 *diaeresis = true;
603 } 603 }
604 604
605 605
606 if (shift) { *shift = 0; shift = 0; } 606 if (shift) { *shift = 0; shift = 0; }
607 607
608 /* 608 /*
609 * 609 *
610 if (lock) { *lock = 0; lock = 0; } 610 if (lock) { *lock = 0; lock = 0; }
611 * 611 *
612 */ 612 */
613 613
614 if (meta) { *meta = 0; meta = 0; } 614 if (meta) { *meta = 0; meta = 0; }
615 if (circumflex) { 615 if (circumflex) {
616 616
617 // *circumflex = 0; 617 // *circumflex = 0;
618 // 618 //
619 // same thing the diaeresis pointer points too 619 // same thing the diaeresis pointer points too
620 620
621 circumflex = 0; 621 circumflex = 0;
622 } 622 }
623 623
624 624
625 qkeycode = 0; 625 qkeycode = 0;
626 626
627 // Back accent 627 // Back accent
628 } else if (qkeycode == 0x2002) { 628 } else if (qkeycode == 0x2002) {
629 need_repaint = TRUE; 629 need_repaint = TRUE;
630 630
631 if (baccent) { 631 if (baccent) {
632 632
633 *baccent = 0; 633 *baccent = 0;
634 baccent = 0; 634 baccent = 0;
635 635
636 } else { 636 } else {
637 637
638 baccent = keys->pressedPtr(row, col); 638 baccent = keys->pressedPtr(row, col);
639 *baccent = true; 639 *baccent = true;
640 } 640 }
641 641
642 642
643 if (shift) { *shift = 0; shift = 0; } 643 if (shift) { *shift = 0; shift = 0; }
644 if (meta) { *meta = 0; meta = 0; } 644 if (meta) { *meta = 0; meta = 0; }
645 if (accent) { *accent = 0; accent = 0; } 645 if (accent) { *accent = 0; accent = 0; }
646 646
647 qkeycode = 0; 647 qkeycode = 0;
648 648
649 // Accent 649 // Accent
650 } else if (qkeycode == 0x2003) { 650 } else if (qkeycode == 0x2003) {
651 need_repaint = TRUE; 651 need_repaint = TRUE;
652 652
653 if (accent) { 653 if (accent) {
654 654
655 *accent = 0; 655 *accent = 0;
656 accent = 0; 656 accent = 0;
657 657
658 } else { 658 } else {
659 659
660 accent = keys->pressedPtr(row, col); 660 accent = keys->pressedPtr(row, col);
661 *accent = true; 661 *accent = true;
662 } 662 }
663 663
664 664
665 if (shift) { *shift = 0; shift = 0; } 665 if (shift) { *shift = 0; shift = 0; }
666 if (meta) { *meta = 0; meta = 0; } 666 if (meta) { *meta = 0; meta = 0; }
667 if (baccent) { *baccent = 0; } 667 if (baccent) { *baccent = 0; }
668 668
669 qkeycode = 0; 669 qkeycode = 0;
670 } 670 }