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,795 +1,795 @@
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 ) {
613 p.setPen(keycolor_hi); 613 p.setPen(keycolor_hi);
614 p.drawLine( x, y, x+kw-1, y ); 614 p.drawLine( x, y, x+kw-1, y );
615 } 615 }
616 616
617 // bottom 617 // bottom
618 p.setPen(keycolor_lo); 618 p.setPen(keycolor_lo);
619 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); 619 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 );
620 620
621 } else { 621 } else {
622 p.fillRect( x, y, kw, keyHeight, cg.background() ); 622 p.fillRect( x, y, kw, keyHeight, cg.background() );
623 } 623 }
624 } 624 }
625 625
626 x += kw; 626 x += kw;
627 kw = defaultKeyWidth; 627 kw = defaultKeyWidth;
628 k = getKey( kw ); 628 k = getKey( kw );
629 } 629 }
630 } 630 }
631} 631}
632 632
633 633
634void Keyboard::mousePressEvent(QMouseEvent *e) 634void Keyboard::mousePressEvent(QMouseEvent *e)
635{ 635{
636 clearHighlight(); // typing fast? 636 clearHighlight(); // typing fast?
637 637
638 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; 638 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth;
639 int j = (e->y() - picks->height()) / keyHeight; 639 int j = (e->y() - picks->height()) / keyHeight;
640 640
641 int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); 641 int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) );
642 bool need_repaint = FALSE; 642 bool need_repaint = FALSE;
643 unicode = -1; 643 unicode = -1;
644 qkeycode = 0; 644 qkeycode = 0;
645 if ( k >= 0x80 ) { 645 if ( k >= 0x80 ) {
646 if ( k == ShiftCode ) { 646 if ( k == ShiftCode ) {
647 shift = !shift; 647 shift = !shift;
648 need_repaint = TRUE; 648 need_repaint = TRUE;
649 } else if ( k == AltCode ){ 649 } else if ( k == AltCode ){
650 alt = !alt; 650 alt = !alt;
651 need_repaint = TRUE; 651 need_repaint = TRUE;
652 } else if ( k == CapsCode ) { 652 } else if ( k == CapsCode ) {
653 lock = !lock; 653 lock = !lock;
654 need_repaint = TRUE; 654 need_repaint = TRUE;
655 } else if ( k == CtrlCode ) { 655 } else if ( k == CtrlCode ) {
656 ctrl = !ctrl; 656 ctrl = !ctrl;
657 need_repaint = TRUE; 657 need_repaint = TRUE;
658 } else if ( k == 0224 /* Expand */ ) { 658 } else if ( k == 0224 /* Expand */ ) {
659 useLargeKeys = !useLargeKeys; 659 useLargeKeys = !useLargeKeys;
660 resizeEvent(0); 660 resizeEvent(0);
661 repaint( TRUE ); // need it to clear first 661 repaint( TRUE ); // need it to clear first
662 } else if ( k == 0225 /* Opti/Toggle */ ) { 662 } else if ( k == 0225 /* Opti/Toggle */ ) {
663 useOptiKeys = !useOptiKeys; 663 useOptiKeys = !useOptiKeys;
664 resizeEvent(0); 664 resizeEvent(0);
665 repaint( TRUE ); // need it to clear first 665 repaint( TRUE ); // need it to clear first
666 } else { 666 } else {
667 qkeycode = specialM[ k - 0x80 ].qcode; 667 qkeycode = specialM[ k - 0x80 ].qcode;
668 unicode = specialM[ k - 0x80 ].unicode; 668 unicode = specialM[ k - 0x80 ].unicode;
669 } 669 }
670 } else { 670 } else {
671#if defined(Q_WS_QWS) || defined(_WS_QWS_) 671#if defined(Q_WS_QWS) || defined(_WS_QWS_)
672/* 672/*
673 qk = QWSServer::keyMap()[k].key_code; 673 qk = QWSServer::keyMap()[k].key_code;
674 if ( qk != Key_unknown ) { 674 if ( qk != Key_unknown ) {
675 if ( ctrl ) 675 if ( ctrl )
676 u = QWSServer::keyMap()[k].ctrl_unicode; 676 u = QWSServer::keyMap()[k].ctrl_unicode;
677 else if ( shift^lock ) 677 else if ( shift^lock )
678 u = QWSServer::keyMap()[k].shift_unicode; 678 u = QWSServer::keyMap()[k].shift_unicode;
679 else 679 else
680 u = QWSServer::keyMap()[k].unicode; 680 u = QWSServer::keyMap()[k].unicode;
681 } 681 }
682*/ 682*/
683 char shifted = k; 683 char shifted = k;
684 if ( !isalpha( k ) ) { 684 if ( !isalpha( k ) ) {
685 // ### Fixme, bad code, needs improving, whole thing needs to 685 // ### Fixme, bad code, needs improving, whole thing needs to
686 // be re-coded to get rid of the way it did things with scancodes etc 686 // be re-coded to get rid of the way it did things with scancodes etc
687 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 687 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
688 if ( shiftMap[i].normal == k ) 688 if ( shiftMap[i].normal == k )
689 shifted = shiftMap[i].shifted; 689 shifted = shiftMap[i].shifted;
690 } else { 690 } else {
691 shifted = toupper( k ); 691 shifted = toupper( k );
692 } 692 }
693 QChar tempChar( shift^lock ? shifted : k ); 693 QChar tempChar( shift^lock ? shifted : k );
694 unicode = tempChar.unicode(); 694 unicode = tempChar.unicode();
695#endif 695#endif
696 } 696 }
697 if ( unicode != -1 ) { 697 if ( unicode != -1 ) {
698 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | 698 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) |
699 (alt ? Qt::AltButton : 0); 699 (alt ? Qt::AltButton : 0);
700#if defined(Q_WS_QWS) || defined(_WS_QWS_) 700#if defined(Q_WS_QWS) || defined(_WS_QWS_)
701 emit key( unicode, qkeycode, modifiers, true, false ); 701 emit key( unicode, qkeycode, modifiers, true, false );
702 repeatTimer->start( 500 ); 702 repeatTimer->start( 500 );
703#endif 703#endif
704 need_repaint = shift || alt || ctrl; 704 need_repaint = shift || alt || ctrl;
705 shift = alt = ctrl = FALSE; 705 shift = alt = ctrl = FALSE;
706 //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); 706 //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 );
707 707
708 KeyboardConfig *dc = picks->dc; 708 KeyboardConfig *dc = picks->dc;
709 709
710 if (dc) { 710 if (dc) {
711 if (qkeycode == Qt::Key_Backspace) { 711 if (qkeycode == Qt::Key_Backspace) {
712 dc->input.remove(dc->input.last()); // remove last input 712 dc->input.remove(dc->input.last()); // remove last input
713 dc->decBackspaces(); 713 dc->decBackspaces();
714 } else if ( k == 0226 || qkeycode == Qt::Key_Return || 714 } else if ( k == 0226 || qkeycode == Qt::Key_Return ||
715 qkeycode == Qt::Key_Space || 715 qkeycode == Qt::Key_Space ||
716 QChar(unicode).isPunct() ) { 716 QChar(unicode).isPunct() ) {
717 dc->input.clear(); 717 dc->input.clear();
718 dc->resetBackspaces(); 718 dc->resetBackspaces();
719 } else { 719 } else {
720 dc->add(QString(QChar(unicode))); 720 dc->add(QString(QChar(unicode)));
721 dc->incBackspaces(); 721 dc->incBackspaces();
722 } 722 }
723 } 723 }
724 724
725 picks->repaint(); 725 picks->repaint();
726 726
727 } 727 }
728 pressedKey = k; 728 pressedKey = k;
729 if ( need_repaint ) { 729 if ( need_repaint ) {
730 repaint( FALSE ); 730 repaint( FALSE );
731 } else { 731 } else {
732 QPainter p(this); 732 QPainter p(this);
733 drawKeyboard( p, pressedKey ); 733 drawKeyboard( p, pressedKey );
734 } 734 }
735 pressTid = startTimer(80); 735 pressTid = startTimer(80);
736 pressed = TRUE; 736 pressed = TRUE;
737} 737}
738 738
739 739
740void Keyboard::mouseReleaseEvent(QMouseEvent*) 740void Keyboard::mouseReleaseEvent(QMouseEvent*)
741{ 741{
742 if ( pressTid == 0 ) 742 if ( pressTid == 0 )
743 clearHighlight(); 743 clearHighlight();
744#if defined(Q_WS_QWS) || defined(_WS_QWS_) 744#if defined(Q_WS_QWS) || defined(_WS_QWS_)
745 if ( unicode != -1 ) { 745 if ( unicode != -1 ) {
746 emit key( unicode, qkeycode, modifiers, false, false ); 746 emit key( unicode, qkeycode, modifiers, false, false );
747 repeatTimer->stop(); 747 repeatTimer->stop();
748 } 748 }
749#endif 749#endif
750 pressed = FALSE; 750 pressed = FALSE;
751} 751}
752 752
753void Keyboard::timerEvent(QTimerEvent* e) 753void Keyboard::timerEvent(QTimerEvent* e)
754{ 754{
755 if ( e->timerId() == pressTid ) { 755 if ( e->timerId() == pressTid ) {
756 killTimer(pressTid); 756 killTimer(pressTid);
757 pressTid = 0; 757 pressTid = 0;
758 if ( !pressed ) 758 if ( !pressed )
759 clearHighlight(); 759 clearHighlight();
760 } 760 }
761} 761}
762 762
763void Keyboard::repeat() 763void Keyboard::repeat()
764{ 764{
765 repeatTimer->start( 150 ); 765 repeatTimer->start( 150 );
766 emit key( unicode, qkeycode, modifiers, true, true ); 766 emit key( unicode, qkeycode, modifiers, true, true );
767} 767}
768 768
769void Keyboard::clearHighlight() 769void Keyboard::clearHighlight()
770{ 770{
771 if ( pressedKey >= 0 ) { 771 if ( pressedKey >= 0 ) {
772 int tmp = pressedKey; 772 int tmp = pressedKey;
773 pressedKey = -1; 773 pressedKey = -1;
774 QPainter p(this); 774 QPainter p(this);
775 drawKeyboard( p, tmp ); 775 drawKeyboard( p, tmp );
776 } 776 }
777} 777}
778 778
779 779
780QSize Keyboard::sizeHint() const 780QSize Keyboard::sizeHint() const
781{ 781{
782 QFontMetrics fm=fontMetrics(); 782 QFontMetrics fm=fontMetrics();
783 int keyHeight = fm.lineSpacing()+2; 783 int keyHeight = fm.lineSpacing()+2;
784 784
785 if (useOptiKeys) 785 if (useOptiKeys)
786 keyHeight += 1; 786 keyHeight += 1;
787 787
788 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); 788 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 );
789} 789}
790 790
791 791
792void Keyboard::resetState() 792void Keyboard::resetState()
793{ 793{
794 picks->resetState(); 794 picks->resetState();
795} 795}
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,810 +1,810 @@
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
626 if ( threeD ) { 626 if ( threeD ) {
627 p.setPen(keycolor_hi); 627 p.setPen(keycolor_hi);
628 p.drawLine( x, y, x+kw-1, y ); 628 p.drawLine( x, y, x+kw-1, y );
629 } 629 }
630 630
631 // bottom 631 // bottom
632 p.setPen(keycolor_lo); 632 p.setPen(keycolor_lo);
633 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); 633 p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 );
634 634
635 } else { 635 } else {
636 p.fillRect( x, y, kw, keyHeight, cg.background() ); 636 p.fillRect( x, y, kw, keyHeight, cg.background() );
637 } 637 }
638 } 638 }
639 639
640 x += kw; 640 x += kw;
641 kw = defaultKeyWidth; 641 kw = defaultKeyWidth;
642 k = getKey( kw ); 642 k = getKey( kw );
643 } 643 }
644 } 644 }
645} 645}
646 646
647 647
648void Keyboard::mousePressEvent(QMouseEvent *e) 648void Keyboard::mousePressEvent(QMouseEvent *e)
649{ 649{
650 clearHighlight(); // typing fast? 650 clearHighlight(); // typing fast?
651 651
652 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; 652 int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth;
653 int j = (e->y() - picks->height()) / keyHeight; 653 int j = (e->y() - picks->height()) / keyHeight;
654 654
655 int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); 655 int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) );
656 bool need_repaint = FALSE; 656 bool need_repaint = FALSE;
657 unicode = -1; 657 unicode = -1;
658 qkeycode = 0; 658 qkeycode = 0;
659 if ( k >= 0x80 ) { 659 if ( k >= 0x80 ) {
660 if ( k == ShiftCode ) { 660 if ( k == ShiftCode ) {
661 shift = !shift; 661 shift = !shift;
662 need_repaint = TRUE; 662 need_repaint = TRUE;
663 } else if ( k == AltCode ){ 663 } else if ( k == AltCode ){
664 alt = !alt; 664 alt = !alt;
665 need_repaint = TRUE; 665 need_repaint = TRUE;
666 } else if ( k == CapsCode ) { 666 } else if ( k == CapsCode ) {
667 lock = !lock; 667 lock = !lock;
668 need_repaint = TRUE; 668 need_repaint = TRUE;
669 } else if ( k == CtrlCode ) { 669 } else if ( k == CtrlCode ) {
670 ctrl = !ctrl; 670 ctrl = !ctrl;
671 need_repaint = TRUE; 671 need_repaint = TRUE;
672 } else if ( k == 0224 /* Expand */ ) { 672 } else if ( k == 0224 /* Expand */ ) {
673 useLargeKeys = !useLargeKeys; 673 useLargeKeys = !useLargeKeys;
674 resizeEvent(0); 674 resizeEvent(0);
675 repaint( TRUE ); // need it to clear first 675 repaint( TRUE ); // need it to clear first
676 } else if ( k == 0225 /* Opti/Toggle */ ) { 676 } else if ( k == 0225 /* Opti/Toggle */ ) {
677 useOptiKeys = !useOptiKeys; 677 useOptiKeys = !useOptiKeys;
678 resizeEvent(0); 678 resizeEvent(0);
679 repaint( TRUE ); // need it to clear first 679 repaint( TRUE ); // need it to clear first
680 } else { 680 } else {
681 qkeycode = specialM[ k - 0x80 ].qcode; 681 qkeycode = specialM[ k - 0x80 ].qcode;
682 unicode = specialM[ k - 0x80 ].unicode; 682 unicode = specialM[ k - 0x80 ].unicode;
683 } 683 }
684 } else { 684 } else {
685#if defined(Q_WS_QWS) || defined(_WS_QWS_) 685#if defined(Q_WS_QWS) || defined(_WS_QWS_)
686/* 686/*
687 qk = QWSServer::keyMap()[k].key_code; 687 qk = QWSServer::keyMap()[k].key_code;
688 if ( qk != Key_unknown ) { 688 if ( qk != Key_unknown ) {
689 if ( ctrl ) 689 if ( ctrl )
690 u = QWSServer::keyMap()[k].ctrl_unicode; 690 u = QWSServer::keyMap()[k].ctrl_unicode;
691 else if ( shift^lock ) 691 else if ( shift^lock )
692 u = QWSServer::keyMap()[k].shift_unicode; 692 u = QWSServer::keyMap()[k].shift_unicode;
693 else 693 else
694 u = QWSServer::keyMap()[k].unicode; 694 u = QWSServer::keyMap()[k].unicode;
695 } 695 }
696*/ 696*/
697 char shifted = k; 697 char shifted = k;
698 if ( !isalpha( k ) ) { 698 if ( !isalpha( k ) ) {
699 // ### Fixme, bad code, needs improving, whole thing needs to 699 // ### Fixme, bad code, needs improving, whole thing needs to
700 // be re-coded to get rid of the way it did things with scancodes etc 700 // be re-coded to get rid of the way it did things with scancodes etc
701 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) 701 for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ )
702 if ( shiftMap[i].normal == k ) 702 if ( shiftMap[i].normal == k )
703 shifted = shiftMap[i].shifted; 703 shifted = shiftMap[i].shifted;
704 } else { 704 } else {
705 shifted = toupper( k ); 705 shifted = toupper( k );
706 } 706 }
707 QChar tempChar( shift^lock ? shifted : k ); 707 QChar tempChar( shift^lock ? shifted : k );
708 unicode = tempChar.unicode(); 708 unicode = tempChar.unicode();
709#endif 709#endif
710 } 710 }
711 if ( unicode != -1 ) { 711 if ( unicode != -1 ) {
712 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | 712 modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) |
713 (alt ? Qt::AltButton : 0); 713 (alt ? Qt::AltButton : 0);
714#if defined(Q_WS_QWS) || defined(_WS_QWS_) 714#if defined(Q_WS_QWS) || defined(_WS_QWS_)
715 emit key( unicode, qkeycode, modifiers, true, false ); 715 emit key( unicode, qkeycode, modifiers, true, false );
716 repeatTimer->start( 500 ); 716 repeatTimer->start( 500 );
717#endif 717#endif
718 need_repaint = shift || alt || ctrl; 718 need_repaint = shift || alt || ctrl;
719 shift = alt = ctrl = FALSE; 719 shift = alt = ctrl = FALSE;
720 //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); 720 //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 );
721 721
722 KeyboardConfig *dc = picks->dc; 722 KeyboardConfig *dc = picks->dc;
723 723
724 if (dc) { 724 if (dc) {
725 if (qkeycode == Qt::Key_Backspace) { 725 if (qkeycode == Qt::Key_Backspace) {
726 dc->input.remove(dc->input.last()); // remove last input 726 dc->input.remove(dc->input.last()); // remove last input
727 dc->decBackspaces(); 727 dc->decBackspaces();
728 } else if ( k == 0226 || qkeycode == Qt::Key_Return || 728 } else if ( k == 0226 || qkeycode == Qt::Key_Return ||
729 qkeycode == Qt::Key_Space || 729 qkeycode == Qt::Key_Space ||
730 QChar(unicode).isPunct() ) { 730 QChar(unicode).isPunct() ) {
731 dc->input.clear(); 731 dc->input.clear();
732 dc->resetBackspaces(); 732 dc->resetBackspaces();
733 } else { 733 } else {
734 dc->add(QString(QChar(unicode))); 734 dc->add(QString(QChar(unicode)));
735 dc->incBackspaces(); 735 dc->incBackspaces();
736 } 736 }
737 } 737 }
738 738
739 picks->repaint(); 739 picks->repaint();
740 740
741 } 741 }
742 pressedKey = k; 742 pressedKey = k;
743 if ( need_repaint ) { 743 if ( need_repaint ) {
744 repaint( FALSE ); 744 repaint( FALSE );
745 } else { 745 } else {
746 QPainter p(this); 746 QPainter p(this);
747 drawKeyboard( p, pressedKey ); 747 drawKeyboard( p, pressedKey );
748 } 748 }
749 pressTid = startTimer(80); 749 pressTid = startTimer(80);
750 pressed = TRUE; 750 pressed = TRUE;
751} 751}
752 752
753 753
754void Keyboard::mouseReleaseEvent(QMouseEvent*) 754void Keyboard::mouseReleaseEvent(QMouseEvent*)
755{ 755{
756 if ( pressTid == 0 ) 756 if ( pressTid == 0 )
757 clearHighlight(); 757 clearHighlight();
758#if defined(Q_WS_QWS) || defined(_WS_QWS_) 758#if defined(Q_WS_QWS) || defined(_WS_QWS_)
759 if ( unicode != -1 ) { 759 if ( unicode != -1 ) {
760 emit key( unicode, qkeycode, modifiers, false, false ); 760 emit key( unicode, qkeycode, modifiers, false, false );
761 repeatTimer->stop(); 761 repeatTimer->stop();
762 } 762 }
763#endif 763#endif
764 pressed = FALSE; 764 pressed = FALSE;
765} 765}
766 766
767void Keyboard::timerEvent(QTimerEvent* e) 767void Keyboard::timerEvent(QTimerEvent* e)
768{ 768{
769 if ( e->timerId() == pressTid ) { 769 if ( e->timerId() == pressTid ) {
770 killTimer(pressTid); 770 killTimer(pressTid);
771 pressTid = 0; 771 pressTid = 0;
772 if ( !pressed ) 772 if ( !pressed )
773 clearHighlight(); 773 clearHighlight();
774 } 774 }
775} 775}
776 776
777void Keyboard::repeat() 777void Keyboard::repeat()
778{ 778{
779 779
780 repeatTimer->start( 200 ); 780 repeatTimer->start( 200 );
781 emit key( unicode, qkeycode, modifiers, true, true ); 781 emit key( unicode, qkeycode, modifiers, true, true );
782} 782}
783 783
784void Keyboard::clearHighlight() 784void Keyboard::clearHighlight()
785{ 785{
786 if ( pressedKey >= 0 ) { 786 if ( pressedKey >= 0 ) {
787 int tmp = pressedKey; 787 int tmp = pressedKey;
788 pressedKey = -1; 788 pressedKey = -1;
789 QPainter p(this); 789 QPainter p(this);
790 drawKeyboard( p, tmp ); 790 drawKeyboard( p, tmp );
791 } 791 }
792} 792}
793 793
794 794
795QSize Keyboard::sizeHint() const 795QSize Keyboard::sizeHint() const
796{ 796{
797 QFontMetrics fm=fontMetrics(); 797 QFontMetrics fm=fontMetrics();
798 int keyHeight = fm.lineSpacing()+2; 798 int keyHeight = fm.lineSpacing()+2;
799 799
800 if (useOptiKeys) 800 if (useOptiKeys)
801 keyHeight += 1; 801 keyHeight += 1;
802 802
803 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); 803 return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 );
804} 804}
805 805
806 806
807void Keyboard::resetState() 807void Keyboard::resetState()
808{ 808{
809 picks->resetState(); 809 picks->resetState();
810} 810}
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,1182 +1,1182 @@
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 }
671 671
672 } 672 }
673 else { // normal char 673 else { // normal char
674 if ((shift || lock) && keys->shift(unicode)) { 674 if ((shift || lock) && keys->shift(unicode)) {
675 675
676 // make diaeresis/circumflex -> shift input shifted 676 // make diaeresis/circumflex -> shift input shifted
677 // diaeresis/circumflex chars 677 // diaeresis/circumflex chars
678 678
679 if (circumflex && keys->circumflex(keys->shift(unicode))) 679 if (circumflex && keys->circumflex(keys->shift(unicode)))
680 unicode = keys->circumflex(keys->shift(unicode)); 680 unicode = keys->circumflex(keys->shift(unicode));
681 else if (diaeresis && keys->diaeresis(keys->shift(unicode))) 681 else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
682 unicode = keys->diaeresis(keys->shift(unicode)); 682 unicode = keys->diaeresis(keys->shift(unicode));
683 else if (baccent && keys->baccent(keys->shift(unicode))) 683 else if (baccent && keys->baccent(keys->shift(unicode)))
684 unicode = keys->baccent(keys->shift(unicode)); 684 unicode = keys->baccent(keys->shift(unicode));
685 else if (accent && keys->accent(keys->shift(unicode))) 685 else if (accent && keys->accent(keys->shift(unicode)))
686 unicode = keys->accent(keys->shift(unicode)); 686 unicode = keys->accent(keys->shift(unicode));
687 else if (meta && keys->meta(keys->shift(unicode))) 687 else if (meta && keys->meta(keys->shift(unicode)))
688 unicode = keys->meta(keys->shift(unicode)); 688 unicode = keys->meta(keys->shift(unicode));
689 else 689 else
690 unicode = keys->shift(unicode); 690 unicode = keys->shift(unicode);
691 } 691 }
692 else if (meta && keys->meta(unicode)) { 692 else if (meta && keys->meta(unicode)) {
693 unicode = keys->meta(unicode); 693 unicode = keys->meta(unicode);
694 } 694 }
695 else if (circumflex && keys->circumflex(unicode)) { 695 else if (circumflex && keys->circumflex(unicode)) {
696 unicode = keys->circumflex(unicode); 696 unicode = keys->circumflex(unicode);
697 } 697 }
698 else if (diaeresis && keys->diaeresis(unicode)) { 698 else if (diaeresis && keys->diaeresis(unicode)) {
699 699
700 unicode = keys->diaeresis(unicode); 700 unicode = keys->diaeresis(unicode);
701 } 701 }
702 else if (baccent && keys->baccent(unicode)) { 702 else if (baccent && keys->baccent(unicode)) {
703 unicode = keys->baccent(unicode); 703 unicode = keys->baccent(unicode);
704 } 704 }
705 else if (accent && keys->accent(unicode)) { 705 else if (accent && keys->accent(unicode)) {
706 unicode = keys->accent(unicode); 706 unicode = keys->accent(unicode);
707 } 707 }
708 } 708 }
709 709
710 // korean parsing 710 // korean parsing
711 if (keys->lang == "ko") { 711 if (keys->lang == "ko") {
712 712
713 unicode = parseKoreanInput(unicode); 713 unicode = parseKoreanInput(unicode);
714 } 714 }
715 715
716 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 716 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
717 717
718 if ('A' <= unicode && unicode <= 'z' && modifiers) { 718 if ('A' <= unicode && unicode <= 'z' && modifiers) {
719 719
720 qkeycode = QChar(unicode).upper(); 720 qkeycode = QChar(unicode).upper();
721 unicode = qkeycode - '@'; 721 unicode = qkeycode - '@';
722 } 722 }
723 723
724 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 724 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
725 725
726 // pickboard stuff 726 // pickboard stuff
727 if (usePicks) { 727 if (usePicks) {
728 728
729 KeyboardConfig *dc = picks->dc; 729 KeyboardConfig *dc = picks->dc;
730 730
731 if (dc) { 731 if (dc) {
732 if (qkeycode == Qt::Key_Backspace) { 732 if (qkeycode == Qt::Key_Backspace) {
733 dc->input.remove(dc->input.last()); // remove last input 733 dc->input.remove(dc->input.last()); // remove last input
734 dc->decBackspaces(); 734 dc->decBackspaces();
735 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 735 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
736 dc->input.clear(); 736 dc->input.clear();
737 dc->resetBackspaces(); 737 dc->resetBackspaces();
738 } else { 738 } else {
739 dc->add(QString(QChar(unicode))); 739 dc->add(QString(QChar(unicode)));
740 dc->incBackspaces(); 740 dc->incBackspaces();
741 } 741 }
742 } 742 }
743 picks->repaint(); 743 picks->repaint();
744 } 744 }
745 745
746 746
747 // painting 747 // painting
748 pressed = TRUE; 748 pressed = TRUE;
749 749
750 pressedKeyRow = row; 750 pressedKeyRow = row;
751 pressedKeyCol = col; 751 pressedKeyCol = col;
752 752
753 if (need_repaint) repaint(FALSE); 753 if (need_repaint) repaint(FALSE);
754 else { // just paint the one key pressed 754 else { // just paint the one key pressed
755 755
756 756
757 757
758 QPainter p(this); 758 QPainter p(this);
759 drawKeyboard(p, row, col); 759 drawKeyboard(p, row, col);
760 760
761 } 761 }
762 762
763 if (useRepeat) repeatTimer->start( 800 ); 763 if (useRepeat) repeatTimer->start( 800 );
764 //pressTid = startTimer(80); 764 //pressTid = startTimer(80);
765 765
766} 766}
767 767
768void Keyboard::receive(const QCString &msg, const QByteArray &data) 768void Keyboard::receive(const QCString &msg, const QByteArray &data)
769{ 769{
770 if (msg == "setmultikey(QString)") { 770 if (msg == "setmultikey(QString)") {
771 QDataStream stream(data, IO_ReadOnly); 771 QDataStream stream(data, IO_ReadOnly);
772 QString map; 772 QString map;
773 stream >> map; 773 stream >> map;
774 setMapToFile(map); 774 setMapToFile(map);
775 } else if (msg == "getmultikey()") { 775 } else if (msg == "getmultikey()") {
776 reloadSw(); 776 reloadSw();
777 } 777 }
778} 778}
779 779
780/* Keyboard::mouseReleaseEvent {{{1 */ 780/* Keyboard::mouseReleaseEvent {{{1 */
781void Keyboard::mouseReleaseEvent(QMouseEvent*) 781void Keyboard::mouseReleaseEvent(QMouseEvent*)
782{ 782{
783 pressed = FALSE; 783 pressed = FALSE;
784 //if ( pressTid == 0 ) 784 //if ( pressTid == 0 )
785#if defined(Q_WS_QWS) || defined(_WS_QWS_) 785#if defined(Q_WS_QWS) || defined(_WS_QWS_)
786 if ( unicode != -1 ) { 786 if ( unicode != -1 ) {
787 emit key( unicode, qkeycode, modifiers, false, false ); 787 emit key( unicode, qkeycode, modifiers, false, false );
788 repeatTimer->stop(); 788 repeatTimer->stop();
789 } 789 }
790#endif 790#endif
791 if (shift && unicode != 0) { 791 if (shift && unicode != 0) {
792 792
793 793
794 *shift = 0; // unpress shift key 794 *shift = 0; // unpress shift key
795 shift = 0; // reset the shift pointer 795 shift = 0; // reset the shift pointer
796 repaint(FALSE); 796 repaint(FALSE);
797 797
798 } 798 }
799 if (ctrl && unicode != 0) { 799 if (ctrl && unicode != 0) {
800 800
801 *ctrl = 0; 801 *ctrl = 0;
802 ctrl = 0; 802 ctrl = 0;
803 repaint(FALSE); 803 repaint(FALSE);
804 804
805 } 805 }
806 if (alt && alt != 0) { 806 if (alt && alt != 0) {
807 807
808 *alt = 0; 808 *alt = 0;
809 alt = 0; 809 alt = 0;
810 repaint(FALSE); 810 repaint(FALSE);
811 811
812 } 812 }
813 813
814 /* 814 /*
815 * do not make the meta key release after being pressed 815 * do not make the meta key release after being pressed
816 * 816 *
817 817
818 else if (meta && unicode != 0) { 818 else if (meta && unicode != 0) {
819 819
820 *meta = 0; 820 *meta = 0;
821 meta = 0; 821 meta = 0;
822 repaint(FALSE); 822 repaint(FALSE);
823 } 823 }
824 824
825 */ 825 */
826 826
827 else clearHighlight(); 827 else clearHighlight();
828} 828}
829 829
830/* Keyboard::timerEvent {{{1 */ 830/* Keyboard::timerEvent {{{1 */
831 831
832/* dont know what this does, but i think it is here so that if your screen 832/* dont know what this does, but i think it is here so that if your screen
833 * sticks (like on an ipaq) then it will stop repeating if you click another 833 * sticks (like on an ipaq) then it will stop repeating if you click another
834 * key... but who knows what anything does in this thing anyway? 834 * key... but who knows what anything does in this thing anyway?
835 835
836 void Keyboard::timerEvent(QTimerEvent* e) 836 void Keyboard::timerEvent(QTimerEvent* e)
837{ 837{
838 if ( e->timerId() == pressTid ) { 838 if ( e->timerId() == pressTid ) {
839 killTimer(pressTid); 839 killTimer(pressTid);
840 pressTid = 0; 840 pressTid = 0;
841 if ( !pressed ) 841 if ( !pressed )
842 cout << "calling clearHighlight from timerEvent\n"; 842 cout << "calling clearHighlight from timerEvent\n";
843 //clearHighlight(); 843 //clearHighlight();
844 } 844 }
845} 845}
846*/ 846*/
847 847
848void Keyboard::repeat() 848void Keyboard::repeat()
849{ 849{
850 850
851 repeatTimer->start( 200 ); 851 repeatTimer->start( 200 );
852 emit key( unicode, qkeycode, modifiers, true, true ); 852 emit key( unicode, qkeycode, modifiers, true, true );
853} 853}
854 854
855void Keyboard::clearHighlight() 855void Keyboard::clearHighlight()
856{ 856{
857 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 857 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
858 int tmpRow = pressedKeyRow; 858 int tmpRow = pressedKeyRow;
859 int tmpCol = pressedKeyCol; 859 int tmpCol = pressedKeyCol;
860 860
861 pressedKeyRow = -1; 861 pressedKeyRow = -1;
862 pressedKeyCol = -1; 862 pressedKeyCol = -1;
863 863
864 QPainter p(this); 864 QPainter p(this);
865 drawKeyboard(p, tmpRow, tmpCol); 865 drawKeyboard(p, tmpRow, tmpCol);
866 } 866 }
867} 867}
868 868
869 869
870/* Keyboard::sizeHint {{{1 */ 870/* Keyboard::sizeHint {{{1 */
871QSize Keyboard::sizeHint() const 871QSize Keyboard::sizeHint() const
872{ 872{
873 QFontMetrics fm=fontMetrics(); 873 QFontMetrics fm=fontMetrics();
874 int keyHeight = fm.lineSpacing() + 2; 874 int keyHeight = fm.lineSpacing() + 2;
875 875
876 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1); 876 return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
877} 877}
878 878
879 879
880void Keyboard::resetState() 880void Keyboard::resetState()
881{ 881{
882 if (shift) { *shift = 0; shift = 0; } 882 if (shift) { *shift = 0; shift = 0; }
883 if (lock) {*lock = 0; lock = 0; } 883 if (lock) {*lock = 0; lock = 0; }
884 if (meta) { *meta = 0; meta = 0; } 884 if (meta) { *meta = 0; meta = 0; }
885 if (circumflex) { *circumflex = 0; circumflex = 0; } 885 if (circumflex) { *circumflex = 0; circumflex = 0; }
886 if (diaeresis) { *diaeresis = 0; diaeresis = 0; } 886 if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
887 if (baccent) { *baccent = 0; baccent = 0; } 887 if (baccent) { *baccent = 0; baccent = 0; }
888 if (accent) { *accent = 0; accent = 0; } 888 if (accent) { *accent = 0; accent = 0; }
889 889
890 schar = mchar = echar = 0; 890 schar = mchar = echar = 0;
891 picks->resetState(); 891 picks->resetState();
892} 892}
893 893
894/* Keyboard::togglePickboard {{{1 */ 894/* Keyboard::togglePickboard {{{1 */
895void Keyboard::togglePickboard(bool on_off) 895void Keyboard::togglePickboard(bool on_off)
896{ 896{
897 usePicks = on_off; 897 usePicks = on_off;
898 if (usePicks) { 898 if (usePicks) {
899 picks->show(); 899 picks->show();
900 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 900 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
901 //adjustSize(); 901 //adjustSize();
902 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 902 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
903 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 903 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
904 } else { 904 } else {
905 905
906 picks->hide(); 906 picks->hide();
907 picks->resetState(); 907 picks->resetState();
908 //move(x(), y() + picks->height()); 908 //move(x(), y() + picks->height());
909 //adjustSize(); 909 //adjustSize();
910 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 910 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
911 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 911 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
912 912
913 } 913 }
914 /* 914 /*
915 * this closes && opens the input method 915 * this closes && opens the input method
916 */ 916 */
917 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 917 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
918 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 918 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
919} 919}
920 920
921void Keyboard::toggleRepeat(bool on) { 921void Keyboard::toggleRepeat(bool on) {
922 922
923 useRepeat = on; 923 useRepeat = on;
924 //cout << "setting useRepeat to: " << useRepeat << "\n"; 924 //cout << "setting useRepeat to: " << useRepeat << "\n";
925} 925}
926 926
927void Keyboard::cleanupConfigDlg() { 927void Keyboard::cleanupConfigDlg() {
928 928
929 if ( configdlg ) { 929 if ( configdlg ) {
930 delete configdlg; 930 delete configdlg;
931 configdlg = 0; 931 configdlg = 0;
932 } 932 }
933} 933}
934 934
935void Keyboard::reloadSw() { 935void Keyboard::reloadSw() {
936 QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)"); 936 QCopEnvelope e("MultiKey/Switcher", "setsw(QString,QString)");
937 937
938 Config* config = new Config("multikey"); 938 Config* config = new Config("multikey");
939 config->setGroup("keymaps"); 939 config->setGroup("keymaps");
940 QString current_map = config->readEntry("current", "en.keymap"); 940 QString current_map = config->readEntry("current", "en.keymap");
941 delete config; 941 delete config;
942 942
943 e << ConfigDlg::loadSw().join("|") << current_map; 943 e << ConfigDlg::loadSw().join("|") << current_map;
944} 944}
945 945
946/* Keyboard::setMapTo ... {{{1 */ 946/* Keyboard::setMapTo ... {{{1 */
947void Keyboard::setMapToDefault() { 947void Keyboard::setMapToDefault() {
948 948
949 949
950 /* load current locale language map */ 950 /* load current locale language map */
951 Config *config = new Config("locale"); 951 Config *config = new Config("locale");
952 config->setGroup( "Language" ); 952 config->setGroup( "Language" );
953 QString l = config->readEntry( "Language" , "en" ); 953 QString l = config->readEntry( "Language" , "en" );
954 delete config; 954 delete config;
955 955
956 /* if Language represents as en_US, ru_RU, etc... */ 956 /* if Language represents as en_US, ru_RU, etc... */
957 int d = l.find('_'); 957 int d = l.find('_');
958 if (d != -1) { 958 if (d != -1) {
959 l.remove(d, l.length()-d); 959 l.remove(d, l.length()-d);
960 } 960 }
961 QString key_map = QPEApplication::qpeDir() + "share/multikey/" 961 QString key_map = QPEApplication::qpeDir() + "share/multikey/"
962 + l + ".keymap"; 962 + l + ".keymap";
963 963
964 /* save change to multikey config file */ 964 /* save change to multikey config file */
965 config = new Config("multikey"); 965 config = new Config("multikey");
966 config->setGroup ("keymaps"); 966 config->setGroup ("keymaps");
967 config->writeEntry ("current", key_map); // default closed 967 config->writeEntry ("current", key_map); // default closed
968 delete config; 968 delete config;
969 969
970 int prevRows = keys->rows(); 970 int prevRows = keys->rows();
971 971
972 delete keys; 972 delete keys;
973 keys = new Keys(key_map); 973 keys = new Keys(key_map);
974 974
975 // have to repaint the keyboard 975 // have to repaint the keyboard
976 if (prevRows != keys->rows()) { 976 if (prevRows != keys->rows()) {
977 977
978 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 978 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
979 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 979 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
980 980
981 } else repaint(FALSE); 981 } else repaint(FALSE);
982 982
983 resetState(); 983 resetState();
984} 984}
985 985
986void Keyboard::setMapToFile(QString map) { 986void Keyboard::setMapToFile(QString map) {
987 987
988 /* save change to multikey config file */ 988 /* save change to multikey config file */
989 Config *config = new Config("multikey"); 989 Config *config = new Config("multikey");
990 config->setGroup ("keymaps"); 990 config->setGroup ("keymaps");
991 config->writeEntry ("current", map); // default closed 991 config->writeEntry ("current", map); // default closed
992 992
993 delete config; 993 delete config;
994 994
995 int prevRows = keys->rows(); 995 int prevRows = keys->rows();
996 996
997 delete keys; 997 delete keys;
998 if (QFile(map).exists()) 998 if (QFile(map).exists())
999 keys = new Keys(map); 999 keys = new Keys(map);
1000 else 1000 else
1001 keys = new Keys(); 1001 keys = new Keys();
1002 1002
1003 if (keys->rows() != prevRows) { 1003 if (keys->rows() != prevRows) {
1004 1004
1005 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 1005 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
1006 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 1006 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
1007 } 1007 }
1008 else repaint(FALSE); 1008 else repaint(FALSE);
1009 1009
1010 resetState(); 1010 resetState();
1011} 1011}
1012 1012
1013/* Keybaord::reloadKeyboard {{{1 */ 1013/* Keybaord::reloadKeyboard {{{1 */
1014void Keyboard::reloadKeyboard() { 1014void Keyboard::reloadKeyboard() {
1015 1015
1016 // reload colors and redraw 1016 // reload colors and redraw
1017 loadKeyboardColors(); 1017 loadKeyboardColors();
1018 repaint(); 1018 repaint();
1019 1019
1020} 1020}
1021 1021
1022void Keyboard::loadKeyboardColors() { 1022void Keyboard::loadKeyboardColors() {
1023 1023
1024 Config config ("multikey"); 1024 Config config ("multikey");
1025 config.setGroup("colors"); 1025 config.setGroup("colors");
1026 1026
1027 QStringList color; 1027 QStringList color;
1028 color = config.readListEntry("keycolor", QChar(',')); 1028 color = config.readListEntry("keycolor", QChar(','));
1029 if (color.isEmpty()) { 1029 if (color.isEmpty()) {
1030 color = QStringList::split(",", "240,240,240"); 1030 color = QStringList::split(",", "240,240,240");
1031 config.writeEntry("keycolor", color.join(",")); 1031 config.writeEntry("keycolor", color.join(","));
1032 1032
1033 } 1033 }
1034 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1034 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1035 1035
1036 color = config.readListEntry("keycolor_pressed", QChar(',')); 1036 color = config.readListEntry("keycolor_pressed", QChar(','));
1037 if (color.isEmpty()) { 1037 if (color.isEmpty()) {
1038 color = QStringList::split(",", "171,183,198"); 1038 color = QStringList::split(",", "171,183,198");
1039 config.writeEntry("keycolor_pressed", color.join(",")); 1039 config.writeEntry("keycolor_pressed", color.join(","));
1040 1040
1041 } 1041 }
1042 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1042 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1043 1043
1044 color = config.readListEntry("keycolor_lines", QChar(',')); 1044 color = config.readListEntry("keycolor_lines", QChar(','));
1045 if (color.isEmpty()) { 1045 if (color.isEmpty()) {
1046 color = QStringList::split(",", "138,148,160"); 1046 color = QStringList::split(",", "138,148,160");
1047 config.writeEntry("keycolor_lines", color.join(",")); 1047 config.writeEntry("keycolor_lines", color.join(","));
1048 1048
1049 } 1049 }
1050 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1050 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1051 1051
1052 color = config.readListEntry("textcolor", QChar(',')); 1052 color = config.readListEntry("textcolor", QChar(','));
1053 if (color.isEmpty()) { 1053 if (color.isEmpty()) {
1054 color = QStringList::split(",", "43,54,68"); 1054 color = QStringList::split(",", "43,54,68");
1055 config.writeEntry("textcolor", color.join(",")); 1055 config.writeEntry("textcolor", color.join(","));
1056 1056
1057 } 1057 }
1058 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 1058 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
1059 1059
1060} 1060}
1061 1061
1062/* korean input functions {{{1 1062/* korean input functions {{{1
1063 * 1063 *
1064 * TODO 1064 * TODO
1065 * one major problem with this implementation is that you can't move the 1065 * one major problem with this implementation is that you can't move the
1066 * cursor after inputing korean chars, otherwise it will eat up and replace 1066 * cursor after inputing korean chars, otherwise it will eat up and replace
1067 * the char before the cursor you move to. fix that 1067 * the char before the cursor you move to. fix that
1068 * 1068 *
1069 * make backspace delete one single char, not the whole thing if still 1069 * make backspace delete one single char, not the whole thing if still
1070 * editing. 1070 * editing.
1071 * 1071 *
1072 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 1072 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
1073 * 1073 *
1074 * how korean input works 1074 * how korean input works
1075 * 1075 *
1076 * all following chars means unicode char value and are in hex 1076 * all following chars means unicode char value and are in hex
1077 * 1077 *
1078 * 초음 = schar (start char) 1078 * 초음 = schar (start char)
1079 * 중음 = mchar (middle char) 1079 * 중음 = mchar (middle char)
1080 * 끝음 = echar (end char) 1080 * 끝음 = echar (end char)
1081 * 1081 *
1082 * there are 19 schars. unicode position is at 1100 - 1112 1082 * there are 19 schars. unicode position is at 1100 - 1112
1083 * there are 21 mchars. unicode position is at 1161 - 1175 1083 * there are 21 mchars. unicode position is at 1161 - 1175
1084 * there are 27 echars. unicode position is at 11a8 - 11c2 1084 * there are 27 echars. unicode position is at 11a8 - 11c2
1085 * 1085 *
1086 * the map with everything combined is at ac00 - d7a3 1086 * the map with everything combined is at ac00 - d7a3
1087 * 1087 *
1088 */ 1088 */
1089 1089
1090ushort Keyboard::parseKoreanInput (ushort c) { 1090ushort Keyboard::parseKoreanInput (ushort c) {
1091 1091
1092 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 1092 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
1093 || 1093 ||
1094 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 1094 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
1095 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 1095 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
1096 1096
1097 schar = 0, mchar = 0, echar = 0; 1097 schar = 0, mchar = 0, echar = 0;
1098 return c; 1098 return c;
1099 } 1099 }
1100 1100
1101 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 1101 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
1102 1102
1103 if (schar == 0 || (schar != 0 && mchar == 0)) { 1103 if (schar == 0 || (schar != 0 && mchar == 0)) {
1104 schar = c; mchar = 0; echar = 0; 1104 schar = c; mchar = 0; echar = 0;
1105 return c; 1105 return c;
1106 } 1106 }
1107 else if (mchar != 0) { 1107 else if (mchar != 0) {
1108 1108
1109 if (echar == 0) { 1109 if (echar == 0) {
1110 1110
1111 if (!(echar = constoe(c))) { 1111 if (!(echar = constoe(c))) {
1112 1112
1113 schar = c; mchar = 0; echar = 0; 1113 schar = c; mchar = 0; echar = 0;
1114 return c; 1114 return c;
1115 } 1115 }
1116 1116
1117 } 1117 }
1118 else { // must figure out what the echar is 1118 else { // must figure out what the echar is
1119 1119
1120 if (echar == 0x11a8) { // ㄱ 1120 if (echar == 0x11a8) { // ㄱ
1121 1121
1122 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ 1122 if (c == 0x1100) echar = 0x11a9; // ㄱ + ㄱ
1123 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ 1123 else if (c == 0x1109) echar = 0x11aa; // ㄱ + ㅅ
1124 else { 1124 else {
1125 schar = c; mchar = 0; echar = 0; 1125 schar = c; mchar = 0; echar = 0;
1126 return c; 1126 return c;
1127 } 1127 }
1128 1128
1129 } else if (echar == 0x11ab) { // ㄴ 1129 } else if (echar == 0x11ab) { // ㄴ
1130 1130
1131 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ 1131 if (c == 0x110c) echar = 0x11ac; // ㄴ + ㅈ
1132 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ 1132 else if (c == 0x1112) echar = 0x11ad; // ㄴ + ㅎ
1133 else { 1133 else {
1134 schar = c; mchar = 0; echar = 0; 1134 schar = c; mchar = 0; echar = 0;
1135 return c; 1135 return c;
1136 } 1136 }
1137 1137
1138 } else if (echar == 0x11af) { // ㄹ 1138 } else if (echar == 0x11af) { // ㄹ
1139 1139
1140 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ 1140 if (c == 0x1100) echar = 0x11b0; // ㄹ + ㄱ
1141 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ 1141 else if (c == 0x1106) echar = 0x11b1; // ㄹ + ㅁ
1142 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ 1142 else if (c == 0x1107) echar = 0x11b2; // ㄹ + ㅂ
1143 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ 1143 else if (c == 0x1109) echar = 0x11b3; // ㄹ + ㅅ
1144 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ 1144 else if (c == 0x1110) echar = 0x11b4; // ㄹ + ㅌ
1145 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ 1145 else if (c == 0x1111) echar = 0x11b5; // ㄹ + ㅍ
1146 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ 1146 else if (c == 0x1112) echar = 0x11b6; // ㄹ + ㅎ
1147 else { 1147 else {
1148 schar = c; mchar = 0; echar = 0; 1148 schar = c; mchar = 0; echar = 0;
1149 return c; 1149 return c;
1150 } 1150 }
1151 1151
1152 } else if (echar == 0x11b8) { // ㅂ 1152 } else if (echar == 0x11b8) { // ㅂ
1153 1153
1154 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ 1154 if (c == 0x1109) echar = 0x11b9; // ㅂ + ㅅ
1155 else { 1155 else {
1156 schar = c; mchar = 0; echar = 0; 1156 schar = c; mchar = 0; echar = 0;
1157 return c; 1157 return c;
1158 } 1158 }
1159 1159
1160 } else if (echar == 0x11ba) { // ㅅ 1160 } else if (echar == 0x11ba) { // ㅅ
1161 1161
1162 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ 1162 if (c == 0x1109) echar = 0x11bb; // ㅅ + ㅅ
1163 else { 1163 else {
1164 schar = c; mchar = 0; echar = 0; 1164 schar = c; mchar = 0; echar = 0;
1165 return c; 1165 return c;
1166 } 1166 }
1167 1167
1168 } else { // if any other char, cannot combine chars 1168 } else { // if any other char, cannot combine chars
1169 1169
1170 schar = c; mchar = 0; echar = 0; 1170 schar = c; mchar = 0; echar = 0;
1171 return c; 1171 return c;
1172 } 1172 }
1173 1173
1174 unicode = echar; 1174 unicode = echar;
1175 } 1175 }
1176 } 1176 }
1177 1177
1178 } 1178 }
1179 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 1179 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
1180 1180
1181 if (schar != 0 && mchar == 0) { mchar = c; } 1181 if (schar != 0 && mchar == 0) { mchar = c; }
1182 1182