author | mickeyl <mickeyl> | 2005-01-05 15:22:09 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-01-05 15:22:09 (UTC) |
commit | 34ae22499b91f483f1cf505e515047ea11e8eaf0 (patch) (unidiff) | |
tree | 555ad0f77c87d445f1ca688f96a78fe903211190 | |
parent | 80823d4cbd234a54a15d6b439bd37a8ea42e7904 (diff) | |
download | opie-34ae22499b91f483f1cf505e515047ea11e8eaf0.zip opie-34ae22499b91f483f1cf505e515047ea11e8eaf0.tar.gz opie-34ae22499b91f483f1cf505e515047ea11e8eaf0.tar.bz2 |
remove hard coded fonts for dvorak, keyboard, multikey, pickboard, and unikeyboard
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | inputmethods/dvorak/dvorak.cpp | 13 | ||||
-rw-r--r-- | inputmethods/keyboard/keyboard.cpp | 13 | ||||
-rw-r--r-- | inputmethods/multikey/keyboard.cpp | 6 | ||||
-rw-r--r-- | inputmethods/pickboard/pickboard.cpp | 15 | ||||
-rw-r--r-- | inputmethods/unikeyboard/unikeyboard.cpp | 12 |
6 files changed, 45 insertions, 17 deletions
@@ -1,184 +1,185 @@ | |||
1 | 2005-??-??Opie 1.2.0 | 1 | 2005-??-??Opie 1.2.0 |
2 | 2 | ||
3 | New Features | 3 | New Features |
4 | ------------ | 4 | ------------ |
5 | 5 | ||
6 | Fixed Bugs | 6 | Fixed Bugs |
7 | ---------- | 7 | ---------- |
8 | * #1501 - Fixing bug in todo sql backend (eilers) | 8 | * #1501 - Fixed bug in todo sql backend (eilers) |
9 | * n.a - Removed hard coded font sizes in a couple of inputmethods (mickeyl) | ||
9 | 10 | ||
10 | Internal | 11 | Internal |
11 | -------- | 12 | -------- |
12 | * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) | 13 | * Added the Qtopia 1.7 SDK macros for quick-apps to easa compilation of 3rd party apps against our headers (mickeyl) |
13 | 14 | ||
14 | 2004-11-26Opie 1.1.8 | 15 | 2004-11-26Opie 1.1.8 |
15 | 16 | ||
16 | New Features | 17 | New Features |
17 | ------------ | 18 | ------------ |
18 | * PackageManager supports installation of local ipkg files (drw) | 19 | * PackageManager supports installation of local ipkg files (drw) |
19 | * PackageManager supports linking of applications to root (drw) | 20 | * PackageManager supports linking of applications to root (drw) |
20 | * PackageManager supports src/gz feeds (drw,wimpie) | 21 | * PackageManager supports src/gz feeds (drw,wimpie) |
21 | * Added a syslog information tab to sysinfo (mickeyl) | 22 | * Added a syslog information tab to sysinfo (mickeyl) |
22 | * Added new, more consistent, PIM icons + a GIMP teplate (ar) | 23 | * Added new, more consistent, PIM icons + a GIMP teplate (ar) |
23 | 24 | ||
24 | Fixed Bugs | 25 | Fixed Bugs |
25 | ---------- | 26 | ---------- |
26 | * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) | 27 | * #1017 - Tetrix doesn't display correctly for high resolution screens (drw) |
27 | * #1269 - VCards were imported into personal area if it was activated (eilers) | 28 | * #1269 - VCards were imported into personal area if it was activated (eilers) |
28 | * #1464 - Packagemanager dont set active filter after install a package (drw) | 29 | * #1464 - Packagemanager dont set active filter after install a package (drw) |
29 | * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) | 30 | * #1479 - Improved VCard-Parser to import VCards created by Evolution 2 and Apple Addressbook (eilers) |
30 | * #1493 - Fixed one column layout bug of the launcher (hrw) | 31 | * #1493 - Fixed one column layout bug of the launcher (hrw) |
31 | * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) | 32 | * n.a. - PackageManager - (Minor UI tweak) in filter dialog, when option is enabled, set focus to widget that corresponds to that option (drw) |
32 | * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) | 33 | * n.a. - PackageManager - (Minor UI tweak) fix double entry in source feed configuration when adding a new feed (drw) |
33 | * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) | 34 | * n.a. - Battery Applet - fix sizing of battery info popup (drw,mickeyl) |
34 | 35 | ||
35 | Internal | 36 | Internal |
36 | -------- | 37 | -------- |
37 | * Moved libopie1 to unsupported (mickeyl) | 38 | * Moved libopie1 to unsupported (mickeyl) |
38 | * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) | 39 | * Implemented generic queryByExample() with incremental searching. A lot of internal changes of the Pim2-library (eilers) |
39 | * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) | 40 | * Added fast and full featured and incremental sorted() for SQL addressbook backend (eilers) |
40 | 41 | ||
41 | 2004-11-14Opie 1.1.7 | 42 | 2004-11-14Opie 1.1.7 |
42 | 43 | ||
43 | New Features | 44 | New Features |
44 | ------------ | 45 | ------------ |
45 | * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) | 46 | * libOpieDB now uses SQLite V3 instead V2. Remember to upgrade your database files! (eilers) |
46 | * Backup now uses the busy indicator when backing up and restore (ar) | 47 | * Backup now uses the busy indicator when backing up and restore (ar) |
47 | * OpiePlayer2 gained adding of Directories to the playlist (zecke) | 48 | * OpiePlayer2 gained adding of Directories to the playlist (zecke) |
48 | * OpiePlayer2 better error handling (zecke) | 49 | * OpiePlayer2 better error handling (zecke) |
49 | * OpiePlayer2 progress indication while streaming (zecke) | 50 | * OpiePlayer2 progress indication while streaming (zecke) |
50 | * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) | 51 | * OpiePlayer2 ported to use libxine 1.0.0-rc6a (brad,zecke) |
51 | * Ported brightnessapplet from Qtopia 1.7 (mickeyl) | 52 | * Ported brightnessapplet from Qtopia 1.7 (mickeyl) |
52 | * Opie-Eye got a Digital Camera File Backend (alwin,zecke) | 53 | * Opie-Eye got a Digital Camera File Backend (alwin,zecke) |
53 | * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) | 54 | * Support for Tuxpad1 of Tradesquare.NL (mickeyl,zecke) |
54 | * Opie-Console use Custom Font and Size in a Profile (harlekin) | 55 | * Opie-Console use Custom Font and Size in a Profile (harlekin) |
55 | * Opie-Console transparently log the Output and Input to a file (harlekin) | 56 | * Opie-Console transparently log the Output and Input to a file (harlekin) |
56 | * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) | 57 | * Added new O-menu icon to lock the PDA immediately: opie-lockapplet (clem) |
57 | * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) | 58 | * Opie-Security now hides the plugin-based authentication tabs if no auth. plugin package is installed (clem) |
58 | * Opie-Security gained a 'test authentication' button (clem) | 59 | * Opie-Security gained a 'test authentication' button (clem) |
59 | * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults | 60 | * Opie-Eye got a more unique layout (menubar), a slideshow, user can setup some defaults |
60 | * Opie-Mail improve the handling of POP mail boxes (alwin) | 61 | * Opie-Mail improve the handling of POP mail boxes (alwin) |
61 | * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) | 62 | * Both Opie-Eye and Opie-Mail were greatly improved due the hard work of Rajko Albrecht(alwin) |
62 | * Opie IRC - backports of the 'NeIRC fork' (zecke) | 63 | * Opie IRC - backports of the 'NeIRC fork' (zecke) |
63 | 64 | ||
64 | Fixed Bugs | 65 | Fixed Bugs |
65 | ---------- | 66 | ---------- |
66 | * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) | 67 | * #501 - Pickboard is able to show 'Umlaute' (TT,zecke) |
67 | * #608 - Make Opie usable for left handed users (zecke) | 68 | * #608 - Make Opie usable for left handed users (zecke) |
68 | * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) | 69 | * #957 - Import of VCards/VTodos/VEvents with BASE64 encoding (ljp,zecke) |
69 | * #1245 - Opie-Go 'paused' (zecke) | 70 | * #1245 - Opie-Go 'paused' (zecke) |
70 | * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) | 71 | * #1358 - DocTab didn't show any MimeTypes (was fixed earlier) (zecke) |
71 | * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) | 72 | * #1380 - QDateBookAccess::remove() doesn't remove entries (eilers, zecke) |
72 | * #1395 - Build VNC Backend with gcc3.4 | 73 | * #1395 - Build VNC Backend with gcc3.4 |
73 | * #1440 - The icon of opie-mobilemsg is missing (CoreDump) | 74 | * #1440 - The icon of opie-mobilemsg is missing (CoreDump) |
74 | * #1426 - Add missing opie-bartender Icon (CoreDump) | 75 | * #1426 - Add missing opie-bartender Icon (CoreDump) |
75 | * #1445 - Opie-Sheet Has No Icon (CoreDump) | 76 | * #1445 - Opie-Sheet Has No Icon (CoreDump) |
76 | * #1448 - Brightness Applet added (mickeyl) | 77 | * #1448 - Brightness Applet added (mickeyl) |
77 | * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) | 78 | * #1450 - ZSame didn't clear the bonus item after winning a game (zecke) |
78 | * #1482 - Fix OFileSelector to be able to sort by size (zecke) | 79 | * #1482 - Fix OFileSelector to be able to sort by size (zecke) |
79 | * n.a. - Opie-mail: fixed some crasher, some layout-problems | 80 | * n.a. - Opie-mail: fixed some crasher, some layout-problems |
80 | * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) | 81 | * n.a. - Converted applications to not hardcode /opt/QtPalmtop but to use QPEApplication::qpeDir (zecke) |
81 | * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) | 82 | * n.a. - Converted usage of qpeDir() not to include a '/' as first charachter of the string (zecke) |
82 | * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) | 83 | * n.a. - Build system: Enable distcc and ccache when crosscompiling too, and use them everywhere we can (clem) |
83 | * n.a. - Build system: Fix deps in several config.in (and fix scripts/deps.pl too) to stop breaking builds, especially with make -j highNumber (clem) | 84 | * n.a. - Build system: Fix deps in several config.in (and fix scripts/deps.pl too) to stop breaking builds, especially with make -j highNumber (clem) |
84 | * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) | 85 | * n.a. - Removed hardcoded icon size in a couple of applets (mickeyl) |
85 | 86 | ||
86 | Internal | 87 | Internal |
87 | -------- | 88 | -------- |
88 | * Opie-Qashmoney has been moved to unsupported (mickeyl) | 89 | * Opie-Qashmoney has been moved to unsupported (mickeyl) |
89 | * Opie-Ubrowser has been moved to unsupported (mickeyl) | 90 | * Opie-Ubrowser has been moved to unsupported (mickeyl) |
90 | 91 | ||
91 | 2004-09-17Opie 1.1.6 | 92 | 2004-09-17Opie 1.1.6 |
92 | 93 | ||
93 | New Features | 94 | New Features |
94 | ------------ | 95 | ------------ |
95 | * Fifteen gained configurable number of items (zecke) | 96 | * Fifteen gained configurable number of items (zecke) |
96 | * Fifteen can have custom background images (zecke) | 97 | * Fifteen can have custom background images (zecke) |
97 | * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) | 98 | * Added daemonizing capabilities to QWS Server [via Qt/Embedded] (mickeyl) |
98 | * Integrated the new security framework into libopie2 (zecke,clem) | 99 | * Integrated the new security framework into libopie2 (zecke,clem) |
99 | * Converted the launcher to use the new security framework (zecke) | 100 | * Converted the launcher to use the new security framework (zecke) |
100 | * Backup can now handle custom locations for backup and restore (ar) | 101 | * Backup can now handle custom locations for backup and restore (ar) |
101 | * Implemented right-on-hold feedback (wimpie,zecke) | 102 | * Implemented right-on-hold feedback (wimpie,zecke) |
102 | * Lots of new features in opie-reader (tim,pohly) | 103 | * Lots of new features in opie-reader (tim,pohly) |
103 | * Build system cleanups (schurig) | 104 | * Build system cleanups (schurig) |
104 | 105 | ||
105 | Fixed Bugs | 106 | Fixed Bugs |
106 | -------- | 107 | -------- |
107 | * #1005 - Fixed backup to CompactFlash (ar) | 108 | * #1005 - Fixed backup to CompactFlash (ar) |
108 | * #1167 - Fixed Opie write crashing on more text than one page (ar) | 109 | * #1167 - Fixed Opie write crashing on more text than one page (ar) |
109 | * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) | 110 | * #1225 - Fixed repeated light flashing on Zaurus with keyz (mickeyl) |
110 | * #1359 - Fixed bookmarks in Gutenbrowser (ljp) | 111 | * #1359 - Fixed bookmarks in Gutenbrowser (ljp) |
111 | * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) | 112 | * #1361 - Fixed auto upercase in Opie-Addressbook (eilers) |
112 | * #1370 - Pimconverter now reacts on cancel key (eilers) | 113 | * #1370 - Pimconverter now reacts on cancel key (eilers) |
113 | * #1376 - Bring back the capslock/numlock display (zecke) | 114 | * #1376 - Bring back the capslock/numlock display (zecke) |
114 | * #1383 - Language settings now warns about losing open apps (Markus Litz) | 115 | * #1383 - Language settings now warns about losing open apps (Markus Litz) |
115 | * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) | 116 | * #1393 - Fixed line wrap issues in opie-console for the default profile (mickeyl) |
116 | * #1394 - Fixed oversized headline in opie-login (coredump) | 117 | * #1394 - Fixed oversized headline in opie-login (coredump) |
117 | * #1396 - Opie-console captures the escape key and vim is working (zecke) | 118 | * #1396 - Opie-console captures the escape key and vim is working (zecke) |
118 | * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) | 119 | * #1401 - Scrollbar is now only visible if necessary in DocTab (mickeyl) |
119 | 120 | ||
120 | 2004-07-06Opie 1.1.4 | 121 | 2004-07-06Opie 1.1.4 |
121 | 122 | ||
122 | New Features | 123 | New Features |
123 | ------------ | 124 | ------------ |
124 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) | 125 | * Added four themes courtesy Robert Griebl (http://www.softforge.de/zstyle) |
125 | * Added Conversion tool for pim-data (eilers) | 126 | * Added Conversion tool for pim-data (eilers) |
126 | * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) | 127 | * Introduced new OPimAccessFactory and OBackendFactory which simplyfies database access (eilers) |
127 | * Modified the PIM API for providing generic use of OPimRecords (eilers) | 128 | * Modified the PIM API for providing generic use of OPimRecords (eilers) |
128 | * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) | 129 | * Clicking on the application symbol now iterates over the application's top level widgets if already raised (zecke) |
129 | 130 | ||
130 | Fixed Bugs | 131 | Fixed Bugs |
131 | -------- | 132 | -------- |
132 | * #1068 - Country Drop Down Box Off Screen | 133 | * #1068 - Country Drop Down Box Off Screen |
133 | * #1291 - Opie tinykate does not open .desktop files (ar) | 134 | * #1291 - Opie tinykate does not open .desktop files (ar) |
134 | * #1291 - Opie sheet not saving correctly (ar) | 135 | * #1291 - Opie sheet not saving correctly (ar) |
135 | * #1294 - Opie does not know about British Summer Time | 136 | * #1294 - Opie does not know about British Summer Time |
136 | * #1314 - Drawpad initialization (mickeyl) | 137 | * #1314 - Drawpad initialization (mickeyl) |
137 | * #1317 - Packagemanager crashes on hold-down or install (chicken) | 138 | * #1317 - Packagemanager crashes on hold-down or install (chicken) |
138 | * #1321 - Batteryapplet graphic glitch (harlekin) | 139 | * #1321 - Batteryapplet graphic glitch (harlekin) |
139 | * #1324 - ZSafe not starting up (mickeyl) | 140 | * #1324 - ZSafe not starting up (mickeyl) |
140 | * #1328 - Personal Home Address fields is trimmed to 1char (eilers) | 141 | * #1328 - Personal Home Address fields is trimmed to 1char (eilers) |
141 | * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) | 142 | * #1327 - Opie-mail ipk does not depend on libopiedb2 (chicken) |
142 | * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) | 143 | * #1345 - Networksettingsplugin wlan plugin dependency on libpcap0 (mickeyl) |
143 | * #1348 - Datebook dependency on libopiedb2 (chicken) | 144 | * #1348 - Datebook dependency on libopiedb2 (chicken) |
144 | * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) | 145 | * #1328 - Switched SQLDatabase and VCards char encoding from latin1 to unicode (eilers) |
145 | 146 | ||
146 | 2004-04-25Opie 1.1.3 | 147 | 2004-04-25Opie 1.1.3 |
147 | 148 | ||
148 | * Introduced first implementation of SQL-Support using SQLite (eilers) | 149 | * Introduced first implementation of SQL-Support using SQLite (eilers) |
149 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) | 150 | * Added a new Gutenberg Project reader app - opie-gutenbrowser (ljp) |
150 | * Added a real system graffiti character set (brad) | 151 | * Added a real system graffiti character set (brad) |
151 | * Added Generic Keyconfig Widget (zecke) | 152 | * Added Generic Keyconfig Widget (zecke) |
152 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) | 153 | * Improved Screenshotapplet and Drawpad integration. You can now open a screenshot in drawpad and take notes (zecke) |
153 | * Added new Bible reader app - opie-dagger (drw) | 154 | * Added new Bible reader app - opie-dagger (drw) |
154 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) | 155 | * Added a new Image Viewer. Work is ongoing (zecke,alwin) |
155 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) | 156 | * Added namespace usage in libopie2 and everywhere (zecke,alwin) |
156 | * Enabled the possibility to pass command line arguments to applications (mickeyl) | 157 | * Enabled the possibility to pass command line arguments to applications (mickeyl) |
157 | * Added an about applet showing some credits and information about Opie (mickeyl) | 158 | * Added an about applet showing some credits and information about Opie (mickeyl) |
158 | * Added benchmarking functionality to sysinfo (mickeyl) | 159 | * Added benchmarking functionality to sysinfo (mickeyl) |
159 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) | 160 | * Added applet and configuration application for switching hardware keyboard layouts (alwin) |
160 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) | 161 | * Ported applications from libopie1 to libopie2* (drw,ar,alwin) |
161 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) | 162 | * Imported fullscreen and font improvements from the Qkonsole fork to embeddedkonsole (waspe) |
162 | * Clean-up of package information in control files (drw) | 163 | * Clean-up of package information in control files (drw) |
163 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) | 164 | * Repaired mediummount which was broken since integrating the quicklauncher (alwin) |
164 | * Improved big-screen support (zecke,ar) | 165 | * Improved big-screen support (zecke,ar) |
165 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) | 166 | * Improved multikeyboard support, added keyboard layout switching applet (mouse) |
166 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) | 167 | * Added a new mail client based on libetpan (harlekin,alwin,jgf) |
167 | * Added new package manager - opie-packagemanager (drw) | 168 | * Added new package manager - opie-packagemanager (drw) |
168 | * Improved light-n-power for C7x0 (mickeyl) | 169 | * Improved light-n-power for C7x0 (mickeyl) |
169 | * Added automatic rotation support for C7x0 (treke) | 170 | * Added automatic rotation support for C7x0 (treke) |
170 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) | 171 | * Split libopie1 up into a set of smaller - functionally grouped - libraries (mickeyl) |
171 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) | 172 | * Added scanning the wireless network neighbourhood to networksettings (mickeyl) |
172 | 173 | ||
173 | 2003-11-29Opie 1.0.3 | 174 | 2003-11-29Opie 1.0.3 |
174 | 175 | ||
175 | * Released as Version 1.0.3 | 176 | * Released as Version 1.0.3 |
176 | * Improved i18n (various contributors) | 177 | * Improved i18n (various contributors) |
177 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) | 178 | * Reduced application startup time by integrating the TT quicklauncher (zecke,harlekin) |
178 | * Made the Documents Tab optional (mickeyl) | 179 | * Made the Documents Tab optional (mickeyl) |
179 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) | 180 | * Integrated basic support for HP iPAQ 54xx and the Jornada 5xx (chicken) |
180 | 181 | ||
181 | 2003-08-04Opie 1.0.0 | 182 | 2003-08-04Opie 1.0.0 |
182 | 183 | ||
183 | * Released as Version 1.0.0 | 184 | * Released as Version 1.0.0 |
184 | * Including a PPP module for easy dial up (tille,harlekin,zecke) | 185 | * Including a PPP module for easy dial up (tille,harlekin,zecke) |
diff --git a/inputmethods/dvorak/dvorak.cpp b/inputmethods/dvorak/dvorak.cpp index 2137f22..3781e38 100644 --- a/inputmethods/dvorak/dvorak.cpp +++ b/inputmethods/dvorak/dvorak.cpp | |||
@@ -1,795 +1,802 @@ | |||
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 | #include <qpe/config.h> | |
25 | #include <qwindowsystem_qws.h> | 25 | #include <qwindowsystem_qws.h> |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qfontmetrics.h> | 27 | #include <qfontmetrics.h> |
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <ctype.h> | 29 | #include <ctype.h> |
30 | 30 | ||
31 | 31 | ||
32 | #define USE_SMALL_BACKSPACE | 32 | #define USE_SMALL_BACKSPACE |
33 | 33 | ||
34 | using namespace Dvorak; | 34 | using namespace Dvorak; |
35 | 35 | ||
36 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 36 | Keyboard::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 | // get the default font | ||
47 | Config *config = new Config( "qpe" ); | ||
48 | config->setGroup( "Appearance" ); | ||
49 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); | ||
50 | int fontSize = config->readNumEntry( "FontSize", 10 ); | ||
51 | delete config; | ||
52 | |||
46 | picks = new KeyboardPicks( this ); | 53 | picks = new KeyboardPicks( this ); |
47 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 54 | picks->setFont( QFont( familyStr, fontSize ) ); |
48 | setFont( QFont( "smallsmooth", 9 ) ); | 55 | setFont( QFont( familyStr, fontSize ) ); |
49 | picks->initialise(); | 56 | picks->initialise(); |
50 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 57 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
51 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 58 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
52 | 59 | ||
53 | repeatTimer = new QTimer( this ); | 60 | repeatTimer = new QTimer( this ); |
54 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 61 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
55 | } | 62 | } |
56 | 63 | ||
57 | void Keyboard::resizeEvent(QResizeEvent*) | 64 | void Keyboard::resizeEvent(QResizeEvent*) |
58 | { | 65 | { |
59 | int ph = picks->sizeHint().height(); | 66 | int ph = picks->sizeHint().height(); |
60 | picks->setGeometry( 0, 0, width(), ph ); | 67 | picks->setGeometry( 0, 0, width(), ph ); |
61 | keyHeight = (height()-ph)/5; | 68 | keyHeight = (height()-ph)/5; |
62 | int nk; | 69 | int nk; |
63 | if ( useOptiKeys ) { | 70 | if ( useOptiKeys ) { |
64 | nk = 15; | 71 | nk = 15; |
65 | } else if ( useLargeKeys ) { | 72 | } else if ( useLargeKeys ) { |
66 | nk = 15; | 73 | nk = 15; |
67 | } else { | 74 | } else { |
68 | nk = 19; | 75 | nk = 19; |
69 | } | 76 | } |
70 | defaultKeyWidth = width()/nk; | 77 | defaultKeyWidth = width()/nk; |
71 | xoffs = (width()-defaultKeyWidth*nk)/2; | 78 | xoffs = (width()-defaultKeyWidth*nk)/2; |
72 | } | 79 | } |
73 | 80 | ||
74 | void KeyboardPicks::initialise() | 81 | void KeyboardPicks::initialise() |
75 | { | 82 | { |
76 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 83 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
77 | mode = 0; | 84 | mode = 0; |
78 | dc = new KeyboardConfig(this); | 85 | dc = new KeyboardConfig(this); |
79 | configs.append(dc); | 86 | configs.append(dc); |
80 | } | 87 | } |
81 | 88 | ||
82 | QSize KeyboardPicks::sizeHint() const | 89 | QSize KeyboardPicks::sizeHint() const |
83 | { | 90 | { |
84 | return QSize(240,fontMetrics().lineSpacing()); | 91 | return QSize(240,fontMetrics().lineSpacing()); |
85 | } | 92 | } |
86 | 93 | ||
87 | 94 | ||
88 | void KeyboardConfig::generateText(const QString &s) | 95 | void KeyboardConfig::generateText(const QString &s) |
89 | { | 96 | { |
90 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 97 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
91 | for (int i=0; i<(int)backspaces; i++) { | 98 | for (int i=0; i<(int)backspaces; i++) { |
92 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false ); | 99 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false ); |
93 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false ); | 100 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false ); |
94 | } | 101 | } |
95 | for (int i=0; i<(int)s.length(); i++) { | 102 | for (int i=0; i<(int)s.length(); i++) { |
96 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 103 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
97 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 104 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
98 | } | 105 | } |
99 | parent->emitKey( 0, ::Qt::Key_Space, 0, true, false ); | 106 | parent->emitKey( 0, ::Qt::Key_Space, 0, true, false ); |
100 | parent->emitKey( 0, ::Qt::Key_Space, 0, false, false ); | 107 | parent->emitKey( 0, ::Qt::Key_Space, 0, false, false ); |
101 | backspaces = 0; | 108 | backspaces = 0; |
102 | #endif | 109 | #endif |
103 | } | 110 | } |
104 | 111 | ||
105 | 112 | ||
106 | //PC keyboard layout and scancodes | 113 | //PC keyboard layout and scancodes |
107 | 114 | ||
108 | /* | 115 | /* |
109 | Format: length, code, length, code, ..., 0 | 116 | Format: length, code, length, code, ..., 0 |
110 | 117 | ||
111 | length is measured in half the width of a standard key. | 118 | length is measured in half the width of a standard key. |
112 | If code < 0x80 we have length/2 consecutive standard keys, | 119 | If code < 0x80 we have length/2 consecutive standard keys, |
113 | starting with scancode code. | 120 | starting with scancode code. |
114 | 121 | ||
115 | Special keys are hardcoded, one at a time, with length of key | 122 | 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 | 123 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
117 | up in specialM[]. (The special keys are not keymappable.) | 124 | up in specialM[]. (The special keys are not keymappable.) |
118 | 125 | ||
119 | */ | 126 | */ |
120 | 127 | ||
121 | static const uchar * const keyboard_opti[5] = { | 128 | static 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", | 129 | (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", | 130 | (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", | 131 | (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", | 132 | (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" | 133 | (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 | }; | 134 | }; |
128 | 135 | ||
129 | static const uchar * const keyboard_standard[5] = { | 136 | static const uchar * const keyboard_standard[5] = { |
130 | 137 | ||
131 | #ifdef USE_SMALL_BACKSPACE | 138 | #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", | 139 | (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 | 140 | #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", | 141 | (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 | 142 | #endif |
136 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP | 143 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP |
137 | 144 | ||
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", | 145 | (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 | 146 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN |
140 | 147 | ||
141 | (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203", | 148 | (const uchar *const)"\004\202\002a\002o\002e\002u\002i\002d\002h\002t\002n\002s\002-\004\203", |
142 | //CAPS + asdf.. + RETURN | 149 | //CAPS + asdf.. + RETURN |
143 | 150 | ||
144 | (const uchar *const)"\005\204\002;\002q\002j\002k\002x\002b\002m\002w\002v\002z\005\204\002\223\002\223\002\211", | 151 | (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 | 152 | //SHIFT + zxcv... //+ UP |
146 | 153 | ||
147 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" | 154 | (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 | 155 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT |
149 | 156 | ||
150 | }; | 157 | }; |
151 | 158 | ||
152 | 159 | ||
153 | struct ShiftMap { | 160 | struct ShiftMap { |
154 | char normal; | 161 | char normal; |
155 | char shifted; | 162 | char shifted; |
156 | }; | 163 | }; |
157 | 164 | ||
158 | 165 | ||
159 | static const ShiftMap shiftMap[] = { | 166 | static const ShiftMap shiftMap[] = { |
160 | { '`', '~' }, | 167 | { '`', '~' }, |
161 | { '1', '!' }, | 168 | { '1', '!' }, |
162 | { '2', '@' }, | 169 | { '2', '@' }, |
163 | { '3', '#' }, | 170 | { '3', '#' }, |
164 | { '4', '$' }, | 171 | { '4', '$' }, |
165 | { '5', '%' }, | 172 | { '5', '%' }, |
166 | { '6', '^' }, | 173 | { '6', '^' }, |
167 | { '7', '&' }, | 174 | { '7', '&' }, |
168 | { '8', '*' }, | 175 | { '8', '*' }, |
169 | { '9', '(' }, | 176 | { '9', '(' }, |
170 | { '0', ')' }, | 177 | { '0', ')' }, |
171 | { '-', '_' }, | 178 | { '-', '_' }, |
172 | { '=', '+' }, | 179 | { '=', '+' }, |
173 | { '\\', '|' }, | 180 | { '\\', '|' }, |
174 | { '[', '{' }, | 181 | { '[', '{' }, |
175 | { ']', '}' }, | 182 | { ']', '}' }, |
176 | { ';', ':' }, | 183 | { ';', ':' }, |
177 | { '\'', '"' }, | 184 | { '\'', '"' }, |
178 | { ',', '<' }, | 185 | { ',', '<' }, |
179 | { '.', '>' }, | 186 | { '.', '>' }, |
180 | { '/', '?' } | 187 | { '/', '?' } |
181 | }; | 188 | }; |
182 | 189 | ||
183 | 190 | ||
184 | /* XPM */ | 191 | /* XPM */ |
185 | static const char * const uparrow_xpm[]={ | 192 | static const char * const uparrow_xpm[]={ |
186 | "9 9 2 1", | 193 | "9 9 2 1", |
187 | "a c #000000", | 194 | "a c #000000", |
188 | ". c None", | 195 | ". c None", |
189 | ".........", | 196 | ".........", |
190 | "....a....", | 197 | "....a....", |
191 | "...aaa...", | 198 | "...aaa...", |
192 | "..aaaaa..", | 199 | "..aaaaa..", |
193 | "....a....", | 200 | "....a....", |
194 | "....a....", | 201 | "....a....", |
195 | "....a....", | 202 | "....a....", |
196 | "....a....", | 203 | "....a....", |
197 | "........."}; | 204 | "........."}; |
198 | /* XPM */ | 205 | /* XPM */ |
199 | static const char * const leftarrow_xpm[]={ | 206 | static const char * const leftarrow_xpm[]={ |
200 | "9 9 2 1", | 207 | "9 9 2 1", |
201 | "a c #000000", | 208 | "a c #000000", |
202 | ". c None", | 209 | ". c None", |
203 | ".........", | 210 | ".........", |
204 | ".........", | 211 | ".........", |
205 | "...a.....", | 212 | "...a.....", |
206 | "..aa.....", | 213 | "..aa.....", |
207 | ".aaaaaaa.", | 214 | ".aaaaaaa.", |
208 | "..aa.....", | 215 | "..aa.....", |
209 | "...a.....", | 216 | "...a.....", |
210 | ".........", | 217 | ".........", |
211 | "........."}; | 218 | "........."}; |
212 | /* XPM */ | 219 | /* XPM */ |
213 | static const char * const downarrow_xpm[]={ | 220 | static const char * const downarrow_xpm[]={ |
214 | "9 9 2 1", | 221 | "9 9 2 1", |
215 | "a c #000000", | 222 | "a c #000000", |
216 | ". c None", | 223 | ". c None", |
217 | ".........", | 224 | ".........", |
218 | "....a....", | 225 | "....a....", |
219 | "....a....", | 226 | "....a....", |
220 | "....a....", | 227 | "....a....", |
221 | "....a....", | 228 | "....a....", |
222 | "..aaaaa..", | 229 | "..aaaaa..", |
223 | "...aaa...", | 230 | "...aaa...", |
224 | "....a....", | 231 | "....a....", |
225 | "........."}; | 232 | "........."}; |
226 | /* XPM */ | 233 | /* XPM */ |
227 | static const char * const rightarrow_xpm[]={ | 234 | static const char * const rightarrow_xpm[]={ |
228 | "9 9 2 1", | 235 | "9 9 2 1", |
229 | "a c #000000", | 236 | "a c #000000", |
230 | ". c None", | 237 | ". c None", |
231 | ".........", | 238 | ".........", |
232 | ".........", | 239 | ".........", |
233 | ".....a...", | 240 | ".....a...", |
234 | ".....aa..", | 241 | ".....aa..", |
235 | ".aaaaaaa.", | 242 | ".aaaaaaa.", |
236 | ".....aa..", | 243 | ".....aa..", |
237 | ".....a...", | 244 | ".....a...", |
238 | ".........", | 245 | ".........", |
239 | "........."}; | 246 | "........."}; |
240 | /* XPM */ | 247 | /* XPM */ |
241 | static const char * const insert_xpm[]={ | 248 | static const char * const insert_xpm[]={ |
242 | "9 9 2 1", | 249 | "9 9 2 1", |
243 | "a c #000000", | 250 | "a c #000000", |
244 | ". c None", | 251 | ". c None", |
245 | ".........", | 252 | ".........", |
246 | "a........", | 253 | "a........", |
247 | "a.aaa.aaa", | 254 | "a.aaa.aaa", |
248 | "a.a.a.a..", | 255 | "a.a.a.a..", |
249 | "a.a.a..a.", | 256 | "a.a.a..a.", |
250 | "a.a.a...a", | 257 | "a.a.a...a", |
251 | "a.a.a.aaa", | 258 | "a.a.a.aaa", |
252 | ".........", | 259 | ".........", |
253 | "........."}; | 260 | "........."}; |
254 | /* XPM */ | 261 | /* XPM */ |
255 | static const char * const delete_xpm[]={ | 262 | static const char * const delete_xpm[]={ |
256 | "9 9 2 1", | 263 | "9 9 2 1", |
257 | "a c #000000", | 264 | "a c #000000", |
258 | ". c None", | 265 | ". c None", |
259 | ".........", | 266 | ".........", |
260 | "aa......a", | 267 | "aa......a", |
261 | "a.a.aaa.a", | 268 | "a.a.aaa.a", |
262 | "a.a.a.a.a", | 269 | "a.a.a.a.a", |
263 | "a.a.aaa.a.", | 270 | "a.a.aaa.a.", |
264 | "a.a.a...a", | 271 | "a.a.a...a", |
265 | "aaa.aaa.a", | 272 | "aaa.aaa.a", |
266 | ".........", | 273 | ".........", |
267 | "........."}; | 274 | "........."}; |
268 | /* XPM */ | 275 | /* XPM */ |
269 | static const char * const home_xpm[]={ | 276 | static const char * const home_xpm[]={ |
270 | "9 9 2 1", | 277 | "9 9 2 1", |
271 | "a c #000000", | 278 | "a c #000000", |
272 | ". c None", | 279 | ". c None", |
273 | "....a....", | 280 | "....a....", |
274 | "...a.a...", | 281 | "...a.a...", |
275 | "..a...a..", | 282 | "..a...a..", |
276 | ".a.....a.", | 283 | ".a.....a.", |
277 | "aa.aaa.aa", | 284 | "aa.aaa.aa", |
278 | ".a.a.a.a.", | 285 | ".a.a.a.a.", |
279 | ".a.a.a.a.", | 286 | ".a.a.a.a.", |
280 | ".aaaaaaa.", | 287 | ".aaaaaaa.", |
281 | "........."}; | 288 | "........."}; |
282 | /* XPM */ | 289 | /* XPM */ |
283 | static const char * const end_xpm[]={ | 290 | static const char * const end_xpm[]={ |
284 | "10 9 2 1", | 291 | "10 9 2 1", |
285 | "a c #000000", | 292 | "a c #000000", |
286 | ". c None", | 293 | ". c None", |
287 | "..........", | 294 | "..........", |
288 | "aa.......a", | 295 | "aa.......a", |
289 | "a..aaa.aaa", | 296 | "a..aaa.aaa", |
290 | "aa.a.a.a.a", | 297 | "aa.a.a.a.a", |
291 | "a..a.a.a.a", | 298 | "a..a.a.a.a", |
292 | "a..a.a.a.a", | 299 | "a..a.a.a.a", |
293 | "aa.a.a.aaa", | 300 | "aa.a.a.aaa", |
294 | "..........", | 301 | "..........", |
295 | ".........."}; | 302 | ".........."}; |
296 | /* XPM */ | 303 | /* XPM */ |
297 | static const char * const pageup_xpm[]={ | 304 | static const char * const pageup_xpm[]={ |
298 | "9 9 2 1", | 305 | "9 9 2 1", |
299 | "a c #000000", | 306 | "a c #000000", |
300 | ". c None", | 307 | ". c None", |
301 | ".aaa.aaa.", | 308 | ".aaa.aaa.", |
302 | ".a.a.a.a.", | 309 | ".a.a.a.a.", |
303 | ".aaa..aa.", | 310 | ".aaa..aa.", |
304 | ".a...aaa.", | 311 | ".a...aaa.", |
305 | ".........", | 312 | ".........", |
306 | ".a.a.aaa.", | 313 | ".a.a.aaa.", |
307 | ".a.a.a.a.", | 314 | ".a.a.a.a.", |
308 | ".aaa.aaa.", | 315 | ".aaa.aaa.", |
309 | ".....a..."}; | 316 | ".....a..."}; |
310 | /* XPM */ | 317 | /* XPM */ |
311 | static const char * const pagedown_xpm[]={ | 318 | static const char * const pagedown_xpm[]={ |
312 | "9 9 2 1", | 319 | "9 9 2 1", |
313 | "a c #000000", | 320 | "a c #000000", |
314 | ". c None", | 321 | ". c None", |
315 | ".aaa.aaa.", | 322 | ".aaa.aaa.", |
316 | ".a.a.a.a.", | 323 | ".a.a.a.a.", |
317 | ".aaa..aa.", | 324 | ".aaa..aa.", |
318 | ".a...aaa.", | 325 | ".a...aaa.", |
319 | ".........", | 326 | ".........", |
320 | "...a.....", | 327 | "...a.....", |
321 | ".aaa.aaa.", | 328 | ".aaa.aaa.", |
322 | ".a.a.a.a.", | 329 | ".a.a.a.a.", |
323 | ".aaa.a.a."}; | 330 | ".aaa.a.a."}; |
324 | /* XPM */ | 331 | /* XPM */ |
325 | static const char * const expand_xpm[]={ | 332 | static const char * const expand_xpm[]={ |
326 | "4 9 2 1", | 333 | "4 9 2 1", |
327 | "a c #408040", | 334 | "a c #408040", |
328 | ". c None", | 335 | ". c None", |
329 | "a...", | 336 | "a...", |
330 | "aa..", | 337 | "aa..", |
331 | "aaa.", | 338 | "aaa.", |
332 | "aaaa", | 339 | "aaaa", |
333 | "aaaa", | 340 | "aaaa", |
334 | "aaaa", | 341 | "aaaa", |
335 | "aaa.", | 342 | "aaa.", |
336 | "aa..", | 343 | "aa..", |
337 | "a..."}; | 344 | "a..."}; |
338 | /* XPM */ | 345 | /* XPM */ |
339 | #ifdef USE_SMALL_BACKSPACE | 346 | #ifdef USE_SMALL_BACKSPACE |
340 | static const char * const backspace_xpm[]={ | 347 | static const char * const backspace_xpm[]={ |
341 | "9 9 2 1", | 348 | "9 9 2 1", |
342 | "a c #000000", | 349 | "a c #000000", |
343 | ". c None", | 350 | ". c None", |
344 | ".........", | 351 | ".........", |
345 | ".........", | 352 | ".........", |
346 | "...a.....", | 353 | "...a.....", |
347 | "..aa.....", | 354 | "..aa.....", |
348 | ".aaaaaaaa", | 355 | ".aaaaaaaa", |
349 | "..aa.....", | 356 | "..aa.....", |
350 | "...a.....", | 357 | "...a.....", |
351 | ".........", | 358 | ".........", |
352 | "........."}; | 359 | "........."}; |
353 | #else | 360 | #else |
354 | static const char * const backspace_xpm[]={ | 361 | static const char * const backspace_xpm[]={ |
355 | "21 9 2 1", | 362 | "21 9 2 1", |
356 | "a c #000000", | 363 | "a c #000000", |
357 | ". c None", | 364 | ". c None", |
358 | ".....................", | 365 | ".....................", |
359 | ".....................", | 366 | ".....................", |
360 | ".....aaa..a..........", | 367 | ".....aaa..a..........", |
361 | ".a...a..a.a.a.aaa.aaa", | 368 | ".a...a..a.a.a.aaa.aaa", |
362 | "aaaa.aaa..aa..aa..a.a", | 369 | "aaaa.aaa..aa..aa..a.a", |
363 | ".a...a..a.aaa..aa.a.a", | 370 | ".a...a..a.aaa..aa.a.a", |
364 | ".....aaaa.a.a.aaa.aa.", | 371 | ".....aaaa.a.a.aaa.aa.", |
365 | "..................a..", | 372 | "..................a..", |
366 | "....................."}; | 373 | "....................."}; |
367 | #endif | 374 | #endif |
368 | /* XPM */ | 375 | /* XPM */ |
369 | static const char * const escape_xpm[]={ | 376 | static const char * const escape_xpm[]={ |
370 | "9 9 2 1", | 377 | "9 9 2 1", |
371 | "a c #000000", | 378 | "a c #000000", |
372 | ". c None", | 379 | ". c None", |
373 | ".........", | 380 | ".........", |
374 | ".........", | 381 | ".........", |
375 | ".aa.aa.aa", | 382 | ".aa.aa.aa", |
376 | ".a..a..a.", | 383 | ".a..a..a.", |
377 | ".aa.aa.a.", | 384 | ".aa.aa.a.", |
378 | ".a...a.a.", | 385 | ".a...a.a.", |
379 | ".aa.aa.aa", | 386 | ".aa.aa.aa", |
380 | ".........", | 387 | ".........", |
381 | "........."}; | 388 | "........."}; |
382 | 389 | ||
383 | 390 | ||
384 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, | 391 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, |
385 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, | 392 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, |
386 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, | 393 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, |
387 | Opti, ResetDict, | 394 | Opti, ResetDict, |
388 | Divide, Multiply, Add, Subtract, Decimal, Equal, | 395 | Divide, Multiply, Add, Subtract, Decimal, Equal, |
389 | Percent, Sqrt, Inverse, Escape }; | 396 | Percent, Sqrt, Inverse, Escape }; |
390 | 397 | ||
391 | typedef struct SpecialMap { | 398 | typedef struct SpecialMap { |
392 | int qcode; | 399 | int qcode; |
393 | ushort unicode; | 400 | ushort unicode; |
394 | const char * label; | 401 | const char * label; |
395 | const char * const * xpm; | 402 | const char * const * xpm; |
396 | }; | 403 | }; |
397 | 404 | ||
398 | 405 | ||
399 | static const SpecialMap specialM[] = { | 406 | static const SpecialMap specialM[] = { |
400 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, | 407 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, |
401 | { Qt::Key_Tab, 9,"Tab", NULL }, | 408 | { Qt::Key_Tab, 9,"Tab", NULL }, |
402 | { Qt::Key_CapsLock, 0,"Caps", NULL }, | 409 | { Qt::Key_CapsLock, 0,"Caps", NULL }, |
403 | { Qt::Key_Return, 13,"Ret", NULL }, | 410 | { Qt::Key_Return, 13,"Ret", NULL }, |
404 | { Qt::Key_Shift, 0,"Shift", NULL }, | 411 | { Qt::Key_Shift, 0,"Shift", NULL }, |
405 | { Qt::Key_Control, 0,"Ctrl", NULL }, | 412 | { Qt::Key_Control, 0,"Ctrl", NULL }, |
406 | { Qt::Key_Alt, 0,"Alt", NULL }, | 413 | { Qt::Key_Alt, 0,"Alt", NULL }, |
407 | { Qt::Key_Space, ' ',"", NULL }, | 414 | { Qt::Key_Space, ' ',"", NULL }, |
408 | { BackSlash, 43,"\\", NULL }, | 415 | { BackSlash, 43,"\\", NULL }, |
409 | 416 | ||
410 | // Need images? | 417 | // Need images? |
411 | { Qt::Key_Up, 0,"^", uparrow_xpm }, | 418 | { Qt::Key_Up, 0,"^", uparrow_xpm }, |
412 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, | 419 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, |
413 | { Qt::Key_Down, 0,"v", downarrow_xpm }, | 420 | { Qt::Key_Down, 0,"v", downarrow_xpm }, |
414 | { Qt::Key_Right, 0,">", rightarrow_xpm }, | 421 | { Qt::Key_Right, 0,">", rightarrow_xpm }, |
415 | { Qt::Key_Insert, 0,"I", insert_xpm }, | 422 | { Qt::Key_Insert, 0,"I", insert_xpm }, |
416 | { Qt::Key_Home, 0,"H", home_xpm }, | 423 | { Qt::Key_Home, 0,"H", home_xpm }, |
417 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, | 424 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, |
418 | { Qt::Key_End, 0,"E", end_xpm }, | 425 | { Qt::Key_End, 0,"E", end_xpm }, |
419 | { Qt::Key_Delete, 0,"X", delete_xpm }, | 426 | { Qt::Key_Delete, 0,"X", delete_xpm }, |
420 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, | 427 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, |
421 | { Blank, 0," ", NULL }, | 428 | { Blank, 0," ", NULL }, |
422 | { Expand, 0,"->", expand_xpm }, | 429 | { Expand, 0,"->", expand_xpm }, |
423 | { Opti, 0,"#", NULL }, | 430 | { Opti, 0,"#", NULL }, |
424 | { ResetDict, 0,"R", NULL }, | 431 | { ResetDict, 0,"R", NULL }, |
425 | 432 | ||
426 | // number pad stuff | 433 | // number pad stuff |
427 | { Divide, 0,"/", NULL }, | 434 | { Divide, 0,"/", NULL }, |
428 | { Multiply, 0,"*", NULL }, | 435 | { Multiply, 0,"*", NULL }, |
429 | { Add, 0,"+", NULL }, | 436 | { Add, 0,"+", NULL }, |
430 | { Subtract, 0,"-", NULL }, | 437 | { Subtract, 0,"-", NULL }, |
431 | { Decimal, 0,".", NULL }, | 438 | { Decimal, 0,".", NULL }, |
432 | { Equal, 0,"=", NULL }, | 439 | { Equal, 0,"=", NULL }, |
433 | { Percent, 0,"%", NULL }, | 440 | { Percent, 0,"%", NULL }, |
434 | { Sqrt, 0, "^1/2", NULL }, | 441 | { Sqrt, 0, "^1/2", NULL }, |
435 | { Inverse, 0, "1/x", NULL }, | 442 | { Inverse, 0, "1/x", NULL }, |
436 | 443 | ||
437 | { Escape, 27, "ESC", escape_xpm } | 444 | { Escape, 27, "ESC", escape_xpm } |
438 | }; | 445 | }; |
439 | 446 | ||
440 | 447 | ||
441 | static int keycode( int i2, int j, const uchar **keyboard ) | 448 | static int keycode( int i2, int j, const uchar **keyboard ) |
442 | { | 449 | { |
443 | if ( j <0 || j >= 5 ) | 450 | if ( j <0 || j >= 5 ) |
444 | return 0; | 451 | return 0; |
445 | 452 | ||
446 | const uchar *row = keyboard[j]; | 453 | const uchar *row = keyboard[j]; |
447 | 454 | ||
448 | while ( *row && *row <= i2 ) { | 455 | while ( *row && *row <= i2 ) { |
449 | i2 -= *row; | 456 | i2 -= *row; |
450 | row += 2; | 457 | row += 2; |
451 | } | 458 | } |
452 | 459 | ||
453 | if ( !*row ) return 0; | 460 | if ( !*row ) return 0; |
454 | 461 | ||
455 | int k; | 462 | int k; |
456 | if ( row[1] >= 0x80 ) { | 463 | if ( row[1] >= 0x80 ) { |
457 | k = row[1]; | 464 | k = row[1]; |
458 | } else { | 465 | } else { |
459 | k = row[1]+i2/2; | 466 | k = row[1]+i2/2; |
460 | } | 467 | } |
461 | 468 | ||
462 | return k; | 469 | return k; |
463 | } | 470 | } |
464 | 471 | ||
465 | 472 | ||
466 | /* | 473 | /* |
467 | return scancode and width of first key in row \a j if \a j >= 0, | 474 | 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. | 475 | or next key on current row if \a j < 0. |
469 | 476 | ||
470 | */ | 477 | */ |
471 | 478 | ||
472 | int Keyboard::getKey( int &w, int j ) { | 479 | int Keyboard::getKey( int &w, int j ) { |
473 | static const uchar *row = 0; | 480 | static const uchar *row = 0; |
474 | static int key_i = 0; | 481 | static int key_i = 0; |
475 | static int scancode = 0; | 482 | static int scancode = 0; |
476 | static int half = 0; | 483 | static int half = 0; |
477 | 484 | ||
478 | if ( j >= 0 && j < 5 ) { | 485 | if ( j >= 0 && j < 5 ) { |
479 | if (useOptiKeys) | 486 | if (useOptiKeys) |
480 | row = keyboard_opti[j]; | 487 | row = keyboard_opti[j]; |
481 | else | 488 | else |
482 | row = keyboard_standard[j]; | 489 | row = keyboard_standard[j]; |
483 | half=0; | 490 | half=0; |
484 | } | 491 | } |
485 | 492 | ||
486 | if ( !row || !*row ) { | 493 | if ( !row || !*row ) { |
487 | return 0; | 494 | return 0; |
488 | } else if ( row[1] >= 0x80 ) { | 495 | } else if ( row[1] >= 0x80 ) { |
489 | scancode = row[1]; | 496 | scancode = row[1]; |
490 | w = (row[0] * w + (half++&1)) / 2; | 497 | w = (row[0] * w + (half++&1)) / 2; |
491 | row += 2; | 498 | row += 2; |
492 | return scancode; | 499 | return scancode; |
493 | } else if ( key_i <= 0 ) { | 500 | } else if ( key_i <= 0 ) { |
494 | key_i = row[0]/2; | 501 | key_i = row[0]/2; |
495 | scancode = row[1]; | 502 | scancode = row[1]; |
496 | } | 503 | } |
497 | key_i--; | 504 | key_i--; |
498 | if ( key_i <= 0 ) | 505 | if ( key_i <= 0 ) |
499 | row += 2; | 506 | row += 2; |
500 | return scancode++; | 507 | return scancode++; |
501 | } | 508 | } |
502 | 509 | ||
503 | 510 | ||
504 | void Keyboard::paintEvent(QPaintEvent* e) | 511 | void Keyboard::paintEvent(QPaintEvent* e) |
505 | { | 512 | { |
506 | QPainter painter(this); | 513 | QPainter painter(this); |
507 | painter.setClipRect(e->rect()); | 514 | painter.setClipRect(e->rect()); |
508 | drawKeyboard( painter ); | 515 | drawKeyboard( painter ); |
509 | picks->dc->draw( &painter ); | 516 | picks->dc->draw( &painter ); |
510 | } | 517 | } |
511 | 518 | ||
512 | 519 | ||
513 | /* | 520 | /* |
514 | Draw the keyboard. | 521 | Draw the keyboard. |
515 | 522 | ||
516 | If key >= 0, only the specified key is drawn. | 523 | If key >= 0, only the specified key is drawn. |
517 | */ | 524 | */ |
518 | void Keyboard::drawKeyboard( QPainter &p, int key ) | 525 | void Keyboard::drawKeyboard( QPainter &p, int key ) |
519 | { | 526 | { |
520 | const bool threeD = FALSE; | 527 | const bool threeD = FALSE; |
521 | const QColorGroup& cg = colorGroup(); | 528 | const QColorGroup& cg = colorGroup(); |
522 | QColor keycolor = // cg.background(); | 529 | QColor keycolor = // cg.background(); |
523 | QColor(240,240,230); // Beige! | 530 | QColor(240,240,230); // Beige! |
524 | QColor keycolor_pressed = cg.mid(); | 531 | QColor keycolor_pressed = cg.mid(); |
525 | QColor keycolor_lo = cg.dark(); | 532 | QColor keycolor_lo = cg.dark(); |
526 | QColor keycolor_hi = cg.light(); | 533 | QColor keycolor_hi = cg.light(); |
527 | QColor textcolor = QColor(0,0,0); // cg.text(); | 534 | QColor textcolor = QColor(0,0,0); // cg.text(); |
528 | 535 | ||
529 | int margin = threeD ? 1 : 0; | 536 | int margin = threeD ? 1 : 0; |
530 | 537 | ||
531 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); | 538 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); |
532 | 539 | ||
533 | for ( int j = 0; j < 5; j++ ) { | 540 | for ( int j = 0; j < 5; j++ ) { |
534 | int y = j * keyHeight + picks->height() + 1; | 541 | int y = j * keyHeight + picks->height() + 1; |
535 | int x = xoffs; | 542 | int x = xoffs; |
536 | int kw = defaultKeyWidth; | 543 | int kw = defaultKeyWidth; |
537 | int k= getKey( kw, j ); | 544 | int k= getKey( kw, j ); |
538 | while ( k ) { | 545 | while ( k ) { |
539 | if ( key < 0 || k == key ) { | 546 | if ( key < 0 || k == key ) { |
540 | QString s; | 547 | QString s; |
541 | bool pressed = (k == pressedKey); | 548 | bool pressed = (k == pressedKey); |
542 | bool blank = (k == 0223); | 549 | bool blank = (k == 0223); |
543 | const char * const * xpm = NULL; | 550 | const char * const * xpm = NULL; |
544 | 551 | ||
545 | if ( k >= 0x80 ) { | 552 | if ( k >= 0x80 ) { |
546 | s = specialM[k - 0x80].label; | 553 | s = specialM[k - 0x80].label; |
547 | 554 | ||
548 | xpm = specialM[k - 0x80].xpm; | 555 | xpm = specialM[k - 0x80].xpm; |
549 | 556 | ||
550 | if ( k == ShiftCode ) { | 557 | if ( k == ShiftCode ) { |
551 | pressed = shift; | 558 | pressed = shift; |
552 | } else if ( k == CapsCode ) { | 559 | } else if ( k == CapsCode ) { |
553 | pressed = lock; | 560 | pressed = lock; |
554 | } else if ( k == CtrlCode ) { | 561 | } else if ( k == CtrlCode ) { |
555 | pressed = ctrl; | 562 | pressed = ctrl; |
556 | } else if ( k == AltCode ) { | 563 | } else if ( k == AltCode ) { |
557 | pressed = alt; | 564 | pressed = alt; |
558 | } | 565 | } |
559 | } else { | 566 | } else { |
560 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 567 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
561 | /* | 568 | /* |
562 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : | 569 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : |
563 | QWSServer::keyMap()[k].unicode); | 570 | QWSServer::keyMap()[k].unicode); |
564 | */ | 571 | */ |
565 | // ### Fixme, bad code, needs improving, whole thing needs to | 572 | // ### 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 | 573 | // be re-coded to get rid of the way it did things with scancodes etc |
567 | char shifted = k; | 574 | char shifted = k; |
568 | if ( !isalpha( k ) ) { | 575 | if ( !isalpha( k ) ) { |
569 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 576 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
570 | if ( shiftMap[i].normal == k ) | 577 | if ( shiftMap[i].normal == k ) |
571 | shifted = shiftMap[i].shifted; | 578 | shifted = shiftMap[i].shifted; |
572 | } else { | 579 | } else { |
573 | shifted = toupper( k ); | 580 | shifted = toupper( k ); |
574 | } | 581 | } |
575 | s = QChar( shift^lock ? shifted : k ); | 582 | s = QChar( shift^lock ? shifted : k ); |
576 | #endif | 583 | #endif |
577 | } | 584 | } |
578 | 585 | ||
579 | if (!blank) { | 586 | if (!blank) { |
580 | if ( pressed ) | 587 | if ( pressed ) |
581 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); | 588 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); |
582 | else | 589 | else |
583 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); | 590 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); |
584 | 591 | ||
585 | if ( threeD ) { | 592 | if ( threeD ) { |
586 | p.setPen(pressed ? keycolor_lo : keycolor_hi); | 593 | p.setPen(pressed ? keycolor_lo : keycolor_hi); |
587 | p.drawLine( x, y+1, x, y+keyHeight-2 ); | 594 | p.drawLine( x, y+1, x, y+keyHeight-2 ); |
588 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); | 595 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); |
589 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); | 596 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); |
590 | } else if ( j == 0 ) { | 597 | } else if ( j == 0 ) { |
591 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 598 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
592 | p.drawLine( x, y, x+kw, y ); | 599 | p.drawLine( x, y, x+kw, y ); |
593 | } | 600 | } |
594 | 601 | ||
595 | // right | 602 | // right |
596 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 603 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
597 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); | 604 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); |
598 | 605 | ||
599 | if ( threeD ) { | 606 | if ( threeD ) { |
600 | p.setPen(keycolor_lo.light()); | 607 | p.setPen(keycolor_lo.light()); |
601 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); | 608 | 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 ); | 609 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); |
603 | } | 610 | } |
604 | 611 | ||
605 | if (xpm) { | 612 | if (xpm) { |
606 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); | 613 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); |
607 | } else { | 614 | } else { |
608 | p.setPen(textcolor); | 615 | p.setPen(textcolor); |
609 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); | 616 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); |
610 | } | 617 | } |
611 | 618 | ||
612 | if ( threeD ) { | 619 | if ( threeD ) { |
613 | p.setPen(keycolor_hi); | 620 | p.setPen(keycolor_hi); |
614 | p.drawLine( x, y, x+kw-1, y ); | 621 | p.drawLine( x, y, x+kw-1, y ); |
615 | } | 622 | } |
616 | 623 | ||
617 | // bottom | 624 | // bottom |
618 | p.setPen(keycolor_lo); | 625 | p.setPen(keycolor_lo); |
619 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); | 626 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); |
620 | 627 | ||
621 | } else { | 628 | } else { |
622 | p.fillRect( x, y, kw, keyHeight, cg.background() ); | 629 | p.fillRect( x, y, kw, keyHeight, cg.background() ); |
623 | } | 630 | } |
624 | } | 631 | } |
625 | 632 | ||
626 | x += kw; | 633 | x += kw; |
627 | kw = defaultKeyWidth; | 634 | kw = defaultKeyWidth; |
628 | k = getKey( kw ); | 635 | k = getKey( kw ); |
629 | } | 636 | } |
630 | } | 637 | } |
631 | } | 638 | } |
632 | 639 | ||
633 | 640 | ||
634 | void Keyboard::mousePressEvent(QMouseEvent *e) | 641 | void Keyboard::mousePressEvent(QMouseEvent *e) |
635 | { | 642 | { |
636 | clearHighlight(); // typing fast? | 643 | clearHighlight(); // typing fast? |
637 | 644 | ||
638 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; | 645 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; |
639 | int j = (e->y() - picks->height()) / keyHeight; | 646 | int j = (e->y() - picks->height()) / keyHeight; |
640 | 647 | ||
641 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); | 648 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); |
642 | bool need_repaint = FALSE; | 649 | bool need_repaint = FALSE; |
643 | unicode = -1; | 650 | unicode = -1; |
644 | qkeycode = 0; | 651 | qkeycode = 0; |
645 | if ( k >= 0x80 ) { | 652 | if ( k >= 0x80 ) { |
646 | if ( k == ShiftCode ) { | 653 | if ( k == ShiftCode ) { |
647 | shift = !shift; | 654 | shift = !shift; |
648 | need_repaint = TRUE; | 655 | need_repaint = TRUE; |
649 | } else if ( k == AltCode ){ | 656 | } else if ( k == AltCode ){ |
650 | alt = !alt; | 657 | alt = !alt; |
651 | need_repaint = TRUE; | 658 | need_repaint = TRUE; |
652 | } else if ( k == CapsCode ) { | 659 | } else if ( k == CapsCode ) { |
653 | lock = !lock; | 660 | lock = !lock; |
654 | need_repaint = TRUE; | 661 | need_repaint = TRUE; |
655 | } else if ( k == CtrlCode ) { | 662 | } else if ( k == CtrlCode ) { |
656 | ctrl = !ctrl; | 663 | ctrl = !ctrl; |
657 | need_repaint = TRUE; | 664 | need_repaint = TRUE; |
658 | } else if ( k == 0224 /* Expand */ ) { | 665 | } else if ( k == 0224 /* Expand */ ) { |
659 | useLargeKeys = !useLargeKeys; | 666 | useLargeKeys = !useLargeKeys; |
660 | resizeEvent(0); | 667 | resizeEvent(0); |
661 | repaint( TRUE ); // need it to clear first | 668 | repaint( TRUE ); // need it to clear first |
662 | } else if ( k == 0225 /* Opti/Toggle */ ) { | 669 | } else if ( k == 0225 /* Opti/Toggle */ ) { |
663 | useOptiKeys = !useOptiKeys; | 670 | useOptiKeys = !useOptiKeys; |
664 | resizeEvent(0); | 671 | resizeEvent(0); |
665 | repaint( TRUE ); // need it to clear first | 672 | repaint( TRUE ); // need it to clear first |
666 | } else { | 673 | } else { |
667 | qkeycode = specialM[ k - 0x80 ].qcode; | 674 | qkeycode = specialM[ k - 0x80 ].qcode; |
668 | unicode = specialM[ k - 0x80 ].unicode; | 675 | unicode = specialM[ k - 0x80 ].unicode; |
669 | } | 676 | } |
670 | } else { | 677 | } else { |
671 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 678 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
672 | /* | 679 | /* |
673 | qk = QWSServer::keyMap()[k].key_code; | 680 | qk = QWSServer::keyMap()[k].key_code; |
674 | if ( qk != Key_unknown ) { | 681 | if ( qk != Key_unknown ) { |
675 | if ( ctrl ) | 682 | if ( ctrl ) |
676 | u = QWSServer::keyMap()[k].ctrl_unicode; | 683 | u = QWSServer::keyMap()[k].ctrl_unicode; |
677 | else if ( shift^lock ) | 684 | else if ( shift^lock ) |
678 | u = QWSServer::keyMap()[k].shift_unicode; | 685 | u = QWSServer::keyMap()[k].shift_unicode; |
679 | else | 686 | else |
680 | u = QWSServer::keyMap()[k].unicode; | 687 | u = QWSServer::keyMap()[k].unicode; |
681 | } | 688 | } |
682 | */ | 689 | */ |
683 | char shifted = k; | 690 | char shifted = k; |
684 | if ( !isalpha( k ) ) { | 691 | if ( !isalpha( k ) ) { |
685 | // ### Fixme, bad code, needs improving, whole thing needs to | 692 | // ### 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 | 693 | // 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++ ) | 694 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
688 | if ( shiftMap[i].normal == k ) | 695 | if ( shiftMap[i].normal == k ) |
689 | shifted = shiftMap[i].shifted; | 696 | shifted = shiftMap[i].shifted; |
690 | } else { | 697 | } else { |
691 | shifted = toupper( k ); | 698 | shifted = toupper( k ); |
692 | } | 699 | } |
693 | QChar tempChar( shift^lock ? shifted : k ); | 700 | QChar tempChar( shift^lock ? shifted : k ); |
694 | unicode = tempChar.unicode(); | 701 | unicode = tempChar.unicode(); |
695 | #endif | 702 | #endif |
696 | } | 703 | } |
697 | if ( unicode != -1 ) { | 704 | if ( unicode != -1 ) { |
698 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | | 705 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | |
699 | (alt ? Qt::AltButton : 0); | 706 | (alt ? Qt::AltButton : 0); |
700 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 707 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
701 | emit key( unicode, qkeycode, modifiers, true, false ); | 708 | emit key( unicode, qkeycode, modifiers, true, false ); |
702 | repeatTimer->start( 500 ); | 709 | repeatTimer->start( 500 ); |
703 | #endif | 710 | #endif |
704 | need_repaint = shift || alt || ctrl; | 711 | need_repaint = shift || alt || ctrl; |
705 | shift = alt = ctrl = FALSE; | 712 | shift = alt = ctrl = FALSE; |
706 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); | 713 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); |
707 | 714 | ||
708 | KeyboardConfig *dc = picks->dc; | 715 | KeyboardConfig *dc = picks->dc; |
709 | 716 | ||
710 | if (dc) { | 717 | if (dc) { |
711 | if (qkeycode == Qt::Key_Backspace) { | 718 | if (qkeycode == Qt::Key_Backspace) { |
712 | dc->input.remove(dc->input.last()); // remove last input | 719 | dc->input.remove(dc->input.last()); // remove last input |
713 | dc->decBackspaces(); | 720 | dc->decBackspaces(); |
714 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || | 721 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || |
715 | qkeycode == Qt::Key_Space || | 722 | qkeycode == Qt::Key_Space || |
716 | QChar(unicode).isPunct() ) { | 723 | QChar(unicode).isPunct() ) { |
717 | dc->input.clear(); | 724 | dc->input.clear(); |
718 | dc->resetBackspaces(); | 725 | dc->resetBackspaces(); |
719 | } else { | 726 | } else { |
720 | dc->add(QString(QChar(unicode))); | 727 | dc->add(QString(QChar(unicode))); |
721 | dc->incBackspaces(); | 728 | dc->incBackspaces(); |
722 | } | 729 | } |
723 | } | 730 | } |
724 | 731 | ||
725 | picks->repaint(); | 732 | picks->repaint(); |
726 | 733 | ||
727 | } | 734 | } |
728 | pressedKey = k; | 735 | pressedKey = k; |
729 | if ( need_repaint ) { | 736 | if ( need_repaint ) { |
730 | repaint( FALSE ); | 737 | repaint( FALSE ); |
731 | } else { | 738 | } else { |
732 | QPainter p(this); | 739 | QPainter p(this); |
733 | drawKeyboard( p, pressedKey ); | 740 | drawKeyboard( p, pressedKey ); |
734 | } | 741 | } |
735 | pressTid = startTimer(80); | 742 | pressTid = startTimer(80); |
736 | pressed = TRUE; | 743 | pressed = TRUE; |
737 | } | 744 | } |
738 | 745 | ||
739 | 746 | ||
740 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 747 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
741 | { | 748 | { |
742 | if ( pressTid == 0 ) | 749 | if ( pressTid == 0 ) |
743 | clearHighlight(); | 750 | clearHighlight(); |
744 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 751 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
745 | if ( unicode != -1 ) { | 752 | if ( unicode != -1 ) { |
746 | emit key( unicode, qkeycode, modifiers, false, false ); | 753 | emit key( unicode, qkeycode, modifiers, false, false ); |
747 | repeatTimer->stop(); | 754 | repeatTimer->stop(); |
748 | } | 755 | } |
749 | #endif | 756 | #endif |
750 | pressed = FALSE; | 757 | pressed = FALSE; |
751 | } | 758 | } |
752 | 759 | ||
753 | void Keyboard::timerEvent(QTimerEvent* e) | 760 | void Keyboard::timerEvent(QTimerEvent* e) |
754 | { | 761 | { |
755 | if ( e->timerId() == pressTid ) { | 762 | if ( e->timerId() == pressTid ) { |
756 | killTimer(pressTid); | 763 | killTimer(pressTid); |
757 | pressTid = 0; | 764 | pressTid = 0; |
758 | if ( !pressed ) | 765 | if ( !pressed ) |
759 | clearHighlight(); | 766 | clearHighlight(); |
760 | } | 767 | } |
761 | } | 768 | } |
762 | 769 | ||
763 | void Keyboard::repeat() | 770 | void Keyboard::repeat() |
764 | { | 771 | { |
765 | repeatTimer->start( 150 ); | 772 | repeatTimer->start( 150 ); |
766 | emit key( unicode, qkeycode, modifiers, true, true ); | 773 | emit key( unicode, qkeycode, modifiers, true, true ); |
767 | } | 774 | } |
768 | 775 | ||
769 | void Keyboard::clearHighlight() | 776 | void Keyboard::clearHighlight() |
770 | { | 777 | { |
771 | if ( pressedKey >= 0 ) { | 778 | if ( pressedKey >= 0 ) { |
772 | int tmp = pressedKey; | 779 | int tmp = pressedKey; |
773 | pressedKey = -1; | 780 | pressedKey = -1; |
774 | QPainter p(this); | 781 | QPainter p(this); |
775 | drawKeyboard( p, tmp ); | 782 | drawKeyboard( p, tmp ); |
776 | } | 783 | } |
777 | } | 784 | } |
778 | 785 | ||
779 | 786 | ||
780 | QSize Keyboard::sizeHint() const | 787 | QSize Keyboard::sizeHint() const |
781 | { | 788 | { |
782 | QFontMetrics fm=fontMetrics(); | 789 | QFontMetrics fm=fontMetrics(); |
783 | int keyHeight = fm.lineSpacing()+2; | 790 | int keyHeight = fm.lineSpacing()+2; |
784 | 791 | ||
785 | if (useOptiKeys) | 792 | if (useOptiKeys) |
786 | keyHeight += 1; | 793 | keyHeight += 1; |
787 | 794 | ||
788 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); | 795 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); |
789 | } | 796 | } |
790 | 797 | ||
791 | 798 | ||
792 | void Keyboard::resetState() | 799 | void Keyboard::resetState() |
793 | { | 800 | { |
794 | picks->resetState(); | 801 | picks->resetState(); |
795 | } | 802 | } |
diff --git a/inputmethods/keyboard/keyboard.cpp b/inputmethods/keyboard/keyboard.cpp index fb88f2a..39d44cd 100644 --- a/inputmethods/keyboard/keyboard.cpp +++ b/inputmethods/keyboard/keyboard.cpp | |||
@@ -1,810 +1,817 @@ | |||
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 | #include <qpe/config.h> | |
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 | ||
33 | using namespace KeyboardInput; | 33 | using namespace KeyboardInput; |
34 | 34 | ||
35 | #define USE_SMALL_BACKSPACE | 35 | #define USE_SMALL_BACKSPACE |
36 | 36 | ||
37 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 37 | Keyboard::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 | // get the default font | ||
48 | Config *config = new Config( "qpe" ); | ||
49 | config->setGroup( "Appearance" ); | ||
50 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); | ||
51 | int fontSize = config->readNumEntry( "FontSize", 10 ); | ||
52 | delete config; | ||
53 | |||
47 | picks = new KeyboardPicks( this ); | 54 | picks = new KeyboardPicks( this ); |
48 | picks->setFont( QFont( "smallsmooth", 9 ) ); | 55 | picks->setFont( QFont( familyStr, fontSize ) ); |
49 | setFont( QFont( "smallsmooth", 9 ) ); | 56 | setFont( QFont( familyStr, fontSize ) ); |
50 | picks->initialise(); | 57 | picks->initialise(); |
51 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), | 58 | QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), |
52 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); | 59 | this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); |
53 | 60 | ||
54 | repeatTimer = new QTimer( this ); | 61 | repeatTimer = new QTimer( this ); |
55 | 62 | ||
56 | // temporary quick and dirty fix for the "sticky keyboard bug" | 63 | // temporary quick and dirty fix for the "sticky keyboard bug" |
57 | // on ipaq. | 64 | // on ipaq. |
58 | // struct utsname name; | 65 | // struct utsname name; |
59 | // if (uname(&name) != -1) | 66 | // if (uname(&name) != -1) |
60 | // { | 67 | // { |
61 | //QString release=name.release; | 68 | //QString release=name.release; |
62 | //qWarning("System release: %s\n", name.release); | 69 | //qWarning("System release: %s\n", name.release); |
63 | //if(release.find("embedix",0,TRUE) !=-1) | 70 | //if(release.find("embedix",0,TRUE) !=-1) |
64 | // { | 71 | // { |
65 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); | 72 | connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); |
66 | // } | 73 | // } |
67 | // } | 74 | // } |
68 | } | 75 | } |
69 | 76 | ||
70 | void Keyboard::resizeEvent(QResizeEvent*) | 77 | void Keyboard::resizeEvent(QResizeEvent*) |
71 | { | 78 | { |
72 | int ph = picks->sizeHint().height(); | 79 | int ph = picks->sizeHint().height(); |
73 | picks->setGeometry( 0, 0, width(), ph ); | 80 | picks->setGeometry( 0, 0, width(), ph ); |
74 | keyHeight = (height()-ph)/5; | 81 | keyHeight = (height()-ph)/5; |
75 | int nk; | 82 | int nk; |
76 | if ( useOptiKeys ) { | 83 | if ( useOptiKeys ) { |
77 | nk = 15; | 84 | nk = 15; |
78 | } else if ( useLargeKeys ) { | 85 | } else if ( useLargeKeys ) { |
79 | nk = 15; | 86 | nk = 15; |
80 | } else { | 87 | } else { |
81 | nk = 19; | 88 | nk = 19; |
82 | } | 89 | } |
83 | defaultKeyWidth = width()/nk; | 90 | defaultKeyWidth = width()/nk; |
84 | xoffs = (width()-defaultKeyWidth*nk)/2; | 91 | xoffs = (width()-defaultKeyWidth*nk)/2; |
85 | } | 92 | } |
86 | 93 | ||
87 | void KeyboardPicks::initialise() | 94 | void KeyboardPicks::initialise() |
88 | { | 95 | { |
89 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); | 96 | setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); |
90 | mode = 0; | 97 | mode = 0; |
91 | dc = new KeyboardConfig(this); | 98 | dc = new KeyboardConfig(this); |
92 | configs.append(dc); | 99 | configs.append(dc); |
93 | } | 100 | } |
94 | 101 | ||
95 | QSize KeyboardPicks::sizeHint() const | 102 | QSize KeyboardPicks::sizeHint() const |
96 | { | 103 | { |
97 | return QSize(240,fontMetrics().lineSpacing()); | 104 | return QSize(240,fontMetrics().lineSpacing()); |
98 | } | 105 | } |
99 | 106 | ||
100 | 107 | ||
101 | void KeyboardConfig::generateText(const QString &s) | 108 | void KeyboardConfig::generateText(const QString &s) |
102 | { | 109 | { |
103 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 110 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
104 | for (int i=0; i<(int)backspaces; i++) { | 111 | for (int i=0; i<(int)backspaces; i++) { |
105 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false ); | 112 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, true, false ); |
106 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false ); | 113 | parent->emitKey( 0, ::Qt::Key_Backspace, 0, false, false ); |
107 | } | 114 | } |
108 | for (int i=0; i<(int)s.length(); i++) { | 115 | for (int i=0; i<(int)s.length(); i++) { |
109 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); | 116 | parent->emitKey( s[i].unicode(), 0, 0, true, false ); |
110 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); | 117 | parent->emitKey( s[i].unicode(), 0, 0, false, false ); |
111 | } | 118 | } |
112 | parent->emitKey( 0, ::Qt::Key_Space, 0, true, false ); | 119 | parent->emitKey( 0, ::Qt::Key_Space, 0, true, false ); |
113 | parent->emitKey( 0, ::Qt::Key_Space, 0, false, false ); | 120 | parent->emitKey( 0, ::Qt::Key_Space, 0, false, false ); |
114 | backspaces = 0; | 121 | backspaces = 0; |
115 | #endif | 122 | #endif |
116 | } | 123 | } |
117 | 124 | ||
118 | 125 | ||
119 | //PC keyboard layout and scancodes | 126 | //PC keyboard layout and scancodes |
120 | 127 | ||
121 | /* | 128 | /* |
122 | Format: length, code, length, code, ..., 0 | 129 | Format: length, code, length, code, ..., 0 |
123 | 130 | ||
124 | length is measured in half the width of a standard key. | 131 | length is measured in half the width of a standard key. |
125 | If code < 0x80 we have length/2 consecutive standard keys, | 132 | If code < 0x80 we have length/2 consecutive standard keys, |
126 | starting with scancode code. | 133 | starting with scancode code. |
127 | 134 | ||
128 | Special keys are hardcoded, one at a time, with length of key | 135 | 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 | 136 | and code >= 0x80, these are NOT standard PC scancodes, but are looked |
130 | up in specialM[]. (The special keys are not keymappable.) | 137 | up in specialM[]. (The special keys are not keymappable.) |
131 | 138 | ||
132 | */ | 139 | */ |
133 | 140 | ||
134 | static const uchar * const keyboard_opti[5] = { | 141 | static 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", | 142 | (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", | 143 | (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", | 144 | (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", | 145 | (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" | 146 | (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 | }; | 147 | }; |
141 | 148 | ||
142 | 149 | ||
143 | static const uchar * const keyboard_standard[5] = { | 150 | static const uchar * const keyboard_standard[5] = { |
144 | 151 | ||
145 | #ifdef USE_SMALL_BACKSPACE | 152 | #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", | 153 | (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 | 154 | #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", | 155 | (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 | 156 | #endif |
150 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP | 157 | //~ + 123...+ BACKSPACE //+ INSERT + HOME + PGUP |
151 | 158 | ||
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", | 159 | (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 | 160 | //TAB + qwerty.. + backslash //+ DEL + END + PGDN |
154 | 161 | ||
155 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", | 162 | (const uchar *const)"\004\202\002a\002s\002d\002f\002g\002h\002j\002k\002l\002;\002'\004\203", |
156 | //CAPS + asdf.. + RETURN | 163 | //CAPS + asdf.. + RETURN |
157 | 164 | ||
158 | (const uchar *const)"\005\204\002z\002x\002c\002v\002b\002n\002m\002,\002.\002/\005\204\002\223\002\223\002\211", | 165 | (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 | 166 | //SHIFT + zxcv... //+ UP |
160 | 167 | ||
161 | (const uchar *const)"\003\205\003\206\022\207\003\206\003\205\002\223\002\212\002\213\002\214" | 168 | (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 | 169 | //CTRL + ALT + SPACE //+ LEFT + DOWN + RIGHT |
163 | 170 | ||
164 | }; | 171 | }; |
165 | 172 | ||
166 | 173 | ||
167 | struct ShiftMap { | 174 | struct ShiftMap { |
168 | char normal; | 175 | char normal; |
169 | char shifted; | 176 | char shifted; |
170 | }; | 177 | }; |
171 | 178 | ||
172 | 179 | ||
173 | static const ShiftMap shiftMap[] = { | 180 | static const ShiftMap shiftMap[] = { |
174 | { '`', '~' }, | 181 | { '`', '~' }, |
175 | { '1', '!' }, | 182 | { '1', '!' }, |
176 | { '2', '@' }, | 183 | { '2', '@' }, |
177 | { '3', '#' }, | 184 | { '3', '#' }, |
178 | { '4', '$' }, | 185 | { '4', '$' }, |
179 | { '5', '%' }, | 186 | { '5', '%' }, |
180 | { '6', '^' }, | 187 | { '6', '^' }, |
181 | { '7', '&' }, | 188 | { '7', '&' }, |
182 | { '8', '*' }, | 189 | { '8', '*' }, |
183 | { '9', '(' }, | 190 | { '9', '(' }, |
184 | { '0', ')' }, | 191 | { '0', ')' }, |
185 | { '-', '_' }, | 192 | { '-', '_' }, |
186 | { '=', '+' }, | 193 | { '=', '+' }, |
187 | { '\\', '|' }, | 194 | { '\\', '|' }, |
188 | { '[', '{' }, | 195 | { '[', '{' }, |
189 | { ']', '}' }, | 196 | { ']', '}' }, |
190 | { ';', ':' }, | 197 | { ';', ':' }, |
191 | { '\'', '"' }, | 198 | { '\'', '"' }, |
192 | { ',', '<' }, | 199 | { ',', '<' }, |
193 | { '.', '>' }, | 200 | { '.', '>' }, |
194 | { '/', '?' } | 201 | { '/', '?' } |
195 | }; | 202 | }; |
196 | 203 | ||
197 | 204 | ||
198 | /* XPM */ | 205 | /* XPM */ |
199 | static const char * const uparrow_xpm[]={ | 206 | static const char * const uparrow_xpm[]={ |
200 | "9 9 2 1", | 207 | "9 9 2 1", |
201 | "a c #000000", | 208 | "a c #000000", |
202 | ". c None", | 209 | ". c None", |
203 | ".........", | 210 | ".........", |
204 | "....a....", | 211 | "....a....", |
205 | "...aaa...", | 212 | "...aaa...", |
206 | "..aaaaa..", | 213 | "..aaaaa..", |
207 | "....a....", | 214 | "....a....", |
208 | "....a....", | 215 | "....a....", |
209 | "....a....", | 216 | "....a....", |
210 | "....a....", | 217 | "....a....", |
211 | "........."}; | 218 | "........."}; |
212 | /* XPM */ | 219 | /* XPM */ |
213 | static const char * const leftarrow_xpm[]={ | 220 | static const char * const leftarrow_xpm[]={ |
214 | "9 9 2 1", | 221 | "9 9 2 1", |
215 | "a c #000000", | 222 | "a c #000000", |
216 | ". c None", | 223 | ". c None", |
217 | ".........", | 224 | ".........", |
218 | ".........", | 225 | ".........", |
219 | "...a.....", | 226 | "...a.....", |
220 | "..aa.....", | 227 | "..aa.....", |
221 | ".aaaaaaa.", | 228 | ".aaaaaaa.", |
222 | "..aa.....", | 229 | "..aa.....", |
223 | "...a.....", | 230 | "...a.....", |
224 | ".........", | 231 | ".........", |
225 | "........."}; | 232 | "........."}; |
226 | /* XPM */ | 233 | /* XPM */ |
227 | static const char * const downarrow_xpm[]={ | 234 | static const char * const downarrow_xpm[]={ |
228 | "9 9 2 1", | 235 | "9 9 2 1", |
229 | "a c #000000", | 236 | "a c #000000", |
230 | ". c None", | 237 | ". c None", |
231 | ".........", | 238 | ".........", |
232 | "....a....", | 239 | "....a....", |
233 | "....a....", | 240 | "....a....", |
234 | "....a....", | 241 | "....a....", |
235 | "....a....", | 242 | "....a....", |
236 | "..aaaaa..", | 243 | "..aaaaa..", |
237 | "...aaa...", | 244 | "...aaa...", |
238 | "....a....", | 245 | "....a....", |
239 | "........."}; | 246 | "........."}; |
240 | /* XPM */ | 247 | /* XPM */ |
241 | static const char * const rightarrow_xpm[]={ | 248 | static const char * const rightarrow_xpm[]={ |
242 | "9 9 2 1", | 249 | "9 9 2 1", |
243 | "a c #000000", | 250 | "a c #000000", |
244 | ". c None", | 251 | ". c None", |
245 | ".........", | 252 | ".........", |
246 | ".........", | 253 | ".........", |
247 | ".....a...", | 254 | ".....a...", |
248 | ".....aa..", | 255 | ".....aa..", |
249 | ".aaaaaaa.", | 256 | ".aaaaaaa.", |
250 | ".....aa..", | 257 | ".....aa..", |
251 | ".....a...", | 258 | ".....a...", |
252 | ".........", | 259 | ".........", |
253 | "........."}; | 260 | "........."}; |
254 | /* XPM */ | 261 | /* XPM */ |
255 | static const char * const insert_xpm[]={ | 262 | static const char * const insert_xpm[]={ |
256 | "9 9 2 1", | 263 | "9 9 2 1", |
257 | "a c #000000", | 264 | "a c #000000", |
258 | ". c None", | 265 | ". c None", |
259 | ".........", | 266 | ".........", |
260 | "a........", | 267 | "a........", |
261 | "a.aaa.aaa", | 268 | "a.aaa.aaa", |
262 | "a.a.a.a..", | 269 | "a.a.a.a..", |
263 | "a.a.a..a.", | 270 | "a.a.a..a.", |
264 | "a.a.a...a", | 271 | "a.a.a...a", |
265 | "a.a.a.aaa", | 272 | "a.a.a.aaa", |
266 | ".........", | 273 | ".........", |
267 | "........."}; | 274 | "........."}; |
268 | /* XPM */ | 275 | /* XPM */ |
269 | static const char * const delete_xpm[]={ | 276 | static const char * const delete_xpm[]={ |
270 | "9 9 2 1", | 277 | "9 9 2 1", |
271 | "a c #000000", | 278 | "a c #000000", |
272 | ". c None", | 279 | ". c None", |
273 | ".........", | 280 | ".........", |
274 | "aa......a", | 281 | "aa......a", |
275 | "a.a.aaa.a", | 282 | "a.a.aaa.a", |
276 | "a.a.a.a.a", | 283 | "a.a.a.a.a", |
277 | "a.a.aaa.a.", | 284 | "a.a.aaa.a.", |
278 | "a.a.a...a", | 285 | "a.a.a...a", |
279 | "aaa.aaa.a", | 286 | "aaa.aaa.a", |
280 | ".........", | 287 | ".........", |
281 | "........."}; | 288 | "........."}; |
282 | /* XPM */ | 289 | /* XPM */ |
283 | static const char * const home_xpm[]={ | 290 | static const char * const home_xpm[]={ |
284 | "9 9 2 1", | 291 | "9 9 2 1", |
285 | "a c #000000", | 292 | "a c #000000", |
286 | ". c None", | 293 | ". c None", |
287 | "....a....", | 294 | "....a....", |
288 | "...a.a...", | 295 | "...a.a...", |
289 | "..a...a..", | 296 | "..a...a..", |
290 | ".a.....a.", | 297 | ".a.....a.", |
291 | "aa.aaa.aa", | 298 | "aa.aaa.aa", |
292 | ".a.a.a.a.", | 299 | ".a.a.a.a.", |
293 | ".a.a.a.a.", | 300 | ".a.a.a.a.", |
294 | ".aaaaaaa.", | 301 | ".aaaaaaa.", |
295 | "........."}; | 302 | "........."}; |
296 | /* XPM */ | 303 | /* XPM */ |
297 | static const char * const end_xpm[]={ | 304 | static const char * const end_xpm[]={ |
298 | "10 9 2 1", | 305 | "10 9 2 1", |
299 | "a c #000000", | 306 | "a c #000000", |
300 | ". c None", | 307 | ". c None", |
301 | "..........", | 308 | "..........", |
302 | "aa.......a", | 309 | "aa.......a", |
303 | "a..aaa.aaa", | 310 | "a..aaa.aaa", |
304 | "aa.a.a.a.a", | 311 | "aa.a.a.a.a", |
305 | "a..a.a.a.a", | 312 | "a..a.a.a.a", |
306 | "a..a.a.a.a", | 313 | "a..a.a.a.a", |
307 | "aa.a.a.aaa", | 314 | "aa.a.a.aaa", |
308 | "..........", | 315 | "..........", |
309 | ".........."}; | 316 | ".........."}; |
310 | /* XPM */ | 317 | /* XPM */ |
311 | static const char * const pageup_xpm[]={ | 318 | static const char * const pageup_xpm[]={ |
312 | "9 9 2 1", | 319 | "9 9 2 1", |
313 | "a c #000000", | 320 | "a c #000000", |
314 | ". c None", | 321 | ". c None", |
315 | ".aaa.aaa.", | 322 | ".aaa.aaa.", |
316 | ".a.a.a.a.", | 323 | ".a.a.a.a.", |
317 | ".aaa..aa.", | 324 | ".aaa..aa.", |
318 | ".a...aaa.", | 325 | ".a...aaa.", |
319 | ".........", | 326 | ".........", |
320 | ".a.a.aaa.", | 327 | ".a.a.aaa.", |
321 | ".a.a.a.a.", | 328 | ".a.a.a.a.", |
322 | ".aaa.aaa.", | 329 | ".aaa.aaa.", |
323 | ".....a..."}; | 330 | ".....a..."}; |
324 | /* XPM */ | 331 | /* XPM */ |
325 | static const char * const pagedown_xpm[]={ | 332 | static const char * const pagedown_xpm[]={ |
326 | "9 9 2 1", | 333 | "9 9 2 1", |
327 | "a c #000000", | 334 | "a c #000000", |
328 | ". c None", | 335 | ". c None", |
329 | ".aaa.aaa.", | 336 | ".aaa.aaa.", |
330 | ".a.a.a.a.", | 337 | ".a.a.a.a.", |
331 | ".aaa..aa.", | 338 | ".aaa..aa.", |
332 | ".a...aaa.", | 339 | ".a...aaa.", |
333 | ".........", | 340 | ".........", |
334 | "...a.....", | 341 | "...a.....", |
335 | ".aaa.aaa.", | 342 | ".aaa.aaa.", |
336 | ".a.a.a.a.", | 343 | ".a.a.a.a.", |
337 | ".aaa.a.a."}; | 344 | ".aaa.a.a."}; |
338 | /* XPM */ | 345 | /* XPM */ |
339 | static const char * const expand_xpm[]={ | 346 | static const char * const expand_xpm[]={ |
340 | "4 9 2 1", | 347 | "4 9 2 1", |
341 | "a c #408040", | 348 | "a c #408040", |
342 | ". c None", | 349 | ". c None", |
343 | "a...", | 350 | "a...", |
344 | "aa..", | 351 | "aa..", |
345 | "aaa.", | 352 | "aaa.", |
346 | "aaaa", | 353 | "aaaa", |
347 | "aaaa", | 354 | "aaaa", |
348 | "aaaa", | 355 | "aaaa", |
349 | "aaa.", | 356 | "aaa.", |
350 | "aa..", | 357 | "aa..", |
351 | "a..."}; | 358 | "a..."}; |
352 | /* XPM */ | 359 | /* XPM */ |
353 | #ifdef USE_SMALL_BACKSPACE | 360 | #ifdef USE_SMALL_BACKSPACE |
354 | static const char * const backspace_xpm[]={ | 361 | static const char * const backspace_xpm[]={ |
355 | "9 9 2 1", | 362 | "9 9 2 1", |
356 | "a c #000000", | 363 | "a c #000000", |
357 | ". c None", | 364 | ". c None", |
358 | ".........", | 365 | ".........", |
359 | ".........", | 366 | ".........", |
360 | "...a.....", | 367 | "...a.....", |
361 | "..aa.....", | 368 | "..aa.....", |
362 | ".aaaaaaaa", | 369 | ".aaaaaaaa", |
363 | "..aa.....", | 370 | "..aa.....", |
364 | "...a.....", | 371 | "...a.....", |
365 | ".........", | 372 | ".........", |
366 | "........."}; | 373 | "........."}; |
367 | #else | 374 | #else |
368 | static const char * const backspace_xpm[]={ | 375 | static const char * const backspace_xpm[]={ |
369 | "21 9 2 1", | 376 | "21 9 2 1", |
370 | "a c #000000", | 377 | "a c #000000", |
371 | ". c None", | 378 | ". c None", |
372 | ".....................", | 379 | ".....................", |
373 | ".....................", | 380 | ".....................", |
374 | ".....aaa..a..........", | 381 | ".....aaa..a..........", |
375 | ".a...a..a.a.a.aaa.aaa", | 382 | ".a...a..a.a.a.aaa.aaa", |
376 | "aaaa.aaa..aa..aa..a.a", | 383 | "aaaa.aaa..aa..aa..a.a", |
377 | ".a...a..a.aaa..aa.a.a", | 384 | ".a...a..a.aaa..aa.a.a", |
378 | ".....aaaa.a.a.aaa.aa.", | 385 | ".....aaaa.a.a.aaa.aa.", |
379 | "..................a..", | 386 | "..................a..", |
380 | "....................."}; | 387 | "....................."}; |
381 | #endif | 388 | #endif |
382 | /* XPM */ | 389 | /* XPM */ |
383 | static const char * const escape_xpm[]={ | 390 | static const char * const escape_xpm[]={ |
384 | "9 9 2 1", | 391 | "9 9 2 1", |
385 | "a c #000000", | 392 | "a c #000000", |
386 | ". c None", | 393 | ". c None", |
387 | ".........", | 394 | ".........", |
388 | ".........", | 395 | ".........", |
389 | ".aa.aa.aa", | 396 | ".aa.aa.aa", |
390 | ".a..a..a.", | 397 | ".a..a..a.", |
391 | ".aa.aa.a.", | 398 | ".aa.aa.a.", |
392 | ".a...a.a.", | 399 | ".a...a.a.", |
393 | ".aa.aa.aa", | 400 | ".aa.aa.aa", |
394 | ".........", | 401 | ".........", |
395 | "........."}; | 402 | "........."}; |
396 | 403 | ||
397 | 404 | ||
398 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, | 405 | enum { BSCode = 0x80, TabCode, CapsCode, RetCode, |
399 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, | 406 | ShiftCode, CtrlCode, AltCode, SpaceCode, BackSlash, |
400 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, | 407 | UpCode, LeftCode, DownCode, RightCode, Blank, Expand, |
401 | Opti, ResetDict, | 408 | Opti, ResetDict, |
402 | Divide, Multiply, Add, Subtract, Decimal, Equal, | 409 | Divide, Multiply, Add, Subtract, Decimal, Equal, |
403 | Percent, Sqrt, Inverse, Escape }; | 410 | Percent, Sqrt, Inverse, Escape }; |
404 | 411 | ||
405 | typedef struct SpecialMap { | 412 | typedef struct SpecialMap { |
406 | int qcode; | 413 | int qcode; |
407 | ushort unicode; | 414 | ushort unicode; |
408 | const char * label; | 415 | const char * label; |
409 | const char * const * xpm; | 416 | const char * const * xpm; |
410 | }; | 417 | }; |
411 | 418 | ||
412 | 419 | ||
413 | static const SpecialMap specialM[] = { | 420 | static const SpecialMap specialM[] = { |
414 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, | 421 | { Qt::Key_Backspace, 8,"<", backspace_xpm }, |
415 | { Qt::Key_Tab, 9,"Tab", NULL }, | 422 | { Qt::Key_Tab, 9,"Tab", NULL }, |
416 | { Qt::Key_CapsLock, 0,"Caps", NULL }, | 423 | { Qt::Key_CapsLock, 0,"Caps", NULL }, |
417 | { Qt::Key_Return, 13,"Ret", NULL }, | 424 | { Qt::Key_Return, 13,"Ret", NULL }, |
418 | { Qt::Key_Shift, 0,"Shift", NULL }, | 425 | { Qt::Key_Shift, 0,"Shift", NULL }, |
419 | { Qt::Key_Control, 0,"Ctrl", NULL }, | 426 | { Qt::Key_Control, 0,"Ctrl", NULL }, |
420 | { Qt::Key_Alt, 0,"Alt", NULL }, | 427 | { Qt::Key_Alt, 0,"Alt", NULL }, |
421 | { Qt::Key_Space, ' ',"", NULL }, | 428 | { Qt::Key_Space, ' ',"", NULL }, |
422 | { BackSlash, 43,"\\", NULL }, | 429 | { BackSlash, 43,"\\", NULL }, |
423 | 430 | ||
424 | // Need images? | 431 | // Need images? |
425 | { Qt::Key_Up, 0,"^", uparrow_xpm }, | 432 | { Qt::Key_Up, 0,"^", uparrow_xpm }, |
426 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, | 433 | { Qt::Key_Left, 0,"<", leftarrow_xpm }, |
427 | { Qt::Key_Down, 0,"v", downarrow_xpm }, | 434 | { Qt::Key_Down, 0,"v", downarrow_xpm }, |
428 | { Qt::Key_Right, 0,">", rightarrow_xpm }, | 435 | { Qt::Key_Right, 0,">", rightarrow_xpm }, |
429 | { Qt::Key_Insert, 0,"I", insert_xpm }, | 436 | { Qt::Key_Insert, 0,"I", insert_xpm }, |
430 | { Qt::Key_Home, 0,"H", home_xpm }, | 437 | { Qt::Key_Home, 0,"H", home_xpm }, |
431 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, | 438 | { Qt::Key_PageUp, 0,"U", pageup_xpm }, |
432 | { Qt::Key_End, 0,"E", end_xpm }, | 439 | { Qt::Key_End, 0,"E", end_xpm }, |
433 | { Qt::Key_Delete, 0,"X", delete_xpm }, | 440 | { Qt::Key_Delete, 0,"X", delete_xpm }, |
434 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, | 441 | { Qt::Key_PageDown, 0,"D", pagedown_xpm }, |
435 | { Blank, 0," ", NULL }, | 442 | { Blank, 0," ", NULL }, |
436 | { Expand, 0,"->", expand_xpm }, | 443 | { Expand, 0,"->", expand_xpm }, |
437 | { Opti, 0,"#", NULL }, | 444 | { Opti, 0,"#", NULL }, |
438 | { ResetDict, 0,"R", NULL }, | 445 | { ResetDict, 0,"R", NULL }, |
439 | 446 | ||
440 | // number pad stuff | 447 | // number pad stuff |
441 | { Divide, 0,"/", NULL }, | 448 | { Divide, 0,"/", NULL }, |
442 | { Multiply, 0,"*", NULL }, | 449 | { Multiply, 0,"*", NULL }, |
443 | { Add, 0,"+", NULL }, | 450 | { Add, 0,"+", NULL }, |
444 | { Subtract, 0,"-", NULL }, | 451 | { Subtract, 0,"-", NULL }, |
445 | { Decimal, 0,".", NULL }, | 452 | { Decimal, 0,".", NULL }, |
446 | { Equal, 0,"=", NULL }, | 453 | { Equal, 0,"=", NULL }, |
447 | { Percent, 0,"%", NULL }, | 454 | { Percent, 0,"%", NULL }, |
448 | { Sqrt, 0, "^1/2", NULL }, | 455 | { Sqrt, 0, "^1/2", NULL }, |
449 | { Inverse, 0, "1/x", NULL }, | 456 | { Inverse, 0, "1/x", NULL }, |
450 | 457 | ||
451 | { Escape, 27, "ESC", escape_xpm } | 458 | { Escape, 27, "ESC", escape_xpm } |
452 | }; | 459 | }; |
453 | 460 | ||
454 | 461 | ||
455 | static int keycode( int i2, int j, const uchar **keyboard ) | 462 | static int keycode( int i2, int j, const uchar **keyboard ) |
456 | { | 463 | { |
457 | if ( j <0 || j >= 5 ) | 464 | if ( j <0 || j >= 5 ) |
458 | return 0; | 465 | return 0; |
459 | 466 | ||
460 | const uchar *row = keyboard[j]; | 467 | const uchar *row = keyboard[j]; |
461 | 468 | ||
462 | while ( *row && *row <= i2 ) { | 469 | while ( *row && *row <= i2 ) { |
463 | i2 -= *row; | 470 | i2 -= *row; |
464 | row += 2; | 471 | row += 2; |
465 | } | 472 | } |
466 | 473 | ||
467 | if ( !*row ) return 0; | 474 | if ( !*row ) return 0; |
468 | 475 | ||
469 | int k; | 476 | int k; |
470 | if ( row[1] >= 0x80 ) { | 477 | if ( row[1] >= 0x80 ) { |
471 | k = row[1]; | 478 | k = row[1]; |
472 | } else { | 479 | } else { |
473 | k = row[1]+i2/2; | 480 | k = row[1]+i2/2; |
474 | } | 481 | } |
475 | 482 | ||
476 | return k; | 483 | return k; |
477 | } | 484 | } |
478 | 485 | ||
479 | 486 | ||
480 | /* | 487 | /* |
481 | return scancode and width of first key in row \a j if \a j >= 0, | 488 | 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. | 489 | or next key on current row if \a j < 0. |
483 | 490 | ||
484 | */ | 491 | */ |
485 | 492 | ||
486 | int Keyboard::getKey( int &w, int j ) { | 493 | int Keyboard::getKey( int &w, int j ) { |
487 | static const uchar *row = 0; | 494 | static const uchar *row = 0; |
488 | static int key_i = 0; | 495 | static int key_i = 0; |
489 | static int scancode = 0; | 496 | static int scancode = 0; |
490 | static int half = 0; | 497 | static int half = 0; |
491 | 498 | ||
492 | if ( j >= 0 && j < 5 ) { | 499 | if ( j >= 0 && j < 5 ) { |
493 | if (useOptiKeys) | 500 | if (useOptiKeys) |
494 | row = keyboard_opti[j]; | 501 | row = keyboard_opti[j]; |
495 | else | 502 | else |
496 | row = keyboard_standard[j]; | 503 | row = keyboard_standard[j]; |
497 | half=0; | 504 | half=0; |
498 | } | 505 | } |
499 | 506 | ||
500 | if ( !row || !*row ) { | 507 | if ( !row || !*row ) { |
501 | return 0; | 508 | return 0; |
502 | } else if ( row[1] >= 0x80 ) { | 509 | } else if ( row[1] >= 0x80 ) { |
503 | scancode = row[1]; | 510 | scancode = row[1]; |
504 | w = (row[0] * w + (half++&1)) / 2; | 511 | w = (row[0] * w + (half++&1)) / 2; |
505 | row += 2; | 512 | row += 2; |
506 | return scancode; | 513 | return scancode; |
507 | } else if ( key_i <= 0 ) { | 514 | } else if ( key_i <= 0 ) { |
508 | key_i = row[0]/2; | 515 | key_i = row[0]/2; |
509 | scancode = row[1]; | 516 | scancode = row[1]; |
510 | } | 517 | } |
511 | key_i--; | 518 | key_i--; |
512 | if ( key_i <= 0 ) | 519 | if ( key_i <= 0 ) |
513 | row += 2; | 520 | row += 2; |
514 | return scancode++; | 521 | return scancode++; |
515 | } | 522 | } |
516 | 523 | ||
517 | 524 | ||
518 | void Keyboard::paintEvent(QPaintEvent* e) | 525 | void Keyboard::paintEvent(QPaintEvent* e) |
519 | { | 526 | { |
520 | QPainter painter(this); | 527 | QPainter painter(this); |
521 | painter.setClipRect(e->rect()); | 528 | painter.setClipRect(e->rect()); |
522 | drawKeyboard( painter ); | 529 | drawKeyboard( painter ); |
523 | picks->dc->draw( &painter ); | 530 | picks->dc->draw( &painter ); |
524 | } | 531 | } |
525 | 532 | ||
526 | 533 | ||
527 | /* | 534 | /* |
528 | Draw the keyboard. | 535 | Draw the keyboard. |
529 | 536 | ||
530 | If key >= 0, only the specified key is drawn. | 537 | If key >= 0, only the specified key is drawn. |
531 | */ | 538 | */ |
532 | void Keyboard::drawKeyboard( QPainter &p, int key ) | 539 | void Keyboard::drawKeyboard( QPainter &p, int key ) |
533 | { | 540 | { |
534 | const bool threeD = FALSE; | 541 | const bool threeD = FALSE; |
535 | const QColorGroup& cg = colorGroup(); | 542 | const QColorGroup& cg = colorGroup(); |
536 | QColor keycolor = // cg.background(); | 543 | QColor keycolor = // cg.background(); |
537 | QColor(240,240,230); // Beige! | 544 | QColor(240,240,230); // Beige! |
538 | QColor keycolor_pressed = cg.mid(); | 545 | QColor keycolor_pressed = cg.mid(); |
539 | QColor keycolor_lo = cg.dark(); | 546 | QColor keycolor_lo = cg.dark(); |
540 | QColor keycolor_hi = cg.light(); | 547 | QColor keycolor_hi = cg.light(); |
541 | QColor textcolor = QColor(0,0,0); // cg.text(); | 548 | QColor textcolor = QColor(0,0,0); // cg.text(); |
542 | 549 | ||
543 | int margin = threeD ? 1 : 0; | 550 | int margin = threeD ? 1 : 0; |
544 | 551 | ||
545 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); | 552 | // p.fillRect( 0, , kw-1, keyHeight-2, keycolor_pressed ); |
546 | 553 | ||
547 | for ( int j = 0; j < 5; j++ ) { | 554 | for ( int j = 0; j < 5; j++ ) { |
548 | int y = j * keyHeight + picks->height() + 1; | 555 | int y = j * keyHeight + picks->height() + 1; |
549 | int x = xoffs; | 556 | int x = xoffs; |
550 | int kw = defaultKeyWidth; | 557 | int kw = defaultKeyWidth; |
551 | int k= getKey( kw, j ); | 558 | int k= getKey( kw, j ); |
552 | while ( k ) { | 559 | while ( k ) { |
553 | if ( key < 0 || k == key ) { | 560 | if ( key < 0 || k == key ) { |
554 | QString s; | 561 | QString s; |
555 | bool pressed = (k == pressedKey); | 562 | bool pressed = (k == pressedKey); |
556 | bool blank = (k == 0223); | 563 | bool blank = (k == 0223); |
557 | const char * const * xpm = NULL; | 564 | const char * const * xpm = NULL; |
558 | 565 | ||
559 | if ( k >= 0x80 ) { | 566 | if ( k >= 0x80 ) { |
560 | s = specialM[k - 0x80].label; | 567 | s = specialM[k - 0x80].label; |
561 | 568 | ||
562 | xpm = specialM[k - 0x80].xpm; | 569 | xpm = specialM[k - 0x80].xpm; |
563 | 570 | ||
564 | if ( k == ShiftCode ) { | 571 | if ( k == ShiftCode ) { |
565 | pressed = shift; | 572 | pressed = shift; |
566 | } else if ( k == CapsCode ) { | 573 | } else if ( k == CapsCode ) { |
567 | pressed = lock; | 574 | pressed = lock; |
568 | } else if ( k == CtrlCode ) { | 575 | } else if ( k == CtrlCode ) { |
569 | pressed = ctrl; | 576 | pressed = ctrl; |
570 | } else if ( k == AltCode ) { | 577 | } else if ( k == AltCode ) { |
571 | pressed = alt; | 578 | pressed = alt; |
572 | } | 579 | } |
573 | } else { | 580 | } else { |
574 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 581 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
575 | /* | 582 | /* |
576 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : | 583 | s = QChar( shift^lock ? QWSServer::keyMap()[k].shift_unicode : |
577 | QWSServer::keyMap()[k].unicode); | 584 | QWSServer::keyMap()[k].unicode); |
578 | */ | 585 | */ |
579 | // ### Fixme, bad code, needs improving, whole thing needs to | 586 | // ### 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 | 587 | // be re-coded to get rid of the way it did things with scancodes etc |
581 | char shifted = k; | 588 | char shifted = k; |
582 | if ( !isalpha( k ) ) { | 589 | if ( !isalpha( k ) ) { |
583 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) | 590 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
584 | if ( shiftMap[i].normal == k ) | 591 | if ( shiftMap[i].normal == k ) |
585 | shifted = shiftMap[i].shifted; | 592 | shifted = shiftMap[i].shifted; |
586 | } else { | 593 | } else { |
587 | shifted = toupper( k ); | 594 | shifted = toupper( k ); |
588 | } | 595 | } |
589 | s = QChar( shift^lock ? shifted : k ); | 596 | s = QChar( shift^lock ? shifted : k ); |
590 | #endif | 597 | #endif |
591 | } | 598 | } |
592 | 599 | ||
593 | if (!blank) { | 600 | if (!blank) { |
594 | if ( pressed ) | 601 | if ( pressed ) |
595 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); | 602 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor_pressed ); |
596 | else | 603 | else |
597 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); | 604 | p.fillRect( x+margin, y+margin, kw-margin, keyHeight-margin-1, keycolor ); |
598 | 605 | ||
599 | if ( threeD ) { | 606 | if ( threeD ) { |
600 | p.setPen(pressed ? keycolor_lo : keycolor_hi); | 607 | p.setPen(pressed ? keycolor_lo : keycolor_hi); |
601 | p.drawLine( x, y+1, x, y+keyHeight-2 ); | 608 | p.drawLine( x, y+1, x, y+keyHeight-2 ); |
602 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); | 609 | p.drawLine( x+1, y+1, x+1, y+keyHeight-3 ); |
603 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); | 610 | p.drawLine( x+1, y+1, x+1+kw-2, y+1 ); |
604 | } else if ( j == 0 ) { | 611 | } else if ( j == 0 ) { |
605 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 612 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
606 | p.drawLine( x, y, x+kw, y ); | 613 | p.drawLine( x, y, x+kw, y ); |
607 | } | 614 | } |
608 | 615 | ||
609 | // right | 616 | // right |
610 | p.setPen(pressed ? keycolor_hi : keycolor_lo); | 617 | p.setPen(pressed ? keycolor_hi : keycolor_lo); |
611 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); | 618 | p.drawLine( x+kw-1, y, x+kw-1, y+keyHeight-2 ); |
612 | 619 | ||
613 | if ( threeD ) { | 620 | if ( threeD ) { |
614 | p.setPen(keycolor_lo.light()); | 621 | p.setPen(keycolor_lo.light()); |
615 | p.drawLine( x+kw-2, y+keyHeight-2, x+kw-2, y+1 ); | 622 | 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 ); | 623 | p.drawLine( x+kw-2, y+keyHeight-2, x+1, y+keyHeight-2 ); |
617 | } | 624 | } |
618 | 625 | ||
619 | if (xpm) { | 626 | if (xpm) { |
620 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); | 627 | p.drawPixmap( x + 1, y + 2, QPixmap((const char**)xpm) ); |
621 | } else { | 628 | } else { |
622 | p.setPen(textcolor); | 629 | p.setPen(textcolor); |
623 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); | 630 | p.drawText( x - 1, y, kw, keyHeight-2, AlignCenter, s ); |
624 | } | 631 | } |
625 | 632 | ||
626 | if ( threeD ) { | 633 | if ( threeD ) { |
627 | p.setPen(keycolor_hi); | 634 | p.setPen(keycolor_hi); |
628 | p.drawLine( x, y, x+kw-1, y ); | 635 | p.drawLine( x, y, x+kw-1, y ); |
629 | } | 636 | } |
630 | 637 | ||
631 | // bottom | 638 | // bottom |
632 | p.setPen(keycolor_lo); | 639 | p.setPen(keycolor_lo); |
633 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); | 640 | p.drawLine( x, y+keyHeight-1, x+kw-1, y+keyHeight-1 ); |
634 | 641 | ||
635 | } else { | 642 | } else { |
636 | p.fillRect( x, y, kw, keyHeight, cg.background() ); | 643 | p.fillRect( x, y, kw, keyHeight, cg.background() ); |
637 | } | 644 | } |
638 | } | 645 | } |
639 | 646 | ||
640 | x += kw; | 647 | x += kw; |
641 | kw = defaultKeyWidth; | 648 | kw = defaultKeyWidth; |
642 | k = getKey( kw ); | 649 | k = getKey( kw ); |
643 | } | 650 | } |
644 | } | 651 | } |
645 | } | 652 | } |
646 | 653 | ||
647 | 654 | ||
648 | void Keyboard::mousePressEvent(QMouseEvent *e) | 655 | void Keyboard::mousePressEvent(QMouseEvent *e) |
649 | { | 656 | { |
650 | clearHighlight(); // typing fast? | 657 | clearHighlight(); // typing fast? |
651 | 658 | ||
652 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; | 659 | int i2 = ((e->x() - xoffs) * 2) / defaultKeyWidth; |
653 | int j = (e->y() - picks->height()) / keyHeight; | 660 | int j = (e->y() - picks->height()) / keyHeight; |
654 | 661 | ||
655 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); | 662 | int k = keycode( i2, j, (const uchar **)((useOptiKeys) ? keyboard_opti : keyboard_standard) ); |
656 | bool need_repaint = FALSE; | 663 | bool need_repaint = FALSE; |
657 | unicode = -1; | 664 | unicode = -1; |
658 | qkeycode = 0; | 665 | qkeycode = 0; |
659 | if ( k >= 0x80 ) { | 666 | if ( k >= 0x80 ) { |
660 | if ( k == ShiftCode ) { | 667 | if ( k == ShiftCode ) { |
661 | shift = !shift; | 668 | shift = !shift; |
662 | need_repaint = TRUE; | 669 | need_repaint = TRUE; |
663 | } else if ( k == AltCode ){ | 670 | } else if ( k == AltCode ){ |
664 | alt = !alt; | 671 | alt = !alt; |
665 | need_repaint = TRUE; | 672 | need_repaint = TRUE; |
666 | } else if ( k == CapsCode ) { | 673 | } else if ( k == CapsCode ) { |
667 | lock = !lock; | 674 | lock = !lock; |
668 | need_repaint = TRUE; | 675 | need_repaint = TRUE; |
669 | } else if ( k == CtrlCode ) { | 676 | } else if ( k == CtrlCode ) { |
670 | ctrl = !ctrl; | 677 | ctrl = !ctrl; |
671 | need_repaint = TRUE; | 678 | need_repaint = TRUE; |
672 | } else if ( k == 0224 /* Expand */ ) { | 679 | } else if ( k == 0224 /* Expand */ ) { |
673 | useLargeKeys = !useLargeKeys; | 680 | useLargeKeys = !useLargeKeys; |
674 | resizeEvent(0); | 681 | resizeEvent(0); |
675 | repaint( TRUE ); // need it to clear first | 682 | repaint( TRUE ); // need it to clear first |
676 | } else if ( k == 0225 /* Opti/Toggle */ ) { | 683 | } else if ( k == 0225 /* Opti/Toggle */ ) { |
677 | useOptiKeys = !useOptiKeys; | 684 | useOptiKeys = !useOptiKeys; |
678 | resizeEvent(0); | 685 | resizeEvent(0); |
679 | repaint( TRUE ); // need it to clear first | 686 | repaint( TRUE ); // need it to clear first |
680 | } else { | 687 | } else { |
681 | qkeycode = specialM[ k - 0x80 ].qcode; | 688 | qkeycode = specialM[ k - 0x80 ].qcode; |
682 | unicode = specialM[ k - 0x80 ].unicode; | 689 | unicode = specialM[ k - 0x80 ].unicode; |
683 | } | 690 | } |
684 | } else { | 691 | } else { |
685 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 692 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
686 | /* | 693 | /* |
687 | qk = QWSServer::keyMap()[k].key_code; | 694 | qk = QWSServer::keyMap()[k].key_code; |
688 | if ( qk != Key_unknown ) { | 695 | if ( qk != Key_unknown ) { |
689 | if ( ctrl ) | 696 | if ( ctrl ) |
690 | u = QWSServer::keyMap()[k].ctrl_unicode; | 697 | u = QWSServer::keyMap()[k].ctrl_unicode; |
691 | else if ( shift^lock ) | 698 | else if ( shift^lock ) |
692 | u = QWSServer::keyMap()[k].shift_unicode; | 699 | u = QWSServer::keyMap()[k].shift_unicode; |
693 | else | 700 | else |
694 | u = QWSServer::keyMap()[k].unicode; | 701 | u = QWSServer::keyMap()[k].unicode; |
695 | } | 702 | } |
696 | */ | 703 | */ |
697 | char shifted = k; | 704 | char shifted = k; |
698 | if ( !isalpha( k ) ) { | 705 | if ( !isalpha( k ) ) { |
699 | // ### Fixme, bad code, needs improving, whole thing needs to | 706 | // ### 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 | 707 | // 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++ ) | 708 | for ( unsigned i = 0; i < sizeof(shiftMap)/sizeof(ShiftMap); i++ ) |
702 | if ( shiftMap[i].normal == k ) | 709 | if ( shiftMap[i].normal == k ) |
703 | shifted = shiftMap[i].shifted; | 710 | shifted = shiftMap[i].shifted; |
704 | } else { | 711 | } else { |
705 | shifted = toupper( k ); | 712 | shifted = toupper( k ); |
706 | } | 713 | } |
707 | QChar tempChar( shift^lock ? shifted : k ); | 714 | QChar tempChar( shift^lock ? shifted : k ); |
708 | unicode = tempChar.unicode(); | 715 | unicode = tempChar.unicode(); |
709 | #endif | 716 | #endif |
710 | } | 717 | } |
711 | if ( unicode != -1 ) { | 718 | if ( unicode != -1 ) { |
712 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | | 719 | modifiers = (shift ? Qt::ShiftButton : 0) | (ctrl ? Qt::ControlButton : 0) | |
713 | (alt ? Qt::AltButton : 0); | 720 | (alt ? Qt::AltButton : 0); |
714 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 721 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
715 | emit key( unicode, qkeycode, modifiers, true, false ); | 722 | emit key( unicode, qkeycode, modifiers, true, false ); |
716 | repeatTimer->start( 500 ); | 723 | repeatTimer->start( 500 ); |
717 | #endif | 724 | #endif |
718 | need_repaint = shift || alt || ctrl; | 725 | need_repaint = shift || alt || ctrl; |
719 | shift = alt = ctrl = FALSE; | 726 | shift = alt = ctrl = FALSE; |
720 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); | 727 | //qDebug( "pressed %d -> %04x ('%c')", k, u, u&0xffff < 256 ? u&0xff : 0 ); |
721 | 728 | ||
722 | KeyboardConfig *dc = picks->dc; | 729 | KeyboardConfig *dc = picks->dc; |
723 | 730 | ||
724 | if (dc) { | 731 | if (dc) { |
725 | if (qkeycode == Qt::Key_Backspace) { | 732 | if (qkeycode == Qt::Key_Backspace) { |
726 | dc->input.remove(dc->input.last()); // remove last input | 733 | dc->input.remove(dc->input.last()); // remove last input |
727 | dc->decBackspaces(); | 734 | dc->decBackspaces(); |
728 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || | 735 | } else if ( k == 0226 || qkeycode == Qt::Key_Return || |
729 | qkeycode == Qt::Key_Space || | 736 | qkeycode == Qt::Key_Space || |
730 | QChar(unicode).isPunct() ) { | 737 | QChar(unicode).isPunct() ) { |
731 | dc->input.clear(); | 738 | dc->input.clear(); |
732 | dc->resetBackspaces(); | 739 | dc->resetBackspaces(); |
733 | } else { | 740 | } else { |
734 | dc->add(QString(QChar(unicode))); | 741 | dc->add(QString(QChar(unicode))); |
735 | dc->incBackspaces(); | 742 | dc->incBackspaces(); |
736 | } | 743 | } |
737 | } | 744 | } |
738 | 745 | ||
739 | picks->repaint(); | 746 | picks->repaint(); |
740 | 747 | ||
741 | } | 748 | } |
742 | pressedKey = k; | 749 | pressedKey = k; |
743 | if ( need_repaint ) { | 750 | if ( need_repaint ) { |
744 | repaint( FALSE ); | 751 | repaint( FALSE ); |
745 | } else { | 752 | } else { |
746 | QPainter p(this); | 753 | QPainter p(this); |
747 | drawKeyboard( p, pressedKey ); | 754 | drawKeyboard( p, pressedKey ); |
748 | } | 755 | } |
749 | pressTid = startTimer(80); | 756 | pressTid = startTimer(80); |
750 | pressed = TRUE; | 757 | pressed = TRUE; |
751 | } | 758 | } |
752 | 759 | ||
753 | 760 | ||
754 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 761 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
755 | { | 762 | { |
756 | if ( pressTid == 0 ) | 763 | if ( pressTid == 0 ) |
757 | clearHighlight(); | 764 | clearHighlight(); |
758 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 765 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
759 | if ( unicode != -1 ) { | 766 | if ( unicode != -1 ) { |
760 | emit key( unicode, qkeycode, modifiers, false, false ); | 767 | emit key( unicode, qkeycode, modifiers, false, false ); |
761 | repeatTimer->stop(); | 768 | repeatTimer->stop(); |
762 | } | 769 | } |
763 | #endif | 770 | #endif |
764 | pressed = FALSE; | 771 | pressed = FALSE; |
765 | } | 772 | } |
766 | 773 | ||
767 | void Keyboard::timerEvent(QTimerEvent* e) | 774 | void Keyboard::timerEvent(QTimerEvent* e) |
768 | { | 775 | { |
769 | if ( e->timerId() == pressTid ) { | 776 | if ( e->timerId() == pressTid ) { |
770 | killTimer(pressTid); | 777 | killTimer(pressTid); |
771 | pressTid = 0; | 778 | pressTid = 0; |
772 | if ( !pressed ) | 779 | if ( !pressed ) |
773 | clearHighlight(); | 780 | clearHighlight(); |
774 | } | 781 | } |
775 | } | 782 | } |
776 | 783 | ||
777 | void Keyboard::repeat() | 784 | void Keyboard::repeat() |
778 | { | 785 | { |
779 | 786 | ||
780 | repeatTimer->start( 200 ); | 787 | repeatTimer->start( 200 ); |
781 | emit key( unicode, qkeycode, modifiers, true, true ); | 788 | emit key( unicode, qkeycode, modifiers, true, true ); |
782 | } | 789 | } |
783 | 790 | ||
784 | void Keyboard::clearHighlight() | 791 | void Keyboard::clearHighlight() |
785 | { | 792 | { |
786 | if ( pressedKey >= 0 ) { | 793 | if ( pressedKey >= 0 ) { |
787 | int tmp = pressedKey; | 794 | int tmp = pressedKey; |
788 | pressedKey = -1; | 795 | pressedKey = -1; |
789 | QPainter p(this); | 796 | QPainter p(this); |
790 | drawKeyboard( p, tmp ); | 797 | drawKeyboard( p, tmp ); |
791 | } | 798 | } |
792 | } | 799 | } |
793 | 800 | ||
794 | 801 | ||
795 | QSize Keyboard::sizeHint() const | 802 | QSize Keyboard::sizeHint() const |
796 | { | 803 | { |
797 | QFontMetrics fm=fontMetrics(); | 804 | QFontMetrics fm=fontMetrics(); |
798 | int keyHeight = fm.lineSpacing()+2; | 805 | int keyHeight = fm.lineSpacing()+2; |
799 | 806 | ||
800 | if (useOptiKeys) | 807 | if (useOptiKeys) |
801 | keyHeight += 1; | 808 | keyHeight += 1; |
802 | 809 | ||
803 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); | 810 | return QSize( 320, keyHeight * 5 + picks->sizeHint().height() + 1 ); |
804 | } | 811 | } |
805 | 812 | ||
806 | 813 | ||
807 | void Keyboard::resetState() | 814 | void Keyboard::resetState() |
808 | { | 815 | { |
809 | picks->resetState(); | 816 | picks->resetState(); |
810 | } | 817 | } |
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp index f8cafd5..96fb484 100644 --- a/inputmethods/multikey/keyboard.cpp +++ b/inputmethods/multikey/keyboard.cpp | |||
@@ -1,1617 +1,1617 @@ | |||
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 | ||
40 | using namespace MultiKey; | 40 | using namespace MultiKey; |
41 | 41 | ||
42 | static const char * const kb_config_xpm[] = { | 42 | static 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 */ |
55 | Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : | 55 | Keyboard::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 | int fontSize = config->readNumEntry( "FontSize", 10 ); | ||
69 | delete config; | 70 | delete config; |
70 | 71 | ||
71 | config = new Config("multikey"); | 72 | config = new Config("multikey"); |
72 | config->setGroup ("general"); | 73 | config->setGroup ("general"); |
73 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed | 74 | usePicks = config->readBoolEntry ("usePickboard", 0); // default closed |
74 | useRepeat = config->readBoolEntry ("useRepeat", 1); | 75 | useRepeat = config->readBoolEntry ("useRepeat", 1); |
75 | delete config; | 76 | delete config; |
76 | 77 | ||
77 | 78 | setFont( QFont( familyStr, fontSize ) ); | |
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, fontSize ) ); |
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 | ||
102 | Keyboard::~Keyboard() { | 102 | Keyboard::~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 */ |
112 | void Keyboard::resizeEvent(QResizeEvent*) | 112 | void 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 */ |
130 | void KeyboardPicks::initialise() | 130 | void 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 */ |
139 | QSize KeyboardPicks::sizeHint() const | 139 | QSize 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 */ |
146 | void KeyboardConfig::generateText(const QString &s) | 146 | void 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 */ |
167 | void Keyboard::paintEvent(QPaintEvent* e) | 167 | void 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 | ||
178 | void Keyboard::drawKeyboard(QPainter &p, int row, int col) | 178 | void 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 */ |
341 | void Keyboard::mousePressEvent(QMouseEvent *e) | 341 | void 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 | ||
768 | void Keyboard::receive(const QCString &msg, const QByteArray &data) | 768 | void 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 */ |
781 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 781 | void 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 | ||
848 | void Keyboard::repeat() | 848 | void 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 | ||
855 | void Keyboard::clearHighlight() | 855 | void 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 */ |
871 | QSize Keyboard::sizeHint() const | 871 | QSize 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 | ||
880 | void Keyboard::resetState() | 880 | void 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 */ |
895 | void Keyboard::togglePickboard(bool on_off) | 895 | void 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 | ||
921 | void Keyboard::toggleRepeat(bool on) { | 921 | void 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 | ||
927 | void Keyboard::cleanupConfigDlg() { | 927 | void 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 | ||
935 | void Keyboard::reloadSw() { | 935 | void 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 */ |
947 | void Keyboard::setMapToDefault() { | 947 | void 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 | ||
986 | void Keyboard::setMapToFile(QString map) { | 986 | void 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 */ |
1014 | void Keyboard::reloadKeyboard() { | 1014 | void 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 | ||
1022 | void Keyboard::loadKeyboardColors() { | 1022 | void 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 | ||
1090 | ushort Keyboard::parseKoreanInput (ushort c) { | 1090 | ushort 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 | ||
1183 | else if (schar != 0 && mchar != 0 && echar == 0) { | 1183 | else if (schar != 0 && mchar != 0 && echar == 0) { |
1184 | 1184 | ||
1185 | switch (mchar) { | 1185 | switch (mchar) { |
1186 | case 0x1169: | 1186 | case 0x1169: |
1187 | if (c == 0x1161) mchar = 0x116a; | 1187 | if (c == 0x1161) mchar = 0x116a; |
1188 | else if (c == 0x1162) mchar = 0x116b; | 1188 | else if (c == 0x1162) mchar = 0x116b; |
1189 | else if (c == 0x1175) mchar = 0x116c; | 1189 | else if (c == 0x1175) mchar = 0x116c; |
1190 | else { | 1190 | else { |
1191 | schar = 0; mchar = 0; echar = 0; | 1191 | schar = 0; mchar = 0; echar = 0; |
1192 | return c; | 1192 | return c; |
1193 | } | 1193 | } |
1194 | break; | 1194 | break; |
1195 | case 0x116e: | 1195 | case 0x116e: |
1196 | if (c == 0x1165) mchar = 0x116f; | 1196 | if (c == 0x1165) mchar = 0x116f; |
1197 | else if (c == 0x1166) mchar = 0x1170; | 1197 | else if (c == 0x1166) mchar = 0x1170; |
1198 | else if (c == 0x1175) mchar = 0x1171; | 1198 | else if (c == 0x1175) mchar = 0x1171; |
1199 | else { | 1199 | else { |
1200 | schar = 0; mchar = 0; echar = 0; | 1200 | schar = 0; mchar = 0; echar = 0; |
1201 | return c; | 1201 | return c; |
1202 | } | 1202 | } |
1203 | break; | 1203 | break; |
1204 | case 0x1173: | 1204 | case 0x1173: |
1205 | if (c == 0x1175) mchar = 0x1174; | 1205 | if (c == 0x1175) mchar = 0x1174; |
1206 | else { | 1206 | else { |
1207 | schar = 0; mchar = 0; echar = 0; | 1207 | schar = 0; mchar = 0; echar = 0; |
1208 | return c; | 1208 | return c; |
1209 | } | 1209 | } |
1210 | break; | 1210 | break; |
1211 | default: | 1211 | default: |
1212 | schar = 0; mchar = 0; echar = 0; | 1212 | schar = 0; mchar = 0; echar = 0; |
1213 | return c; | 1213 | return c; |
1214 | } | 1214 | } |
1215 | } | 1215 | } |
1216 | else if (schar != 0 && mchar != 0 && echar != 0) { | 1216 | else if (schar != 0 && mchar != 0 && echar != 0) { |
1217 | 1217 | ||
1218 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1218 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1219 | 1219 | ||
1220 | ushort prev = 0; | 1220 | ushort prev = 0; |
1221 | switch (echar) { | 1221 | switch (echar) { |
1222 | /* | 1222 | /* |
1223 | case 0x11a9: | 1223 | case 0x11a9: |
1224 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1224 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1225 | schar = 0x1100; | 1225 | schar = 0x1100; |
1226 | break; | 1226 | break; |
1227 | */ | 1227 | */ |
1228 | case 0x11aa: | 1228 | case 0x11aa: |
1229 | prev = combineKoreanChars(schar, mchar, 0x11a8); | 1229 | prev = combineKoreanChars(schar, mchar, 0x11a8); |
1230 | schar = 0x1109; | 1230 | schar = 0x1109; |
1231 | break; | 1231 | break; |
1232 | case 0x11ac: | 1232 | case 0x11ac: |
1233 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1233 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1234 | schar = 0x110c; | 1234 | schar = 0x110c; |
1235 | break; | 1235 | break; |
1236 | case 0x11ad: | 1236 | case 0x11ad: |
1237 | prev = combineKoreanChars(schar, mchar, 0x11ab); | 1237 | prev = combineKoreanChars(schar, mchar, 0x11ab); |
1238 | schar = 0x1112; | 1238 | schar = 0x1112; |
1239 | break; | 1239 | break; |
1240 | case 0x11b0: | 1240 | case 0x11b0: |
1241 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1241 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1242 | schar = 0x1100; | 1242 | schar = 0x1100; |
1243 | break; | 1243 | break; |
1244 | case 0x11b1: | 1244 | case 0x11b1: |
1245 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1245 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1246 | schar = 0x1106; | 1246 | schar = 0x1106; |
1247 | break; | 1247 | break; |
1248 | case 0x11b2: | 1248 | case 0x11b2: |
1249 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1249 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1250 | schar = 0x1107; | 1250 | schar = 0x1107; |
1251 | break; | 1251 | break; |
1252 | case 0x11b3: | 1252 | case 0x11b3: |
1253 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1253 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1254 | schar = 0x1109; | 1254 | schar = 0x1109; |
1255 | break; | 1255 | break; |
1256 | case 0x11b4: | 1256 | case 0x11b4: |
1257 | prev = combineKoreanChars(schar, mchar, 0x11af); | 1257 | prev = combineKoreanChars(schar, mchar, 0x11af); |
1258 | schar = 0x1110; | 1258 | schar = 0x1110; |
1259 | break; | 1259 | break; |
1260 | case 0x11b9: | 1260 | case 0x11b9: |
1261 | prev = combineKoreanChars(schar, mchar, 0x11b8); | 1261 | prev = combineKoreanChars(schar, mchar, 0x11b8); |
1262 | schar = 0x1109; | 1262 | schar = 0x1109; |
1263 | break; | 1263 | break; |
1264 | /* | 1264 | /* |
1265 | case 0x11bb: | 1265 | case 0x11bb: |
1266 | prev = combineKoreanChars(schar, mchar, 0x11ba); | 1266 | prev = combineKoreanChars(schar, mchar, 0x11ba); |
1267 | schar = 0x1109; | 1267 | schar = 0x1109; |
1268 | break; | 1268 | break; |
1269 | */ | 1269 | */ |
1270 | default: | 1270 | default: |
1271 | 1271 | ||
1272 | if (constoe(echar)) { | 1272 | if (constoe(echar)) { |
1273 | 1273 | ||
1274 | prev = combineKoreanChars(schar, mchar, 0); | 1274 | prev = combineKoreanChars(schar, mchar, 0); |
1275 | schar = constoe(echar); | 1275 | schar = constoe(echar); |
1276 | } | 1276 | } |
1277 | break; | 1277 | break; |
1278 | } | 1278 | } |
1279 | 1279 | ||
1280 | emit key( prev, prev, 0, true, false ); | 1280 | emit key( prev, prev, 0, true, false ); |
1281 | 1281 | ||
1282 | mchar = c; echar = 0; | 1282 | mchar = c; echar = 0; |
1283 | 1283 | ||
1284 | return combineKoreanChars(schar, mchar, 0); | 1284 | return combineKoreanChars(schar, mchar, 0); |
1285 | 1285 | ||
1286 | } | 1286 | } |
1287 | else { | 1287 | else { |
1288 | schar = 0; mchar = 0; echar = 0; | 1288 | schar = 0; mchar = 0; echar = 0; |
1289 | return c; | 1289 | return c; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | } | 1292 | } |
1293 | else /*if (c == ' ')*/ return c; | 1293 | else /*if (c == ' ')*/ return c; |
1294 | 1294 | ||
1295 | 1295 | ||
1296 | // and now... finally delete previous char, and return new char | 1296 | // and now... finally delete previous char, and return new char |
1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); | 1297 | emit key( 8, Qt::Key_Backspace, 0, true, false ); |
1298 | 1298 | ||
1299 | 1299 | ||
1300 | return combineKoreanChars( schar, mchar, echar); | 1300 | return combineKoreanChars( schar, mchar, echar); |
1301 | 1301 | ||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { | 1304 | ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { |
1305 | 1305 | ||
1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; | 1306 | return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; |
1307 | 1307 | ||
1308 | } | 1308 | } |
1309 | 1309 | ||
1310 | ushort Keyboard::constoe(const ushort c) { | 1310 | ushort Keyboard::constoe(const ushort c) { |
1311 | 1311 | ||
1312 | // converts schars to echars if possible | 1312 | // converts schars to echars if possible |
1313 | 1313 | ||
1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar | 1314 | if (0x1100 <= c && c <= 0x1112) { // schar to echar |
1315 | 1315 | ||
1316 | switch (c) { | 1316 | switch (c) { |
1317 | case 0x1100: return 0x11a8; | 1317 | case 0x1100: return 0x11a8; |
1318 | case 0x1101: return 0x11a9; | 1318 | case 0x1101: return 0x11a9; |
1319 | case 0x1102: return 0x11ab; | 1319 | case 0x1102: return 0x11ab; |
1320 | case 0x1103: return 0x11ae; | 1320 | case 0x1103: return 0x11ae; |
1321 | case 0x1105: return 0x11af; | 1321 | case 0x1105: return 0x11af; |
1322 | case 0x1106: return 0x11b7; | 1322 | case 0x1106: return 0x11b7; |
1323 | case 0x1107: return 0x11b8; | 1323 | case 0x1107: return 0x11b8; |
1324 | case 0x1109: return 0x11ba; | 1324 | case 0x1109: return 0x11ba; |
1325 | case 0x110a: return 0x11bb; | 1325 | case 0x110a: return 0x11bb; |
1326 | case 0x110b: return 0x11bc; | 1326 | case 0x110b: return 0x11bc; |
1327 | case 0x110c: return 0x11bd; | 1327 | case 0x110c: return 0x11bd; |
1328 | case 0x110e: return 0x11be; | 1328 | case 0x110e: return 0x11be; |
1329 | case 0x110f: return 0x11bf; | 1329 | case 0x110f: return 0x11bf; |
1330 | case 0x1110: return 0x11c0; | 1330 | case 0x1110: return 0x11c0; |
1331 | case 0x1111: return 0x11c1; | 1331 | case 0x1111: return 0x11c1; |
1332 | case 0x1112: return 0x11c2; | 1332 | case 0x1112: return 0x11c2; |
1333 | default: return 0; | 1333 | default: return 0; |
1334 | 1334 | ||
1335 | } | 1335 | } |
1336 | 1336 | ||
1337 | } else { //echar to schar | 1337 | } else { //echar to schar |
1338 | 1338 | ||
1339 | switch (c) { | 1339 | switch (c) { |
1340 | case 0x11a8: return 0x1100; | 1340 | case 0x11a8: return 0x1100; |
1341 | case 0x11a9: return 0x1101; | 1341 | case 0x11a9: return 0x1101; |
1342 | case 0x11ab: return 0x1102; | 1342 | case 0x11ab: return 0x1102; |
1343 | case 0x11ae: return 0x1103; | 1343 | case 0x11ae: return 0x1103; |
1344 | case 0x11af: return 0x1105; | 1344 | case 0x11af: return 0x1105; |
1345 | case 0x11b7: return 0x1106; | 1345 | case 0x11b7: return 0x1106; |
1346 | case 0x11b8: return 0x1107; | 1346 | case 0x11b8: return 0x1107; |
1347 | case 0x11ba: return 0x1109; | 1347 | case 0x11ba: return 0x1109; |
1348 | case 0x11bb: return 0x110a; | 1348 | case 0x11bb: return 0x110a; |
1349 | case 0x11bc: return 0x110b; | 1349 | case 0x11bc: return 0x110b; |
1350 | case 0x11bd: return 0x110c; | 1350 | case 0x11bd: return 0x110c; |
1351 | case 0x11be: return 0x110e; | 1351 | case 0x11be: return 0x110e; |
1352 | case 0x11bf: return 0x110f; | 1352 | case 0x11bf: return 0x110f; |
1353 | case 0x11c0: return 0x1110; | 1353 | case 0x11c0: return 0x1110; |
1354 | case 0x11c1: return 0x1111; | 1354 | case 0x11c1: return 0x1111; |
1355 | case 0x11c2: return 0x1112; | 1355 | case 0x11c2: return 0x1112; |
1356 | default: return 0; | 1356 | default: return 0; |
1357 | 1357 | ||
1358 | } | 1358 | } |
1359 | 1359 | ||
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | 1363 | ||
1364 | // Keys::Keys {{{1 | 1364 | // Keys::Keys {{{1 |
1365 | 1365 | ||
1366 | Keys::Keys() { | 1366 | Keys::Keys() { |
1367 | 1367 | ||
1368 | Config *config = new Config ("multikey"); | 1368 | Config *config = new Config ("multikey"); |
1369 | config->setGroup( "keymaps" ); | 1369 | config->setGroup( "keymaps" ); |
1370 | QString map = config->readEntry( "current" ); | 1370 | QString map = config->readEntry( "current" ); |
1371 | delete config; | 1371 | delete config; |
1372 | 1372 | ||
1373 | if (map.isNull() || !(QFile(map).exists())) { | 1373 | if (map.isNull() || !(QFile(map).exists())) { |
1374 | 1374 | ||
1375 | Config *config = new Config("locale"); | 1375 | Config *config = new Config("locale"); |
1376 | config->setGroup( "Language" ); | 1376 | config->setGroup( "Language" ); |
1377 | QString l = config->readEntry( "Language" , "en" ); | 1377 | QString l = config->readEntry( "Language" , "en" ); |
1378 | delete config; | 1378 | delete config; |
1379 | 1379 | ||
1380 | map = QPEApplication::qpeDir() + "share/multikey/" | 1380 | map = QPEApplication::qpeDir() + "share/multikey/" |
1381 | + l + ".keymap"; | 1381 | + l + ".keymap"; |
1382 | 1382 | ||
1383 | } | 1383 | } |
1384 | if (map.isNull() || !(QFile(map).exists())) { | 1384 | if (map.isNull() || !(QFile(map).exists())) { |
1385 | map = QPEApplication::qpeDir() + "share/multikey/en.keymap"; | 1385 | map = QPEApplication::qpeDir() + "share/multikey/en.keymap"; |
1386 | } | 1386 | } |
1387 | 1387 | ||
1388 | setKeysFromFile(map); | 1388 | setKeysFromFile(map); |
1389 | } | 1389 | } |
1390 | 1390 | ||
1391 | Keys::Keys(const char * filename) { | 1391 | Keys::Keys(const char * filename) { |
1392 | 1392 | ||
1393 | setKeysFromFile(filename); | 1393 | setKeysFromFile(filename); |
1394 | } | 1394 | } |
1395 | 1395 | ||
1396 | // Keys::setKeysFromFile {{{2 | 1396 | // Keys::setKeysFromFile {{{2 |
1397 | void Keys::setKeysFromFile(const char * filename) { | 1397 | void Keys::setKeysFromFile(const char * filename) { |
1398 | 1398 | ||
1399 | QFile f(filename); | 1399 | QFile f(filename); |
1400 | 1400 | ||
1401 | if (f.open(IO_ReadOnly)) { | 1401 | if (f.open(IO_ReadOnly)) { |
1402 | 1402 | ||
1403 | QTextStream t(&f); | 1403 | QTextStream t(&f); |
1404 | int row; | 1404 | int row; |
1405 | int qcode; | 1405 | int qcode; |
1406 | ushort unicode; | 1406 | ushort unicode; |
1407 | int width; | 1407 | int width; |
1408 | QString buf; | 1408 | QString buf; |
1409 | QString comment; | 1409 | QString comment; |
1410 | char * xpm[256]; //couldnt be larger than that... could it? | 1410 | char * xpm[256]; //couldnt be larger than that... could it? |
1411 | QImage *xpm2pix = 0; | 1411 | QImage *xpm2pix = 0; |
1412 | 1412 | ||
1413 | buf = t.readLine(); | 1413 | buf = t.readLine(); |
1414 | while (buf) { | 1414 | while (buf) { |
1415 | 1415 | ||
1416 | // get rid of comments | 1416 | // get rid of comments |
1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); | 1417 | buf.replace(QRegExp("#.*$", FALSE, FALSE), ""); |
1418 | 1418 | ||
1419 | // key definition | 1419 | // key definition |
1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { | 1420 | if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { |
1421 | // no $1 type referencing!!! this implementation of regexp sucks | 1421 | // no $1 type referencing!!! this implementation of regexp sucks |
1422 | 1422 | ||
1423 | // dont know of any sscanf() type funcs in Qt lib | 1423 | // dont know of any sscanf() type funcs in Qt lib |
1424 | QTextStream tmp (buf, IO_ReadOnly); | 1424 | QTextStream tmp (buf, IO_ReadOnly); |
1425 | tmp >> row >> qcode >> unicode >> width >> comment; | 1425 | tmp >> row >> qcode >> unicode >> width >> comment; |
1426 | 1426 | ||
1427 | buf = t.readLine(); | 1427 | buf = t.readLine(); |
1428 | int xpmLineCount = 0; | 1428 | int xpmLineCount = 0; |
1429 | xpm2pix = 0; | 1429 | xpm2pix = 0; |
1430 | 1430 | ||
1431 | // erase blank space | 1431 | // erase blank space |
1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); | 1432 | while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); |
1433 | 1433 | ||
1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { | 1434 | while (buf.contains(QRegExp("^\\s*\".*\""))) { |
1435 | 1435 | ||
1436 | QString xpmBuf = buf.stripWhiteSpace(); | 1436 | QString xpmBuf = buf.stripWhiteSpace(); |
1437 | 1437 | ||
1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; | 1438 | xpm[xpmLineCount] = new char [xpmBuf.length()]; |
1439 | 1439 | ||
1440 | int j = 0; | 1440 | int j = 0; |
1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { | 1441 | for (ushort i = 0; i < xpmBuf.length(); i++) { |
1442 | if (xpmBuf[i].latin1() != '"') { | 1442 | if (xpmBuf[i].latin1() != '"') { |
1443 | 1443 | ||
1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); | 1444 | ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); |
1445 | j++; | 1445 | j++; |
1446 | } | 1446 | } |
1447 | 1447 | ||
1448 | } | 1448 | } |
1449 | // have to close that facker up | 1449 | // have to close that facker up |
1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; | 1450 | ((char *)xpm[xpmLineCount])[j] = '\0'; |
1451 | 1451 | ||
1452 | xpmLineCount++; | 1452 | xpmLineCount++; |
1453 | buf = t.readLine(); | 1453 | buf = t.readLine(); |
1454 | } | 1454 | } |
1455 | if (xpmLineCount) { | 1455 | if (xpmLineCount) { |
1456 | 1456 | ||
1457 | xpm2pix = new QImage((const char **)xpm); | 1457 | xpm2pix = new QImage((const char **)xpm); |
1458 | for (int i = 0; i < xpmLineCount; i++) | 1458 | for (int i = 0; i < xpmLineCount; i++) |
1459 | 1459 | ||
1460 | delete [] (xpm[i]); | 1460 | delete [] (xpm[i]); |
1461 | 1461 | ||
1462 | } | 1462 | } |
1463 | setKey(row, qcode, unicode, width, xpm2pix); | 1463 | setKey(row, qcode, unicode, width, xpm2pix); |
1464 | } | 1464 | } |
1465 | 1465 | ||
1466 | // shift map | 1466 | // shift map |
1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1467 | else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1468 | 1468 | ||
1469 | QTextStream tmp (buf, IO_ReadOnly); | 1469 | QTextStream tmp (buf, IO_ReadOnly); |
1470 | ushort lower, shift; | 1470 | ushort lower, shift; |
1471 | tmp >> lower >> shift; | 1471 | tmp >> lower >> shift; |
1472 | 1472 | ||
1473 | shiftMap.insert(lower, shift); | 1473 | shiftMap.insert(lower, shift); |
1474 | 1474 | ||
1475 | buf = t.readLine(); | 1475 | buf = t.readLine(); |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | // meta key map | 1478 | // meta key map |
1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1479 | else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1480 | 1480 | ||
1481 | QTextStream tmp (buf, IO_ReadOnly); | 1481 | QTextStream tmp (buf, IO_ReadOnly); |
1482 | ushort lower, shift; | 1482 | ushort lower, shift; |
1483 | QChar m; | 1483 | QChar m; |
1484 | tmp >> m >> lower >> shift; | 1484 | tmp >> m >> lower >> shift; |
1485 | 1485 | ||
1486 | metaMap.insert(lower, shift); | 1486 | metaMap.insert(lower, shift); |
1487 | 1487 | ||
1488 | buf = t.readLine(); | 1488 | buf = t.readLine(); |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | // circumflex | 1491 | // circumflex |
1492 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1492 | else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1493 | 1493 | ||
1494 | QTextStream tmp (buf, IO_ReadOnly); | 1494 | QTextStream tmp (buf, IO_ReadOnly); |
1495 | ushort lower, shift; | 1495 | ushort lower, shift; |
1496 | QChar c; | 1496 | QChar c; |
1497 | tmp >> c >> lower >> shift; | 1497 | tmp >> c >> lower >> shift; |
1498 | 1498 | ||
1499 | circumflexMap.insert(lower, shift); | 1499 | circumflexMap.insert(lower, shift); |
1500 | 1500 | ||
1501 | buf = t.readLine(); | 1501 | buf = t.readLine(); |
1502 | } | 1502 | } |
1503 | // diaeresis | 1503 | // diaeresis |
1504 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1504 | else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1505 | 1505 | ||
1506 | QTextStream tmp (buf, IO_ReadOnly); | 1506 | QTextStream tmp (buf, IO_ReadOnly); |
1507 | ushort lower, shift; | 1507 | ushort lower, shift; |
1508 | QChar d; | 1508 | QChar d; |
1509 | tmp >> d >> lower >> shift; | 1509 | tmp >> d >> lower >> shift; |
1510 | 1510 | ||
1511 | diaeresisMap.insert(lower, shift); | 1511 | diaeresisMap.insert(lower, shift); |
1512 | 1512 | ||
1513 | buf = t.readLine(); | 1513 | buf = t.readLine(); |
1514 | } | 1514 | } |
1515 | // back accent | 1515 | // back accent |
1516 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1516 | else if (buf.contains(QRegExp("^\\s*b\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1517 | 1517 | ||
1518 | QTextStream tmp (buf, IO_ReadOnly); | 1518 | QTextStream tmp (buf, IO_ReadOnly); |
1519 | ushort lower, shift; | 1519 | ushort lower, shift; |
1520 | QChar d; | 1520 | QChar d; |
1521 | tmp >> d >> lower >> shift; | 1521 | tmp >> d >> lower >> shift; |
1522 | 1522 | ||
1523 | baccentMap.insert(lower, shift); | 1523 | baccentMap.insert(lower, shift); |
1524 | 1524 | ||
1525 | qDebug ("Estoy aadiendo %i con %i", lower, shift); | 1525 | qDebug ("Estoy aadiendo %i con %i", lower, shift); |
1526 | buf = t.readLine(); | 1526 | buf = t.readLine(); |
1527 | } | 1527 | } |
1528 | // accent | 1528 | // accent |
1529 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { | 1529 | else if (buf.contains(QRegExp("^\\s*a\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { |
1530 | 1530 | ||
1531 | QTextStream tmp (buf, IO_ReadOnly); | 1531 | QTextStream tmp (buf, IO_ReadOnly); |
1532 | ushort lower, shift; | 1532 | ushort lower, shift; |
1533 | QChar d; | 1533 | QChar d; |
1534 | tmp >> d >> lower >> shift; | 1534 | tmp >> d >> lower >> shift; |
1535 | 1535 | ||
1536 | accentMap.insert(lower, shift); | 1536 | accentMap.insert(lower, shift); |
1537 | 1537 | ||
1538 | buf = t.readLine(); | 1538 | buf = t.readLine(); |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | // other variables like lang & title & sw | 1541 | // other variables like lang & title & sw |
1542 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { | 1542 | else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { |
1543 | 1543 | ||
1544 | QTextStream tmp (buf, IO_ReadOnly); | 1544 | QTextStream tmp (buf, IO_ReadOnly); |
1545 | QString name, equals, value; | 1545 | QString name, equals, value; |
1546 | 1546 | ||
1547 | tmp >> name >> equals >> value; | 1547 | tmp >> name >> equals >> value; |
1548 | 1548 | ||
1549 | if (name == "lang") { | 1549 | if (name == "lang") { |
1550 | 1550 | ||
1551 | lang = value; | 1551 | lang = value; |
1552 | 1552 | ||
1553 | } | 1553 | } |
1554 | 1554 | ||
1555 | buf = t.readLine(); | 1555 | buf = t.readLine(); |
1556 | } | 1556 | } |
1557 | // comments | 1557 | // comments |
1558 | else if (buf.contains(QRegExp("^\\s*#"))) { | 1558 | else if (buf.contains(QRegExp("^\\s*#"))) { |
1559 | 1559 | ||
1560 | buf = t.readLine(); | 1560 | buf = t.readLine(); |
1561 | 1561 | ||
1562 | } else { // blank line, or garbage | 1562 | } else { // blank line, or garbage |
1563 | 1563 | ||
1564 | buf = t.readLine(); | 1564 | buf = t.readLine(); |
1565 | 1565 | ||
1566 | } | 1566 | } |
1567 | 1567 | ||
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | f.close(); | 1570 | f.close(); |
1571 | } else { | 1571 | } else { |
1572 | // We couldnt find the selected keymap, give them a configure button | 1572 | // We couldnt find the selected keymap, give them a configure button |
1573 | QImage * btn = new QImage((const char ** )kb_config_xpm); | 1573 | QImage * btn = new QImage((const char ** )kb_config_xpm); |
1574 | setKey(1, 0x1030, 0, 2, btn); | 1574 | setKey(1, 0x1030, 0, 2, btn); |
1575 | } | 1575 | } |
1576 | 1576 | ||
1577 | } | 1577 | } |
1578 | 1578 | ||
1579 | 1579 | ||
1580 | // Keys::setKey {{{2 | 1580 | // Keys::setKey {{{2 |
1581 | void Keys::setKey(const int row, const int qcode, const ushort unicode, | 1581 | void Keys::setKey(const int row, const int qcode, const ushort unicode, |
1582 | const int width, QImage *pix) { | 1582 | const int width, QImage *pix) { |
1583 | 1583 | ||
1584 | Key * key; | 1584 | Key * key; |
1585 | key = new Key; | 1585 | key = new Key; |
1586 | key->qcode = qcode; | 1586 | key->qcode = qcode; |
1587 | key->unicode = unicode; | 1587 | key->unicode = unicode; |
1588 | key->width = width; | 1588 | key->width = width; |
1589 | 1589 | ||
1590 | // share key->pressed between same keys | 1590 | // share key->pressed between same keys |
1591 | bool found = 0; | 1591 | bool found = 0; |
1592 | for (int i = 1; i <= 5; i++) { | 1592 | for (int i = 1; i <= 5; i++) { |
1593 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1593 | for (unsigned int j = 0; j < keys[i].count(); j++) |
1594 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { | 1594 | if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { |
1595 | 1595 | ||
1596 | key->pressed = keys[i].at(j)->pressed; | 1596 | key->pressed = keys[i].at(j)->pressed; |
1597 | found = 1; | 1597 | found = 1; |
1598 | } | 1598 | } |
1599 | 1599 | ||
1600 | } | 1600 | } |
1601 | if (!found) { | 1601 | if (!found) { |
1602 | 1602 | ||
1603 | key->pressed = new bool; | 1603 | key->pressed = new bool; |
1604 | *(key->pressed) = 0; | 1604 | *(key->pressed) = 0; |
1605 | } | 1605 | } |
1606 | 1606 | ||
1607 | key->pix = pix; | 1607 | key->pix = pix; |
1608 | 1608 | ||
1609 | 1609 | ||
1610 | keys[row].append(key); | 1610 | keys[row].append(key); |
1611 | } | 1611 | } |
1612 | 1612 | ||
1613 | // Keys::~Keys {{{2 | 1613 | // Keys::~Keys {{{2 |
1614 | Keys::~Keys() { | 1614 | Keys::~Keys() { |
1615 | 1615 | ||
1616 | for (int i = 1; i <= 5; i++) | 1616 | for (int i = 1; i <= 5; i++) |
1617 | for (unsigned int j = 0; j < keys[i].count(); j++) | 1617 | for (unsigned int j = 0; j < keys[i].count(); j++) |
diff --git a/inputmethods/pickboard/pickboard.cpp b/inputmethods/pickboard/pickboard.cpp index 1611cb0..e5365ba 100644 --- a/inputmethods/pickboard/pickboard.cpp +++ b/inputmethods/pickboard/pickboard.cpp | |||
@@ -1,110 +1,115 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include "pickboard.h" | 20 | #include "pickboard.h" |
21 | #include "pickboardpicks.h" | 21 | #include "pickboardpicks.h" |
22 | #include "pickboardcfg.h" | 22 | #include "pickboardcfg.h" |
23 | 23 | ||
24 | #include <qpe/global.h> | 24 | #include <qpe/global.h> |
25 | 25 | #include <qpe/config.h> | |
26 | #include <qpainter.h> | 26 | #include <qpainter.h> |
27 | #include <qlist.h> | 27 | #include <qlist.h> |
28 | #include <qbitmap.h> | 28 | #include <qbitmap.h> |
29 | #include <qlayout.h> | 29 | #include <qlayout.h> |
30 | #include <qvbox.h> | 30 | #include <qvbox.h> |
31 | #include <qdialog.h> | 31 | #include <qdialog.h> |
32 | #include <qscrollview.h> | 32 | #include <qscrollview.h> |
33 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
34 | #include <qhbuttongroup.h> | 34 | #include <qhbuttongroup.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qmessagebox.h> | 36 | #include <qmessagebox.h> |
37 | #ifdef QWS | 37 | #ifdef QWS |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | /*! \class Pickboard | 41 | /*! \class Pickboard |
42 | \brief The Pickboard class provides an input method | 42 | \brief The Pickboard class provides an input method |
43 | based on a virtual keyboard combined with word-completion. | 43 | based on a virtual keyboard combined with word-completion. |
44 | 44 | ||
45 | This version of Pickboard is Dual Licensed Software. However, for you to be | 45 | This version of Pickboard is Dual Licensed Software. However, for you to be |
46 | able to license the technology to others, you may require a T9(R) Text | 46 | able to license the technology to others, you may require a T9(R) Text |
47 | Input license from Tegic Communications Corporation. More information can | 47 | Input license from Tegic Communications Corporation. More information can |
48 | be found at http://www.t9.com/. | 48 | be found at http://www.t9.com/. |
49 | 49 | ||
50 | \legalese | 50 | \legalese |
51 | This version of Pickboard is Dual Licensed Software. However, for you to be | 51 | This version of Pickboard is Dual Licensed Software. However, for you to be |
52 | able to license the technology to others, you may require a T9(R) Text | 52 | able to license the technology to others, you may require a T9(R) Text |
53 | Input license from Tegic Communications Corporation. More information can | 53 | Input license from Tegic Communications Corporation. More information can |
54 | be found at http://www.t9.com/. | 54 | be found at http://www.t9.com/. |
55 | */ | 55 | */ |
56 | 56 | ||
57 | /* XPM */ | 57 | /* XPM */ |
58 | static const char * const menu_xpm[]={ | 58 | static const char * const menu_xpm[]={ |
59 | "9 9 2 1", | 59 | "9 9 2 1", |
60 | "a c #000000", | 60 | "a c #000000", |
61 | ". c None", | 61 | ". c None", |
62 | ".........", | 62 | ".........", |
63 | ".........", | 63 | ".........", |
64 | ".........", | 64 | ".........", |
65 | "....a....", | 65 | "....a....", |
66 | "...aaa...", | 66 | "...aaa...", |
67 | "..aaaaa..", | 67 | "..aaaaa..", |
68 | ".aaaaaaa.", | 68 | ".aaaaaaa.", |
69 | ".........", | 69 | ".........", |
70 | "........."}; | 70 | "........."}; |
71 | 71 | ||
72 | class PickboardPrivate { | 72 | class PickboardPrivate { |
73 | public: | 73 | public: |
74 | PickboardPrivate(Pickboard* parent) | 74 | PickboardPrivate(Pickboard* parent) |
75 | { | 75 | { |
76 | picks = new PickboardPicks(parent); | 76 | picks = new PickboardPicks(parent); |
77 | picks->initialise(); | 77 | picks->initialise(); |
78 | menu = new QPushButton(parent); | 78 | menu = new QPushButton(parent); |
79 | menu->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding)); | 79 | menu->setSizePolicy(QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding)); |
80 | menu->setPixmap(QPixmap((const char **)menu_xpm)); | 80 | menu->setPixmap(QPixmap((const char **)menu_xpm)); |
81 | QObject::connect(menu,SIGNAL(clicked()),picks,SLOT(doMenu())); | 81 | QObject::connect(menu,SIGNAL(clicked()),picks,SLOT(doMenu())); |
82 | QObject::connect(picks,SIGNAL(key(ushort,ushort,ushort,bool,bool)), | 82 | QObject::connect(picks,SIGNAL(key(ushort,ushort,ushort,bool,bool)), |
83 | parent,SIGNAL(key(ushort,ushort,ushort,bool,bool))); | 83 | parent,SIGNAL(key(ushort,ushort,ushort,bool,bool))); |
84 | } | 84 | } |
85 | 85 | ||
86 | PickboardPicks* picks; | 86 | PickboardPicks* picks; |
87 | QPushButton* menu; | 87 | QPushButton* menu; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | Pickboard::Pickboard(QWidget* parent, const char* name, WFlags f) : | 90 | Pickboard::Pickboard(QWidget* parent, const char* name, WFlags f) : |
91 | QFrame(parent,name,f) | 91 | QFrame(parent,name,f) |
92 | { | 92 | { |
93 | (new QHBoxLayout(this))->setAutoAdd(TRUE); | 93 | (new QHBoxLayout(this))->setAutoAdd(TRUE); |
94 | d = new PickboardPrivate(this); | 94 | d = new PickboardPrivate(this); |
95 | // under Win32 we may not have smallsmooth font | 95 | |
96 | #ifndef Q_OS_WIN32 | 96 | // get the default font |
97 | setFont( QFont( "smallsmooth", 9 ) ); | 97 | Config *config = new Config( "qpe" ); |
98 | #endif | 98 | config->setGroup( "Appearance" ); |
99 | QString familyStr = config->readEntry( "FontFamily", "smallsmooth" ); | ||
100 | int fontSize = config->readNumEntry( "FontSize", 10 ); | ||
101 | delete config; | ||
102 | |||
103 | setFont( QFont( familyStr, fontSize ) ); | ||
99 | } | 104 | } |
100 | 105 | ||
101 | Pickboard::~Pickboard() | 106 | Pickboard::~Pickboard() |
102 | { | 107 | { |
103 | delete d; | 108 | delete d; |
104 | } | 109 | } |
105 | 110 | ||
106 | void Pickboard::resetState() | 111 | void Pickboard::resetState() |
107 | { | 112 | { |
108 | d->picks->resetState(); | 113 | d->picks->resetState(); |
109 | } | 114 | } |
110 | 115 | ||
diff --git a/inputmethods/unikeyboard/unikeyboard.cpp b/inputmethods/unikeyboard/unikeyboard.cpp index aa74c66..23d96ad 100644 --- a/inputmethods/unikeyboard/unikeyboard.cpp +++ b/inputmethods/unikeyboard/unikeyboard.cpp | |||
@@ -1,278 +1,286 @@ | |||
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 "unikeyboard.h" | 21 | #include "unikeyboard.h" |
22 | 22 | ||
23 | #include <qpe/fontmanager.h> | 23 | #include <qpe/fontmanager.h> |
24 | 24 | #include <qpe/config.h> | |
25 | #include <qpainter.h> | 25 | #include <qpainter.h> |
26 | #include <qfontmetrics.h> | 26 | #include <qfontmetrics.h> |
27 | #include <qcombobox.h> | 27 | #include <qcombobox.h> |
28 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 28 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
29 | #include <qwindowsystem_qws.h> | 29 | #include <qwindowsystem_qws.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | static const int nw = 8; | 32 | static const int nw = 8; |
33 | 33 | ||
34 | typedef struct BlockMap { | 34 | typedef struct BlockMap { |
35 | ushort start; | 35 | ushort start; |
36 | ushort stop; | 36 | ushort stop; |
37 | const char *name; | 37 | const char *name; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | //# Start Code; Block Name | 40 | //# Start Code; Block Name |
41 | 41 | ||
42 | static const BlockMap blockMap[] = | 42 | static const BlockMap blockMap[] = |
43 | { | 43 | { |
44 | {0x0000, 0x007F, "Basic Latin"}, | 44 | {0x0000, 0x007F, "Basic Latin"}, |
45 | {0x0080, 0x00FF, "Latin-1 Supplement"}, | 45 | {0x0080, 0x00FF, "Latin-1 Supplement"}, |
46 | {0x0100, 0x017F, "Latin Extended-A"}, | 46 | {0x0100, 0x017F, "Latin Extended-A"}, |
47 | {0x0180, 0x024F, "Latin Extended-B"}, | 47 | {0x0180, 0x024F, "Latin Extended-B"}, |
48 | {0x0250, 0x02AF, "IPA Extensions"}, | 48 | {0x0250, 0x02AF, "IPA Extensions"}, |
49 | {0x02B0, 0x02FF, "Spacing Modifier Letters"}, | 49 | {0x02B0, 0x02FF, "Spacing Modifier Letters"}, |
50 | {0x0300, 0x036F, "Combining Diacritical Marks"}, | 50 | {0x0300, 0x036F, "Combining Diacritical Marks"}, |
51 | {0x0370, 0x03FF, "Greek"}, | 51 | {0x0370, 0x03FF, "Greek"}, |
52 | {0x0400, 0x04FF, "Cyrillic"}, | 52 | {0x0400, 0x04FF, "Cyrillic"}, |
53 | {0x0530, 0x058F, "Armenian"}, | 53 | {0x0530, 0x058F, "Armenian"}, |
54 | {0x0590, 0x05FF, "Hebrew"}, | 54 | {0x0590, 0x05FF, "Hebrew"}, |
55 | {0x0600, 0x06FF, "Arabic"}, | 55 | {0x0600, 0x06FF, "Arabic"}, |
56 | {0x0700, 0x074F, "Syriac "}, | 56 | {0x0700, 0x074F, "Syriac "}, |
57 | {0x0780, 0x07BF, "Thaana"}, | 57 | {0x0780, 0x07BF, "Thaana"}, |
58 | {0x0900, 0x097F, "Devanagari"}, | 58 | {0x0900, 0x097F, "Devanagari"}, |
59 | {0x0980, 0x09FF, "Bengali"}, | 59 | {0x0980, 0x09FF, "Bengali"}, |
60 | {0x0A00, 0x0A7F, "Gurmukhi"}, | 60 | {0x0A00, 0x0A7F, "Gurmukhi"}, |
61 | {0x0A80, 0x0AFF, "Gujarati"}, | 61 | {0x0A80, 0x0AFF, "Gujarati"}, |
62 | {0x0B00, 0x0B7F, "Oriya"}, | 62 | {0x0B00, 0x0B7F, "Oriya"}, |
63 | {0x0B80, 0x0BFF, "Tamil"}, | 63 | {0x0B80, 0x0BFF, "Tamil"}, |
64 | {0x0C00, 0x0C7F, "Telugu"}, | 64 | {0x0C00, 0x0C7F, "Telugu"}, |
65 | {0x0C80, 0x0CFF, "Kannada"}, | 65 | {0x0C80, 0x0CFF, "Kannada"}, |
66 | {0x0D00, 0x0D7F, "Malayalam"}, | 66 | {0x0D00, 0x0D7F, "Malayalam"}, |
67 | {0x0D80, 0x0DFF, "Sinhala"}, | 67 | {0x0D80, 0x0DFF, "Sinhala"}, |
68 | {0x0E00, 0x0E7F, "Thai"}, | 68 | {0x0E00, 0x0E7F, "Thai"}, |
69 | {0x0E80, 0x0EFF, "Lao"}, | 69 | {0x0E80, 0x0EFF, "Lao"}, |
70 | {0x0F00, 0x0FFF, "Tibetan"}, | 70 | {0x0F00, 0x0FFF, "Tibetan"}, |
71 | {0x1000, 0x109F, "Myanmar "}, | 71 | {0x1000, 0x109F, "Myanmar "}, |
72 | {0x10A0, 0x10FF, "Georgian"}, | 72 | {0x10A0, 0x10FF, "Georgian"}, |
73 | {0x1100, 0x11FF, "Hangul Jamo"}, | 73 | {0x1100, 0x11FF, "Hangul Jamo"}, |
74 | {0x1200, 0x137F, "Ethiopic"}, | 74 | {0x1200, 0x137F, "Ethiopic"}, |
75 | {0x13A0, 0x13FF, "Cherokee"}, | 75 | {0x13A0, 0x13FF, "Cherokee"}, |
76 | {0x1400, 0x167F, "Unified Canadian Aboriginal Syllabics"}, | 76 | {0x1400, 0x167F, "Unified Canadian Aboriginal Syllabics"}, |
77 | {0x1680, 0x169F, "Ogham"}, | 77 | {0x1680, 0x169F, "Ogham"}, |
78 | {0x16A0, 0x16FF, "Runic"}, | 78 | {0x16A0, 0x16FF, "Runic"}, |
79 | {0x1780, 0x17FF, "Khmer"}, | 79 | {0x1780, 0x17FF, "Khmer"}, |
80 | {0x1800, 0x18AF, "Mongolian"}, | 80 | {0x1800, 0x18AF, "Mongolian"}, |
81 | {0x1E00, 0x1EFF, "Latin Extended Additional"}, | 81 | {0x1E00, 0x1EFF, "Latin Extended Additional"}, |
82 | {0x1F00, 0x1FFF, "Greek Extended"}, | 82 | {0x1F00, 0x1FFF, "Greek Extended"}, |
83 | {0x2000, 0x206F, "General Punctuation"}, | 83 | {0x2000, 0x206F, "General Punctuation"}, |
84 | {0x2070, 0x209F, "Superscripts and Subscripts"}, | 84 | {0x2070, 0x209F, "Superscripts and Subscripts"}, |
85 | {0x20A0, 0x20CF, "Currency Symbols"}, | 85 | {0x20A0, 0x20CF, "Currency Symbols"}, |
86 | {0x20D0, 0x20FF, "Combining Marks for Symbols"}, | 86 | {0x20D0, 0x20FF, "Combining Marks for Symbols"}, |
87 | {0x2100, 0x214F, "Letterlike Symbols"}, | 87 | {0x2100, 0x214F, "Letterlike Symbols"}, |
88 | {0x2150, 0x218F, "Number Forms"}, | 88 | {0x2150, 0x218F, "Number Forms"}, |
89 | {0x2190, 0x21FF, "Arrows"}, | 89 | {0x2190, 0x21FF, "Arrows"}, |
90 | {0x2200, 0x22FF, "Mathematical Operators"}, | 90 | {0x2200, 0x22FF, "Mathematical Operators"}, |
91 | {0x2300, 0x23FF, "Miscellaneous Technical"}, | 91 | {0x2300, 0x23FF, "Miscellaneous Technical"}, |
92 | {0x2400, 0x243F, "Control Pictures"}, | 92 | {0x2400, 0x243F, "Control Pictures"}, |
93 | {0x2440, 0x245F, "Optical Character Recognition"}, | 93 | {0x2440, 0x245F, "Optical Character Recognition"}, |
94 | {0x2460, 0x24FF, "Enclosed Alphanumerics"}, | 94 | {0x2460, 0x24FF, "Enclosed Alphanumerics"}, |
95 | {0x2500, 0x257F, "Box Drawing"}, | 95 | {0x2500, 0x257F, "Box Drawing"}, |
96 | {0x2580, 0x259F, "Block Elements"}, | 96 | {0x2580, 0x259F, "Block Elements"}, |
97 | {0x25A0, 0x25FF, "Geometric Shapes"}, | 97 | {0x25A0, 0x25FF, "Geometric Shapes"}, |
98 | {0x2600, 0x26FF, "Miscellaneous Symbols"}, | 98 | {0x2600, 0x26FF, "Miscellaneous Symbols"}, |
99 | {0x2700, 0x27BF, "Dingbats"}, | 99 | {0x2700, 0x27BF, "Dingbats"}, |
100 | {0x2800, 0x28FF, "Braille Patterns"}, | 100 | {0x2800, 0x28FF, "Braille Patterns"}, |
101 | {0x2E80, 0x2EFF, "CJK Radicals Supplement"}, | 101 | {0x2E80, 0x2EFF, "CJK Radicals Supplement"}, |
102 | {0x2F00, 0x2FDF, "Kangxi Radicals"}, | 102 | {0x2F00, 0x2FDF, "Kangxi Radicals"}, |
103 | {0x2FF0, 0x2FFF, "Ideographic Description Characters"}, | 103 | {0x2FF0, 0x2FFF, "Ideographic Description Characters"}, |
104 | {0x3000, 0x303F, "CJK Symbols and Punctuation"}, | 104 | {0x3000, 0x303F, "CJK Symbols and Punctuation"}, |
105 | {0x3040, 0x309F, "Hiragana"}, | 105 | {0x3040, 0x309F, "Hiragana"}, |
106 | {0x30A0, 0x30FF, "Katakana"}, | 106 | {0x30A0, 0x30FF, "Katakana"}, |
107 | {0x3100, 0x312F, "Bopomofo"}, | 107 | {0x3100, 0x312F, "Bopomofo"}, |
108 | {0x3130, 0x318F, "Hangul Compatibility Jamo"}, | 108 | {0x3130, 0x318F, "Hangul Compatibility Jamo"}, |
109 | {0x3190, 0x319F, "Kanbun"}, | 109 | {0x3190, 0x319F, "Kanbun"}, |
110 | {0x31A0, 0x31BF, "Bopomofo Extended"}, | 110 | {0x31A0, 0x31BF, "Bopomofo Extended"}, |
111 | {0x3200, 0x32FF, "Enclosed CJK Letters and Months"}, | 111 | {0x3200, 0x32FF, "Enclosed CJK Letters and Months"}, |
112 | {0x3300, 0x33FF, "CJK Compatibility"}, | 112 | {0x3300, 0x33FF, "CJK Compatibility"}, |
113 | {0x3400, 0x4DB5, "CJK Unified Ideographs Extension A"}, | 113 | {0x3400, 0x4DB5, "CJK Unified Ideographs Extension A"}, |
114 | {0x4E00, 0x9FFF, "CJK Unified Ideographs"}, | 114 | {0x4E00, 0x9FFF, "CJK Unified Ideographs"}, |
115 | {0xA000, 0xA48F, "Yi Syllables"}, | 115 | {0xA000, 0xA48F, "Yi Syllables"}, |
116 | {0xA490, 0xA4CF, "Yi Radicals"}, | 116 | {0xA490, 0xA4CF, "Yi Radicals"}, |
117 | {0xAC00, 0xD7A3, "Hangul Syllables"}, | 117 | {0xAC00, 0xD7A3, "Hangul Syllables"}, |
118 | {0xD800, 0xDB7F, "High Surrogates"}, | 118 | {0xD800, 0xDB7F, "High Surrogates"}, |
119 | {0xDB80, 0xDBFF, "High Private Use Surrogates"}, | 119 | {0xDB80, 0xDBFF, "High Private Use Surrogates"}, |
120 | {0xDC00, 0xDFFF, "Low Surrogates"}, | 120 | {0xDC00, 0xDFFF, "Low Surrogates"}, |
121 | {0xE000, 0xF8FF, "Private Use"}, | 121 | {0xE000, 0xF8FF, "Private Use"}, |
122 | {0xF900, 0xFAFF, "CJK Compatibility Ideographs"}, | 122 | {0xF900, 0xFAFF, "CJK Compatibility Ideographs"}, |
123 | {0xFB00, 0xFB4F, "Alphabetic Presentation Forms"}, | 123 | {0xFB00, 0xFB4F, "Alphabetic Presentation Forms"}, |
124 | {0xFB50, 0xFDFF, "Arabic Presentation Forms-A"}, | 124 | {0xFB50, 0xFDFF, "Arabic Presentation Forms-A"}, |
125 | {0xFE20, 0xFE2F, "Combining Half Marks"}, | 125 | {0xFE20, 0xFE2F, "Combining Half Marks"}, |
126 | {0xFE30, 0xFE4F, "CJK Compatibility Forms"}, | 126 | {0xFE30, 0xFE4F, "CJK Compatibility Forms"}, |
127 | {0xFE50, 0xFE6F, "Small Form Variants"}, | 127 | {0xFE50, 0xFE6F, "Small Form Variants"}, |
128 | {0xFE70, 0xFEFE, "Arabic Presentation Forms-B"}, | 128 | {0xFE70, 0xFEFE, "Arabic Presentation Forms-B"}, |
129 | {0xFF00, 0xFEFF, "Halfwidth and Fullwidth Forms"}, | 129 | {0xFF00, 0xFEFF, "Halfwidth and Fullwidth Forms"}, |
130 | {0xFFF0, 0xFFEF, "Specials"}, | 130 | {0xFFF0, 0xFFEF, "Specials"}, |
131 | {0xFFFF, 0xFFFF, 0} }; | 131 | {0xFFFF, 0xFFFF, 0} }; |
132 | 132 | ||
133 | 133 | ||
134 | UniScrollview::UniScrollview(QWidget* parent, const char* name, int f) : | 134 | UniScrollview::UniScrollview(QWidget* parent, const char* name, int f) : |
135 | QScrollView(parent, name, f) | 135 | QScrollView(parent, name, f) |
136 | { | 136 | { |
137 | // smallFont.setRawName( "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1" ); //###### | 137 | // smallFont.setRawName( "-adobe-courier-medium-r-normal--10-100-75-75-m-60-iso8859-1" ); //###### |
138 | smallFont = QFont( "Helvetica", 8 ); | 138 | |
139 | // get the default font | ||
140 | Config *config = new Config( "qpe" ); | ||
141 | config->setGroup( "Appearance" ); | ||
142 | QString familyStr = config->readEntry( "FontFamily", "Helvetica" ); | ||
143 | int fontSize = config->readNumEntry( "FontSize", 8 ) - 2; | ||
144 | delete config; | ||
145 | |||
146 | smallFont = QFont( familyStr, fontSize ); | ||
139 | QFontMetrics sfm( smallFont ); | 147 | QFontMetrics sfm( smallFont ); |
140 | xoff = sfm.width( "AAA" ); | 148 | xoff = sfm.width( "AAA" ); |
141 | setFont( FontManager::unicodeFont( FontManager::Fixed ) ); | 149 | setFont( FontManager::unicodeFont( FontManager::Fixed ) ); |
142 | QFontMetrics fm( font() ); | 150 | QFontMetrics fm( font() ); |
143 | cellsize = fm.lineSpacing() + 2; | 151 | cellsize = fm.lineSpacing() + 2; |
144 | resizeContents( cellsize*nw, cellsize*65536/nw ); | 152 | resizeContents( cellsize*nw, cellsize*65536/nw ); |
145 | verticalScrollBar()->setLineStep(cellsize); | 153 | verticalScrollBar()->setLineStep(cellsize); |
146 | 154 | ||
147 | viewport()->setBackgroundMode( QWidget::PaletteBase ); | 155 | viewport()->setBackgroundMode( QWidget::PaletteBase ); |
148 | } | 156 | } |
149 | 157 | ||
150 | 158 | ||
151 | 159 | ||
152 | void UniScrollview::contentsMousePressEvent(QMouseEvent* e) | 160 | void UniScrollview::contentsMousePressEvent(QMouseEvent* e) |
153 | { | 161 | { |
154 | if ( e->x() < xoff || e->x() > xoff + nw*cellsize ) | 162 | if ( e->x() < xoff || e->x() > xoff + nw*cellsize ) |
155 | return; | 163 | return; |
156 | int row = e->y()/cellsize; | 164 | int row = e->y()/cellsize; |
157 | int col = (e->x()-xoff)/cellsize; | 165 | int col = (e->x()-xoff)/cellsize; |
158 | int u = row*nw+col; | 166 | int u = row*nw+col; |
159 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 167 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
160 | emit key( u, 0, 0, true, false ); | 168 | emit key( u, 0, 0, true, false ); |
161 | emit key( u, 0, 0, false, false ); | 169 | emit key( u, 0, 0, false, false ); |
162 | #endif | 170 | #endif |
163 | } | 171 | } |
164 | 172 | ||
165 | 173 | ||
166 | void UniScrollview::contentsMouseReleaseEvent(QMouseEvent*) | 174 | void UniScrollview::contentsMouseReleaseEvent(QMouseEvent*) |
167 | { | 175 | { |
168 | } | 176 | } |
169 | 177 | ||
170 | void UniScrollview::scrollTo( int unicode ) | 178 | void UniScrollview::scrollTo( int unicode ) |
171 | { | 179 | { |
172 | int row = unicode / nw; | 180 | int row = unicode / nw; |
173 | setContentsPos( 0, row*cellsize ); | 181 | setContentsPos( 0, row*cellsize ); |
174 | } | 182 | } |
175 | 183 | ||
176 | 184 | ||
177 | void UniScrollview::drawContents( QPainter *p, int /*cx*/, int cy, int /*cw*/, int ch ) | 185 | void UniScrollview::drawContents( QPainter *p, int /*cx*/, int cy, int /*cw*/, int ch ) |
178 | { | 186 | { |
179 | QFontMetrics fm = fontMetrics(); | 187 | QFontMetrics fm = fontMetrics(); |
180 | int row = cy / cellsize; | 188 | int row = cy / cellsize; |
181 | int y = row*cellsize; | 189 | int y = row*cellsize; |
182 | while ( y < cy+ch ) { | 190 | while ( y < cy+ch ) { |
183 | p->drawLine( xoff, y, xoff+nw*cellsize, y ); | 191 | p->drawLine( xoff, y, xoff+nw*cellsize, y ); |
184 | if ( row*nw%16 == 0 ) { | 192 | if ( row*nw%16 == 0 ) { |
185 | p->setFont( smallFont ); | 193 | p->setFont( smallFont ); |
186 | QString s; | 194 | QString s; |
187 | s.sprintf( "%03X", row*nw/16 ); | 195 | s.sprintf( "%03X", row*nw/16 ); |
188 | p->drawText( 0, y, xoff, cellsize, AlignLeft, s ); | 196 | p->drawText( 0, y, xoff, cellsize, AlignLeft, s ); |
189 | p->setFont( font() ); | 197 | p->setFont( font() ); |
190 | } | 198 | } |
191 | for ( int i = 0; i < nw; i++ ) { | 199 | for ( int i = 0; i < nw; i++ ) { |
192 | p->drawLine( xoff+i*cellsize, y, xoff+i*cellsize, y+cellsize ); | 200 | p->drawLine( xoff+i*cellsize, y, xoff+i*cellsize, y+cellsize ); |
193 | QChar u = row*nw + i; | 201 | QChar u = row*nw + i; |
194 | if ( fm.inFont( u ) ) | 202 | if ( fm.inFont( u ) ) |
195 | p->drawText( xoff+i*cellsize, y, cellsize, cellsize, AlignCenter, | 203 | p->drawText( xoff+i*cellsize, y, cellsize, cellsize, AlignCenter, |
196 | u ); | 204 | u ); |
197 | } | 205 | } |
198 | p->drawLine( xoff+nw*cellsize, y, xoff+nw*cellsize, y+cellsize ); | 206 | p->drawLine( xoff+nw*cellsize, y, xoff+nw*cellsize, y+cellsize ); |
199 | row++; | 207 | row++; |
200 | y += cellsize; | 208 | y += cellsize; |
201 | } | 209 | } |
202 | } | 210 | } |
203 | 211 | ||
204 | 212 | ||
205 | 213 | ||
206 | 214 | ||
207 | UniKeyboard::UniKeyboard(QWidget* parent, const char* name, int f ) | 215 | UniKeyboard::UniKeyboard(QWidget* parent, const char* name, int f ) |
208 | : QFrame( parent, name, f ) | 216 | : QFrame( parent, name, f ) |
209 | { | 217 | { |
210 | setFrameStyle( NoFrame ); | 218 | setFrameStyle( NoFrame ); |
211 | sv = new UniScrollview( this ); | 219 | sv = new UniScrollview( this ); |
212 | cb = new QComboBox( FALSE, this ); | 220 | cb = new QComboBox( FALSE, this ); |
213 | currentBlock = 0; | 221 | currentBlock = 0; |
214 | QFontMetrics fm = sv->fontMetrics(); | 222 | QFontMetrics fm = sv->fontMetrics(); |
215 | cbmap = new int[sizeof(blockMap)/sizeof(blockMap[0])]; | 223 | cbmap = new int[sizeof(blockMap)/sizeof(blockMap[0])]; |
216 | for ( int i = 0; blockMap[i].name; i++ ) { | 224 | for ( int i = 0; blockMap[i].name; i++ ) { |
217 | bool any=FALSE; | 225 | bool any=FALSE; |
218 | for ( int c=blockMap[i].start; !any && c<=blockMap[i].stop; c++ ) | 226 | for ( int c=blockMap[i].start; !any && c<=blockMap[i].stop; c++ ) |
219 | any = fm.inFont(QChar(c)); | 227 | any = fm.inFont(QChar(c)); |
220 | if ( any ) { | 228 | if ( any ) { |
221 | cbmap[cb->count()]=i; | 229 | cbmap[cb->count()]=i; |
222 | cb->insertItem( blockMap[i].name ); | 230 | cb->insertItem( blockMap[i].name ); |
223 | } | 231 | } |
224 | } | 232 | } |
225 | connect( cb, SIGNAL( activated(int)), this, SLOT( handleCombo(int)) ); | 233 | connect( cb, SIGNAL( activated(int)), this, SLOT( handleCombo(int)) ); |
226 | connect( sv, SIGNAL( contentsMoving(int,int)), this, SLOT( svMove(int,int)) ); | 234 | connect( sv, SIGNAL( contentsMoving(int,int)), this, SLOT( svMove(int,int)) ); |
227 | connect( sv, SIGNAL( key(ushort,ushort,ushort,bool,bool)), | 235 | connect( sv, SIGNAL( key(ushort,ushort,ushort,bool,bool)), |
228 | this, SIGNAL( key(ushort,ushort,ushort,bool,bool)) ); | 236 | this, SIGNAL( key(ushort,ushort,ushort,bool,bool)) ); |
229 | } | 237 | } |
230 | 238 | ||
231 | UniKeyboard::~UniKeyboard() | 239 | UniKeyboard::~UniKeyboard() |
232 | { | 240 | { |
233 | delete [] cbmap; | 241 | delete [] cbmap; |
234 | } | 242 | } |
235 | 243 | ||
236 | void UniKeyboard::resizeEvent(QResizeEvent *) | 244 | void UniKeyboard::resizeEvent(QResizeEvent *) |
237 | { | 245 | { |
238 | int d = frameWidth(); | 246 | int d = frameWidth(); |
239 | cb->setGeometry( d, d, width()-2*d, cb->sizeHint().height() ); | 247 | cb->setGeometry( d, d, width()-2*d, cb->sizeHint().height() ); |
240 | sv->setGeometry( d, cb->height()+d, width()-2*d, height()-cb->height()-2*d ); | 248 | sv->setGeometry( d, cb->height()+d, width()-2*d, height()-cb->height()-2*d ); |
241 | } | 249 | } |
242 | 250 | ||
243 | void UniKeyboard::svMove( int /*x*/, int y ) | 251 | void UniKeyboard::svMove( int /*x*/, int y ) |
244 | { | 252 | { |
245 | int cs = sv->cellSize(); | 253 | int cs = sv->cellSize(); |
246 | int u = ((y+cs-1)/cs) * nw; | 254 | int u = ((y+cs-1)/cs) * nw; |
247 | int i = currentBlock; | 255 | int i = currentBlock; |
248 | while ( i > 0 && blockMap[i].start > u ) { | 256 | while ( i > 0 && blockMap[i].start > u ) { |
249 | i--; | 257 | i--; |
250 | } | 258 | } |
251 | while ( blockMap[i+1].name && blockMap[i+1].start < u ) { | 259 | while ( blockMap[i+1].name && blockMap[i+1].start < u ) { |
252 | i++; | 260 | i++; |
253 | } | 261 | } |
254 | if ( i != currentBlock ) { | 262 | if ( i != currentBlock ) { |
255 | currentBlock = i; | 263 | currentBlock = i; |
256 | for (int ind=0; ind<cb->count(); ind++) { | 264 | for (int ind=0; ind<cb->count(); ind++) { |
257 | if ( cbmap[ind] == i ) { | 265 | if ( cbmap[ind] == i ) { |
258 | cb->setCurrentItem( ind ); | 266 | cb->setCurrentItem( ind ); |
259 | break; | 267 | break; |
260 | } | 268 | } |
261 | } | 269 | } |
262 | } | 270 | } |
263 | } | 271 | } |
264 | 272 | ||
265 | void UniKeyboard::handleCombo( int i ) | 273 | void UniKeyboard::handleCombo( int i ) |
266 | { | 274 | { |
267 | currentBlock = cbmap[i]; | 275 | currentBlock = cbmap[i]; |
268 | sv->scrollTo( blockMap[currentBlock].start ); | 276 | sv->scrollTo( blockMap[currentBlock].start ); |
269 | } | 277 | } |
270 | 278 | ||
271 | void UniKeyboard::resetState() | 279 | void UniKeyboard::resetState() |
272 | { | 280 | { |
273 | } | 281 | } |
274 | 282 | ||
275 | QSize UniKeyboard::sizeHint() const | 283 | QSize UniKeyboard::sizeHint() const |
276 | { | 284 | { |
277 | return QSize( 240, 2+sv->cellSize()*4+cb->sizeHint().height() ); | 285 | return QSize( 240, 2+sv->cellSize()*4+cb->sizeHint().height() ); |
278 | } | 286 | } |