Compare commits

..

112 Commits

Author SHA1 Message Date
Simon Rozman
78ccf1b2cf Version set to 2.0-beta 2016-05-13 18:54:11 +02:00
Simon Rozman
c921d533a9 Issue with non included term trailing in sub-word index fixed 2016-05-13 18:47:12 +02:00
Simon Rozman
e4fb91e305 Settings moved from menu(s) to configuration dialog
(closes #21)
2016-05-13 16:22:51 +02:00
Simon Rozman
a81dd7e250 Character request feature added
(closes #13)
2016-05-13 13:36:25 +02:00
Simon Rozman
a4fe4b6a26 Current character category display added to character selector 2016-05-13 13:24:18 +02:00
Simon Rozman
1198579963 Character category index fixed 2016-05-13 13:22:17 +02:00
Simon Rozman
5d732522fe wxZRColaCharGrid memory leak fixed
(fixes #23)
2016-05-13 13:21:39 +02:00
Simon Rozman
155fb03c5a Character search moved to separate thread for smoother experience 2016-05-13 12:11:38 +02:00
Simon Rozman
710937f8df Language ID type redeclaration for easier and safer work 2016-05-13 10:16:29 +02:00
Simon Rozman
4e435b044c Additional operators 2016-05-13 10:16:23 +02:00
Simon Rozman
4ec7dc3ca5 Search optimizations 2016-05-13 09:32:36 +02:00
Simon Rozman
9c3c1585d5 Character Select finished
(closes #11)
2016-05-13 03:44:28 +02:00
Simon Rozman
53ce3a2411 COMDAT Folding disabled for debug builds 2016-05-12 17:15:04 +02:00
Simon Rozman
643a8dcb82 Sub-module update 2016-05-12 14:12:09 +02:00
Simon Rozman
9337b660d2 Database update 2016-05-12 10:56:07 +02:00
Simon Rozman
44f2ef1ae1 Work on character selector continues 2016-05-11 14:39:57 +02:00
Simon Rozman
4aa0d9183e Support for Unicode character database added 2016-05-11 14:39:20 +02:00
Simon Rozman
e3c6a01722 ZRCola::index::compare_sort() reverts to compare() by default now 2016-05-11 12:40:14 +02:00
Simon Rozman
0d30a89d22 Character selector merged back to continue work
# Conflicts:
#	ZRCola/ZRCola.fbp
#	ZRCola/ZRCola.vcxproj
#	ZRCola/ZRCola.vcxproj.filters
#	ZRCola/locale/sl_SI.po
#	ZRCola/zrcolafrm.cpp
#	ZRCola/zrcolafrm.h
#	ZRCola/zrcolagui.cpp
#	ZRCola/zrcolagui.h
2016-05-11 09:00:59 +02:00
Simon Rozman
23ba447283 ZRCola now minimizes to system tray.
(closes #20)
2016-05-10 13:10:37 +02:00
Simon Rozman
a27f7f470d (De)Composition moved to idle processing & other optimizations
(fixes #19)
2016-05-10 09:41:35 +02:00
Simon Rozman
50790ad01d ZRCola no longer responds to Ctrl+Alt shortcuts when invoked with AltGr 2016-05-09 16:48:54 +02:00
Simon Rozman
ae3344d5eb Aesthetic modifications 2016-05-09 11:57:19 +02:00
Simon Rozman
79ae4855e3 Additional "text updated" event generation added to fix premature event receiving on EM_REPLACESEL
(fixes #19)
2016-05-09 11:57:02 +02:00
Simon Rozman
349bc34fa8 libZRColaUI extended to use wxWidgets and ZRColaApp::GetKeySequenceAsText() moved back to ZRCola::keyseq_db::GetSequenceAsText() for general accessibility 2016-05-09 11:05:21 +02:00
Simon Rozman
92bbc9a8bf Version set to 2.0-alpha7. 2016-05-06 15:05:43 +02:00
Simon Rozman
b88cafcdfd Missing dependency added 2016-05-06 15:05:26 +02:00
Simon Rozman
994ec6461e Non-working locale-specific key sequences issue fixed 2016-05-06 14:27:12 +02:00
Simon Rozman
1867235007 Key sequences (shortcuts) added to Character Catalog tooltips 2016-05-06 13:42:14 +02:00
Simon Rozman
7545e9dadf Key sequence naming moved to ZRCola to allow localization 2016-05-06 13:40:55 +02:00
Simon Rozman
eb67174bed - Key sequences moved to wxZRCola app for global availability
- Top window retrieval mechanism in wxZRColaKeyHandler more robust now
2016-05-06 12:24:21 +02:00
Simon Rozman
8f33c72ad7 Inline function optimization more aggressive now 2016-05-06 12:11:41 +02:00
Simon Rozman
dbdfa139c4 Sub-module update 2016-05-06 12:11:10 +02:00
Simon Rozman
dd87605ac2 Character grid updated to show wxAui style tool tips 2016-05-06 11:56:41 +02:00
Simon Rozman
5c9a9cab03 INS+Unicode status bar message more descriptive now 2016-05-06 11:32:30 +02:00
Simon Rozman
d86c1d004d Tooltips added to character grid 2016-05-06 11:25:41 +02:00
Simon Rozman
7bd217ec47 Aesthetic modifications 2016-05-06 11:25:12 +02:00
Simon Rozman
01c50ba9e1 wxZRColaCharGrid now forwards Tab key to allow classic dialog control navigation 2016-05-06 08:40:03 +02:00
Simon Rozman
f9ef646f22 On-screen character catalog added 2016-05-05 15:37:44 +02:00
Simon Rozman
2a6212d19d Character group data cleanup 2016-05-05 15:21:25 +02:00
Simon Rozman
1a6dc8b723 AUI initial organization fixed 2016-05-05 08:15:54 +02:00
Simon Rozman
3b6eff0b44 Changed Cut/Copy/Paste event forwarding logic to avoid deadlocks in future 2016-05-04 15:54:07 +02:00
Simon Rozman
9a2bc6b743 Language localization optimization 2016-05-04 15:52:47 +02:00
Simon Rozman
6e4cd60152 Character group database support added 2016-05-04 15:49:51 +02:00
Simon Rozman
f2f0b007c4 wxAui becoming main UI 2016-05-03 13:33:43 +02:00
Simon Rozman
306be13fca GUI switched to wxAui 2016-05-03 13:29:24 +02:00
Simon Rozman
eb75e020e9 Folder icon added 2016-05-03 12:44:58 +02:00
Simon Rozman
bbb09f3779 8.3 file names now unique across module variations 2016-05-03 12:43:10 +02:00
Simon Rozman
99a4b2e6c8 Insert+Unicode keyboard feature added 2016-04-30 15:37:06 +02:00
Simon Rozman
3ff9459198 Slovenian translation update 2016-04-30 15:36:03 +02:00
Simon Rozman
8bdef858a0 Composition recognition improvements 2016-04-30 14:55:52 +02:00
Simon Rozman
4ef335b6aa Version set to 2.0-alpha6 2016-04-29 13:09:19 +02:00
Simon Rozman
15365aff46 Input language detection added
(closes #2)
2016-04-29 12:54:39 +02:00
Simon Rozman
4a27d62b4e ZRCola::LangConvert() function added 2016-04-29 12:35:59 +02:00
Simon Rozman
38bf070a4a Auto-start on logon feature added
(closes #8)
2016-04-29 09:51:40 +02:00
Simon Rozman
b7533d4b27 Character selector feature skeleton added 2016-04-26 16:05:42 +02:00
Simon Rozman
c7df06ba1e Fixed order in SQL queries for consistent ZRCola.zrcdb generation 2016-04-26 15:43:33 +02:00
Simon Rozman
b9d636fb30 CharDescGenerate job added to generate character descriptions 2016-04-26 15:26:11 +02:00
Simon Rozman
ac005c0b77 Merge branch 'master' of https://github.com/Amebis/ZRCola 2016-04-23 22:23:00 +02:00
Simon Rozman
58f354f028 GUI edit boxes labeled now 2016-04-23 22:22:46 +02:00
Simon Rozman
a1a1852552 GUI edit boxes labeled now 2016-04-23 22:16:03 +02:00
Simon Rozman
7807e8a918 ZRCola.fbp added to project 2016-04-23 22:14:49 +02:00
Simon Rozman
3daaff4260 Script to import UnicodeData.txt to ZRCola.mdb added 2016-04-23 14:02:50 +02:00
Simon Rozman
840c8240b7 Composer panel settings moved for simpler configuration organization 2016-04-23 06:38:48 +02:00
Simon Rozman
21114d818c On-screen Unicode dump added
(closes #14)
2016-04-22 16:12:59 +02:00
Simon Rozman
7a424da3fc Code to Save & Restore text moved to wxZRColaComposerPanel to avoid confusion with GUI persistence 2016-04-22 14:24:17 +02:00
Simon Rozman
82d2fc42bd Minor updates of auto-saving feature 2016-04-22 13:39:34 +02:00
Simon Rozman
5f755aa3d9 Auto-Save & Restore of text added
(closes #16)
2016-04-22 13:29:30 +02:00
Simon Rozman
8c51f9c2a6 Ambiguous decomposition sequences now decompose to first ranked decomposition
(resolves #18)
2016-04-22 11:30:42 +02:00
Simon Rozman
5df7ca886b Decomposition before composition added
(resolves #17)
2016-04-22 11:00:11 +02:00
Simon Rozman
2e89edb62c Source and destination index mapping on the left side of the first transformation issue fixed 2016-04-22 10:59:29 +02:00
Simon Rozman
a021dd31f7 ZRCola::mapping is generic now 2016-04-20 12:24:23 +02:00
Simon Rozman
5e4331903b Language names are displayed with the localized full name now
(closes #15)
2016-04-13 20:39:14 +02:00
Simon Rozman
55c76265df Redundant check removed 2016-04-13 12:41:41 +02:00
Simon Rozman
5a2fcf7cb2 Version set to 2.0-alpha5. 2016-04-13 11:05:09 +02:00
Simon Rozman
4fba54bdb2 Text language for decomposition GUI support added
(closes #1)
2016-04-13 11:03:38 +02:00
Simon Rozman
ab3ef08a5f Translation database moved to ZRColaApp 2016-04-12 14:47:14 +02:00
Simon Rozman
c21e1b8198 Sub-module update 2016-04-11 13:53:08 +02:00
Simon Rozman
7e6eaefd42 Doxygen annotation update 2016-04-11 13:52:57 +02:00
Simon Rozman
f735bd5bee Decomposition can omit language specific characters now 2016-04-11 13:28:19 +02:00
Simon Rozman
b7f3305019 ZRCola::langid_t moved to common.h 2016-04-11 12:51:49 +02:00
Simon Rozman
b194662c03 Typo in documentation fixed 2016-04-11 12:41:40 +02:00
Simon Rozman
177edd19e8 Languages and language-specific characters added to the database 2016-04-11 12:41:22 +02:00
Simon Rozman
fc93474b9a Characters with decompositions starting with # do not decompose any more. 2016-04-11 10:21:11 +02:00
Simon Rozman
02f164cee6 Version set to 2.0-alpha4 2016-04-08 14:54:18 +02:00
Simon Rozman
a35c0d83ca Merge branch 'master' of https://github.com/Amebis/ZRCola 2016-04-08 14:49:47 +02:00
Simon Rozman
6b4ed23801 ZRCola database updated
(resolves #7)
2016-04-08 14:49:27 +02:00
Simon Rozman
2c602ad659 ZRCola database updated 2016-04-08 14:48:23 +02:00
Simon Rozman
279537b1f3 Combinations with partial longer match not composed issue resolved
(resolves #6)
2016-04-08 14:45:28 +02:00
Simon Rozman
f918c49bfd Accessing an element of table before determining size issue resolved 2016-04-08 13:48:33 +02:00
Simon Rozman
72c29a692e GUI aligned with stock text 2016-04-08 13:22:23 +02:00
Simon Rozman
fc78a650a2 Select All (text) feature added 2016-04-08 13:01:09 +02:00
Simon Rozman
acec7098e5 Minor GUI improvements 2016-04-08 12:44:35 +02:00
Simon Rozman
98eff47054 Clipboard events are forwarded to focused control now
(resolves #12)
2016-04-08 12:35:38 +02:00
Simon Rozman
cd2c20fc06 Version set to 2.0-alpha3. 2016-04-08 09:22:10 +02:00
Simon Rozman
ac772671cc Publish target split into PublishPre and Publish 2016-04-08 09:21:53 +02:00
Simon Rozman
acfe980705 Non-working OEM key sequences issue fixed
resolves #5
2016-04-07 14:52:45 +02:00
Simon Rozman
426b7a6227 Keyboard sequence monitoring upgraded not to react on modifier keys, canceling multi-key sequences when non-first key modifier pressed 2016-04-07 14:49:28 +02:00
Simon Rozman
834743c7dd Cleanup 2016-04-07 13:10:54 +02:00
Simon Rozman
c8628ef4eb Key sequence import fixed (resolves #7) 2016-04-07 12:53:19 +02:00
Simon Rozman
4f52304fe9 Advertised shortcuts disabled (closes #4) 2016-04-07 10:50:31 +02:00
Simon Rozman
eef80067bb Language setting moved from HKCU (per-user) to HKLM (global) 2016-04-07 09:41:29 +02:00
Simon Rozman
9240288245 Generic module names replaced 2016-04-06 14:14:35 +02:00
Simon Rozman
1b41ff7aab Version set to 2.0-alpha2 2016-04-06 13:21:24 +02:00
Simon Rozman
61af77e7b6 Main window size and position is remembered now 2016-04-06 13:15:03 +02:00
Simon Rozman
ee7f94d776 Old configuration delete added 2016-04-06 13:12:44 +02:00
Simon Rozman
1cb4f470c6 Application's config is global now 2016-04-06 13:09:33 +02:00
Simon Rozman
8fd0437502 GUI upgrade: Edit menu added, tool bar added, status bar added 2016-04-06 12:33:38 +02:00
Simon Rozman
93361f0edb Partial key sequence match no longer propagates the event 2016-04-06 12:29:07 +02:00
Simon Rozman
2007d04812 Non-Slovenian setup no longer include Slovenian localization 2016-04-05 14:54:54 +02:00
Simon Rozman
a4aff5151e Merged consecutive characters issue fixed 2016-04-05 14:38:59 +02:00
Simon Rozman
ce43a99b30 Sub-module update 2016-04-04 15:36:28 +02:00
124 changed files with 25421 additions and 789 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1 @@
System Folder\wxmsw30u_adv_vc100.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System (64-bit) Folder\wxmsw30u_adv_vc100_x64.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System Folder\wxmsw30u_aui_vc100.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System (64-bit) Folder\wxmsw30u_aui_vc100_x64.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System Folder\wxmsw30ud_adv_vc100.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System (64-bit) Folder\wxmsw30ud_adv_vc100_x64.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System Folder\wxmsw30ud_aui_vc100.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -0,0 +1 @@
System (64-bit) Folder\wxmsw30ud_aui_vc100_x64.dll

Binary file not shown.

View File

@@ -0,0 +1,24 @@
#
# Copyright 1991-2016 Amebis
#
# This file is part of ZRCola.
#
# ZRCola is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# ZRCola is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
#
[splosno]
jezik=0
deli=featZRCola
[parametri]

View File

@@ -53,7 +53,9 @@ All :: "$(LANG).$(PLAT).$(CFG).Component-1.idt"
Component ComponentId Directory_ Attributes Condition KeyPath
s$(MSIBUILD_LENGTH_ID) S38 s$(MSIBUILD_LENGTH_ID) i2 S255 S$(MSIBUILD_LENGTH_ID)
Component Component
!IF "$(LANG)" == "Sl"
compwxstd.mo.sl_SI {A5FEEA94-08CA-4E12-993F-A115601EF258} ZRCOLALOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) filewxstd.mo.sl_SI
!ENDIF
compLocalizationRepositoryPath {0E96110A-C38D-4600-9AE2-B8B59AF53A00} ZRCOLALOCDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regLocalizationRepositoryPath
compLanguage {B78359AC-9484-402C-8384-3A4595B39389} ZRCOLALOCDIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regLanguage
compDatabasePath {DF3C720D-50BB-4377-9EE0-9AC21C02B9DD} ZRCOLADATADIR $(MSIBUILD_COMPONENT_ATTRIB_REGISTRY) regDatabasePath
@@ -62,6 +64,9 @@ comp00_ZRCola_Re.ttf {B6CE8B39-11DC-4B59-B10C-3F0FFE8F81AF} FontsFolder 0 file0
comp00_ZRCola_It.ttf {10613965-2874-470D-9D5A-B7D535AA3317} FontsFolder 0 file00_ZRCola_It.ttf
comp00_ZRCola_Bd.ttf {C036BE8D-6D2F-4DBF-99D6-F53702EAEBB6} FontsFolder 0 file00_ZRCola_Bd.ttf
comp00_ZRCola_BI.ttf {883DDA9A-DA85-4FC4-95B7-EF0E08766DEF} FontsFolder 0 file00_ZRCola_BI.ttf
!IF "$(LANG)" == "Sl"
compZRCola.zrcdb.mo.sl_SI {6572EAD1-EE48-46A1-A28E-77985B667F67} ZRCOLALOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) fileZRCola.zrcdb.mo.sl_SI
!ENDIF
<<NOKEEP
@@ -226,12 +231,17 @@ All :: "$(LANG).$(PLAT).$(CFG).File-1.idt"
File Component_ FileName FileSize Version Language Attributes Sequence
s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID) l255 i4 S$(MSIBUILD_LENGTH_ID) S20 I2 i2
File File
!IF "$(LANG)" == "Sl"
filewxstd.mo.sl_SI compwxstd.mo.sl_SI wxstd.mo 0 1060 0 1
!ENDIF
fileZRCola.zrcdb compZRCola.zrcdb ZRCOLA~1.ZRC|ZRCola.zrcdb 0 0 1
file00_ZRCola_Re.ttf comp00_ZRCola_Re.ttf 00_ZRC~1.TTF|00_ZRCola_Re.ttf 0 0 1
file00_ZRCola_It.ttf comp00_ZRCola_It.ttf 00_ZRC~2.TTF|00_ZRCola_It.ttf 0 0 1
file00_ZRCola_Bd.ttf comp00_ZRCola_Bd.ttf 00_ZRC~3.TTF|00_ZRCola_Bd.ttf 0 0 1
file00_ZRCola_BI.ttf comp00_ZRCola_BI.ttf 00_ZRC~4.TTF|00_ZRCola_BI.ttf 0 0 1
!IF "$(LANG)" == "Sl"
fileZRCola.zrcdb.mo.sl_SI compZRCola.zrcdb.mo.sl_SI ZRCOLA~1.MO|ZRCola-zrcdb.mo 0 1060 0 1
!ENDIF
<<NOKEEP
@@ -313,6 +323,7 @@ s$(MSIBUILD_LENGTH_ID) l0
Property Property
ARPPRODUCTICON iconZRCola.ico
ALLUSERS 1
DISABLEADVTSHORTCUTS 1
INSTALLLEVEL 3
InstallMode Typical
SecureCustomProperties OLDPRODUCTFOUND;NEWPRODUCTFOUND
@@ -342,7 +353,7 @@ regDatabasePath 2 SOFTWARE\Amebis\ZRCola DatabasePath [ZRCOLADATADIR] compDataba
Registry Root Key Name Value Component_
s$(MSIBUILD_LENGTH_ID) i2 l255 L255 L0 s$(MSIBUILD_LENGTH_ID)
1252 Registry Registry
regLanguage 1 SOFTWARE\Amebis\ZRCola Language #60 compLanguage
regLanguage 2 SOFTWARE\Amebis\ZRCola Language #60 compLanguage
<<NOKEEP
"De.$(PLAT).$(CFG).Registry-2.idt" : "En.$(PLAT).$(CFG).Registry-2.idtx" "..\locale\de_DE.po"

View File

@@ -82,6 +82,7 @@ Setup \
SetupDebug \
Register \
Unregister \
PublishPre \
Publish :: "MSI\MSIBuild\Version\Version.mak"
$(MAKE) /f "Makefile" /$(MAKEFLAGS) HAS_VERSION=1 $@
@@ -183,12 +184,15 @@ RegisterShortcuts :: \
UnregisterShortcuts ::
-if exist "$(PROGRAMDATA)\Microsoft\Windows\Start Menu\Programs\ZRCola" rd /s /q "$(PROGRAMDATA)\Microsoft\Windows\Start Menu\Programs\ZRCola"
Publish :: \
PublishPre :: \
"$(PUBLISH_PACKAGE_DIR)" \
$(REDIST_EN_WIN32) \
$(REDIST_EN_X64) \
$(REDIST_SL_WIN32) \
$(REDIST_SL_X64) \
$(REDIST_SL_X64)
Publish :: \
PublishPre \
"$(PUBLISH_DIR)\catalog-0000.xml"

Submodule Updater updated: e88f1b429f...f1a3ae730a

View File

@@ -74,7 +74,9 @@ compZRCola.exe.Win32 {F30B6545-6203-4B7D-8575-85245A0F90E5} ZRCOLABINDIR 0 file
!IF "$(PLAT)" == "x64"
compZRCola.exe.x64 {D45B105D-2303-459A-AF4B-52AC3AAD5510} ZRCOLABINDIR 256 fileZRCola.exe.x64
!ENDIF
!IF "$(LANG)" == "Sl"
compZRCola.mo.sl_SI {7FF95C71-D8DE-4D2B-A26D-FEB5A1F54D63} ZRCOLALOCSLSIDIR $(MSIBUILD_COMPONENT_ATTRIB_FILE) fileZRCola.mo.sl_SI
!ENDIF
<<NOKEEP
@@ -117,17 +119,21 @@ Feature_ Component_
s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID)
FeatureComponents Feature_ Component_
featZRCola compZRCola.exe.$(PLAT)
featZRCola compZRCola.mo.sl_SI
featZRCola complibZRCola.dll.$(PLAT)
featZRCola complibZRColaUI.dll.$(PLAT)
featZRCola compwxExtend.dll.$(PLAT)
featZRCola compwxExtend.mo.sl_SI
featZRCola compwxstd.mo.sl_SI
featZRCola compLocalizationRepositoryPath
featZRCola compLanguage
featZRCola compDatabasePath
featZRCola compZRCola.zrcdb
featZRCola comp00_ZRCola_Re.ttf
!IF "$(LANG)" == "Sl"
featZRCola compZRCola.mo.sl_SI
featZRCola compZRCola.zrcdb.mo.sl_SI
featZRCola complibZRColaUI.mo.sl_SI
featZRCola compwxExtend.mo.sl_SI
featZRCola compwxstd.mo.sl_SI
!ENDIF
<<NOKEEP
@@ -143,7 +149,9 @@ File Component_ FileName FileSize Version Language Attributes Sequence
s$(MSIBUILD_LENGTH_ID) s$(MSIBUILD_LENGTH_ID) l255 i4 S$(MSIBUILD_LENGTH_ID) S20 I2 i2
File File
fileZRCola.exe.$(PLAT) compZRCola.exe.$(PLAT) ZRCola.exe 0 0 1536 1
!IF "$(LANG)" == "Sl"
fileZRCola.mo.sl_SI compZRCola.mo.sl_SI ZRCola.mo 0 1060 0 1
!ENDIF
<<NOKEEP

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@@ -81,18 +81,26 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="zrcolaapp.cpp" />
<ClCompile Include="zrcolachrcatpnl.cpp" />
<ClCompile Include="zrcolachrgrid.cpp" />
<ClCompile Include="zrcolachrslct.cpp" />
<ClCompile Include="zrcolacomppnl.cpp" />
<ClCompile Include="zrcolafrm.cpp" />
<ClCompile Include="zrcolagui.cpp" />
<ClCompile Include="zrcolakeyhndlr.cpp" />
<ClCompile Include="zrcolasettings.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="zrcolaapp.h" />
<ClInclude Include="zrcolachrcatpnl.h" />
<ClInclude Include="zrcolachrgrid.h" />
<ClInclude Include="zrcolachrslct.h" />
<ClInclude Include="zrcolacomppnl.h" />
<ClInclude Include="zrcolafrm.h" />
<ClInclude Include="zrcolagui.h" />
<ClInclude Include="zrcolakeyhndlr.h" />
<ClInclude Include="zrcolasettings.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\libZRColaUI\build\libZRColaUI.vcxproj">
@@ -106,7 +114,15 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="res\char_select.ico" />
<None Include="res\edit_copy.ico" />
<None Include="res\edit_cut.ico" />
<None Include="res\edit_paste.ico" />
<None Include="res\send_abort.ico" />
<None Include="res\send_composed.ico" />
<None Include="res\send_decomposed.ico" />
<None Include="res\zrcola.ico" />
<None Include="ZRCola.fbp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ZRCola.rc" />

View File

@@ -37,6 +37,18 @@
<ClCompile Include="zrcolakeyhndlr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcolachrgrid.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcolachrcatpnl.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcolachrslct.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="zrcolasettings.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
@@ -57,11 +69,47 @@
<ClInclude Include="zrcolakeyhndlr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcolachrgrid.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcolachrcatpnl.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcolachrslct.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="zrcolasettings.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="res\zrcola.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\send_abort.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\send_composed.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\send_decomposed.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\edit_copy.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\edit_cut.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="res\edit_paste.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="ZRCola.fbp">
<Filter>Resource Files</Filter>
</None>
<None Include="res\char_select.ico">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ZRCola.rc">

View File

@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: ZRCola\n"
"POT-Creation-Date: 2016-03-14 17:18+0100\n"
"PO-Revision-Date: 2016-03-14 17:18+0100\n"
"POT-Creation-Date: 2016-05-13 15:52+0200\n"
"PO-Revision-Date: 2016-05-13 15:52+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n"
@@ -17,27 +17,38 @@ msgstr ""
"X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n"
#: zrcolafrm.cpp:58
#: zrcolafrm.cpp:90 zrcolagui.h:98 MSIBuild/En.Win32.Release.Feature-2.idtx:4
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Release.Feature-2.idtx:4
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:4
msgid "ZRCola"
msgstr "ZRCola"
#: zrcolafrm.cpp:108
msgid ""
"ZRCola keyboard shortcut Win+Z could not be registered. Some functionality "
"ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality "
"will not be available."
msgstr ""
"ZRColine bližnjice na tipkovnici Win+Z ni mogoče registrirati. Nekaj "
"ZRColine bližnjice na tipkovnici Win+F5 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo."
#: zrcolafrm.cpp:58 zrcolafrm.cpp:60
#: zrcolafrm.cpp:108 zrcolafrm.cpp:110
msgid "Warning"
msgstr "Opozorilo"
#: zrcolafrm.cpp:60
#: zrcolafrm.cpp:110
msgid ""
"ZRCola keyboard shortcut Win+Shift+Z could not be registered. Some "
"functionality will not be available."
"ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality "
"will not be available."
msgstr ""
"ZRColine bližnjice na tipkovnici Win+Shift+Z ni mogoče registrirati. Nekaj "
"ZRColine bližnjice na tipkovnici Win+F6 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo."
#: zrcolafrm.cpp:140
#: zrcolafrm.cpp:336
msgid "http://zrcola-2.amebis.si/en/contact/"
msgstr "http://zrcola-2.amebis.si/contact/"
#: zrcolafrm.cpp:342
#, c-format
msgid ""
"ZRCola v%s\n"
@@ -46,60 +57,472 @@ msgstr ""
"ZRCola v%s\n"
"Vse pravice pridržane 2015-%s Amebis"
#: zrcolafrm.cpp:140
#: zrcolafrm.cpp:342
msgid "About ZRCola"
msgstr "O ZRColi"
#: zrcolagui.cpp:32
#: zrcolagui.cpp:36
msgid "E&xit"
msgstr "I&zhod"
#: zrcolagui.cpp:35
msgid "&File"
msgstr "&Datoteka"
#: zrcolagui.cpp:36
msgid "Quit this program"
msgstr "Zapri ta program"
#: zrcolagui.cpp:39
msgid "&About"
msgstr "O progr&amu"
msgid "&Program"
msgstr "&Program"
#: zrcolagui.cpp:42
#: zrcolagui.cpp:72
msgid "Select &All"
msgstr "Izberi &vse"
#: zrcolagui.cpp:72
msgid "Select all text"
msgstr "Izberi celotno besedilo"
#: zrcolagui.cpp:78
msgid "C&haracter Selector..."
msgstr "Izbirnik &znaka ..."
#: zrcolagui.cpp:78 zrcolagui.cpp:166
msgid "Display character selector to select character to insert into text"
msgstr "Prikaži izbirnik znaka za izbor znaka za vstavljanje v besedilo"
#: zrcolagui.cpp:89
msgid "&Send Composed"
msgstr "Pošlji &sestavljeno"
#: zrcolagui.cpp:89 zrcolagui.cpp:168
msgid "Send composed text to source window"
msgstr "Pošlji sestavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:98
msgid "Send &Decomposed"
msgstr "Pošlji &razstavljeno"
#: zrcolagui.cpp:98 zrcolagui.cpp:170
msgid "Send decomposed text to source window"
msgstr "Pošlji razstavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:107
msgid "Abort (De)composition"
msgstr "Prekini raz/sestavljanje"
#: zrcolagui.cpp:107
msgid "Abort composition and return focus to source window"
msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu"
#: zrcolagui.cpp:118
msgid "&Settings..."
msgstr "Na&stavitve ..."
#: zrcolagui.cpp:118
msgid "Open program configuration dialog"
msgstr "Odpri nastavitveni dialog programa"
#: zrcolagui.cpp:121
msgid "&Edit"
msgstr "Ur&edi"
#: zrcolagui.cpp:125
msgid "&Edit Toolbar"
msgstr "Orodna vrstica za ur&ejanje"
#: zrcolagui.cpp:125
msgid "Toggle edit toolbar"
msgstr "Prikaži/skrij orodno vrstico za urejanje"
#: zrcolagui.cpp:129
msgid "&Compose Toolbar"
msgstr "Orodna vrsti&ca za sestavljanje"
#: zrcolagui.cpp:129
msgid "Toggle compose toolbar"
msgstr "Prikaži/skrij orodno vrstico za sestavljanje"
#: zrcolagui.cpp:135
msgid "Character Catalo&g"
msgstr "Katalo&g znakov"
#: zrcolagui.cpp:135
msgid "Toggle character catalog panel"
msgstr "Prikaži/skrij katalog znakov"
#: zrcolagui.cpp:138
msgid "&View"
msgstr "Po&gled"
#: zrcolagui.cpp:142
msgid "&Request a new character..."
msgstr "&Zahtevaj nov znak ..."
#: zrcolagui.cpp:142
msgid "Submit a request to ZRC to add a new character"
msgstr "Oddaj prošnjo ZRC-u za dodajanje novega znaka"
#: zrcolagui.cpp:151
msgid "&Help"
msgstr "&Pomoč"
msgstr "Po&moč"
#: zrcolagui.h:47 MSIBuild/En.Win32.Debug.Feature-2.idtx:4
#: MSIBuild/En.Win32.Debug.Shortcut-2.idtx:4
#: MSIBuild/En.Win32.Release.Feature-2.idtx:4
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Debug.Feature-2.idtx:4
#: MSIBuild/En.x64.Debug.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Release.Feature-2.idtx:4
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:4
msgid "ZRCola"
msgstr "ZRCola"
#: zrcolagui.cpp:156
msgid "Cut"
msgstr "Izreži"
#: zrcolagui.cpp:156
msgid "Cut selection"
msgstr "Izreži izbor"
#: zrcolagui.cpp:158
msgid "Copy"
msgstr "Kopiraj"
#: zrcolagui.cpp:158
msgid "Copy selection"
msgstr "Kopiraj izbor"
#: zrcolagui.cpp:160
msgid "Paste"
msgstr "Prilepi"
#: zrcolagui.cpp:160
msgid "Paste selection"
msgstr "Prilepi izbor"
#: zrcolagui.cpp:163
msgid "Edit"
msgstr "Urejanje"
#: zrcolagui.cpp:166 zrcolagui.h:222
msgid "Character Selector"
msgstr "Izbirnik znaka"
#: zrcolagui.cpp:168
msgid "Send Composed"
msgstr "Pošlji sestavljeno"
#: zrcolagui.cpp:170
msgid "Send Decomposed"
msgstr "Pošlji razstavljeno"
#: zrcolagui.cpp:173
msgid "Compose"
msgstr "Sestavljanje"
#: zrcolagui.cpp:177
msgid "Character Catalog"
msgstr "Katalog znakov"
#: zrcolagui.cpp:181
msgid "(De)Composer"
msgstr "Raz/Sestavljalnik"
#: zrcolagui.cpp:218
msgid "Decomposed Text"
msgstr "Razstavljeno besedilo"
#: zrcolagui.cpp:238
msgid "Decomposed Unicode Dump"
msgstr "Unicode razstavljenega"
#: zrcolagui.cpp:265
msgid "Composed Text"
msgstr "Sestavljeno besedilo"
#: zrcolagui.cpp:285
msgid "Composed Unicode Dump"
msgstr "Unicode sestavljenega"
#: zrcolagui.cpp:405
msgid "&Browse"
msgstr "Pre&brskaj"
#: zrcolagui.cpp:453
msgid "Re&cently Used"
msgstr "Nedavno &uporabljeni"
#: zrcolagui.cpp:494
msgid "Preview"
msgstr "Predogled"
#: zrcolagui.cpp:499
msgid "U+"
msgstr "U+"
#: zrcolagui.cpp:550
msgid "Re&lated"
msgstr "&Sorodni"
#: zrcolagui.cpp:650
msgid ""
"Some character native to specific language you are working with should not "
"decompose to primitives.\n"
"For optimal decomposition you should set the language correctly."
msgstr ""
"Nekateri znaki iz posameznih jezikov, s katerimi delate, se ne smejo "
"razstaviti v dele.\n"
"Za optimalno razstavljanje izberite pravilni jezik."
#: zrcolagui.cpp:654
msgid "Select language &automatically according to selected keyboard"
msgstr "S&amodejno izberi jezik glede na izbrano tipkovnico"
#: zrcolagui.cpp:657
msgid "&Manually select the language from the list below:"
msgstr "Ročno izberi jezik na spodnje&m spisku:"
#: zrcolagui.cpp:669
msgid "Text Language"
msgstr "Jezik besedila"
#: zrcolagui.cpp:674
msgid ""
"ZRCola can be launched every time you log in to your computer.\n"
"It will be available on the system tray and via registered shortcuts Win+F5 "
"and Win+F6."
msgstr ""
"ZRCola se lahko zažene ob vsaki prijavi v vaš računalnik.\n"
"Na voljo bo na vrstici za sistemska obvestila ter preko registriranih "
"bližnjic Win+F5 in Win+F6."
#: zrcolagui.cpp:678
msgid "Start ZRCola &automatically on logon"
msgstr "S&amodejno zaženi ZRColo ob prijavi"
#: zrcolagui.cpp:685
msgid "Startup"
msgstr "Zagon"
#: zrcolakeyhndlr.cpp:44
msgid ""
"INS key is pressed. Type the Unicode code of desired character now (up to "
"four hexadecimal digits: 0-9, A-F), then release INS."
msgstr ""
"Pritisnjena tipka INS. Zdaj vtpikajte kodo Unicode želenega znaka (do štiri "
"šestnajstiške števke: 0-9, A-F), nato izpustite INS."
#: zrcolasettings.cpp:116
msgid "Start ZRCola automatically on logon"
msgstr "Samodejno zaženi ZRColo ob prijavi"
#: zrcolagui.h:258
msgid "Settings"
msgstr "Nastavitve"
# Windows charset for this language (decimal)
#: MSIBuild/En.Win32.Debug.Feature-2.idtx:3
#: MSIBuild/En.Win32.Debug.Shortcut-2.idtx:3
#: MSIBuild/En.Win32.Release.Feature-2.idtx:3
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:3
#: MSIBuild/En.x64.Debug.Feature-2.idtx:3
#: MSIBuild/En.x64.Debug.Shortcut-2.idtx:3
#: MSIBuild/En.x64.Release.Feature-2.idtx:3
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:3
msgid "1252"
msgstr "1250"
#: MSIBuild/En.Win32.Debug.Feature-2.idtx:4
#: MSIBuild/En.Win32.Debug.Shortcut-2.idtx:4
#: MSIBuild/En.Win32.Release.Feature-2.idtx:4
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Debug.Feature-2.idtx:4
#: MSIBuild/En.x64.Debug.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Release.Feature-2.idtx:4
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:4
msgid "Input system for linguistic use"
msgstr "Vnašalni sistem za jezikoslovno rabo"
#~ msgid "Auto Start"
#~ msgstr "Samodejni zagon"
#~ msgid "Select %s language for decomposition"
#~ msgstr "Izberi jezik %s za razstavljanje"
#~ msgid "&Start on Logon"
#~ msgstr "Z&aženi ob prijavi"
#~ msgid "Start this program automatically on logon"
#~ msgstr "Samodejno zaženi ta program ob prijavi"
#~ msgid "Set language according to keyboard layout automatically"
#~ msgstr "Samodejno nastavi jezik glede na izbrano tipkovnico"
#~ msgid "&Unicode"
#~ msgstr "&Unicode"
#~ msgid "Esc"
#~ msgstr "Esc"
#~ msgid "F1"
#~ msgstr "F1"
#~ msgid "F2"
#~ msgstr "F2"
#~ msgid "F3"
#~ msgstr "F3"
#~ msgid "F4"
#~ msgstr "F4"
#~ msgid "F5"
#~ msgstr "F5"
#~ msgid "F6"
#~ msgstr "F6"
#~ msgid "F7"
#~ msgstr "F7"
#~ msgid "F8"
#~ msgstr "F8"
#~ msgid "F9"
#~ msgstr "F9"
#~ msgid "F10"
#~ msgstr "F10"
#~ msgid "F11"
#~ msgstr "F11"
#~ msgid "F12"
#~ msgstr "F12"
#~ msgid "Print Screen"
#~ msgstr "Print Screen"
#~ msgid "Scroll Lock"
#~ msgstr "Scroll Lock"
#~ msgid "Pause"
#~ msgstr "Pause"
#~ msgid "Backspace"
#~ msgstr "Backspace"
#~ msgid "Tab"
#~ msgstr "Tab"
#~ msgid "Caps Lock"
#~ msgstr "Caps Lock"
#~ msgid "Return"
#~ msgstr "Return"
#~ msgid "Space"
#~ msgstr "preslednica"
#~ msgid "Shift"
#~ msgstr "Shift"
#~ msgid "Alt"
#~ msgstr "Alt"
#~ msgid "Ctrl"
#~ msgstr "Ctrl"
#~ msgid "Menu"
#~ msgstr "Menu"
#~ msgid "Insert"
#~ msgstr "Insert"
#~ msgid "Delete"
#~ msgstr "Delete"
#~ msgid "Page Up"
#~ msgstr "Page Up"
#~ msgid "Page Down"
#~ msgstr "Page Down"
#~ msgid "Home"
#~ msgstr "Home"
#~ msgid "End"
#~ msgstr "End"
#~ msgid "Left"
#~ msgstr "Left"
#~ msgid "Up"
#~ msgstr "Up"
#~ msgid "Right"
#~ msgstr "Right"
#~ msgid "Down"
#~ msgstr "Down"
#~ msgid "Num Lock"
#~ msgstr "Num Lock"
#~ msgid "`"
#~ msgstr "`"
#~ msgid "-"
#~ msgstr "-"
#~ msgid "["
#~ msgstr "["
#~ msgid "]"
#~ msgstr "]"
#~ msgid ":"
#~ msgstr ":"
#~ msgid "'"
#~ msgstr "'"
#~ msgid "\\"
#~ msgstr "\\"
#~ msgid ","
#~ msgstr ","
#~ msgid "."
#~ msgstr "."
#~ msgid "/"
#~ msgstr "/"
#~ msgid "INS"
#~ msgstr "INS"
#~ msgid "Character &Groups"
#~ msgstr "Skupine &znakov"
#~ msgid "Language:"
#~ msgstr "Jezik:"
#~ msgid "&About"
#~ msgstr "O progr&amu"
#~ msgid "Cuts selected text and puts it on the clipboard"
#~ msgstr "Izreže izbrano besedilo in ga shrani na odložišče"
#~ msgid "Copies selected text to the clipboard"
#~ msgstr "Kopira izbrano besedilo na odložišče"
#~ msgid "Inserts text from the clipboard"
#~ msgstr "Vstavi besedilo z odložišča"
#~ msgid "&Copy"
#~ msgstr "&Kopiraj"
#~ msgid "&Paste"
#~ msgstr "&Prilepi"
#~ msgid "&File"
#~ msgstr "&Datoteka"
#~ msgid "Send Decomposed (F6)"
#~ msgstr "Pošlji razstavljeno (F6)"
#~ msgid "Send Composed (F5)"
#~ msgstr "Pošlji sestavljeno (F5)"
#~ msgid ""
#~ "ZRCola keyboard shortcut Win+Shift+Z could not be registered. Some "
#~ "functionality will not be available."
#~ msgstr ""
#~ "ZRColine bližnjice na tipkovnici Win+Shift+Z ni mogoče registrirati. "
#~ "Nekaj funkcionalnosti ne bo na voljo."
#, fuzzy
#~ msgid "Authentication progress real time monitor"
#~ msgstr "Nadzira postopek overovljanja v realnem času"

BIN
ZRCola/res/char_select.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1794
ZRCola/res/char_select.pdf Normal file

File diff suppressed because one or more lines are too long

BIN
ZRCola/res/edit_copy.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1593
ZRCola/res/edit_copy.pdf Normal file

File diff suppressed because one or more lines are too long

BIN
ZRCola/res/edit_cut.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1707
ZRCola/res/edit_cut.pdf Normal file

File diff suppressed because one or more lines are too long

BIN
ZRCola/res/edit_paste.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1727
ZRCola/res/edit_paste.pdf Normal file

File diff suppressed because one or more lines are too long

BIN
ZRCola/res/send_abort.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1603
ZRCola/res/send_abort.pdf Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1688
ZRCola/res/send_composed.pdf Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

File diff suppressed because one or more lines are too long

View File

@@ -19,17 +19,33 @@
#pragma once
#include "../include/zrcola.h"
#include "zrcolaapp.h"
#include "zrcolacomppnl.h"
#include "zrcolafrm.h"
#include "zrcolakeyhndlr.h"
#include <wx/ffile.h>
#include <wx/msgdlg.h>
#include <wx/persist.h>
#include <wx/persist/toplevel.h>
#include <wx/utils.h>
#include <wx/valtext.h>
#include <wxex/common.h>
#include <wxex/persist/auimanager.h>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
#include <stdex/idrec.h>
#if defined(__WXMSW__)
#include <Msi.h>
#include <ShObjIdl.h>
#include <ShlGuid.h>
#endif
#include "../include/zrcola.h"
#include "zrcolaapp.h"
#include "zrcolachrgrid.h"
#include "zrcolachrcatpnl.h"
#include "zrcolacomppnl.h"
#include "zrcolafrm.h"
#include "zrcolakeyhndlr.h"
#include "zrcolasettings.h"

View File

@@ -18,6 +18,9 @@
*/
#include "stdafx.h"
#if defined(__WXMSW__)
#pragma comment(lib, "msi.lib")
#endif
//////////////////////////////////////////////////////////////////////////
@@ -28,7 +31,7 @@ wxIMPLEMENT_APP(ZRColaApp);
ZRColaApp::ZRColaApp() :
m_config(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)),
m_mainWnd(NULL),
wxApp()
{
}
@@ -36,23 +39,109 @@ ZRColaApp::ZRColaApp() :
bool ZRColaApp::OnInit()
{
#if defined(__WXMSW__)
// To compensate migration to non-advertised shortcut, do the Microsoft Installer's feature completeness check manually.
// If execution got this far in the first place (EXE and dependent DLLs are present and loadable).
// Furthermore, this increments program usage counter.
if (::MsiQueryFeatureState(_T(ZRCOLA_VERSION_GUID), _T("featZRCola")) != INSTALLSTATE_UNKNOWN)
::MsiUseFeature(_T(ZRCOLA_VERSION_GUID), _T("featZRCola"));
#endif
wxConfigBase *cfgPrev = wxConfigBase::Set(new wxConfig(wxT(ZRCOLA_CFG_APPLICATION), wxT(ZRCOLA_CFG_VENDOR)));
if (cfgPrev) wxDELETE(cfgPrev);
if (!wxApp::OnInit())
return false;
// Set desired locale.
wxLanguage language = (wxLanguage)m_config.Read(wxT("Language"), wxLANGUAGE_DEFAULT);
wxLanguage language = (wxLanguage)wxConfigBase::Get()->Read(wxT("Language"), wxLANGUAGE_DEFAULT);
if (wxLocale::IsAvailable(language)) {
wxString sPath;
if (m_config.Read(wxT("LocalizationRepositoryPath"), &sPath))
if (wxConfigBase::Get()->Read(wxT("LocalizationRepositoryPath"), &sPath))
m_locale.AddCatalogLookupPathPrefix(sPath);
wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend")));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend") wxT(wxExtendVersion)));
wxVERIFY(m_locale.AddCatalog(wxT("libZRColaUI")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola-zrcdb")));
}
wxZRColaFrame* mainFrame = new wxZRColaFrame();
std::fstream dat((LPCTSTR)GetDatabasePath(), std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
if (stdex::idrec::find<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) {
ZRCola::recordsize_t size;
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
if (dat.good()) {
bool has_translation_data = false;
mainFrame->Show();
for (;;) {
ZRCola::recordid_t id;
if (!stdex::idrec::read_id(dat, id, size)) break;
if (id == ZRCola::translation_rec::id) {
dat >> ZRCola::translation_rec(m_t_db);
if (dat.good()) {
has_translation_data = true;
} else {
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
m_t_db.idxComp .clear();
m_t_db.idxDecomp.clear();
m_t_db.data .clear();
}
} else if (id == ZRCola::langchar_rec::id) {
dat >> ZRCola::langchar_rec(m_lc_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
m_lc_db.idxChr.clear();
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
m_lc_db.idxLng.clear();
#endif
m_lc_db.data .clear();
}
} else if (id == ZRCola::language_rec::id) {
dat >> ZRCola::language_rec(m_lang_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading language character data from ZRCola.zrcdb."));
m_lang_db.idxLng.clear();
m_lang_db.data .clear();
}
} else if (id == ZRCola::keyseq_rec::id) {
dat >> ZRCola::keyseq_rec(m_ks_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading key sequences data from ZRCola.zrcdb."));
m_ks_db.idxChr.clear();
m_ks_db.idxKey.clear();
m_ks_db.data .clear();
}
} else if (id == ZRCola::character_rec::id) {
dat >> ZRCola::character_rec(m_chr_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading character data from ZRCola.zrcdb."));
m_chr_db.idxChr.clear();
m_chr_db.data .clear();
}
} else if (id == ZRCola::chrcat_rec::id) {
dat >> ZRCola::chrcat_rec(m_cc_db);
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading character category data from ZRCola.zrcdb."));
m_cc_db.idxChrCat.clear();
m_cc_db.idxRnk .clear();
m_cc_db.data .clear();
}
} else
stdex::idrec::ignore<ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat);
}
if (!has_translation_data)
wxFAIL_MSG(wxT("ZRCola.zrcdb has no translation data."));
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
m_mainWnd = new wxZRColaFrame();
wxPersistentRegisterAndRestore<wxZRColaFrame>(m_mainWnd);
m_mainWnd->Show();
return true;
}

View File

@@ -25,9 +25,14 @@ class ZRColaApp;
#pragma once
#include "zrcolafrm.h"
#include <wx/app.h>
#include <wx/config.h>
#include <wx/intl.h>
#include <zrcola/character.h>
#include <zrcola/language.h>
#include <zrcola/translate.h>
#include <zrcolaui/keyboard.h>
///
@@ -42,8 +47,8 @@ public:
/// Called when application initializes.
///
/// \returns
/// - true if initialization succeeded
/// - false otherwise
/// - \c true if initialization succeeded
/// - \c false otherwise
///
virtual bool OnInit();
@@ -53,10 +58,18 @@ public:
///
inline wxString GetDatabasePath() const;
public:
ZRCola::translation_db m_t_db; ///< Translation database
ZRCola::langchar_db m_lc_db; ///< Language character database
ZRCola::language_db m_lang_db; ///< Language database
ZRCola::keyseq_db m_ks_db; ///< Key sequence database
ZRCola::character_db m_chr_db; ///< Character database
ZRCola::chrcat_db m_cc_db; ///< Characted category database
wxZRColaFrame *m_mainWnd; ///< Main window
protected:
wxConfig m_config; ///< Application configuration
wxLocale m_locale; ///< Current locale
wxLocale m_locale; ///< Current locale
};
@@ -66,7 +79,7 @@ wxDECLARE_APP(ZRColaApp);
inline wxString ZRColaApp::GetDatabasePath() const
{
wxString sPath;
if (m_config.Read(wxT("DatabasePath"), &sPath)) {
if (wxConfigBase::Get()->Read(wxT("DatabasePath"), &sPath)) {
if (!wxEndsWithPathSeparator(sPath))
sPath << wxFILE_SEP_PATH;
} else {

193
ZRCola/zrcolachrcatpnl.cpp Normal file
View File

@@ -0,0 +1,193 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////
// wxZRColaCharacterCatalogPanel
//////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxZRColaCharacterCatalogPanel, wxZRColaCharacterCatalogPanelBase)
EVT_MENU(wxZRColaCharacterCatalogPanel::wxID_FOCUS_DECOMPOSED, wxZRColaCharacterCatalogPanel::OnFocusDecomposed)
END_EVENT_TABLE()
wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) : wxZRColaCharacterCatalogPanelBase(parent)
{
std::fstream dat((LPCTSTR)((ZRColaApp*)wxTheApp)->GetDatabasePath(), std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
if (stdex::idrec::find<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) {
ZRCola::recordsize_t size;
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
if (dat.good()) {
ZRCola::chrgrp_rec rec(m_cg_db);
if (rec.find(dat, size)) {
dat >> rec;
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading character group data from ZRCola.zrcdb."));
m_cg_db.idxRnk.clear();
m_cg_db.data .clear();
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb has no character group data."));
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
if (!m_cg_db.idxRnk.empty()) {
// Populate character group list.
for (size_t i = 0, n = m_cg_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRnk[i];
wxString
label(cg.data, cg.name_len),
label_tran2(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
m_choice->Insert(label_tran2, i);
}
m_cg_id = m_cg_db.idxRnk[0].id;
m_choice->Select(0);
// Update grid by simulating wxEVT_COMMAND_CHOICE_SELECTED event.
wxCommandEvent e(wxEVT_COMMAND_CHOICE_SELECTED, m_grid->GetId());
e.SetInt(0);
OnChoice(e);
}
// Register frame specific hotkey(s).
{
wxAcceleratorEntry entries[1];
entries[0].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_FOCUS_DECOMPOSED);
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
}
}
wxZRColaCharacterCatalogPanel::~wxZRColaCharacterCatalogPanel()
{
}
void wxZRColaCharacterCatalogPanel::OnChoice(wxCommandEvent& event)
{
ZRCola::chrgrp_db::chrgrp &cg = m_cg_db.idxRnk[event.GetSelection()];
m_cg_id = cg.id;
m_grid->SetCharacters(wxString(cg.data + cg.name_len, cg.char_len));
// As size of the grid might have changed, relayout the panel.
Layout();
event.Skip();
}
void wxZRColaCharacterCatalogPanel::OnGridClick(wxGridEvent& event)
{
ZRColaApp *app = (ZRColaApp*)wxTheApp;
if (app->m_mainWnd) {
app->m_mainWnd->m_panel->m_decomposed->WriteText(m_grid->GetCellValue(event.GetRow(), event.GetCol()));
app->m_mainWnd->m_panel->m_decomposed->SetFocus();
}
event.Skip();
}
void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
ZRColaApp *app = (ZRColaApp*)wxTheApp;
if (app->m_mainWnd) {
app->m_mainWnd->m_panel->m_decomposed->WriteText(m_grid->GetCellValue(m_grid->GetCursorRow(), m_grid->GetCursorColumn()));
app->m_mainWnd->m_panel->m_decomposed->SetFocus();
event.StopPropagation();
return;
}
}
event.Skip();
}
void wxZRColaCharacterCatalogPanel::OnFocusDecomposed(wxCommandEvent& event)
{
ZRColaApp *app = (ZRColaApp*)wxTheApp;
if (app->m_mainWnd) {
app->m_mainWnd->m_panel->m_decomposed->SetFocus();
event.StopPropagation();
return;
}
event.Skip();
}
//////////////////////////////////////////////////////////////////////////
// wxPersistentZRColaCharacterCatalogPanel
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaCharacterCatalogPanel::wxPersistentZRColaCharacterCatalogPanel(wxZRColaCharacterCatalogPanel *wnd) : wxPersistentWindow<wxZRColaCharacterCatalogPanel>(wnd)
{
}
wxString wxPersistentZRColaCharacterCatalogPanel::GetKind() const
{
return wxT(wxPERSIST_TLW_KIND);
}
void wxPersistentZRColaCharacterCatalogPanel::Save() const
{
const wxZRColaCharacterCatalogPanel * const wnd = static_cast<const wxZRColaCharacterCatalogPanel*>(GetWindow());
SaveValue(wxT("charGroup"), wnd->m_cg_id);
}
bool wxPersistentZRColaCharacterCatalogPanel::Restore()
{
wxZRColaCharacterCatalogPanel * const wnd = static_cast<wxZRColaCharacterCatalogPanel*>(GetWindow());
// Restore selected character group.
int cg_id;
if (RestoreValue(wxT("charGroup"), &cg_id)) {
for (size_t i = 0, n = wnd->m_cg_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrgrp_db::chrgrp &cg = wnd->m_cg_db.idxRnk[i];
if (cg.id == cg_id) {
wnd->m_cg_id = cg.id;
wnd->m_choice->Select(i);
// Update grid by simulating wxEVT_COMMAND_CHOICE_SELECTED event.
wxCommandEvent e(wxEVT_COMMAND_CHOICE_SELECTED, wnd->m_grid->GetId());
e.SetInt(i);
wnd->OnChoice(e);
break;
}
}
}
return true;
}

79
ZRCola/zrcolachrcatpnl.h Normal file
View File

@@ -0,0 +1,79 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Forward declarations
///
class wxZRColaCharacterCatalogPanel;
#pragma once
#include "zrcolagui.h"
#include <zrcolaui/chargroup.h>
#include <wx/persist/window.h>
///
/// ZRCola character groups panel
///
class wxZRColaCharacterCatalogPanel : public wxZRColaCharacterCatalogPanelBase
{
public:
enum
{
wxID_FOCUS_DECOMPOSED = 6000,
};
wxZRColaCharacterCatalogPanel(wxWindow* parent);
virtual ~wxZRColaCharacterCatalogPanel();
friend class wxPersistentZRColaCharacterCatalogPanel; // Allow saving/restoring window state.
protected:
virtual void OnChoice(wxCommandEvent& event);
virtual void OnGridClick(wxGridEvent& event);
virtual void OnGridKeyDown(wxKeyEvent& event);
void OnFocusDecomposed(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
protected:
ZRCola::chrgrp_db m_cg_db; ///< Character group database
int m_cg_id; ///< Selected character group ID
};
///
/// Supports saving/restoring wxZRColaCharacterCatalogPanel state
///
class wxPersistentZRColaCharacterCatalogPanel : public wxPersistentWindow<wxZRColaCharacterCatalogPanel>
{
public:
wxPersistentZRColaCharacterCatalogPanel(wxZRColaCharacterCatalogPanel *wnd);
virtual wxString GetKind() const;
virtual void Save() const;
virtual bool Restore();
};
inline wxPersistentObject *wxCreatePersistentObject(wxZRColaCharacterCatalogPanel *wnd)
{
return new wxPersistentZRColaCharacterCatalogPanel(wnd);
}

217
ZRCola/zrcolachrgrid.cpp Normal file
View File

@@ -0,0 +1,217 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////
// wxZRColaCharGrid
//////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxZRColaCharGrid, wxGrid)
EVT_SIZE(wxZRColaCharGrid::OnSize)
EVT_KEY_DOWN(wxZRColaCharGrid::OnKeyDown)
EVT_TIMER(wxZRColaCharGrid::wxID_TOOLTIP_TIMER, wxZRColaCharGrid::OnTooltipTimer)
END_EVENT_TABLE()
wxZRColaCharGrid::wxZRColaCharGrid() : wxGrid()
{
Init();
}
wxZRColaCharGrid::wxZRColaCharGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxGrid(parent, id, pos, size, wxWANTS_CHARS, name)
{
Init();
SetDefaultRowSize(wxZRColaCharacterGridRowHeight);
// Create timer for saving the state.
m_timerToolTip.SetOwner(this, wxID_TOOLTIP_TIMER);
// wxEVT_MOTION event must be connected to the wxGridWindow, not wxGrid itself.
wxWindow *gridWnd = GetGridWindow();
gridWnd->Connect(gridWnd->GetId(), wxEVT_MOTION, wxMouseEventHandler(wxZRColaCharGrid::OnMotion), NULL, this);
}
wxZRColaCharGrid::~wxZRColaCharGrid()
{
wxWindow *gridWnd = GetGridWindow();
gridWnd->Disconnect(gridWnd->GetId(), wxEVT_MOTION, wxMouseEventHandler(wxZRColaCharGrid::OnMotion), NULL, this);
}
void wxZRColaCharGrid::Init()
{
m_regenerate = false;
m_isResizing = false;
m_toolTipIdx = (size_t)-1;
}
void wxZRColaCharGrid::SetCharacters(const wxString &chars)
{
m_chars = chars;
m_regenerate = true;
// Invoke OnSize(), which will populate the grid.
wxSizeEvent e(GetSize(), m_windowId);
e.SetEventObject(this);
HandleWindowEvent(e);
}
wxString wxZRColaCharGrid::GetToolTipText(int idx)
{
wxASSERT_MSG(idx < m_chars.Length(), wxT("index out of bounds"));
ZRColaApp *app = (ZRColaApp*)wxTheApp;
// See if this character has a key sequence registered.
ZRCola::keyseq_db::indexKey::size_type start;
bool found;
char ks[sizeof(ZRCola::keyseq_db::keyseq)] = {};
((ZRCola::keyseq_db::keyseq*)ks)->chr = m_chars[idx];
found = app->m_ks_db.idxChr.find(*(ZRCola::keyseq_db::keyseq*)ks, start);
if (found) {
ZRCola::keyseq_db::keyseq &seq = app->m_ks_db.idxChr[start];
wxString ks_str;
if (ZRCola::keyseq_db::GetSequenceAsText(seq.seq, seq.seq_len, ks_str))
return wxString::Format(wxT("U+%04X (%s)"), (int)m_chars[idx], ks_str.c_str());
}
return wxString::Format(wxT("U+%04X"), (int)m_chars[idx]);
}
void wxZRColaCharGrid::OnSize(wxSizeEvent& event)
{
event.Skip();
if (m_isResizing)
return;
m_isResizing = true;
// Calculate initial estimate of columns and rows.
wxSize size(event.GetSize());
size_t
char_len = m_chars.Length();
int
width = size.GetWidth() - m_rowLabelWidth - m_extraWidth,
cols = std::max<int>(width / wxZRColaCharacterGridColumnWidth, 1),
rows = std::max<int>((char_len + cols - 1) / cols, 1);
if (m_colLabelHeight + rows*wxZRColaCharacterGridRowHeight + m_extraHeight > size.GetHeight()) {
// Vertical scrollbar will be shown. Adjust the width and recalculate layout to avoid horizontal scrollbar.
width = std::max<int>(width - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this), 0);
cols = std::max<int>(width / wxZRColaCharacterGridColumnWidth, 1);
rows = std::max<int>((char_len + cols - 1) / cols, 1);
}
BeginBatch();
if (m_regenerate || cols != m_numCols) {
// Build and set new grid data.
wxGridStringTable *table = new wxGridStringTable(rows, cols);
for (int r = 0, i = 0; r < rows; r++)
for (int c = 0; c < cols; c++, i++)
table->SetValue(r, c, i < char_len ? wxString(1, m_chars[i]) : wxEmptyString);
SetTable(table, true);
m_regenerate = false;
}
for (int c = 0; c < cols; c++)
SetColSize(c, wxZRColaCharacterGridColumnWidth);
//// Set column widths to stretch to full width.
//for (int c = 0, x_l = 0; c < cols; c++) {
// int x_r = (c + 1)*width/cols;
// SetColSize(c, x_r - x_l);
// x_l = x_r;
//}
EndBatch();
m_isResizing = false;
}
void wxZRColaCharGrid::OnKeyDown(wxKeyEvent& event)
{
wxWindow *parentWnd;
if (event.GetKeyCode() == WXK_TAB && (parentWnd = GetParent()) != NULL) {
wxNavigationKeyEvent eventNav;
eventNav.SetDirection(!event.ShiftDown());
eventNav.SetWindowChange(event.ControlDown());
eventNav.SetEventObject(this);
if (parentWnd->HandleWindowEvent(eventNav))
return;
}
event.Skip();
}
void wxZRColaCharGrid::OnMotion(wxMouseEvent& event)
{
event.Skip();
wxPoint ptMouse(CalcUnscrolledPosition(event.GetPosition()));
int
col = XToCol(ptMouse.x - m_rowLabelWidth ),
row = YToRow(ptMouse.y - m_colLabelHeight);
if (col == wxNOT_FOUND || row == wxNOT_FOUND )
return;
size_t toolTipIdx = row*m_numCols + col;
if (toolTipIdx >= m_chars.Length()) {
// Index out of range.
m_toolTipIdx = (size_t)-1;
m_timerToolTip.Stop();
return;
} else if (toolTipIdx != m_toolTipIdx) {
// Cell changed.
m_toolTipIdx = toolTipIdx;
wxWindow *gridWnd = GetGridWindow();
if (gridWnd->GetToolTip()) {
// The tooltip is already shown. Update it immediately.
gridWnd->SetToolTip(GetToolTipText(m_toolTipIdx));
} else {
// This must be our initial entry. Schedule tooltip display after 1s.
m_timerToolTip.Start(1000, true);
}
}
}
void wxZRColaCharGrid::OnTooltipTimer(wxTimerEvent& event)
{
event.Skip();
if (m_toolTipIdx >= m_chars.Length())
return;
GetGridWindow()->SetToolTip(GetToolTipText(m_toolTipIdx));
}

91
ZRCola/zrcolachrgrid.h Normal file
View File

@@ -0,0 +1,91 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Forward declarations
///
class wxZRColaCharGrid;
#pragma once
#include <wx/grid.h>
///
/// Character grid layout
///
#define wxZRColaCharacterGridColumnWidth 35
#define wxZRColaCharacterGridRowHeight 35
///
/// ZRCola character grid
///
class wxZRColaCharGrid : public wxGrid
{
public:
enum
{
wxID_TOOLTIP_TIMER = 2000,
};
wxZRColaCharGrid();
wxZRColaCharGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr);
virtual ~wxZRColaCharGrid();
///
/// Sets new array of characters to display
///
/// \param[in] chars The string containing characters to display
///
void SetCharacters(const wxString &chars);
///
/// Returns displayed characters
///
/// \returns The string containing displayed characters
///
inline wxString GetCharacters() const
{
return m_chars;
}
protected:
virtual wxString GetToolTipText(int idx);
void OnSize(wxSizeEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnMotion(wxMouseEvent& event);
void OnTooltipTimer(wxTimerEvent& event);
DECLARE_EVENT_TABLE()
private:
void Init(); // common part of all ctors
protected:
wxString m_chars; ///< Array of Unicode characters to display in the grid
private:
bool m_regenerate; ///< Force regenerate grid table
bool m_isResizing; ///< Prevents nesting of OnSize() method.
wxTimer m_timerToolTip; ///< Timer for displaying tooltip
size_t m_toolTipIdx; ///< Index of cell for tooltip display
};

416
ZRCola/zrcolachrslct.cpp Normal file
View File

@@ -0,0 +1,416 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////
// wxZRColaCharSelect
//////////////////////////////////////////////////////////////////////////
wxDEFINE_EVENT(wxEVT_SEARCH_COMPLETE, wxThreadEvent);
wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) :
m_searchChanged(false),
m_unicodeChanged(false),
m_char(0),
m_searchThread(NULL),
wxZRColaCharSelectBase(parent)
{
Connect(wxID_ANY, wxEVT_SEARCH_COMPLETE, wxThreadEventHandler(wxZRColaCharSelect::OnSearchComplete), NULL, this);
m_unicode->SetValidator(wxHexValidator<wchar_t>(&m_char));
// Fill categories.
ZRColaApp *app = (ZRColaApp*)wxTheApp;
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name, cc.name_len), wxT("ZRCola-zrcdb")), i);
m_categories->Check(idx);
m_ccOrder.insert(std::make_pair(cc.id, idx));
}
ResetResults();
}
wxZRColaCharSelect::~wxZRColaCharSelect()
{
if (m_searchThread)
m_searchThread->Delete();
Disconnect(wxID_ANY, wxEVT_SEARCH_COMPLETE, wxThreadEventHandler(wxZRColaCharSelect::OnSearchComplete), NULL, this);
}
void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
{
event.Skip();
if (m_unicodeChanged) {
if (m_unicode->GetValidator()->TransferFromWindow()) {
ZRColaApp *app = (ZRColaApp*)wxTheApp;
m_gridPreview->SetCellValue(wxString(1, m_char), 0, 0);
{
char chr[sizeof(ZRCola::character_db::character)] = {};
((ZRCola::character_db::character*)chr)->chr = m_char;
size_t start;
if (app->m_chr_db.idxChr.find(*(ZRCola::character_db::character*)chr, start)) {
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[start];
m_description->SetValue(wxString(chr.data, chr.desc_len));
{
char cc[sizeof(ZRCola::chrcat_db::chrcat)] = {};
((ZRCola::chrcat_db::chrcat*)cc)->id = chr.cat;
size_t start;
if (app->m_cc_db.idxChrCat.find(*((ZRCola::chrcat_db::chrcat*)cc), start)) {
const ZRCola::chrcat_db::chrcat &cat = app->m_cc_db.idxChrCat[start];
m_category->SetValue(wxGetTranslation(wxString(cat.name, cat.name_len), wxT("ZRCola-zrcdb")));
} else
m_category->SetValue(wxEmptyString);
}
m_gridRelated->SetCharacters(wxString(chr.data + chr.desc_len, chr.rel_len));
} else {
m_description->SetValue(wxEmptyString);
m_category->SetValue(wxEmptyString);
m_gridRelated->ClearGrid();
}
m_gridRelated->Scroll(0, 0);
}
}
m_unicodeChanged = false;
} else if (m_searchChanged) {
if (m_searchThread)
m_searchThread->Delete();
wxString val(m_search->GetValue());
if (!val.IsEmpty()) {
ZRColaApp *app = (ZRColaApp*)wxTheApp;
m_searchThread = new SearchThread(this);
m_searchThread->m_search.assign(val.c_str(), val.Length());
// Select categories.
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
if (m_categories->IsChecked(i))
m_searchThread->m_cats.insert(cc.id);
}
if (m_searchThread->Run() != wxTHREAD_NO_ERROR) {
wxFAIL_MSG("Can't create the thread!");
delete m_searchThread;
m_searchThread = NULL;
}
} else
ResetResults();
m_searchChanged = false;
}
}
void wxZRColaCharSelect::OnSearchText(wxCommandEvent& event)
{
event.Skip();
m_searchChanged = true;
}
void wxZRColaCharSelect::OnCategoriesToggle(wxCommandEvent& event)
{
event.Skip();
m_searchChanged = true;
}
void wxZRColaCharSelect::OnSearchComplete(wxThreadEvent& event)
{
event.Skip();
if (m_searchThread) {
// Display results.
wxString chars;
chars.reserve(m_searchThread->m_hits.size());
for (std::vector< std::pair<unsigned long, wchar_t> >::const_iterator i = m_searchThread->m_hits.cbegin(), i_end = m_searchThread->m_hits.cend(); i != i_end; ++i)
chars += i->second;
m_gridResults->SetCharacters(chars);
m_searchThread->Delete();
m_searchThread = NULL;
m_gridResults->Scroll(0, 0);
}
}
void wxZRColaCharSelect::OnResultSelectCell(wxGridEvent& event)
{
wxString val(m_gridResults->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnResultCellDClick(wxGridEvent& event)
{
event.Skip();
wxString val(m_gridResults->GetCellValue(event.GetRow(), event.GetCol()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
}
}
void wxZRColaCharSelect::OnResultsKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
wxString val(m_gridResults->GetCellValue(m_gridResults->GetCursorRow(), m_gridResults->GetCursorColumn()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
event.StopPropagation();
return;
}
}
event.Skip();
}
void wxZRColaCharSelect::OnRecentSelectCell(wxGridEvent& event)
{
wxString val(m_gridRecent->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnRecentCellDClick(wxGridEvent& event)
{
event.Skip();
wxString val(m_gridRecent->GetCellValue(event.GetRow(), event.GetCol()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
}
}
void wxZRColaCharSelect::OnRecentKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
wxString val(m_gridRecent->GetCellValue(m_gridRecent->GetCursorRow(), m_gridRecent->GetCursorColumn()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
event.StopPropagation();
return;
}
}
event.Skip();
}
void wxZRColaCharSelect::OnRelatedSelectCell(wxGridEvent& event)
{
wxString val(m_gridRelated->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnUnicodeText(wxCommandEvent& event)
{
event.Skip();
m_unicodeChanged = true;
}
void wxZRColaCharSelect::OnOKButtonClick(wxCommandEvent& event)
{
event.Skip();
wxString
recent(m_gridRecent->GetCharacters()),
val(1, m_char);
for (size_t i = 0, n = recent.Length(); i < n; i++) {
const wxStringCharType c = recent[i];
if (c != m_char)
val += c;
}
m_gridRecent->SetCharacters(val);
}
void wxZRColaCharSelect::ResetResults()
{
// Fill the results.
ZRColaApp *app = (ZRColaApp*)wxTheApp;
size_t i, n = app->m_chr_db.idxChr.size();
wxString val;
val.reserve(n);
for (i = 0; i < n; i++) {
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[i];
std::map<ZRCola::chrcatid_t, int>::const_iterator idx = m_ccOrder.find(chr.cat);
if (idx == m_ccOrder.end() || m_categories->IsChecked(idx->second))
val += chr.chr;
}
m_gridResults->SetCharacters(val);
}
wxZRColaCharSelect::SearchThread::SearchThread(wxZRColaCharSelect *parent) :
m_parent(parent),
wxThread(wxTHREAD_JOINABLE)
{
//// This is a worker thread. Set priority between minimal and normal.
//SetPriority((wxPRIORITY_MIN + wxPRIORITY_DEFAULT) / 2);
}
wxThread::ExitCode wxZRColaCharSelect::SearchThread::Entry()
{
ZRColaApp *app = (ZRColaApp*)wxTheApp;
std::map<wchar_t, unsigned long> hits;
if (TestDestroy()) return (wxThread::ExitCode)1;
{
// Search by indexes and merge results.
std::map<wchar_t, unsigned long> hits_sub;
if (!app->m_chr_db.Search(m_search.c_str(), m_cats, hits, hits_sub, TestDestroyS, this)) return (wxThread::ExitCode)1;
for (std::map<wchar_t, unsigned long>::const_iterator i = hits_sub.cbegin(), i_end = hits_sub.cend(); i != i_end; ++i) {
if (TestDestroy()) return (wxThread::ExitCode)1;
std::map<wchar_t, unsigned long>::iterator idx = hits.find(i->first);
if (idx == hits.end())
hits.insert(std::make_pair(i->first, i->second / 4));
else
idx->second += i->second / 4;
}
}
// Now sort the characters by rank.
m_hits.reserve(hits.size());
for (std::map<wchar_t, unsigned long>::const_iterator i = hits.cbegin(), i_end = hits.cend(); i != i_end; ++i) {
if (TestDestroy()) return (wxThread::ExitCode)1;
m_hits.push_back(std::make_pair(i->second, i->first));
}
std::qsort(m_hits.data(), m_hits.size(), sizeof(std::pair<unsigned long, wchar_t>), CompareHits);
// Signal the event handler that this thread is going to be destroyed.
// NOTE: here we assume that using the m_parent pointer is safe,
// (in this case this is assured by the wxZRColaCharSelect destructor)
wxQueueEvent(m_parent, new wxThreadEvent(wxEVT_SEARCH_COMPLETE));
return 0;
}
int __cdecl wxZRColaCharSelect::SearchThread::CompareHits(const void *a, const void *b)
{
const std::pair<unsigned long, wchar_t> *_a = (const std::pair<unsigned long, wchar_t>*)a;
const std::pair<unsigned long, wchar_t> *_b = (const std::pair<unsigned long, wchar_t>*)b;
if (_a->first > _b->first) return -1;
else if (_a->first < _b->first) return 1;
if (_a->second < _b->second) return -1;
else if (_a->second > _b->second) return 1;
return 0;
}
bool __cdecl wxZRColaCharSelect::SearchThread::TestDestroyS(void *cookie)
{
return static_cast<wxZRColaCharSelect::SearchThread*>(cookie)->TestDestroy();
}
//////////////////////////////////////////////////////////////////////////
// wxPersistentZRColaCharSelect
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentDialog(wnd)
{
}
void wxPersistentZRColaCharSelect::Save() const
{
wxPersistentDialog::Save();
const wxZRColaCharSelect * const wnd = static_cast<const wxZRColaCharSelect*>(GetWindow());
SaveValue(wxT("recentChars"), wnd->m_gridRecent->GetCharacters());
ZRColaApp *app = (ZRColaApp*)wxTheApp;
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
wxString name(wxT("category"));
name.Append(cc.id.data, _countof(cc.id.data));
SaveValue(name, wnd->m_categories->IsChecked(i));
}
}
bool wxPersistentZRColaCharSelect::Restore()
{
wxZRColaCharSelect * const wnd = static_cast<wxZRColaCharSelect*>(GetWindow());
wxString recent;
if (RestoreValue(wxT("recentChars"), &recent))
wnd->m_gridRecent->SetCharacters(recent);
ZRColaApp *app = (ZRColaApp*)wxTheApp;
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
wxString name(wxT("category"));
name.Append(cc.id.data, _countof(cc.id.data));
bool val;
if (RestoreValue(name, &val))
wnd->m_categories->Check(i, val);
}
wnd->ResetResults();
return wxPersistentDialog::Restore();
}

120
ZRCola/zrcolachrslct.h Normal file
View File

@@ -0,0 +1,120 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Forward declarations
///
class wxZRColaCharSelect;
class wxPersistentZRColaCharSelect;
#pragma once
#include "zrcolagui.h"
#include <zrcola/character.h>
#include <wxex/valhex.h>
#include <wxex/persist/dialog.h>
#include <wx/event.h>
#include <wx/thread.h>
#include <map>
wxDECLARE_EVENT(wxEVT_SEARCH_COMPLETE, wxThreadEvent);
///
/// ZRCola character select dialog
///
class wxZRColaCharSelect : public wxZRColaCharSelectBase
{
public:
wxZRColaCharSelect(wxWindow* parent);
virtual ~wxZRColaCharSelect();
friend class wxPersistentZRColaCharSelect; // Allow saving/restoring window state.
friend class SearchThread; // For search thread back-notifications
protected:
virtual void OnIdle(wxIdleEvent& event);
virtual void OnSearchText(wxCommandEvent& event);
virtual void OnCategoriesToggle(wxCommandEvent& event);
void OnSearchComplete(wxThreadEvent& event);
virtual void OnResultSelectCell(wxGridEvent& event);
virtual void OnResultCellDClick(wxGridEvent& event);
virtual void OnResultsKeyDown(wxKeyEvent& event);
virtual void OnRecentSelectCell(wxGridEvent& event);
virtual void OnRecentCellDClick(wxGridEvent& event);
virtual void OnRecentKeyDown(wxKeyEvent& event);
virtual void OnRelatedSelectCell(wxGridEvent& event);
virtual void OnUnicodeText(wxCommandEvent& event);
virtual void OnOKButtonClick(wxCommandEvent& event);
void ResetResults();
public:
wchar_t m_char; ///< Currently selected character (0 when none)
protected:
bool m_searchChanged; ///< Did Search field or category selection change?
std::map<ZRCola::chrcatid_t, int> m_ccOrder; ///< Character category order
bool m_unicodeChanged; ///< Did Unicode field change?
///
/// Search worker thread
///
class SearchThread : public wxThread
{
public:
SearchThread(wxZRColaCharSelect *parent);
protected:
virtual ExitCode Entry();
static int __cdecl CompareHits(const void *a, const void *b);
static bool __cdecl TestDestroyS(void *cookie);
public:
std::wstring m_search; ///< Search phrase
std::set<ZRCola::chrcatid_t> m_cats; ///< Search categories
std::vector< std::pair<unsigned long, wchar_t> > m_hits; ///< Search results
protected:
wxZRColaCharSelect *m_parent; ///< Thread owner
} *m_searchThread; ///< Search thread
};
///
/// Supports saving/restoring wxZRColaCharSelect state
///
class wxPersistentZRColaCharSelect : public wxPersistentDialog
{
public:
wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd);
virtual void Save() const;
virtual bool Restore();
};
inline wxPersistentObject *wxCreatePersistentObject(wxZRColaCharSelect *wnd)
{
return new wxPersistentZRColaCharSelect(wnd);
}

View File

@@ -25,43 +25,129 @@
//////////////////////////////////////////////////////////////////////////
wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
m_progress(false),
m_decomposedChanged(false),
m_composedChanged(false),
m_selDecomposed(0, 0),
m_selComposed(0, 0),
wxZRColaComposerPanelBase(parent)
{
std::fstream dat((LPCTSTR)((ZRColaApp*)wxTheApp)->GetDatabasePath(), std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
if (stdex::idrec::find<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) {
ZRCola::recordsize_t size;
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
if (dat.good()) {
ZRCola::translation_rec rec(m_t_db);
if (rec.find(dat, size)) {
dat >> rec;
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
m_t_db.idxComp .clear();
m_t_db.idxDecomp.clear();
m_t_db.data .clear();
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb has no translation data."));
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
m_decomposed->PushEventHandler(&m_keyhandler);
// Restore the previously saved state (if exists).
wxString fileName(GetStateFileName());
if (wxFileExists(fileName)) {
wxFFile file(fileName, wxT("rb"));
if (file.IsOpened()) {
// Load decomposed text.
unsigned __int64 n;
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString decomposed;
file.Read(wxStringBuffer(decomposed, n), sizeof(wchar_t)*n);
if (!file.Error()) {
// Load composed text.
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString composed;
file.Read(wxStringBuffer(composed, n), sizeof(wchar_t)*n);
if (!file.Error()) {
// Restore state.
m_decomposed->SetValue(decomposed);
m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second);
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, decomposed.GetData(), decomposed.Length(), m_selDecomposed.first, m_selDecomposed.second);
m_decomposedChanged = false;
m_composed->SetValue(composed);
m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second);
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, composed.GetData(), composed.Length(), m_selComposed.first, m_selComposed.second);
m_composedChanged = false;
}
}
}
}
}
}
}
wxZRColaComposerPanel::~wxZRColaComposerPanel()
{
m_decomposed->PopEventHandler();
// This is a controlled exit. Purge saved state.
wxString fileName(GetStateFileName());
if (wxFileExists(fileName))
wxRemoveFile(fileName);
}
void wxZRColaComposerPanel::SynchronizePanels()
{
if (m_decomposedChanged) {
m_timerSave.Stop();
wxString src;
size_t len = GetValue(m_decomposed, src);
std::wstring norm;
((ZRColaApp*)wxTheApp)->m_t_db.Decompose(src.data(), len, norm, &m_mapping1);
std::wstring dst;
((ZRColaApp*)wxTheApp)->m_t_db.Compose(norm.data(), norm.size(), dst, &m_mapping2);
m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second);
// Update decomposed HEX dump.
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, src.data(), len, m_selDecomposed.first, m_selDecomposed.second);
// Update composed text, and its HEX dump.
m_composed->SetValue(dst);
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second)));
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, dst.data(), dst.length(), m_selComposed.first, m_selComposed.second);
// Schedule state save after 3s.
m_timerSave.Start(3000, true);
} else if (m_composedChanged) {
m_timerSave.Stop();
wxString src;
size_t len = GetValue(m_composed, src);
ZRColaApp *app = (ZRColaApp*)wxTheApp;
std::wstring dst;
wxZRColaFrame *mainWnd = dynamic_cast<wxZRColaFrame*>(wxGetActiveWindow());
if (mainWnd)
app->m_t_db.Decompose(src.data(), len, &app->m_lc_db, mainWnd->m_settings->m_lang, dst, &m_mapping2);
else
app->m_t_db.Decompose(src.data(), len, dst, &m_mapping2);
m_mapping1.clear();
m_mapping2.invert();
m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second);
// Update composed HEX dump.
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, src.data(), len, m_selComposed.first, m_selComposed.second);
// Update decomposed text, and its HEX dump.
m_decomposed->SetValue(dst);
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second)));
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, dst.data(), dst.length(), m_selDecomposed.first, m_selDecomposed.second);
// Schedule state save after 3s.
m_timerSave.Start(3000, true);
}
m_decomposedChanged = false;
m_composedChanged = false;
}
void wxZRColaComposerPanel::OnDecomposedPaint(wxPaintEvent& event)
{
event.Skip();
@@ -73,39 +159,55 @@ void wxZRColaComposerPanel::OnDecomposedPaint(wxPaintEvent& event)
// Save new selection first, to avoid loop.
m_selDecomposed.first = from;
m_selDecomposed.second = to;
m_composed->SetSelection(m_mapping.to_composed(from), m_mapping.to_composed(to));
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(from),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(to ));
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(from)),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(to )));
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ),
m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second));
}
}
void wxZRColaComposerPanel::OnDecomposedHexPaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_decomposedHex->GetSelection(&from, &to);
if (m_selDecomposedHex.first != from || m_selDecomposedHex.second != to) {
// Save new selection first, to avoid loop.
m_selDecomposedHex.first = from;
m_selDecomposedHex.second = to;
m_decomposed->SetSelection(
m_selDecomposed.first = m_mappingDecomposedHex.to_src(from),
m_selDecomposed.second = m_mappingDecomposedHex.to_src(to ));
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second)));
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ),
m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second));
}
}
void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event)
{
if (m_progress) {
// We are being updated by wxZRColaComposerPanel::OnComposedText()
event.Skip();
} else {
#ifdef __WINDOWS__
// Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets.
WXHWND hWnd = m_decomposed->GetHWND();
std::vector<wchar_t> src((std::vector<wchar_t>::size_type)::GetWindowTextLengthW(hWnd) + 1);
::GetWindowTextW(hWnd, src.data(), src.size());
#else
wxString src(m_decomposed->GetValue());
#endif
event.Skip();
std::wstring dst;
m_t_db.Compose(src.data(), src.size(), dst, &m_mapping);
long from, to;
m_decomposed->GetSelection(&from, &to);
// Update composed text.
m_progress = true;
m_composed->SetValue(dst);
m_composed->SetSelection(m_mapping.to_composed(from), m_mapping.to_composed(to));
event.Skip();
m_progress = false;
}
// Set the flag the decomposed text changed to trigger idle-time composition.
m_decomposedChanged = true;
}
@@ -120,37 +222,190 @@ void wxZRColaComposerPanel::OnComposedPaint(wxPaintEvent& event)
// Save new selection first, to avoid loop.
m_selComposed.first = from;
m_selComposed.second = to;
m_decomposed->SetSelection(m_mapping.to_decomposed(from), m_mapping.to_decomposed(to));
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(from),
m_selComposedHex.second = m_mappingComposedHex.to_dst(to ));
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(from)),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(to )));
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second));
}
}
void wxZRColaComposerPanel::OnComposedHexPaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_composedHex->GetSelection(&from, &to);
if (m_selComposedHex.first != from || m_selComposedHex.second != to) {
// Save new selection first, to avoid loop.
m_selComposedHex.first = from;
m_selComposedHex.second = to;
m_composed->SetSelection(
m_selComposed.first = m_mappingComposedHex.to_src(from),
m_selComposed.second = m_mappingComposedHex.to_src(to ));
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second)));
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second));
}
}
void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event)
{
if (m_progress) {
// We are being updated by wxZRColaComposerPanel::OnDecomposedText()
event.Skip();
} else {
#ifdef __WINDOWS__
// Use Windows GetWindowTextLength() function to avoid line ending conversion incompletely imposed by wxWidgets.
WXHWND hWnd = m_composed->GetHWND();
std::vector<wchar_t> src((std::vector<wchar_t>::size_type)::GetWindowTextLengthW(hWnd) + 1);
::GetWindowTextW(hWnd, src.data(), src.size());
#else
wxString src(m_composed->GetValue());
#endif
event.Skip();
std::wstring dst;
m_t_db.Decompose(src.data(), src.size(), dst, &m_mapping);
long from, to;
m_composed->GetSelection(&from, &to);
// Update decomposed text.
m_progress = true;
m_decomposed->SetValue(dst);
m_decomposed->SetSelection(m_mapping.to_decomposed(from), m_mapping.to_decomposed(to));
event.Skip();
m_progress = false;
}
// Set the flag the composed text changed to trigger idle-time decomposition.
m_composedChanged = true;
}
void wxZRColaComposerPanel::OnSaveTimer(wxTimerEvent& event)
{
wxString fileName(GetStateFileName());
wxFFile file(fileName, wxT("wb"));
if (file.IsOpened()) {
wxString text;
size_t len;
// Save decomposed text.
len = GetValue(m_decomposed, text);
file.Write(&len, sizeof(len));
file.Write((const wchar_t*)text, sizeof(wchar_t)*len);
// Save composed text.
len = GetValue(m_composed, text);
file.Write(&len, sizeof(len));
file.Write((const wchar_t*)text, sizeof(wchar_t)*len);
}
event.Skip();
}
wxString wxZRColaComposerPanel::GetStateFileName()
{
wxString path;
path = wxFileName::GetTempDir();
if (!wxEndsWithPathSeparator(path))
path += wxFILE_SEP_PATH;
if (!wxDirExists(path))
wxMkdir(path);
wxString fileName(path);
fileName += wxT("ZRColaComposerPanel-state.tmp");
return fileName;
}
size_t wxZRColaComposerPanel::GetValue(wxTextCtrl *wnd, wxString &text)
{
#ifdef __WINDOWS__
// Use Windows GetWindowText() function to avoid line ending conversion incompletely imposed by wxWidgets.
WXHWND hWnd = wnd->GetHWND();
size_t len = ::GetWindowTextLengthW(hWnd);
if (len < 0x100) {
WCHAR buf[0x100];
::GetWindowTextW(hWnd, buf, len + 1);
text.assign(buf, len);
} else {
LPWSTR buf = new WCHAR[len + 1];
::GetWindowTextW(hWnd, buf, len + 1);
text.assign(buf, len);
delete [] buf;
}
return len;
#else
text = wnd->GetValue();
return text.Length();
#endif
}
void wxZRColaComposerPanel::SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &range, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len, long from, long to)
{
wxString hex;
bool first = true;
mapping.clear();
for (size_t i = 0; i < len && src[i]; i++) {
wchar_t c = src[i];
if (c == L'\n' || c == '\r') {
hex += c;
first = true;
} else {
hex += wxString::Format(first ? wxT("%04X") : wxT(" %04X"), src[i]);
mapping.push_back(ZRCola::mapping(i + 1, hex.Length()));
first = false;
}
}
wnd->SetValue(hex);
wnd->SetSelection(
range.first = mapping.to_dst(from),
range.second = mapping.to_dst(to ));
}
//////////////////////////////////////////////////////////////////////////
// wxPersistentZRColaComposerPanel
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaComposerPanel::wxPersistentZRColaComposerPanel(wxZRColaComposerPanel *wnd) : wxPersistentWindow<wxZRColaComposerPanel>(wnd)
{
}
wxString wxPersistentZRColaComposerPanel::GetKind() const
{
return wxT(wxPERSIST_TLW_KIND);
}
void wxPersistentZRColaComposerPanel::Save() const
{
const wxZRColaComposerPanel * const wnd = static_cast<const wxZRColaComposerPanel*>(GetWindow());
SaveValue(wxT("splitDecomposed"), wnd->m_splitterDecomposed->GetSashPosition());
SaveValue(wxT("splitComposed" ), wnd->m_splitterComposed ->GetSashPosition());
}
bool wxPersistentZRColaComposerPanel::Restore()
{
wxZRColaComposerPanel * const wnd = static_cast<wxZRColaComposerPanel*>(GetWindow());
int sashVal;
if (RestoreValue(wxT("splitDecomposed"), &sashVal)) {
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
wnd->m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, wnd );
wnd->m_splitterDecomposed->SetSashPosition(sashVal);
}
if (RestoreValue(wxT("splitComposed"), &sashVal)) {
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
wnd->m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, wnd );
wnd->m_splitterComposed->SetSashPosition(sashVal);
}
return true;
}

View File

@@ -27,7 +27,8 @@ class wxZRColaComposerPanel;
#include "zrcolagui.h"
#include "zrcolakeyhndlr.h"
#include <zrcola/translate.h>
#include <wx/persist/window.h>
#include <wx/timer.h>
#include <utility>
@@ -40,20 +41,54 @@ public:
wxZRColaComposerPanel(wxWindow* parent);
virtual ~wxZRColaComposerPanel();
friend class wxZRColaFrame; // Allow main frame direct access to our members.
void SynchronizePanels();
friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state.
protected:
virtual void OnDecomposedPaint(wxPaintEvent& event);
virtual void OnDecomposedHexPaint(wxPaintEvent& event);
virtual void OnDecomposedText(wxCommandEvent& event);
virtual void OnComposedPaint(wxPaintEvent& event);
virtual void OnComposedHexPaint(wxPaintEvent& event);
virtual void OnComposedText(wxCommandEvent& event);
virtual void OnSaveTimer(wxTimerEvent& event);
static wxString GetStateFileName();
static size_t GetValue(wxTextCtrl *wnd, wxString &text);
static void SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &range, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len, long from, long to);
protected:
ZRCola::translation_db m_t_db; ///< Translation database
bool m_progress; ///< Boolean flag to avoid recursive updates of composed and decomposed text controls
ZRCola::mapping_vector m_mapping; ///< Character index mapping vector between composed and decomposed text
bool m_decomposedChanged; ///< Boolean flag to mark decomposed text "dirty" to trigger composition
bool m_composedChanged; ///< Boolean flag to mark composed text "dirty" to trigger decomposition
ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text
ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and composed text
std::pair<long, long>
m_selDecomposed, ///< Character index of selected text in decomposed text control
m_selComposed; ///< Character index of selected text in composed text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window
m_selDecomposed, ///< Character index of selected text in decomposed text control
m_selDecomposedHex, ///< Character index of selected text in decomposed HEX dump text control
m_selComposed, ///< Character index of selected text in composed text control
m_selComposedHex; ///< Character index of selected text in composed HEX dump text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window
ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump
ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump
};
///
/// Supports saving/restoring wxZRColaComposerPanel state
///
class wxPersistentZRColaComposerPanel : public wxPersistentWindow<wxZRColaComposerPanel>
{
public:
wxPersistentZRColaComposerPanel(wxZRColaComposerPanel *wnd);
virtual wxString GetKind() const;
virtual void Save() const;
virtual bool Restore();
};
inline wxPersistentObject *wxCreatePersistentObject(wxZRColaComposerPanel *wnd)
{
return new wxPersistentZRColaComposerPanel(wnd);
}

View File

@@ -25,30 +25,82 @@
//////////////////////////////////////////////////////////////////////////
wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
EVT_UPDATE_UI_RANGE(wxZRColaFrame::wxID_SEND_COMPOSED, wxZRColaFrame::wxID_SEND_DECOMPOSED, wxZRColaFrame::OnSendUpdate)
EVT_MENU (wxID_EXIT , wxZRColaFrame::OnExit )
EVT_MENU(wxZRColaFrame::wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed )
EVT_MENU(wxZRColaFrame::wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed )
EVT_MENU(wxZRColaFrame::wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort )
EVT_MENU( wxID_EXIT , wxZRColaFrame::OnExit )
EVT_MENU( wxID_ABOUT , wxZRColaFrame::OnAbout )
EVT_UPDATE_UI_RANGE(wxID_CUT , wxID_CLEAR , wxZRColaFrame::OnForwardEventUpdate )
EVT_MENU_RANGE (wxID_CUT , wxID_CLEAR , wxZRColaFrame::OnForwardEvent )
EVT_UPDATE_UI (wxID_SELECTALL , wxZRColaFrame::OnForwardEventUpdate )
EVT_MENU (wxID_SELECTALL , wxZRColaFrame::OnForwardEvent )
EVT_MENU (wxID_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter )
EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate )
EVT_MENU (wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed )
EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed )
EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort )
EVT_MENU (wxID_SETTINGS , wxZRColaFrame::OnSettings )
EVT_UPDATE_UI (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEditUpdate )
EVT_MENU (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEdit )
EVT_UPDATE_UI (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarComposeUpdate )
EVT_MENU (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarCompose )
EVT_UPDATE_UI (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalogUpdate)
EVT_MENU (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalog )
EVT_MENU (wxID_FOCUS_CHARACTER_CATALOG , wxZRColaFrame::OnPanelCharacterCatalogFocus )
EVT_MENU (wxID_HELP_REQCHAR , wxZRColaFrame::OnHelpReqChar )
EVT_MENU (wxID_ABOUT , wxZRColaFrame::OnAbout )
wxEND_EVENT_TABLE()
wxZRColaFrame::wxZRColaFrame() :
m_hWndSource(NULL),
m_chrSelect(NULL),
m_settings(NULL),
wxZRColaFrameBase(NULL)
{
{
// wxFrameBuilder 3.5 does not support wxAUI_TB_HORIZONTAL flag. Add it manually.
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose);
paneInfo.LeftDockable(false);
paneInfo.RightDockable(false);
m_toolbarCompose->SetWindowStyleFlag(m_toolbarCompose->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL);
}
// Restore the wxAuiManager's state here to keep symmetric with save in the destructor below.
// See the comment in destructor why.
wxPersistentAuiManager(&m_mgr).Restore();
// Load main window icons.
#ifdef __WINDOWS__
wxIcon icon_small(wxT("00_zrcola.ico"), wxBITMAP_TYPE_ICO_RESOURCE, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
wxIconBundle icons;
icons.AddIcon(wxIcon(wxT("00_zrcola.ico"), wxBITMAP_TYPE_ICO_RESOURCE, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON)));
icons.AddIcon(icon_small);
icons.AddIcon(wxIcon(wxT("00_zrcola.ico"), wxBITMAP_TYPE_ICO_RESOURCE, ::GetSystemMetrics(SM_CXICON ), ::GetSystemMetrics(SM_CYICON )));
SetIcons(icons);
#else
SetIcon(wxICON(00_zrcola.ico));
wxIcon icon_small(wxICON(00_zrcola.ico));
SetIcon(icon_small);
#endif
m_taskBarIcon = new wxTaskBarIcon();
if (m_taskBarIcon->IsOk()) {
m_taskBarIcon->SetIcon(icon_small, _("ZRCola"));
m_taskBarIcon->Connect(wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEventHandler(wxZRColaFrame::OnTaskbarIconClick), NULL, this);
} else {
// Taskbar icon creation failed. Not the end of the world. No taskbar icon then.
delete m_taskBarIcon;
}
m_settings = new wxZRColaSettings(this);
wxPersistentRegisterAndRestore<wxZRColaSettings>(m_settings);
m_chrSelect = new wxZRColaCharSelect(this);
wxPersistentRegisterAndRestore<wxZRColaCharSelect>(m_chrSelect);
// Set focus.
m_panel->m_decomposed->SetFocus();
// Register global hotkey(s).
@@ -57,12 +109,30 @@ wxZRColaFrame::wxZRColaFrame() :
if (!RegisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE, wxMOD_WIN, VK_F6))
wxMessageBox(_("ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING);
#if defined(__WXMSW__)
// Register notification sink for language detection.
m_ulRefCount = 1;
m_tfSource = NULL;
ITfInputProcessorProfiles *pProfiles;
HRESULT hr = CoCreateInstance(CLSID_TF_InputProcessorProfiles, NULL, CLSCTX_INPROC_SERVER, IID_ITfInputProcessorProfiles, (LPVOID*)&pProfiles);
if(SUCCEEDED(hr)) {
hr = pProfiles->QueryInterface(IID_ITfSource, (LPVOID*)&m_tfSource);
if(SUCCEEDED(hr)) {
hr = m_tfSource->AdviseSink(IID_ITfLanguageProfileNotifySink, (ITfLanguageProfileNotifySink*)this, &m_dwCookie);
if (FAILED(hr) || m_dwCookie == -1) {
m_tfSource->Release();
m_tfSource = NULL;
}
}
pProfiles->Release();
}
#endif
// Register frame specific hotkey(s).
{
wxAcceleratorEntry entries[3];
entries[0].Set(wxACCEL_NORMAL, WXK_F5 , wxID_SEND_COMPOSED);
entries[1].Set(wxACCEL_NORMAL, WXK_F6 , wxID_SEND_DECOMPOSED);
entries[2].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_SEND_ABORT);
wxAcceleratorEntry entries[1];
entries[0].Set(wxACCEL_NORMAL, WXK_F4, wxID_FOCUS_CHARACTER_CATALOG);
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
}
}
@@ -70,9 +140,66 @@ wxZRColaFrame::wxZRColaFrame() :
wxZRColaFrame::~wxZRColaFrame()
{
#if defined(__WXMSW__)
if (m_tfSource) {
m_tfSource->UnadviseSink(m_dwCookie);
m_tfSource->Release();
}
#endif
// Unregister global hotkey(s).
UnregisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE);
UnregisterHotKey(wxZRColaHKID_INVOKE_COMPOSE);
if (m_chrSelect)
delete m_chrSelect;
if (m_settings)
delete m_settings;
if (m_taskBarIcon) {
m_taskBarIcon->Disconnect(wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEventHandler(wxZRColaFrame::OnTaskbarIconClick), NULL, this);
delete m_taskBarIcon;
}
// Save wxAuiManager's state before return to parent's destructor.
// Since the later calls m_mgr.UnInit() the regular persistence mechanism is useless to save wxAuiManager's state.
wxPersistentAuiManager((wxAuiManager*)&m_mgr).Save();
}
void wxZRColaFrame::OnExit(wxCommandEvent& event)
{
Close();
}
void wxZRColaFrame::OnForwardEventUpdate(wxUpdateUIEvent& event)
{
wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl);
if (focusWnd && focusWnd->IsKindOf(wxCLASSINFO(wxTextCtrl)))
focusWnd->GetEventHandler()->ProcessEvent(event);
else
event.Enable(false);
}
void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event)
{
wxControl *focusWnd = wxDynamicCast(FindFocus(), wxControl);
if (focusWnd)
focusWnd->GetEventHandler()->ProcessEvent(event);
else
event.Skip();
}
void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event)
{
if (m_chrSelect->ShowModal() == wxID_OK && m_chrSelect->m_char) {
m_panel->m_decomposed->WriteText(m_chrSelect->m_char);
m_panel->m_decomposed->SetFocus();
}
}
@@ -107,19 +234,106 @@ void wxZRColaFrame::OnSendAbort(wxCommandEvent& event)
::SetActiveWindow(m_hWndSource);
::SetForegroundWindow(m_hWndSource);
m_hWndSource = NULL;
// Select all input in composer to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll();
m_panel->m_composed->SelectAll();
}
// Select all input in composer to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll();
m_panel->m_composed->SelectAll();
event.Skip();
}
void wxZRColaFrame::OnExit(wxCommandEvent& event)
void wxZRColaFrame::OnSettings(wxCommandEvent& event)
{
Close();
m_settings->ShowModal();
}
void wxZRColaFrame::OnIdle(wxIdleEvent& event)
{
m_panel->SynchronizePanels();
event.Skip();
}
void wxZRColaFrame::OnTaskbarIconClick(wxTaskBarIconEvent& event)
{
Iconize(false);
Show(true);
Raise();
event.Skip();
}
void wxZRColaFrame::OnIconize(wxIconizeEvent& event)
{
if (m_taskBarIcon)
Show(!event.IsIconized());
event.Skip();
}
void wxZRColaFrame::OnToolbarEditUpdate(wxUpdateUIEvent& event)
{
event.Check(m_mgr.GetPane(m_toolbarEdit).IsShown());
}
void wxZRColaFrame::OnToolbarEdit(wxCommandEvent& event)
{
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarEdit);
paneInfo.Show(!paneInfo.IsShown());
m_mgr.Update();
}
void wxZRColaFrame::OnToolbarComposeUpdate(wxUpdateUIEvent& event)
{
event.Check(m_mgr.GetPane(m_toolbarCompose).IsShown());
}
void wxZRColaFrame::OnToolbarCompose(wxCommandEvent& event)
{
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose);
paneInfo.Show(!paneInfo.IsShown());
m_mgr.Update();
}
void wxZRColaFrame::OnPanelCharacterCatalogUpdate(wxUpdateUIEvent& event)
{
event.Check(m_mgr.GetPane(m_panelChrCat).IsShown());
}
void wxZRColaFrame::OnPanelCharacterCatalog(wxCommandEvent& event)
{
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_panelChrCat);
paneInfo.Show(!paneInfo.IsShown());
m_mgr.Update();
}
void wxZRColaFrame::OnPanelCharacterCatalogFocus(wxCommandEvent& event)
{
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_panelChrCat);
if (!paneInfo.IsShown()) {
paneInfo.Show(true);
m_mgr.Update();
}
m_panelChrCat->SetFocus();
}
void wxZRColaFrame::OnHelpReqChar(wxCommandEvent& event)
{
wxLaunchDefaultBrowser(_("http://zrcola-2.amebis.si/en/contact/"));
}
@@ -129,27 +343,84 @@ void wxZRColaFrame::OnAbout(wxCommandEvent& event)
}
#if defined(__WXMSW__)
HRESULT STDMETHODCALLTYPE wxZRColaFrame::OnLanguageChange(LANGID langid, __RPC__out BOOL *pfAccept)
{
if (pfAccept) *pfAccept = TRUE;
return S_OK;
}
HRESULT STDMETHODCALLTYPE wxZRColaFrame::OnLanguageChanged()
{
if (m_settings->m_lang_auto) {
// Set keyboard language.
HKL hkl = ::GetKeyboardLayout(0);
ZRCola::LangConvert(LOWORD(hkl), m_settings->m_lang);
}
return S_OK;
}
HRESULT STDMETHODCALLTYPE wxZRColaFrame::QueryInterface(REFIID riid, __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject)
{
if (!ppvObject)
return E_INVALIDARG;
if (riid == IID_IUnknown)
*ppvObject = static_cast<IUnknown*>(this);
else if (riid == IID_ITfLanguageProfileNotifySink)
*ppvObject = static_cast<ITfLanguageProfileNotifySink*>(this);
else {
*ppvObject = NULL;
return E_NOINTERFACE;
}
AddRef();
return NOERROR;
}
ULONG STDMETHODCALLTYPE wxZRColaFrame::AddRef()
{
InterlockedIncrement(&m_ulRefCount);
return m_ulRefCount;
}
ULONG STDMETHODCALLTYPE wxZRColaFrame::Release()
{
// Decrement the object's internal counter.
ULONG ulRefCount = InterlockedDecrement(&m_ulRefCount);
if (m_ulRefCount == 0)
delete this;
return ulRefCount;
}
#endif
void wxZRColaFrame::DoSend(const wxString& str)
{
// Prepare the INPUT table.
wxString::size_type n = str.length();
wxString::const_iterator i_str = str.begin();
std::vector<INPUT> input(n);
std::vector<INPUT> input;
input.reserve(n*2);
for (std::vector<INPUT>::size_type i = 0; i < n; i++, i_str++) {
wxString::char_type c = *i_str;
INPUT &inp = input[i];
inp.type = INPUT_KEYBOARD;
inp.ki.dwFlags = KEYEVENTF_UNICODE;
inp.ki.time = 0;
inp.ki.dwExtraInfo = 0;
if (c == L'\n') {
// Enter (Return) key is sent as CR virtual key code.
inp.ki.wVk = VK_RETURN;
inp.ki.wScan = L'\r';
} else {
inp.ki.wVk = 0;
inp.ki.wScan = c;
}
// Add key down event.
INPUT inp = { INPUT_KEYBOARD };
inp.ki.dwFlags = KEYEVENTF_UNICODE;
inp.ki.wScan = c != L'\n' ? c : L'\r'; // Enter (Return) key is sent as CR.
input.push_back(inp);
// Add key up event.
inp.ki.dwFlags |= KEYEVENTF_KEYUP;
input.push_back(inp);
}
// Return focus to the source window and send the input.
@@ -165,6 +436,8 @@ void wxZRColaFrame::DoSend(const wxString& str)
}
#ifdef __WXMSW__
WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam)
{
if (message == WM_HOTKEY) {
@@ -210,3 +483,38 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM
} else
return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam);
}
#endif
//////////////////////////////////////////////////////////////////////////
// wxPersistentZRColaFrame
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaFrame::wxPersistentZRColaFrame(wxZRColaFrame *wnd) : wxPersistentTLW(wnd)
{
}
void wxPersistentZRColaFrame::Save() const
{
const wxZRColaFrame * const wnd = static_cast<const wxZRColaFrame*>(GetWindow());
wxPersistentZRColaComposerPanel(wnd->m_panel).Save();
wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Save();
wxPersistentTLW::Save();
}
bool wxPersistentZRColaFrame::Restore()
{
const bool r = wxPersistentTLW::Restore();
wxZRColaFrame * const wnd = static_cast<wxZRColaFrame*>(GetWindow());
wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Restore();
wxPersistentZRColaComposerPanel(wnd->m_panel).Restore();
return r;
}

View File

@@ -17,7 +17,6 @@
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Forward declarations
///
@@ -27,6 +26,14 @@ class wxZRColaFrame;
#pragma once
#include "zrcolagui.h"
#include "zrcolachrslct.h"
#include "zrcolasettings.h"
#include <zrcola/language.h>
#include <wx/taskbar.h>
#include <wx/persist/toplevel.h>
#if defined(__WXMSW__)
#include <msctf.h>
#endif
///
@@ -39,34 +46,94 @@ class wxZRColaFrame;
///
/// ZRCola main frame
///
class wxZRColaFrame : public wxZRColaFrameBase
class wxZRColaFrame :
public wxZRColaFrameBase
#if defined(__WXMSW__)
, protected ITfLanguageProfileNotifySink
#endif
{
protected:
enum {
wxID_SEND_COMPOSED = wxID_HIGHEST,
wxID_SEND_DECOMPOSED,
wxID_SEND_ABORT,
public:
enum
{
wxID_FOCUS_CHARACTER_CATALOG = 2000,
};
public:
wxZRColaFrame();
virtual ~wxZRColaFrame();
friend class wxPersistentZRColaFrame;
friend class wxZRColaComposerPanel;
protected:
void OnExit(wxCommandEvent& event);
void OnForwardEventUpdate(wxUpdateUIEvent& event);
void OnForwardEvent(wxCommandEvent& event);
void OnInsertCharacter(wxCommandEvent& event);
void OnSendUpdate(wxUpdateUIEvent& event);
void OnSendComposed(wxCommandEvent& event);
void OnSendDecomposed(wxCommandEvent& event);
void OnSendAbort(wxCommandEvent& event);
void OnExit(wxCommandEvent& event);
void OnSettings(wxCommandEvent& event);
virtual void OnIdle(wxIdleEvent& event);
void OnTaskbarIconClick(wxTaskBarIconEvent& event);
virtual void OnIconize(wxIconizeEvent& event);
void OnToolbarEditUpdate(wxUpdateUIEvent& event);
void OnToolbarEdit(wxCommandEvent& event);
void OnToolbarComposeUpdate(wxUpdateUIEvent& event);
void OnToolbarCompose(wxCommandEvent& event);
void OnPanelCharacterCatalogUpdate(wxUpdateUIEvent& event);
void OnPanelCharacterCatalog(wxCommandEvent& event);
void OnPanelCharacterCatalogFocus(wxCommandEvent& event);
void OnHelpReqChar(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE();
protected:
#if defined(__WXMSW__)
ITfSource *m_tfSource; ///< Text Services install sink helper
DWORD m_dwCookie; ///< Text Services installed sink cookie
// ITfLanguageProfileNotifySink implementation
virtual HRESULT STDMETHODCALLTYPE OnLanguageChange(LANGID langid, __RPC__out BOOL *pfAccept);
virtual HRESULT STDMETHODCALLTYPE OnLanguageChanged();
// IUnknown implementation
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, __RPC__deref_out void __RPC_FAR *__RPC_FAR *ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef();
virtual ULONG STDMETHODCALLTYPE Release();
ULONG m_ulRefCount; ///< COM object reference count
#endif
private:
void DoSend(const wxString& str);
protected:
#ifdef __WXMSW__
virtual WXLRESULT MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam);
#endif
protected:
WXHWND m_hWndSource; ///< handle of the active window, when the ZRCola hotkey was pressed
WXHWND m_hWndSource; ///< Handle of the active window, when the ZRCola hotkey was pressed
wxTaskBarIcon *m_taskBarIcon; ///< Taskbar icon
wxZRColaCharSelect *m_chrSelect; ///< Character selection dialog
wxZRColaSettings *m_settings; ///< Configuration dialog
};
///
/// Supports saving/restoring wxZRColaFrame GUI state
///
class wxPersistentZRColaFrame : public wxPersistentTLW
{
public:
wxPersistentZRColaFrame(wxZRColaFrame *wnd);
virtual void Save() const;
virtual bool Restore();
};
inline wxPersistentObject *wxCreatePersistentObject(wxZRColaFrame *wnd)
{
return new wxPersistentZRColaFrame(wnd);
}

View File

@@ -7,6 +7,8 @@
#include "stdafx.h"
#include "zrcolachrgrid.h"
#include "zrcolagui.h"
// Using the construction of a static object to ensure that the help provider is set
@@ -22,72 +24,295 @@ wxHelpProvider::Set( new wxHelpControllerHelpProvider );
static wxFBContextSensitiveHelpSetter s_wxFBSetTheHelpProvider;
///////////////////////////////////////////////////////////////////////////
wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxFrame( parent, id, title, pos, size, style, name )
{
this->SetSizeHints( wxSize( 150,150 ), wxDefaultSize );
m_mgr.SetManagedWindow(this);
m_mgr.SetFlags(wxAUI_MGR_DEFAULT);
m_menubar = new wxMenuBar( 0 );
m_menuFile = new wxMenu();
m_menuProgram = new wxMenu();
wxMenuItem* m_menuItemExit;
m_menuItemExit = new wxMenuItem( m_menuFile, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Alt+F4"), wxEmptyString, wxITEM_NORMAL );
m_menuFile->Append( m_menuItemExit );
m_menuItemExit = new wxMenuItem( m_menuProgram, wxID_EXIT, wxString( _("E&xit") ) + wxT('\t') + wxT("Alt+F4"), _("Quit this program"), wxITEM_NORMAL );
m_menuProgram->Append( m_menuItemExit );
m_menubar->Append( m_menuFile, _("&File") );
m_menubar->Append( m_menuProgram, _("&Program") );
m_menuEdit = new wxMenu();
wxMenuItem* m_menuItemEditCut;
m_menuItemEditCut = new wxMenuItem( m_menuEdit, wxID_CUT, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemEditCut->SetBitmaps( wxIcon( wxT("edit_cut.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemEditCut->SetBitmap( wxIcon( wxT("edit_cut.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemEditCut );
wxMenuItem* m_menuItemEditCopy;
m_menuItemEditCopy = new wxMenuItem( m_menuEdit, wxID_COPY, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemEditCopy->SetBitmaps( wxIcon( wxT("edit_copy.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemEditCopy->SetBitmap( wxIcon( wxT("edit_copy.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemEditCopy );
wxMenuItem* m_menuItemEditPaste;
m_menuItemEditPaste = new wxMenuItem( m_menuEdit, wxID_PASTE, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemEditPaste->SetBitmaps( wxIcon( wxT("edit_paste.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemEditPaste->SetBitmap( wxIcon( wxT("edit_paste.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemEditPaste );
m_menuEdit->AppendSeparator();
wxMenuItem* m_menuSelectAll;
m_menuSelectAll = new wxMenuItem( m_menuEdit, wxID_SELECTALL, wxString( _("Select &All") ) + wxT('\t') + wxT("Ctrl+A"), _("Select all text"), wxITEM_NORMAL );
m_menuEdit->Append( m_menuSelectAll );
m_menuEdit->AppendSeparator();
wxMenuItem* m_menuCharSelect;
m_menuCharSelect = new wxMenuItem( m_menuEdit, wxID_CHARACTER_SELECTOR, wxString( _("C&haracter Selector...") ) + wxT('\t') + wxT("F8"), _("Display character selector to select character to insert into text"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuCharSelect->SetBitmaps( wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuCharSelect->SetBitmap( wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuCharSelect );
m_menuEdit->AppendSeparator();
wxMenuItem* m_menuItemSendComposed;
m_menuItemSendComposed = new wxMenuItem( m_menuEdit, wxID_SEND_COMPOSED, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemSendComposed->SetBitmaps( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemSendComposed->SetBitmap( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemSendComposed );
wxMenuItem* m_menuItemSendDecomposed;
m_menuItemSendDecomposed = new wxMenuItem( m_menuEdit, wxID_SEND_DECOMPOSED, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemSendDecomposed->SetBitmaps( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemSendDecomposed->SetBitmap( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemSendDecomposed );
wxMenuItem* m_menuItemSendAbort;
m_menuItemSendAbort = new wxMenuItem( m_menuEdit, wxID_SEND_ABORT, wxString( _("Abort (De)composition") ) + wxT('\t') + wxT("Esc"), _("Abort composition and return focus to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemSendAbort->SetBitmaps( wxIcon( wxT("send_abort.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemSendAbort->SetBitmap( wxIcon( wxT("send_abort.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemSendAbort );
m_menuEdit->AppendSeparator();
wxMenuItem* m_menuSettings;
m_menuSettings = new wxMenuItem( m_menuEdit, wxID_SETTINGS, wxString( _("&Settings...") ) , _("Open program configuration dialog"), wxITEM_NORMAL );
m_menuEdit->Append( m_menuSettings );
m_menubar->Append( m_menuEdit, _("&Edit") );
m_menuView = new wxMenu();
wxMenuItem* m_menuItemToolbarEdit;
m_menuItemToolbarEdit = new wxMenuItem( m_menuView, wxID_TOOLBAR_EDIT, wxString( _("&Edit Toolbar") ) , _("Toggle edit toolbar"), wxITEM_CHECK );
m_menuView->Append( m_menuItemToolbarEdit );
wxMenuItem* m_menuItemToolbarCompose;
m_menuItemToolbarCompose = new wxMenuItem( m_menuView, wxID_TOOLBAR_COMPOSE, wxString( _("&Compose Toolbar") ) , _("Toggle compose toolbar"), wxITEM_CHECK );
m_menuView->Append( m_menuItemToolbarCompose );
m_menuView->AppendSeparator();
wxMenuItem* m_menuItemPanelChrGrps;
m_menuItemPanelChrGrps = new wxMenuItem( m_menuView, wxID_PANEL_CHRGRPS, wxString( _("Character Catalo&g") ) , _("Toggle character catalog panel"), wxITEM_CHECK );
m_menuView->Append( m_menuItemPanelChrGrps );
m_menubar->Append( m_menuView, _("&View") );
m_menuHelp = new wxMenu();
wxMenuItem* m_menuItemAbout;
m_menuItemAbout = new wxMenuItem( m_menuHelp, wxID_ABOUT, wxString( _("&About") ) , wxEmptyString, wxITEM_NORMAL );
m_menuHelp->Append( m_menuItemAbout );
wxMenuItem* m_menuHelpReqChar;
m_menuHelpReqChar = new wxMenuItem( m_menuHelp, wxID_HELP_REQCHAR, wxString( _("&Request a new character...") ) , _("Submit a request to ZRC to add a new character"), wxITEM_NORMAL );
m_menuHelp->Append( m_menuHelpReqChar );
m_menuHelp->AppendSeparator();
wxMenuItem* m_menuHelpAbout;
m_menuHelpAbout = new wxMenuItem( m_menuHelp, wxID_ABOUT, wxString( wxEmptyString ) , wxEmptyString, wxITEM_NORMAL );
m_menuHelp->Append( m_menuHelpAbout );
m_menubar->Append( m_menuHelp, _("&Help") );
this->SetMenuBar( m_menubar );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_toolbarEdit = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT );
m_toolEditCut = m_toolbarEdit->AddTool( wxID_CUT, _("Cut"), wxIcon( wxT("edit_cut.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Cut"), _("Cut selection"), NULL );
m_toolEditCopy = m_toolbarEdit->AddTool( wxID_COPY, _("Copy"), wxIcon( wxT("edit_copy.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Copy"), _("Copy selection"), NULL );
m_toolEditPaste = m_toolbarEdit->AddTool( wxID_PASTE, _("Paste"), wxIcon( wxT("edit_paste.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Paste"), _("Paste selection"), NULL );
m_toolbarEdit->Realize();
m_mgr.AddPane( m_toolbarEdit, wxAuiPaneInfo().Name( wxT("toolbarEdit") ).Top().Caption( _("Edit") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() );
m_toolbarCompose = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT );
m_toolCharSelect = m_toolbarCompose->AddTool( wxID_CHARACTER_SELECTOR, _("Character Selector"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Character Selector"), _("Display character selector to select character to insert into text"), NULL );
m_toolSendComposed = m_toolbarCompose->AddTool( wxID_SEND_COMPOSED, _("Send Composed"), wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Composed"), _("Send composed text to source window"), NULL );
m_toolSendDecomposed = m_toolbarCompose->AddTool( wxID_SEND_DECOMPOSED, _("Send Decomposed"), wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Decomposed"), _("Send decomposed text to source window"), NULL );
m_toolbarCompose->Realize();
m_mgr.AddPane( m_toolbarCompose, wxAuiPaneInfo().Name( wxT("toolbarCompose") ).Top().Caption( _("Compose") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() );
m_panelChrCat = new wxZRColaCharacterCatalogPanel( this );
m_mgr.AddPane( m_panelChrCat, wxAuiPaneInfo() .Name( wxT("panelChrGrp") ).Left() .Caption( _("Character Catalog") ).PinButton( true ).Dock().Resizable().FloatingSize( wxDefaultSize ).Row( 1 ).BestSize( wxSize( 150,200 ) ).MinSize( wxSize( 100,100 ) ).Layer( 1 ) );
m_panel = new wxZRColaComposerPanel( this );
bSizerMain->Add( m_panel, 100, wxEXPAND, 5 );
m_mgr.AddPane( m_panel, wxAuiPaneInfo() .Name( wxT("composerPanel") ).Center() .Caption( _("(De)Composer") ).CaptionVisible( false ).CloseButton( false ).PaneBorder( false ).Dock().Resizable().FloatingSize( wxDefaultSize ).Floatable( false ) );
m_statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
this->SetSizer( bSizerMain );
this->Layout();
m_mgr.Update();
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) );
this->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) );
}
wxZRColaFrameBase::~wxZRColaFrameBase()
{
// Disconnect Events
this->Disconnect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) );
this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) );
m_mgr.UnInit();
}
wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : wxPanel( parent, id, pos, size, style )
wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizerEditor;
bSizerEditor = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_decomposed = new wxTextCtrl( this, wxID_DECOMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE );
m_splitterDecomposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterDecomposed->SetSashGravity( 1 );
m_splitterDecomposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this );
m_splitterDecomposed->SetMinimumPaneSize( 5 );
m_panelDecomposedEdit = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedEdit;
bSizerDecomposedEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedEdit2;
bSizerDecomposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL );
m_decomposed = new wxTextCtrl( bSizerDecomposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_decomposed->SetMinSize( wxSize( 100,25 ) );
bSizerEditor->Add( m_decomposed, 50, wxALL|wxEXPAND, 5 );
bSizerDecomposedEdit2->Add( m_decomposed, 1, wxEXPAND, 5 );
m_composed = new wxTextCtrl( this, wxID_COMPOSED, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE );
bSizerDecomposedEdit->Add( bSizerDecomposedEdit2, 1, wxEXPAND, 5 );
m_panelDecomposedEdit->SetSizer( bSizerDecomposedEdit );
m_panelDecomposedEdit->Layout();
bSizerDecomposedEdit->Fit( m_panelDecomposedEdit );
m_panelDecomposedHex = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedHex;
bSizerDecomposedHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedHex2;
bSizerDecomposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL );
m_decomposedHex = new wxTextCtrl( bSizerDecomposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_decomposedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
bSizerDecomposedHex2->Add( m_decomposedHex, 1, wxEXPAND, 5 );
bSizerDecomposedHex->Add( bSizerDecomposedHex2, 1, wxEXPAND, 5 );
m_panelDecomposedHex->SetSizer( bSizerDecomposedHex );
m_panelDecomposedHex->Layout();
bSizerDecomposedHex->Fit( m_panelDecomposedHex );
m_splitterDecomposed->SplitVertically( m_panelDecomposedEdit, m_panelDecomposedHex, -5 );
bSizerMain->Add( m_splitterDecomposed, 50, wxALL|wxEXPAND, 5 );
m_splitterComposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterComposed->SetSashGravity( 1 );
m_splitterComposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this );
m_splitterComposed->SetMinimumPaneSize( 5 );
m_panelComposedEdit = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedEdit;
bSizerComposedEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedEdit2;
bSizerComposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL );
m_composed = new wxTextCtrl( bSizerComposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_composed->SetMinSize( wxSize( 100,25 ) );
bSizerEditor->Add( m_composed, 50, wxALL|wxEXPAND, 5 );
bSizerComposedEdit2->Add( m_composed, 1, wxEXPAND, 5 );
this->SetSizer( bSizerEditor );
bSizerComposedEdit->Add( bSizerComposedEdit2, 1, wxEXPAND, 5 );
m_panelComposedEdit->SetSizer( bSizerComposedEdit );
m_panelComposedEdit->Layout();
bSizerComposedEdit->Fit( m_panelComposedEdit );
m_panelComposedHex = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedHex;
bSizerComposedHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedHex2;
bSizerComposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL );
m_composedHex = new wxTextCtrl( bSizerComposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_composedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
bSizerComposedHex2->Add( m_composedHex, 1, wxEXPAND, 5 );
bSizerComposedHex->Add( bSizerComposedHex2, 1, wxEXPAND, 5 );
m_panelComposedHex->SetSizer( bSizerComposedHex );
m_panelComposedHex->Layout();
bSizerComposedHex->Fit( m_panelComposedHex );
m_splitterComposed->SplitVertically( m_panelComposedEdit, m_panelComposedHex, -5 );
bSizerMain->Add( m_splitterComposed, 50, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain );
this->Layout();
bSizerEditor->Fit( this );
bSizerMain->Fit( this );
m_timerSave.SetOwner( this, wxID_TIMER_SAVE );
// Connect Events
m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this );
m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this );
m_decomposedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this );
m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
}
wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
@@ -95,7 +320,417 @@ wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
// Disconnect Events
m_decomposed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this );
m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this );
m_decomposedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this );
m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
}
wxZRColaCharacterCatalogPanelBase::wxZRColaCharacterCatalogPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name )
{
wxBoxSizer* bSizer;
bSizer = new wxBoxSizer( wxVERTICAL );
wxArrayString m_choiceChoices;
m_choice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choiceChoices, 0 );
m_choice->SetSelection( 0 );
bSizer->Add( m_choice, 0, wxALL|wxEXPAND, 5 );
m_grid = new wxZRColaCharGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_grid->CreateGrid( 0, 0 );
m_grid->EnableEditing( false );
m_grid->EnableGridLines( false );
m_grid->EnableDragGridSize( false );
m_grid->SetMargins( 0, 0 );
// Columns
m_grid->EnableDragColMove( false );
m_grid->EnableDragColSize( false );
m_grid->SetColLabelSize( 0 );
m_grid->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_grid->EnableDragRowSize( false );
m_grid->SetRowLabelSize( 0 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_grid->SetDefaultCellBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
m_grid->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_grid->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_grid->SetMinSize( wxSize( 35,35 ) );
bSizer->Add( m_grid, 1, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizer );
this->Layout();
bSizer->Fit( this );
// Connect Events
m_choice->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( wxZRColaCharacterCatalogPanelBase::OnChoice ), NULL, this );
m_grid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( wxZRColaCharacterCatalogPanelBase::OnGridClick ), NULL, this );
m_grid->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharacterCatalogPanelBase::OnGridKeyDown ), NULL, this );
}
wxZRColaCharacterCatalogPanelBase::~wxZRColaCharacterCatalogPanelBase()
{
// Disconnect Events
m_choice->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( wxZRColaCharacterCatalogPanelBase::OnChoice ), NULL, this );
m_grid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( wxZRColaCharacterCatalogPanelBase::OnGridClick ), NULL, this );
m_grid->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharacterCatalogPanelBase::OnGridKeyDown ), NULL, this );
}
wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxDialog( parent, id, title, pos, size, style, name )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizerContent;
bSizerContent = new wxBoxSizer( wxVERTICAL );
wxBoxSizer* bSizerColumns;
bSizerColumns = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* bSizerLeft;
bSizerLeft = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerBrowse;
sbSizerBrowse = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("&Browse") ), wxVERTICAL );
m_search = new wxSearchCtrl( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
#ifndef __WXMAC__
m_search->ShowSearchButton( true );
#endif
m_search->ShowCancelButton( true );
sbSizerBrowse->Add( m_search, 0, wxALL|wxEXPAND, 5 );
wxArrayString m_categoriesChoices;
m_categories = new wxCheckListBox( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,60 ), m_categoriesChoices, 0 );
sbSizerBrowse->Add( m_categories, 0, wxALL|wxEXPAND, 5 );
m_gridResults = new wxZRColaCharGrid( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxSTATIC_BORDER );
// Grid
m_gridResults->CreateGrid( 0, 0 );
m_gridResults->EnableEditing( false );
m_gridResults->EnableGridLines( false );
m_gridResults->EnableDragGridSize( false );
m_gridResults->SetMargins( 0, 0 );
// Columns
m_gridResults->EnableDragColMove( false );
m_gridResults->EnableDragColSize( false );
m_gridResults->SetColLabelSize( 0 );
m_gridResults->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridResults->EnableDragRowSize( false );
m_gridResults->SetRowLabelSize( 0 );
m_gridResults->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridResults->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridResults->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_gridResults->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_gridResults->SetMinSize( wxSize( 560,35 ) );
m_gridResults->SetMaxSize( wxSize( 560,-1 ) );
sbSizerBrowse->Add( m_gridResults, 1, wxALL|wxEXPAND, 5 );
bSizerLeft->Add( sbSizerBrowse, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerRecent;
sbSizerRecent = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&cently Used") ), wxVERTICAL );
m_gridRecent = new wxZRColaCharGrid( sbSizerRecent->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,35 ), wxSTATIC_BORDER );
// Grid
m_gridRecent->CreateGrid( 0, 0 );
m_gridRecent->EnableEditing( false );
m_gridRecent->EnableGridLines( false );
m_gridRecent->EnableDragGridSize( false );
m_gridRecent->SetMargins( 0, 0 );
// Columns
m_gridRecent->EnableDragColMove( false );
m_gridRecent->EnableDragColSize( false );
m_gridRecent->SetColLabelSize( 0 );
m_gridRecent->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridRecent->EnableDragRowSize( false );
m_gridRecent->SetRowLabelSize( 0 );
m_gridRecent->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridRecent->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridRecent->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_gridRecent->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
sbSizerRecent->Add( m_gridRecent, 0, wxALL|wxEXPAND, 5 );
bSizerLeft->Add( sbSizerRecent, 0, wxALL|wxEXPAND, 5 );
bSizerColumns->Add( bSizerLeft, 1, wxEXPAND, 5 );
wxBoxSizer* bSizerRight;
bSizerRight = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* sbSizerPreview;
sbSizerPreview = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Preview") ), wxVERTICAL );
wxBoxSizer* bSizerUnicode;
bSizerUnicode = new wxBoxSizer( wxHORIZONTAL );
m_labelUnicode = new wxStaticText( sbSizerPreview->GetStaticBox(), wxID_ANY, _("U+"), wxDefaultPosition, wxDefaultSize, 0 );
m_labelUnicode->Wrap( -1 );
bSizerUnicode->Add( m_labelUnicode, 0, wxALIGN_CENTER, 5 );
m_unicode = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50,-1 ), 0 );
bSizerUnicode->Add( m_unicode, 0, wxALIGN_CENTER, 5 );
sbSizerPreview->Add( bSizerUnicode, 0, wxALIGN_CENTER|wxALL, 5 );
m_gridPreview = new wxGrid( sbSizerPreview->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSTATIC_BORDER );
// Grid
m_gridPreview->CreateGrid( 1, 1 );
m_gridPreview->EnableEditing( false );
m_gridPreview->EnableGridLines( false );
m_gridPreview->EnableDragGridSize( false );
m_gridPreview->SetMargins( 0, 0 );
// Columns
m_gridPreview->SetColSize( 0, 200 );
m_gridPreview->EnableDragColMove( false );
m_gridPreview->EnableDragColSize( false );
m_gridPreview->SetColLabelSize( 0 );
m_gridPreview->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridPreview->SetRowSize( 0, 200 );
m_gridPreview->EnableDragRowSize( false );
m_gridPreview->SetRowLabelSize( 0 );
m_gridPreview->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridPreview->SetDefaultCellFont( wxFont( 120, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridPreview->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_gridPreview->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
sbSizerPreview->Add( m_gridPreview, 0, wxALL|wxEXPAND, 5 );
m_description = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_READONLY );
sbSizerPreview->Add( m_description, 1, wxALL|wxEXPAND, 5 );
m_category = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_READONLY );
sbSizerPreview->Add( m_category, 0, wxALL|wxEXPAND, 5 );
bSizerRight->Add( sbSizerPreview, 70, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerRelated;
sbSizerRelated = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&lated") ), wxVERTICAL );
m_gridRelated = new wxZRColaCharGrid( sbSizerRelated->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxSTATIC_BORDER );
// Grid
m_gridRelated->CreateGrid( 0, 0 );
m_gridRelated->EnableEditing( false );
m_gridRelated->EnableGridLines( false );
m_gridRelated->EnableDragGridSize( false );
m_gridRelated->SetMargins( 0, 0 );
// Columns
m_gridRelated->EnableDragColMove( false );
m_gridRelated->EnableDragColSize( false );
m_gridRelated->SetColLabelSize( 0 );
m_gridRelated->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_gridRelated->EnableDragRowSize( false );
m_gridRelated->SetRowLabelSize( 0 );
m_gridRelated->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_gridRelated->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridRelated->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
sbSizerRelated->Add( m_gridRelated, 1, wxALL|wxEXPAND, 5 );
bSizerRight->Add( sbSizerRelated, 30, wxALL|wxEXPAND, 5 );
bSizerColumns->Add( bSizerRight, 0, wxEXPAND, 5 );
bSizerContent->Add( bSizerColumns, 1, wxEXPAND, 5 );
bSizerContent->Add( 5, 5, 0, wxALL|wxEXPAND, 5 );
m_sdbSizerButtons = new wxStdDialogButtonSizer();
m_sdbSizerButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK );
m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel );
m_sdbSizerButtons->Realize();
bSizerContent->Add( m_sdbSizerButtons, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerContent );
this->Layout();
bSizerContent->Fit( this );
// Connect Events
this->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaCharSelectBase::OnIdle ) );
m_search->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this );
m_categories->Connect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( wxZRColaCharSelectBase::OnCategoriesToggle ), NULL, this );
m_gridResults->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnResultCellDClick ), NULL, this );
m_gridResults->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this );
m_gridResults->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnResultsKeyDown ), NULL, this );
m_gridRecent->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentCellDClick ), NULL, this );
m_gridRecent->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this );
m_gridRecent->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnRecentKeyDown ), NULL, this );
m_unicode->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this );
m_gridRelated->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this );
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaCharSelectBase::OnOKButtonClick ), NULL, this );
}
wxZRColaCharSelectBase::~wxZRColaCharSelectBase()
{
// Disconnect Events
this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaCharSelectBase::OnIdle ) );
m_search->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this );
m_categories->Disconnect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( wxZRColaCharSelectBase::OnCategoriesToggle ), NULL, this );
m_gridResults->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnResultCellDClick ), NULL, this );
m_gridResults->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this );
m_gridResults->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnResultsKeyDown ), NULL, this );
m_gridRecent->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentCellDClick ), NULL, this );
m_gridRecent->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this );
m_gridRecent->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnRecentKeyDown ), NULL, this );
m_unicode->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this );
m_gridRelated->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this );
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaCharSelectBase::OnOKButtonClick ), NULL, this );
}
wxZRColaSettingsBase::wxZRColaSettingsBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxDialog( parent, id, title, pos, size, style, name )
{
this->SetSizeHints( wxDefaultSize, wxSize( -1,-1 ) );
wxBoxSizer* bSizerContent;
bSizerContent = new wxBoxSizer( wxVERTICAL );
m_listbook = new wxListbook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLB_DEFAULT );
m_panelLanguage = new wxPanel( m_listbook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerLanguage;
bSizerLanguage = new wxBoxSizer( wxVERTICAL );
m_langLabel = new wxStaticText( m_panelLanguage, wxID_ANY, _("Some character native to specific language you are working with should not decompose to primitives.\nFor optimal decomposition you should set the language correctly."), wxDefaultPosition, wxDefaultSize, 0 );
m_langLabel->Wrap( -1 );
bSizerLanguage->Add( m_langLabel, 0, wxALL|wxEXPAND, 5 );
m_langAuto = new wxRadioButton( m_panelLanguage, wxID_ANY, _("Select language &automatically according to selected keyboard"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
bSizerLanguage->Add( m_langAuto, 0, wxALL|wxEXPAND, 5 );
m_langManual = new wxRadioButton( m_panelLanguage, wxID_ANY, _("&Manually select the language from the list below:"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerLanguage->Add( m_langManual, 0, wxALL|wxEXPAND, 5 );
m_languages = new wxListBox( m_panelLanguage, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_languages->SetMinSize( wxSize( -1,150 ) );
bSizerLanguage->Add( m_languages, 1, wxALL|wxEXPAND, 5 );
m_panelLanguage->SetSizer( bSizerLanguage );
m_panelLanguage->Layout();
bSizerLanguage->Fit( m_panelLanguage );
m_listbook->AddPage( m_panelLanguage, _("Text Language"), true );
m_panelAutoStart = new wxPanel( m_listbook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerAutoStart;
bSizerAutoStart = new wxBoxSizer( wxVERTICAL );
m_autoStartLabel = new wxStaticText( m_panelAutoStart, wxID_ANY, _("ZRCola can be launched every time you log in to your computer.\nIt will be available on the system tray and via registered shortcuts Win+F5 and Win+F6."), wxDefaultPosition, wxDefaultSize, 0 );
m_autoStartLabel->Wrap( -1 );
bSizerAutoStart->Add( m_autoStartLabel, 0, wxALL|wxEXPAND, 5 );
m_autoStart = new wxCheckBox( m_panelAutoStart, wxID_ANY, _("Start ZRCola &automatically on logon"), wxDefaultPosition, wxDefaultSize, 0 );
bSizerAutoStart->Add( m_autoStart, 0, wxALL|wxEXPAND, 5 );
m_panelAutoStart->SetSizer( bSizerAutoStart );
m_panelAutoStart->Layout();
bSizerAutoStart->Fit( m_panelAutoStart );
m_listbook->AddPage( m_panelAutoStart, _("Startup"), false );
#ifdef __WXGTK__ // Small icon style not supported in GTK
wxListView* m_listbookListView = m_listbook->GetListView();
long m_listbookFlags = m_listbookListView->GetWindowStyleFlag();
if( m_listbookFlags & wxLC_SMALL_ICON )
{
m_listbookFlags = ( m_listbookFlags & ~wxLC_SMALL_ICON ) | wxLC_ICON;
}
m_listbookListView->SetWindowStyleFlag( m_listbookFlags );
#endif
bSizerContent->Add( m_listbook, 1, wxEXPAND | wxALL, 5 );
bSizerContent->Add( 0, 0, 0, wxALL|wxEXPAND, 5 );
m_sdbSizerButtons = new wxStdDialogButtonSizer();
m_sdbSizerButtonsOK = new wxButton( this, wxID_OK );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK );
m_sdbSizerButtonsApply = new wxButton( this, wxID_APPLY );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsApply );
m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL );
m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel );
m_sdbSizerButtons->Realize();
bSizerContent->Add( m_sdbSizerButtons, 0, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerContent );
this->Layout();
bSizerContent->Fit( this );
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( wxZRColaSettingsBase::OnInitDialog ) );
m_langAuto->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxZRColaSettingsBase::OnLangAuto ), NULL, this );
m_langManual->Connect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxZRColaSettingsBase::OnLangManual ), NULL, this );
m_sdbSizerButtonsApply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaSettingsBase::OnApplyButtonClick ), NULL, this );
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaSettingsBase::OnOKButtonClick ), NULL, this );
}
wxZRColaSettingsBase::~wxZRColaSettingsBase()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( wxZRColaSettingsBase::OnInitDialog ) );
m_langAuto->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxZRColaSettingsBase::OnLangAuto ), NULL, this );
m_langManual->Disconnect( wxEVT_COMMAND_RADIOBUTTON_SELECTED, wxCommandEventHandler( wxZRColaSettingsBase::OnLangManual ), NULL, this );
m_sdbSizerButtonsApply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaSettingsBase::OnApplyButtonClick ), NULL, this );
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaSettingsBase::OnOKButtonClick ), NULL, this );
}

View File

@@ -12,6 +12,8 @@
#include <wx/xrc/xmlres.h>
#include <wx/cshelp.h>
#include <wx/intl.h>
class wxZRColaCharGrid;
#include <wx/string.h>
#include <wx/bitmap.h>
#include <wx/image.h>
@@ -21,11 +23,30 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include "zrcolacomppnl.h"
#include <wx/sizer.h>
#include <wx/aui/aui.h>
#include <wx/aui/auibar.h>
class wxZRColaCharacterCatalogPanel;
class wxZRColaComposerPanel;
#include <wx/statusbr.h>
#include <wx/frame.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/panel.h>
#include <wx/splitter.h>
#include <wx/timer.h>
#include <wx/choice.h>
#include <wx/grid.h>
#include <wx/srchctrl.h>
#include <wx/checklst.h>
#include <wx/stattext.h>
#include <wx/button.h>
#include <wx/dialog.h>
#include <wx/radiobut.h>
#include <wx/listbox.h>
#include <wx/checkbox.h>
#include <wx/listbook.h>
#include <wx/listctrl.h>
///////////////////////////////////////////////////////////////////////////
@@ -37,14 +58,45 @@ class wxZRColaFrameBase : public wxFrame
private:
protected:
enum
{
wxID_CHARACTER_SELECTOR = 1000,
wxID_SEND_COMPOSED,
wxID_SEND_DECOMPOSED,
wxID_SEND_ABORT,
wxID_SETTINGS,
wxID_TOOLBAR_EDIT,
wxID_TOOLBAR_COMPOSE,
wxID_PANEL_CHRGRPS,
wxID_HELP_REQCHAR
};
wxMenuBar* m_menubar;
wxMenu* m_menuFile;
wxMenu* m_menuProgram;
wxMenu* m_menuEdit;
wxMenu* m_menuView;
wxMenu* m_menuHelp;
wxZRColaComposerPanel* m_panel;
wxAuiToolBar* m_toolbarEdit;
wxAuiToolBarItem* m_toolEditCut;
wxAuiToolBarItem* m_toolEditCopy;
wxAuiToolBarItem* m_toolEditPaste;
wxAuiToolBar* m_toolbarCompose;
wxAuiToolBarItem* m_toolCharSelect;
wxAuiToolBarItem* m_toolSendComposed;
wxAuiToolBarItem* m_toolSendDecomposed;
wxZRColaCharacterCatalogPanel* m_panelChrCat;
wxStatusBar* m_statusBar;
// Virtual event handlers, overide them in your derived class
virtual void OnIconize( wxIconizeEvent& event ) { event.Skip(); }
virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); }
public:
wxZRColaComposerPanel* m_panel;
wxZRColaFrameBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("ZRCola"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,400 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL );
wxZRColaFrameBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("ZRCola"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 600,400 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL, const wxString& name = wxT("ZRCola") );
wxAuiManager m_mgr;
~wxZRColaFrameBase();
@@ -60,24 +112,152 @@ class wxZRColaComposerPanelBase : public wxPanel
protected:
enum
{
wxID_DECOMPOSED = 1000,
wxID_COMPOSED
wxID_TIMER_SAVE = 1000
};
wxTextCtrl* m_decomposed;
wxTextCtrl* m_composed;
wxSplitterWindow* m_splitterDecomposed;
wxPanel* m_panelDecomposedEdit;
wxPanel* m_panelDecomposedHex;
wxTextCtrl* m_decomposedHex;
wxSplitterWindow* m_splitterComposed;
wxPanel* m_panelComposedEdit;
wxPanel* m_panelComposedHex;
wxTextCtrl* m_composedHex;
wxTimer m_timerSave;
// Virtual event handlers, overide them in your derived class
virtual void OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDecomposedHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); }
public:
wxTextCtrl* m_decomposed;
wxTextCtrl* m_composed;
wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxT("ZRColaComposerPanel") );
~wxZRColaComposerPanelBase();
void m_splitterDecomposedOnIdle( wxIdleEvent& )
{
m_splitterDecomposed->SetSashPosition( -5 );
m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this );
}
void m_splitterComposedOnIdle( wxIdleEvent& )
{
m_splitterComposed->SetSashPosition( -5 );
m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this );
}
};
///////////////////////////////////////////////////////////////////////////////
/// Class wxZRColaCharacterCatalogPanelBase
///////////////////////////////////////////////////////////////////////////////
class wxZRColaCharacterCatalogPanelBase : public wxPanel
{
private:
protected:
wxChoice* m_choice;
wxZRColaCharGrid* m_grid;
// Virtual event handlers, overide them in your derived class
virtual void OnChoice( wxCommandEvent& event ) { event.Skip(); }
virtual void OnGridClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnGridKeyDown( wxKeyEvent& event ) { event.Skip(); }
public:
wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL );
~wxZRColaComposerPanelBase();
wxZRColaCharacterCatalogPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxT("ZRColaCharacterCatalog") );
~wxZRColaCharacterCatalogPanelBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class wxZRColaCharSelectBase
///////////////////////////////////////////////////////////////////////////////
class wxZRColaCharSelectBase : public wxDialog
{
private:
protected:
wxSearchCtrl* m_search;
wxCheckListBox* m_categories;
wxZRColaCharGrid* m_gridResults;
wxZRColaCharGrid* m_gridRecent;
wxStaticText* m_labelUnicode;
wxTextCtrl* m_unicode;
wxGrid* m_gridPreview;
wxTextCtrl* m_description;
wxTextCtrl* m_category;
wxZRColaCharGrid* m_gridRelated;
wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); }
virtual void OnSearchText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCategoriesToggle( wxCommandEvent& event ) { event.Skip(); }
virtual void OnResultCellDClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnResultSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnResultsKeyDown( wxKeyEvent& event ) { event.Skip(); }
virtual void OnRecentCellDClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnRecentSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnRecentKeyDown( wxKeyEvent& event ) { event.Skip(); }
virtual void OnUnicodeText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRelatedSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Character Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("ZRColaCharSelect") );
~wxZRColaCharSelectBase();
};
///////////////////////////////////////////////////////////////////////////////
/// Class wxZRColaSettingsBase
///////////////////////////////////////////////////////////////////////////////
class wxZRColaSettingsBase : public wxDialog
{
private:
protected:
wxListbook* m_listbook;
wxPanel* m_panelLanguage;
wxStaticText* m_langLabel;
wxRadioButton* m_langAuto;
wxRadioButton* m_langManual;
wxListBox* m_languages;
wxPanel* m_panelAutoStart;
wxStaticText* m_autoStartLabel;
wxCheckBox* m_autoStart;
wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsApply;
wxButton* m_sdbSizerButtonsCancel;
// Virtual event handlers, overide them in your derived class
virtual void OnInitDialog( wxInitDialogEvent& event ) { event.Skip(); }
virtual void OnLangAuto( wxCommandEvent& event ) { event.Skip(); }
virtual void OnLangManual( wxCommandEvent& event ) { event.Skip(); }
virtual void OnApplyButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
wxZRColaSettingsBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Settings"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("ZRColaSettings") );
~wxZRColaSettingsBase();
};

View File

@@ -24,29 +24,10 @@
// wxZRColaKeyHandler
//////////////////////////////////////////////////////////////////////////
wxZRColaKeyHandler::wxZRColaKeyHandler() : wxEvtHandler()
wxZRColaKeyHandler::wxZRColaKeyHandler() :
m_is_insert(false),
wxEvtHandler()
{
std::fstream dat((LPCTSTR)((ZRColaApp*)wxTheApp)->GetDatabasePath(), std::ios_base::in | std::ios_base::binary);
if (dat.good()) {
if (stdex::idrec::find<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat, ZRCOLA_DB_ID, sizeof(ZRCola::recordid_t))) {
ZRCola::recordsize_t size;
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
if (dat.good()) {
ZRCola::keyseq_rec rec(m_ks_db);
if (rec.find(dat, size)) {
dat >> rec;
if (!dat.good()) {
wxFAIL_MSG(wxT("Error reading translation data from ZRCola.zrcdb."));
m_ks_db.idxChr.clear();
m_ks_db.idxKey.clear();
m_ks_db.data .clear();
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb has no translation data."));
}
} else
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
}
@@ -54,52 +35,134 @@ bool wxZRColaKeyHandler::ProcessEvent(wxEvent& event)
{
if (event.GetEventType() == wxEVT_KEY_DOWN) {
// The character event occured.
ZRCola::keyseq_db::indexKey::size_type start, end;
bool found;
wxKeyEvent &e = (wxKeyEvent&)event;
if (e.GetKeyCode() == WXK_INSERT) {
// Insert key has been pressed.
m_is_insert = true;
wxFrame *pFrame = wxDynamicCast(((ZRColaApp*)wxTheApp)->m_mainWnd, wxFrame);
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(_("INS key is pressed. Type the Unicode code of desired character now (up to four hexadecimal digits: 0-9, A-F), then release INS."));
} else if (m_is_insert) {
wxChar chr = e.GetUnicodeKey();
wxFrame *pFrame = wxDynamicCast(((ZRColaApp*)wxTheApp)->m_mainWnd, wxFrame);
if (('0' <= chr && chr <= '9' || 'A' <= chr && chr <= 'F') && m_insert_seq.size() < 4) {
// A hex-digit pressed. Save it.
m_insert_seq.push_back((char)chr);
{
// Parse key event and save it at the end of the key sequence.
wxKeyEvent &e = (wxKeyEvent&)event;
ZRCola::keyseq_db::keyseq::key_t key;
key.key = e.GetKeyCode(); //wxToupper(e.m_uniChar);
key.modifiers =
(e.ShiftDown() ? ZRCola::keyseq_db::keyseq::SHIFT : 0) |
(e.ControlDown() ? ZRCola::keyseq_db::keyseq::CTRL : 0) |
(e.AltDown() ? ZRCola::keyseq_db::keyseq::ALT : 0);
m_seq.push_back(key);
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(wxString::Format(wxT("U+%s"), (const wxStringCharType*)wxString(m_insert_seq.data(), m_insert_seq.size())));
std::vector<ZRCola::keyseq_db::keyseq::key_t>::size_type n = m_seq.size();
ZRCola::keyseq_db::keyseq *ks = (ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(ZRCola::keyseq_db::keyseq::key_t)*n];
ks->chr = 0;
ks->seq_len = n;
memcpy(ks->seq, m_seq.data(), sizeof(ZRCola::keyseq_db::keyseq::key_t)*n);
found = m_ks_db.idxKey.find(*ks, start, end);
delete ks;
}
if (found) {
// The exact key sequence found.
const ZRCola::keyseq_db::keyseq &ks = m_ks_db.idxKey[start];
m_seq.clear();
wxObject *obj = event.GetEventObject();
if (obj && obj->IsKindOf(wxCLASSINFO(wxTextCtrl))) {
// Push text to source control.
((wxTextCtrl*)obj)->WriteText(ks.chr);
// Event is fully processed now.
event.StopPropagation();
return true;
} else {
// Not a hex-digit.
m_is_insert = false;
m_insert_seq.clear();
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(wxEmptyString);
}
} else if (start < m_ks_db.idxKey.size() &&
ZRCola::keyseq_db::keyseq::CompareSequence(m_seq.data(), m_seq.size(), m_ks_db.idxKey[start].seq, std::min<unsigned __int16>(m_ks_db.idxKey[start].seq_len, m_seq.size())) == 0)
} else if ((e.GetUnicodeKey() || !e.HasAnyModifiers())
#if defined(__WXMSW__)
&& ::GetKeyState(VK_RMENU) >= 0
#endif
)
{
// The sequence is a partial match. Continue watching.
//event.StopPropagation();
//return true;
} else {
// The key sequence has no future chance to match. Start all over again.
m_seq.clear();
ZRColaApp *app = (ZRColaApp*)wxTheApp;
ZRCola::keyseq_db::indexKey::size_type start;
bool found;
wxFrame *pFrame = wxDynamicCast(app->m_mainWnd, wxFrame);
{
// Parse key event and save it at the end of the key sequence.
ZRCola::keyseq_db::keyseq::key_t key;
key.key = e.GetRawKeyCode();
#if defined(__WXMSW__)
// Translate from local keyboard to scan code.
key.key = ::MapVirtualKey(key.key, MAPVK_VK_TO_VSC);
// Translate from scan code to U.S. Keyboard.
static const HKL s_hkl = ::LoadKeyboardLayout(_T("00000409"), 0);
key.key = ::MapVirtualKeyEx(key.key, MAPVK_VSC_TO_VK, s_hkl);
#endif
key.modifiers =
(e.ShiftDown() ? ZRCola::keyseq_db::keyseq::SHIFT : 0) |
(e.ControlDown() ? ZRCola::keyseq_db::keyseq::CTRL : 0) |
(e.AltDown() ? ZRCola::keyseq_db::keyseq::ALT : 0);
m_seq.push_back(key);
std::vector<ZRCola::keyseq_db::keyseq::key_t>::size_type n = m_seq.size();
ZRCola::keyseq_db::keyseq *ks = (ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq) + sizeof(ZRCola::keyseq_db::keyseq::key_t)*n];
ks->chr = 0;
ks->seq_len = n;
memcpy(ks->seq, m_seq.data(), sizeof(ZRCola::keyseq_db::keyseq::key_t)*n);
found = app->m_ks_db.idxKey.find(*ks, start);
delete ks;
}
if (found) {
// The exact key sequence found.
const ZRCola::keyseq_db::keyseq &ks = app->m_ks_db.idxKey[start];
m_seq.clear();
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(wxEmptyString);
wxObject *obj = event.GetEventObject();
if (obj && obj->IsKindOf(wxCLASSINFO(wxTextCtrl))) {
// Push text to source control.
((wxTextCtrl*)obj)->WriteText(ks.chr);
// Event is fully processed now.
event.StopPropagation();
return true;
}
} else if (start < app->m_ks_db.idxKey.size() &&
ZRCola::keyseq_db::keyseq::CompareSequence(m_seq.data(), m_seq.size(), app->m_ks_db.idxKey[start].seq, std::min<unsigned __int16>(app->m_ks_db.idxKey[start].seq_len, m_seq.size())) == 0)
{
// The sequence is a partial match. Continue watching.
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(ZRCola::keyseq_db::GetSequenceAsText(m_seq.data(), m_seq.size()));
event.StopPropagation();
return true;
} else {
// The key sequence has no future chance to match. Start all over again.
m_seq.clear();
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(wxEmptyString);
}
}
} else if (event.GetEventType() == wxEVT_KEY_UP) {
wxKeyEvent &e = (wxKeyEvent&)event;
if (m_is_insert && e.GetKeyCode() == WXK_INSERT) {
// Insert key has been depressed.
wxFrame *pFrame = wxDynamicCast(((ZRColaApp*)wxTheApp)->m_mainWnd, wxFrame);
if (pFrame && pFrame->GetStatusBar())
pFrame->SetStatusText(wxEmptyString);
std::vector<char>::size_type count = m_insert_seq.size();
if (count) {
// Zero terminate sequence and parse the Unicode value.
m_insert_seq.push_back(0);
wchar_t chr = strtoul(m_insert_seq.data(), NULL, 16);
if (chr) {
wxObject *obj = event.GetEventObject();
if (obj && obj->IsKindOf(wxCLASSINFO(wxTextCtrl))) {
// Push text to source control.
((wxTextCtrl*)obj)->WriteText(chr);
}
}
m_insert_seq.clear();
}
m_is_insert = false;
event.StopPropagation();
return true;
}
}

View File

@@ -25,7 +25,6 @@ class wxZRColaKeyHandler;
#pragma once
#include <zrcolaui/keyboard.h>
#include <wx/event.h>
#include <vector>
@@ -41,6 +40,7 @@ public:
virtual bool ProcessEvent(wxEvent& event);
protected:
ZRCola::keyseq_db m_ks_db; ///< Key sequence database
std::vector<ZRCola::keyseq_db::keyseq::key_t> m_seq; ///< Key sequence
bool m_is_insert; ///< Is Insert key pressed?
std::vector<char> m_insert_seq; ///< The Insert char sequence
};

190
ZRCola/zrcolasettings.cpp Normal file
View File

@@ -0,0 +1,190 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
//////////////////////////////////////////////////////////////////////////
// wxZRColaSettings
//////////////////////////////////////////////////////////////////////////
wxZRColaSettings::wxZRColaSettings(wxWindow* parent) :
m_lang_auto(true),
m_lang(ZRCola::langid_t_blank),
wxZRColaSettingsBase(parent)
{
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
m_languages->Clear();
for (size_t i = 0, n = app->m_lang_db.idxLng.size(); i < n; i++) {
const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[i];
wxString
label(lang.name, lang.name_len),
label_tran(wxGetTranslation(label, wxT("ZRCola-zrcdb")));
m_languages->Insert(label_tran, i);
}
}
void wxZRColaSettings::OnInitDialog(wxInitDialogEvent& event)
{
event.Skip();
// Set state of auto-start according to Startup folder shortcut presence.
#if defined(__WXMSW__)
wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk"));
m_autoStart->SetValue(wxFileExists(linkName));
#else
m_autoStart->SetValue(false);
m_panelAutoStart->Enable(false);
#endif
m_languages->Enable(!m_lang_auto);
(m_lang_auto ? m_langAuto : m_langManual)->SetValue(true);
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
char l[sizeof(ZRCola::language_db::language)] = {};
((ZRCola::language_db::language*)l)->id = m_lang;
ZRCola::language_db::indexLang::size_type start;
m_languages->Select(app->m_lang_db.idxLng.find(*(ZRCola::language_db::language*)l, start) ? start : -1);
}
void wxZRColaSettings::OnLangAuto(wxCommandEvent& event)
{
m_languages->Enable(!event.IsChecked());
}
void wxZRColaSettings::OnLangManual(wxCommandEvent& event)
{
m_languages->Enable(event.IsChecked());
}
void wxZRColaSettings::OnApplyButtonClick(wxCommandEvent& event)
{
event.Skip();
#if defined(__WXMSW__)
wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk"));
if (m_autoStart->IsChecked()) {
// Create the shortcut.
IShellLink *sl;
HRESULT hr = ::CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (LPVOID*)&sl);
if (SUCCEEDED(hr)) {
// Setup ZRCola shortcut.
sl->SetPath(wxTheApp->argv[0]);
sl->SetDescription(_("Start ZRCola automatically on logon"));
sl->SetShowCmd(SW_SHOWMINNOACTIVE);
// Query IShellLink for the IPersistFile interface, used for saving the
// shortcut in persistent storage.
IPersistFile *pf;
hr = sl->QueryInterface(IID_IPersistFile, (LPVOID*)&pf);
if (SUCCEEDED(hr)) {
// Save the link by calling IPersistFile::Save.
hr = pf->Save(linkName, TRUE);
pf->Release();
}
sl->Release();
}
} else if (wxFileExists(linkName)) {
// The shortcut already exists. Remove it.
wxRemoveFile(linkName);
}
#endif
if (m_langAuto->GetValue()) {
m_lang_auto = true;
#if defined(__WXMSW__)
// Set update keyboard language.
HKL hkl = ::GetKeyboardLayout(0);
ZRCola::LangConvert(LOWORD(hkl), m_lang);
#endif
} else {
m_lang_auto = false;
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[m_languages->GetSelection()];
if (m_lang != lang.id) {
m_lang = lang.id;
// Notify composed text something changed and should re-decompose.
wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED);
app->m_mainWnd->m_panel->m_composed->ProcessWindowEvent(event2);
}
}
}
void wxZRColaSettings::OnOKButtonClick(wxCommandEvent& event)
{
wxZRColaSettings::OnApplyButtonClick(event);
}
//////////////////////////////////////////////////////////////////////////
// wxPersistentZRColaSettings
//////////////////////////////////////////////////////////////////////////
wxPersistentZRColaSettings::wxPersistentZRColaSettings(wxZRColaSettings *wnd) : wxPersistentDialog(wnd)
{
}
void wxPersistentZRColaSettings::Save() const
{
wxPersistentDialog::Save();
const wxZRColaSettings * const wnd = static_cast<const wxZRColaSettings*>(GetWindow());
SaveValue(wxT("langAuto"), wnd->m_lang_auto);
SaveValue(wxT("lang" ), wxString::FromAscii(wnd->m_lang.data, _countof(wnd->m_lang.data)));
}
bool wxPersistentZRColaSettings::Restore()
{
wxZRColaSettings * const wnd = static_cast<wxZRColaSettings*>(GetWindow());
ZRColaApp *app = ((ZRColaApp*)wxTheApp);
wxString lang;
// Restore automatic language detection setting first.
RestoreValue(wxT("langAuto"), &(wnd->m_lang_auto));
if (wnd->m_lang_auto) {
#if defined(__WXMSW__)
// Set keyboard language.
HKL hkl = ::GetKeyboardLayout(0);
ZRCola::LangConvert(LOWORD(hkl), wnd->m_lang);
#endif
} else if (RestoreValue(wxT("lang"), &lang) && lang.Length() == 3) {
// The language was read from configuration.
wnd->m_lang = lang.c_str();
} else if (!app->m_lang_db.idxLng.empty()) {
const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[0];
wnd->m_lang = lang.id;
} else
wnd->m_lang = ZRCola::langid_t_blank;
return wxPersistentDialog::Restore();
}

72
ZRCola/zrcolasettings.h Normal file
View File

@@ -0,0 +1,72 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
///
/// Forward declarations
///
class wxZRColaSettings;
class wxPersistentZRColaSettings;
#pragma once
#include "zrcolagui.h"
#include <wxex/persist/dialog.h>
///
/// Configuration dialog
///
class wxZRColaSettings : public wxZRColaSettingsBase
{
public:
wxZRColaSettings(wxWindow* parent);
friend class wxPersistentZRColaSettings; // Allow saving/restoring window state.
protected:
virtual void OnInitDialog(wxInitDialogEvent& event);
virtual void OnLangAuto(wxCommandEvent& event);
virtual void OnLangManual(wxCommandEvent& event);
virtual void OnApplyButtonClick(wxCommandEvent& event);
virtual void OnOKButtonClick(wxCommandEvent& event);
public:
bool m_lang_auto; ///< Is language for decomposing resolved using currently selected keyboard
ZRCola::langid_t m_lang; ///< Language for decomposing
};
///
/// Supports saving/restoring wxZRColaSettings state
///
class wxPersistentZRColaSettings : public wxPersistentDialog
{
public:
wxPersistentZRColaSettings(wxZRColaSettings *wnd);
virtual void Save() const;
virtual bool Restore();
};
inline wxPersistentObject *wxCreatePersistentObject(wxZRColaSettings *wnd)
{
return new wxPersistentZRColaSettings(wnd);
}

View File

@@ -20,6 +20,94 @@
#include "stdafx.h"
bool ZRCola::DBSource::character_desc_idx::add_keywords(const wchar_t *str, wchar_t chr, size_t sub)
{
wxASSERT_MSG(str, wxT("string is NULL"));
while (*str) {
// Skip white space.
for (;;) {
if (*str == 0)
return true;
else if (!iswspace(*str))
break;
else
str++;
}
// Get term.
std::wstring term;
if (*str == L'"') {
const wchar_t *str_end = ++str;
for (;;) {
if (*str_end == 0) {
term.assign(str, str_end);
break;
} else if (*str_end == L'"') {
term.assign(str, str_end);
str_end++;
break;
} else
str_end++;
}
str = str_end;
} else {
const wchar_t *str_end = str + 1;
for (; *str_end && !iswspace(*str_end); str_end++);
term.assign(str, str_end);
str = str_end;
}
if (!term.empty()) {
std::transform(term.begin(), term.end(), term.begin(), std::towlower);
if (sub) {
std::wstring::size_type j_end = term.size();
if (j_end >= sub) {
// Insert all keyword substrings "sub" or more characters long.
for (std::wstring::size_type i = 0, i_end = j_end - sub; i <= i_end; ++i) {
for (std::wstring::size_type j = i + sub; j <= j_end; ++j)
add_keyword(term.substr(i, j - i), chr);
}
}
} else {
// Insert exact keyword only.
add_keyword(term, chr);
}
}
}
return true;
}
void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const
{
idx .clear();
idx.keys .clear();
idx.values.clear();
// Pre-allocate memory.
std::vector<wchar_t>::size_type size_keys = 0;
std::vector<wchar_t>::size_type size_values = 0;
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
size_keys += i->first.size();
size_values += i->second.size();
}
idx .reserve(size() );
idx.keys .reserve(size_keys );
idx.values.reserve(size_values);
// Convert the index.
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
ZRCola::mappair_t<unsigned __int32> p = { idx.keys.size(), idx.values.size() };
idx.push_back(p);
idx.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.cend());
idx.values.insert(idx.values.end(), i->second.cbegin(), i->second.cend());
}
}
ZRCola::DBSource::DBSource()
{
}
@@ -27,6 +115,12 @@ ZRCola::DBSource::DBSource()
ZRCola::DBSource::~DBSource()
{
if (m_pCharacterGroup1)
m_pCharacterGroup1.Release();
if (m_comCharacterGroup)
m_comCharacterGroup.Release();
if (m_db)
m_db->Close();
@@ -53,6 +147,23 @@ bool ZRCola::DBSource::Open(LPCTSTR filename)
// Database open and ready.
m_filename = filename;
m_locale = _create_locale(LC_ALL, "Slovenian_Slovenia.1250");
wxASSERT_MSG(!m_comCharacterGroup, wxT("ADO command already created"));
// Create ADO command(s).
wxVERIFY(SUCCEEDED(::CoCreateInstance(CLSID_CADOCommand, NULL, CLSCTX_ALL, IID_IADOCommand, (LPVOID*)&m_comCharacterGroup)));
wxVERIFY(SUCCEEDED(m_comCharacterGroup->put_ActiveConnection(ATL::CComVariant(m_db))));
wxVERIFY(SUCCEEDED(m_comCharacterGroup->put_CommandType(adCmdText)));
wxVERIFY(SUCCEEDED(m_comCharacterGroup->put_CommandText(ATL::CComBSTR(L"SELECT [Znak] FROM [VRS_SkupineZnakov] WHERE [Skupina]=? ORDER BY [Rang] ASC, [Znak] ASC"))));
{
// Create and add command parameters.
ATL::CComPtr<ADOParameters> params;
wxVERIFY(SUCCEEDED(m_comCharacterGroup->get_Parameters(&params)));
wxASSERT_MSG(!m_pCharacterGroup1, wxT("ADO command parameter already created"));
wxVERIFY(SUCCEEDED(m_comCharacterGroup->CreateParameter(ATL::CComBSTR(L"@Skupina"), adVarWChar, adParamInput, 50, ATL::CComVariant(DISP_E_PARAMNOTFOUND, VT_ERROR), &m_pCharacterGroup1)));
wxVERIFY(SUCCEEDED(params->Append(m_pCharacterGroup1)));
}
return true;
} else {
_ftprintf(stderr, wxT("%s: error ZCC0011: Could not open database (0x%x).\n"), (LPCTSTR)filename, hr);
@@ -99,32 +210,81 @@ void ZRCola::DBSource::LogErrors() const
}
bool ZRCola::DBSource::GetValue(const ATL::CComPtr<ADOField>& f, bool& val) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxCHECK(SUCCEEDED(v.ChangeType(VT_BOOL)), false);
val = V_BOOL(&v) ? true : false;
return true;
}
bool ZRCola::DBSource::GetValue(const ATL::CComPtr<ADOField>& f, int& val) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxCHECK(SUCCEEDED(v.ChangeType(VT_I4)), false);
val = V_I4(&v);
return true;
}
bool ZRCola::DBSource::GetValue(const ATL::CComPtr<ADOField>& f, std::wstring& val) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
if (V_VT(&v) != VT_NULL) {
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
val.reserve(::SysStringLen(V_BSTR(&v)));
val = V_BSTR(&v);
} else
val.empty();
return true;
}
bool ZRCola::DBSource::GetUnicodeCharacter(const ATL::CComPtr<ADOField>& f, wchar_t& chr) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
if (V_VT(&v) != VT_NULL) {
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
// Parse the field. Must be exactly one Unicode code.
wxVERIFY(SUCCEEDED(v.ChangeType(VT_BSTR)));
UINT i = 0, n = ::SysStringLen(V_BSTR(&v));
chr = 0;
for (; i < n && V_BSTR(&v)[i]; i++) {
if (L'0' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'9') chr = chr*0x10 + (V_BSTR(&v)[i] - L'0');
else if (L'A' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'F') chr = chr*0x10 + (V_BSTR(&v)[i] - L'A' + 10);
else if (L'a' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'f') chr = chr*0x10 + (V_BSTR(&v)[i] - L'a' + 10);
else break;
}
if (i <= 0 && 4 < i) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0030: Syntax error in \"%.*ls\" field (\"%.*ls\"). Unicode code must be one to four hexadecimal characters long.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
} else if (i != n) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0031: Syntax error in \"%.*ls\" field (\"%.*ls\"). Extra trailing characters.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
// Parse the field. Must be exactly one Unicode code.
UINT i = 0, n = ::SysStringLen(V_BSTR(&v));
chr = 0;
for (; i < n && V_BSTR(&v)[i]; i++) {
if (L'0' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'9') chr = chr*0x10 + (V_BSTR(&v)[i] - L'0');
else if (L'A' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'F') chr = chr*0x10 + (V_BSTR(&v)[i] - L'A' + 10);
else if (L'a' <= V_BSTR(&v)[i] && V_BSTR(&v)[i] <= L'f') chr = chr*0x10 + (V_BSTR(&v)[i] - L'a' + 10);
else break;
}
if (i <= 0 && 4 < i) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0030: Syntax error in \"%.*ls\" field (\"%.*ls\"). Unicode code must be one to four hexadecimal characters long.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
} else if (i != n) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0031: Syntax error in \"%.*ls\" field (\"%.*ls\"). Extra trailing characters.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
} else
chr = 0;
return true;
}
@@ -136,9 +296,9 @@ bool ZRCola::DBSource::GetUnicodeString(const ATL::CComPtr<ADOField>& f, std::ws
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
// Parse the field. Must be "xxxx+xxxx+xxxx..." sequence.
wxVERIFY(SUCCEEDED(v.ChangeType(VT_BSTR)));
str.clear();
for (UINT i = 0, n = ::SysStringLen(V_BSTR(&v)); i < n && V_BSTR(&v)[i];) {
// Parse Unicode code.
@@ -165,59 +325,125 @@ bool ZRCola::DBSource::GetUnicodeString(const ATL::CComPtr<ADOField>& f, std::ws
}
bool ZRCola::DBSource::GetKeySequence(const ATL::CComPtr<ADOField>& f, std::vector<keyseq::keycode>& seq) const
bool ZRCola::DBSource::GetKeyCode(const ATL::CComPtr<ADOField>& f, ZRCola::DBSource::keyseq::keycode& kc) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxVERIFY(SUCCEEDED(v.ChangeType(VT_BSTR)));
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
// Convert to uppercase.
_wcsupr_l(V_BSTR(&v), m_locale);
// Parse the field. Must be comma delimited sequence of key codes.
seq.clear();
// Parse the field.
memset(&kc, 0, sizeof(kc));
for (UINT i = 0, n = ::SysStringLen(V_BSTR(&v)); i < n && V_BSTR(&v)[i];) {
keyseq::keycode kc = {};
while (i < n && V_BSTR(&v)[i]) {
// Parse key code.
static const wchar_t str_shift[] = L"SHIFT+", str_ctrl[] = L"CTRL+", str_alt[] = L"ALT+";
if (i + _countof(str_shift) <= n && wmemcmp(V_BSTR(&v) + i, str_shift, _countof(str_shift) - 1) == 0) {
kc.shift = true;
i += _countof(str_shift) - 1;
} else if (i + _countof(str_ctrl) <= n && wmemcmp(V_BSTR(&v) + i, str_ctrl, _countof(str_ctrl) - 1) == 0) {
kc.ctrl = true;
i += _countof(str_ctrl) - 1;
} else if (i + _countof(str_alt) <= n && wmemcmp(V_BSTR(&v) + i, str_alt, _countof(str_alt) - 1) == 0) {
kc.alt = true;
i += _countof(str_alt) - 1;
} else {
kc.key = V_BSTR(&v)[i];
i++;
break;
// Parse key code.
if (i) {
// Check for "+" separator.
if (V_BSTR(&v)[i] != L'+') {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0070: Syntax error in \"%.*ls\" field (\"%.*ls\"). Key codes must be \"Ctrl+Alt+<key>\" formatted.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
}
i++;
if (i >= n || !V_BSTR(&v)[i]) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0071: Syntax error in \"%.*ls\" field (\"%.*ls\"). Trailing separator \"+\" found.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
}
}
if (i < n && V_BSTR(&v)[i] && V_BSTR(&v)[i] != L',' && !_iswspace_l(V_BSTR(&v)[i], m_locale)) {
static const wchar_t str_shift[] = L"SHIFT", str_ctrl[] = L"CTRL", str_alt[] = L"ALT";
if (i + _countof(str_shift) - 1 <= n && wmemcmp(V_BSTR(&v) + i, str_shift, _countof(str_shift) - 1) == 0) {
kc.shift = true;
i += _countof(str_shift) - 1;
} else if (i + _countof(str_ctrl) - 1 <= n && wmemcmp(V_BSTR(&v) + i, str_ctrl, _countof(str_ctrl) - 1) == 0) {
kc.ctrl = true;
i += _countof(str_ctrl) - 1;
} else if (i + _countof(str_alt) - 1 <= n && wmemcmp(V_BSTR(&v) + i, str_alt, _countof(str_alt) - 1) == 0) {
kc.alt = true;
i += _countof(str_alt) - 1;
} else {
kc.key = V_BSTR(&v)[i];
i++;
}
}
return true;
}
bool ZRCola::DBSource::GetLanguage(const ATL::CComPtr<ADOField>& f, ZRCola::langid_t& lang) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
// Convert to lowercase.
_wcslwr_l(V_BSTR(&v), m_locale);
// Parse the field.
size_t n = wcsnlen(V_BSTR(&v), ::SysStringLen(V_BSTR(&v)));
if (n != 3) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0060: Syntax error in \"%.*ls\" field (\"%.*ls\"). Key sequences must be \"Ctrl+Alt+<key>\" formatted, delimited by commas and/or space.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
_ftprintf(stderr, wxT("%s: error ZCC0080: Syntax error in \"%.*ls\" field (\"%.*ls\"). Language ID must be exactly three (3) characters long.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
if (seq.size() > 0xffff) {
_ftprintf(stderr, wxT("%s: warning ZCC0061: Key sequence \"%.*ls...\" too long. Ignored.\n"), (LPCTSTR)m_filename.c_str(), std::min<UINT>(n, 20), V_BSTR(&v));
return false;
}
seq.push_back(kc);
// Skip delimiter(s) and whitespace.
for (; i < n && V_BSTR(&v)[i] && (V_BSTR(&v)[i] == L',' || _iswspace_l(V_BSTR(&v)[i], m_locale)); i++);
}
for (size_t i = 0;; i++) {
if (i < sizeof(lang)) {
if (i < n) {
wchar_t c = V_BSTR(&v)[i];
if ((unsigned short)c > 0x7f) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0081: Syntax error in \"%.*ls\" field (\"%.*ls\"). Language ID must contain ASCII characters only.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
lang.data[i] = (char)c;
} else
lang.data[i] = 0;
} else
break;
}
if (seq.empty()) {
_ftprintf(stderr, wxT("%s: warning ZCC0062: Empty key sequence. Ignored.\n"), (LPCTSTR)m_filename.c_str());
return false;
}
return true;
}
bool ZRCola::DBSource::GetChrCat(const ATL::CComPtr<ADOField>& f, chrcatid_t& cc) const
{
wxASSERT_MSG(f, wxT("field is empty"));
ATL::CComVariant v;
wxVERIFY(SUCCEEDED(f->get_Value(&v)));
if (V_VT(&v) != VT_NULL) {
wxCHECK(SUCCEEDED(v.ChangeType(VT_BSTR)), false);
// Parse the field.
size_t n = wcsnlen(V_BSTR(&v), ::SysStringLen(V_BSTR(&v)));
if (n < 1 || 2 < n) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0110: Syntax error in \"%.*ls\" field (\"%.*ls\"). Character category ID must be one (1) or two (2) characters long.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
for (size_t i = 0;; i++) {
if (i < sizeof(cc)) {
if (i < n) {
wchar_t c = V_BSTR(&v)[i];
if ((unsigned short)c > 0x7f) {
ATL::CComBSTR fieldname; wxVERIFY(SUCCEEDED(f->get_Name(&fieldname)));
_ftprintf(stderr, wxT("%s: error ZCC0111: Syntax error in \"%.*ls\" field (\"%.*ls\"). Character category ID must contain ASCII characters only.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false;
}
cc.data[i] = (char)c;
} else
cc.data[i] = 0;
} else
break;
}
} else
memset(cc.data, 0, sizeof(cc));
return true;
}
@@ -230,7 +456,12 @@ bool ZRCola::DBSource::SelectTranslations(ATL::CComPtr<ADORecordset> &rs) const
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(L"SELECT [komb], [znak] FROM [VRS_ReplChar] WHERE [rang_komb]=1"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText))) {
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT [komb], [znak], [rang_znak] "
L"FROM [VRS_ReplChar] "
L"WHERE [rang_komb]=1 "
L"ORDER BY [znak], [rang_znak], [komb]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0040: Error loading compositions from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
@@ -259,6 +490,12 @@ bool ZRCola::DBSource::GetTranslation(const ATL::CComPtr<ADORecordset>& rs, ZRCo
wxCHECK(GetUnicodeCharacter(f, t.chr), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"rang_znak"), &f)));
wxCHECK(GetValue(f, t.rank), false);
}
return true;
}
@@ -270,7 +507,11 @@ bool ZRCola::DBSource::SelectKeySequences(ATL::CComPtr<ADORecordset> &rs) const
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(L"SELECT DISTINCT [Znak], [tipka] FROM [wrd_KeyCodes]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText))) {
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [VRS_KeyCodes].[Znak], [VRS_CharGroup].[Name] AS [CharGroup], [VRS_KeyCodes].[KeyCode], [VRS_KeyCodes].[Shift] "
L"FROM [VRS_KeyCodes] LEFT JOIN [VRS_CharGroup] ON [VRS_CharGroup].[CharGroup]=[VRS_KeyCodes].[CharGroup] "
L"ORDER BY [VRS_CharGroup].[Name], [VRS_KeyCodes].[KeyCode], [VRS_KeyCodes].[Shift], [VRS_KeyCodes].[Znak]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0050: Error loading key sequences from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
@@ -293,10 +534,334 @@ bool ZRCola::DBSource::GetKeySequence(const ATL::CComPtr<ADORecordset>& rs, ZRCo
wxCHECK(GetUnicodeCharacter(f, ks.chr), false);
}
keyseq::keycode kc1;
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"tipka"), &f)));
wxCHECK(GetKeySequence(f, ks.seq), false);
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"CharGroup"), &f)));
wxCHECK(GetKeyCode(f, kc1), false);
}
int keycode;
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"KeyCode"), &f)));
wxCHECK(GetValue(f, keycode), false);
}
bool shift;
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Shift"), &f)));
wxCHECK(GetValue(f, shift), false);
}
ks.seq.clear();
if (kc1.key) {
// First key in the sequence is complete.
ks.seq.push_back(kc1);
keyseq::keycode kc2 = { keycode, shift };
ks.seq.push_back(kc2);
} else {
// First key in the sequence is only modifier(s).
kc1.key = keycode;
if (shift) kc1.shift = true;
ks.seq.push_back(kc1);
}
return true;
}
bool ZRCola::DBSource::SelectLanguages(ATL::CComPtr<ADORecordset> &rs) const
{
// Create a new recordset.
if (rs) rs.Release();
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [entCode], [Jezik_En] "
L"FROM [VRS_Jezik] "
L"ORDER BY [entCode], [Jezik_En]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0060: Error loading languages from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
return true;
}
bool ZRCola::DBSource::GetLanguage(const ATL::CComPtr<ADORecordset>& rs, ZRCola::DBSource::language& lang) const
{
wxASSERT_MSG(rs, wxT("recordset is empty"));
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs->get_Fields(&flds)));
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"entCode"), &f)));
wxCHECK(GetLanguage(f, lang.id), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Jezik_En"), &f)));
wxCHECK(GetValue(f, lang.name), false);
}
return true;
}
bool ZRCola::DBSource::SelectLanguageCharacters(ATL::CComPtr<ADORecordset> &rs) const
{
// Create a new recordset.
if (rs) rs.Release();
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [znak], [lang] "
L"FROM [VRS_CharLocal] "
L"ORDER BY [znak], [lang]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0090: Error loading language characters from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
return true;
}
bool ZRCola::DBSource::GetLanguageCharacter(const ATL::CComPtr<ADORecordset>& rs, ZRCola::DBSource::langchar& lc) const
{
wxASSERT_MSG(rs, wxT("recordset is empty"));
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs->get_Fields(&flds)));
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"znak"), &f)));
wxCHECK(GetUnicodeCharacter(f, lc.chr), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"lang"), &f)));
wxCHECK(GetLanguage(f, lc.lang), false);
}
return true;
}
bool ZRCola::DBSource::SelectCharacterGroups(ATL::CComPtr<ADORecordset>& rs) const
{
// Create a new recordset.
if (rs) rs.Release();
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [id], [Skupina], [opis_en], [Rang] "
L"FROM [VRS_SkupinaZnakov] "
L"ORDER BY [Rang], [opis_en]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0090: Error loading character groups from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
return true;
}
bool ZRCola::DBSource::GetCharacterGroup(const ATL::CComPtr<ADORecordset>& rs, chrgrp& cg) const
{
wxASSERT_MSG(rs, wxT("recordset is empty"));
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs->get_Fields(&flds)));
std::wstring id;
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"id"), &f)));
wxCHECK(GetValue(f, cg.id), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Skupina"), &f)));
wxCHECK(GetValue(f, id), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Rang"), &f)));
wxCHECK(GetValue(f, cg.rank), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"opis_en"), &f)));
wxCHECK(GetValue(f, cg.name), false);
}
// Read character list from database.
wxVERIFY(SUCCEEDED(m_pCharacterGroup1->put_Value(ATL::CComVariant(id.c_str()))));
ATL::CComPtr<ADORecordset> rs_chars;
wxVERIFY(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs_chars)));
wxVERIFY(SUCCEEDED(rs_chars->put_CursorLocation(adUseClient)));
wxVERIFY(SUCCEEDED(rs_chars->put_CursorType(adOpenForwardOnly)));
wxVERIFY(SUCCEEDED(rs_chars->put_LockType(adLockReadOnly)));
if (FAILED(rs_chars->Open(ATL::CComVariant(m_comCharacterGroup), ATL::CComVariant(DISP_E_PARAMNOTFOUND, VT_ERROR)))) {
_ftprintf(stderr, wxT("%s: error ZCC0100: Error loading character group characters from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
{
cg.chars.clear();
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs_chars->get_Fields(&flds)));
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Znak"), &f)));
for (VARIANT_BOOL eof = VARIANT_TRUE; SUCCEEDED(rs_chars->get_EOF(&eof)) && !eof; rs_chars->MoveNext()) {
wchar_t c;
wxCHECK(GetUnicodeCharacter(f, c), false);
cg.chars += c;
}
}
return true;
}
bool ZRCola::DBSource::SelectCharacters(ATL::CComPtr<ADORecordset>& rs) const
{
// Create a new recordset.
if (rs) rs.Release();
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [znak], [opis_en], [klj_bes_en], [kat], [znak_v], [znak_m] "
L"FROM [VRS_CharList] "
L"ORDER BY [znak]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0120: Error loading characters from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
return true;
}
bool ZRCola::DBSource::GetCharacter(const ATL::CComPtr<ADORecordset>& rs, character& chr) const
{
wxASSERT_MSG(rs, wxT("recordset is empty"));
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs->get_Fields(&flds)));
wchar_t c;
chr.rel.clear();
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"znak"), &f)));
wxCHECK(GetUnicodeCharacter(f, chr.chr), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"znak_v"), &f)));
wxCHECK(GetUnicodeCharacter(f, c), false);
if (c && c != chr.chr)
chr.rel += c;
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"znak_m"), &f)));
wxCHECK(GetUnicodeCharacter(f, c), false);
if (c && c != chr.chr)
chr.rel += c;
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"opis_en"), &f)));
wxCHECK(GetValue(f, chr.desc), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"klj_bes_en"), &f)));
wxCHECK(GetValue(f, chr.keywords), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"kat"), &f)));
wxCHECK(GetChrCat(f, chr.cat), false);
}
return true;
}
bool ZRCola::DBSource::SelectCharacterCategories(ATL::CComPtr<ADORecordset>& rs) const
{
// Create a new recordset.
if (rs) rs.Release();
wxCHECK(SUCCEEDED(::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_ALL, IID_IADORecordset, (LPVOID*)&rs)), false);
// Open it.
if (FAILED(rs->Open(ATL::CComVariant(
L"SELECT DISTINCT [kat], [opis_en], [Rang] "
L"FROM [VRS_CharCategory] "
L"ORDER BY [Rang], [opis_en]"), ATL::CComVariant(m_db), adOpenStatic, adLockReadOnly, adCmdText)))
{
_ftprintf(stderr, wxT("%s: error ZCC0130: Error loading character categories from database. Please make sure the file is ZRCola.zrc compatible.\n"), m_filename.c_str());
LogErrors();
return false;
}
return true;
}
bool ZRCola::DBSource::GetCharacterCategory(const ATL::CComPtr<ADORecordset>& rs, chrcat& cc) const
{
wxASSERT_MSG(rs, wxT("recordset is empty"));
ATL::CComPtr<ADOFields> flds;
wxVERIFY(SUCCEEDED(rs->get_Fields(&flds)));
std::wstring id;
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"kat"), &f)));
wxCHECK(GetChrCat(f, cc.id), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"Rang"), &f)));
wxCHECK(GetValue(f, cc.rank), false);
}
{
ATL::CComPtr<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(ATL::CComVariant(L"opis_en"), &f)));
wxCHECK(GetValue(f, cc.name), false);
}
return true;

View File

@@ -19,8 +19,12 @@
#pragma once
#include <zrcola/character.h>
#include <zrcola/common.h>
#include <atlbase.h>
#include <adoint.h>
#include <map>
#include <string>
#include <vector>
@@ -37,8 +41,9 @@ namespace ZRCola {
///
class translation {
public:
wchar_t chr; ///< Composed character
std::wstring str; ///< Decomposed string
wchar_t chr; ///< Composed character
std::wstring str; ///< Decomposed string
int rank; ///< Decomposition rank
};
@@ -62,6 +67,118 @@ namespace ZRCola {
std::vector<keycode> seq; ///< Key sequence
};
///
/// Language
///
class language {
public:
ZRCola::langid_t id; ///< Language ID
std::wstring name; ///< Language name
};
///
/// Language Character
///
class langchar {
public:
wchar_t chr; ///> Character
ZRCola::langid_t lang; ///< Language ID
};
///
/// Character group
///
class chrgrp {
public:
int id; ///< Character group ID
int rank; ///< Character group rank
std::wstring name; ///< Character group name
std::wstring chars; ///< Character group characters
};
///
/// Character
///
class character {
public:
wchar_t chr; ///< Character
ZRCola::chrcatid_t cat; ///> Category ID
std::wstring desc; ///< Character description
std::wstring keywords; ///< Additional keywords
std::wstring rel; ///< Related characters
};
///
/// Character description index key comparator
///
struct character_desc_idx_less : public std::binary_function<std::wstring, std::wstring, bool>
{
inline bool operator()(const std::wstring& _Left, const std::wstring& _Right) const
{
size_t
_Left_len = _Left .size(),
_Right_len = _Right.size();
int r = _wcsncoll(_Left.c_str(), _Right.c_str(), std::min<size_t>(_Left_len, _Right_len));
if (r != 0 ) return r < 0;
else if (_Left_len < _Right_len) return true;
return false;
}
};
///
/// Character description index
///
class character_desc_idx : public std::map<std::wstring, std::vector<wchar_t>, character_desc_idx_less>
{
public:
bool add_keywords(const wchar_t *str, wchar_t chr, size_t sub = 0);
void save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const;
protected:
inline void add_keyword(const std::wstring &term, wchar_t chr)
{
iterator idx = find(term);
if (idx == end()) {
// New keyword.
insert(std::make_pair(term, std::vector<wchar_t>(1, chr)));
} else {
// Append to existing keyword.
std::vector<wchar_t> &val = idx->second;
for (std::vector<wchar_t>::iterator i = val.begin(), i_end = val.end(); ; ++i) {
if (i == i_end) {
// End-of-values reached. Append character.
val.push_back(chr);
break;
} else if (*i == chr) {
// Character already among the values.
break;
}
}
}
}
};
///
/// Character category
///
class chrcat {
public:
ZRCola::chrcatid_t id; ///> Category ID
int rank; ///< Character category rank
std::wstring name; ///< Character category name
};
public:
DBSource();
virtual ~DBSource();
@@ -115,6 +232,58 @@ namespace ZRCola {
}
///
/// Splits string to individual keywords
///
/// \param[in ] str String
/// \param[out] keywords Array of keywords
///
/// \returns
/// - true when successful
/// - false otherwise
///
static bool GetKeywords(const wchar_t *str, std::vector< std::wstring > &keywords);
///
/// Gets boolean from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] val Output boolean value
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetValue(const ATL::CComPtr<ADOField>& f, bool& val) const;
///
/// Gets integer from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] val Output integer value
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetValue(const ATL::CComPtr<ADOField>& f, int& val) const;
///
/// Gets string from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] val Output string value
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetValue(const ATL::CComPtr<ADOField>& f, std::wstring& val) const;
///
/// Gets encoded Unicode character from ZRCola.zrc database
///
@@ -142,16 +311,42 @@ namespace ZRCola {
///
/// Gets encoded key sequence from ZRCola.zrc database
/// Gets encoded key from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] seq Output sequence
/// \param[in] f Data field
/// \param[out] kc Output key code
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetKeySequence(const ATL::CComPtr<ADOField>& f, std::vector<keyseq::keycode>& seq) const;
bool GetKeyCode(const ATL::CComPtr<ADOField>& f, keyseq::keycode& kc) const;
///
/// Gets language ID from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] lang Language
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetLanguage(const ATL::CComPtr<ADOField>& f, langid_t& lang) const;
///
/// Gets character category ID from ZRCola.zrc database
///
/// \param[in] f Data field
/// \param[out] cc Character category
///
/// \returns
/// - true when successful
/// - false otherwise
///
bool GetChrCat(const ATL::CComPtr<ADOField>& f, chrcatid_t& cc) const;
///
@@ -203,9 +398,135 @@ namespace ZRCola {
///
bool GetKeySequence(const ATL::CComPtr<ADORecordset>& rs, keyseq& ks) const;
///
/// Returns languages
///
/// \param[out] rs Recordset with results
///
/// \returns
/// - true when query succeeds
/// - false otherwise
///
bool SelectLanguages(ATL::CComPtr<ADORecordset>& rs) const;
///
/// Returns language data
///
/// \param[in] rs Recordset with results
/// \param[out] lang Language
///
/// \returns
/// - true when succeeded
/// - false otherwise
///
bool GetLanguage(const ATL::CComPtr<ADORecordset>& rs, language& lang) const;
///
/// Returns language character
///
/// \param[out] rs Recordset with results
///
/// \returns
/// - true when query succeeds
/// - false otherwise
///
bool SelectLanguageCharacters(ATL::CComPtr<ADORecordset>& rs) const;
///
/// Returns language character data
///
/// \param[in] rs Recordset with results
/// \param[out] lang Language character data
///
/// \returns
/// - true when succeeded
/// - false otherwise
///
bool GetLanguageCharacter(const ATL::CComPtr<ADORecordset>& rs, langchar& lc) const;
///
/// Returns character groups
///
/// \param[out] rs Recordset with results
///
/// \returns
/// - true when query succeeds
/// - false otherwise
///
bool SelectCharacterGroups(ATL::CComPtr<ADORecordset>& rs) const;
///
/// Returns character group data
///
/// \param[in] rs Recordset with results
/// \param[out] cg Character group
///
/// \returns
/// - true when succeeded
/// - false otherwise
///
bool GetCharacterGroup(const ATL::CComPtr<ADORecordset>& rs, chrgrp& cg) const;
///
/// Returns characters
///
/// \param[out] rs Recordset with results
///
/// \returns
/// - true when query succeeds
/// - false otherwise
///
bool SelectCharacters(ATL::CComPtr<ADORecordset>& rs) const;
///
/// Returns character data
///
/// \param[in] rs Recordset with results
/// \param[out] chr Character
///
/// \returns
/// - true when succeeded
/// - false otherwise
///
bool GetCharacter(const ATL::CComPtr<ADORecordset>& rs, character& chr) const;
///
/// Returns character categories
///
/// \param[out] rs Recordset with results
///
/// \returns
/// - true when query succeeds
/// - false otherwise
///
bool SelectCharacterCategories(ATL::CComPtr<ADORecordset>& rs) const;
///
/// Returns character category data
///
/// \param[in] rs Recordset with results
/// \param[out] cc Character category
///
/// \returns
/// - true when succeeded
/// - false otherwise
///
bool GetCharacterCategory(const ATL::CComPtr<ADORecordset>& rs, chrcat& cc) const;
protected:
std::basic_string<TCHAR> m_filename; ///< Database filename
ATL::CComPtr<ADOConnection> m_db; ///< Database
_locale_t m_locale; ///< Database locale
ATL::CComPtr<ADOCommand> m_comCharacterGroup; ///< ADO Command for GetCharacterGroup subquery
ATL::CComPtr<ADOParameter> m_pCharacterGroup1; ///< \c m_comCharacterGroup parameter
};
};

View File

@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: ZRColaCompile\n"
"POT-Creation-Date: 2016-03-14 17:18+0100\n"
"PO-Revision-Date: 2016-03-14 17:18+0100\n"
"POT-Creation-Date: 2016-04-13 18:11+0200\n"
"PO-Revision-Date: 2016-04-13 18:11+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n"
@@ -17,14 +17,18 @@ msgstr ""
"X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n"
#: main.cpp:165
#: main.cpp:276
msgid "Show this help message"
msgstr "Pokaži to sporočilo pomoči"
#: main.cpp:166
msgid "input file"
msgstr "vhodna datoteka"
#: main.cpp:277
msgid "<input file>"
msgstr "<vhodna datoteka>"
#: main.cpp:167
msgid "output file"
msgstr "izhodna datoteka"
#: main.cpp:278
msgid "<output file>"
msgstr "<izhodna datoteka>"
#: main.cpp:279
msgid "<output POT catalog>"
msgstr "<izhodni katalog POT>"

View File

@@ -20,118 +20,6 @@
#include "stdafx.h"
///
/// Writes translation database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Translation database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(std::ostream& stream, const ZRCola::translation_db &db)
{
assert(db.idxComp.size() == db.idxDecomp.size());
unsigned __int32 count;
// Write index count.
ZRCola::translation_db::indexComp::size_type trans_count = db.idxComp.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (trans_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)trans_count;
stream.write((const char*)&count, sizeof(count));
// Write composition index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxComp.data(), sizeof(unsigned __int32)*count);
// Write decomposition index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxDecomp.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes key sequence database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Key sequence database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(std::ostream& stream, const ZRCola::keyseq_db &db)
{
assert(db.idxChr.size() == db.idxKey.size());
unsigned __int32 count;
// Write index count.
ZRCola::keyseq_db::indexChr::size_type ks_count = db.idxChr.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (ks_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)ks_count;
stream.write((const char*)&count, sizeof(count));
// Write character index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
// Write key index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxKey.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Main function
///
@@ -163,8 +51,9 @@ int _tmain(int argc, _TCHAR *argv[])
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
{ wxCMD_LINE_SWITCH, "h" , "help", _("Show this help message"), wxCMD_LINE_VAL_NONE , wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_PARAM , NULL, NULL , _("input file") , wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_PARAM , NULL, NULL , _("output file") , wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_PARAM , NULL, NULL , _("<input file>" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_PARAM , NULL, NULL , _("<output file>" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION_MANDATORY },
{ wxCMD_LINE_PARAM , NULL, NULL , _("<output POT catalog>" ), wxCMD_LINE_VAL_STRING, wxCMD_LINE_OPTION },
{ wxCMD_LINE_NONE }
};
@@ -206,6 +95,10 @@ int _tmain(int argc, _TCHAR *argv[])
bool has_errors = false;
// Set of strings to translate.
bool build_pot = parser.GetParamCount() > 2;
std::set<std::wstring> pot;
// Open file ID.
std::streamoff dst_start = stdex::idrec::open<ZRCola::recordid_t, ZRCola::recordsize_t>(dst, ZRCOLA_DB_ID);
@@ -230,6 +123,8 @@ int _tmain(int argc, _TCHAR *argv[])
// Add translation to index and data.
unsigned __int32 idx = db.data.size();
db.data.push_back(trans.chr);
wxASSERT_MSG((int)0xffff8000 <= trans.rank && trans.rank <= (int)0x00007fff, wxT("transformation rank out of bounds"));
db.data.push_back((unsigned __int16)trans.rank);
std::wstring::size_type n = trans.str.length();
wxASSERT_MSG(n <= 0xffff, wxT("transformation string too long"));
db.data.push_back((unsigned __int16)n);
@@ -259,7 +154,6 @@ int _tmain(int argc, _TCHAR *argv[])
}
}
{
// Get key sequences.
ATL::CComPtr<ADORecordset> rs;
@@ -311,7 +205,7 @@ int _tmain(int argc, _TCHAR *argv[])
&ks2 = db.idxKey[i ];
if (ZRCola::keyseq_db::keyseq::CompareSequence(ks1.seq, ks1.seq_len, ks2.seq, ks2.seq_len) == 0) {
std::wstring seq_str;
wxString seq_str;
ZRCola::keyseq_db::GetSequenceAsText(ks1.seq, ks1.seq_len, seq_str);
_ftprintf(stderr, wxT("%s: warning ZCC0007: Duplicate key sequence (%ls => %04X or %04X). The keyboard behaviour will be unpredictable.\n"), (LPCTSTR)filenameIn.c_str(), seq_str.c_str(), ks1.chr, ks2.chr);
}
@@ -329,6 +223,286 @@ int _tmain(int argc, _TCHAR *argv[])
}
}
{
// Get languages.
ATL::CComPtr<ADORecordset> rs;
if (src.SelectLanguages(rs)) {
size_t count = src.GetRecordsetCount(rs);
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::language lang;
ZRCola::language_db db;
// Preallocate memory.
db.idxLng.reserve(count);
db.data .reserve(count*4);
// Parse languages and build index and data.
while (!ZRCola::DBSource::IsEOF(rs)) {
// Read language from the database.
if (src.GetLanguage(rs, lang)) {
// Add language to index and data.
unsigned __int32 idx = db.data.size();
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::langid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)lang.id.data)[i]);
std::wstring::size_type n = lang.name.length();
wxASSERT_MSG(n <= 0xffff, wxT("language name too long"));
db.data.push_back((unsigned __int16)n);
for (std::wstring::size_type i = 0; i < n; i++)
db.data.push_back(lang.name[i]);
db.idxLng.push_back(idx);
if (build_pot)
pot.insert(lang.name);
} else
has_errors = true;
wxVERIFY(SUCCEEDED(rs->MoveNext()));
}
// Sort indices.
db.idxLng.sort();
// Write languages to file.
dst << ZRCola::language_rec(db);
} else {
_ftprintf(stderr, wxT("%s: error ZCC0009: Error getting language count from database or too many languages.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
} else {
_ftprintf(stderr, wxT("%s: error ZCC0008: Error getting languages from database. Please make sure the file is ZRCola.zrc compatible.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
}
{
// Get language characters.
ATL::CComPtr<ADORecordset> rs;
if (src.SelectLanguageCharacters(rs)) {
size_t count = src.GetRecordsetCount(rs);
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::langchar lc;
ZRCola::langchar_db db;
// Preallocate memory.
db.idxChr.reserve(count);
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
db.idxLng.reserve(count);
#endif
db.data .reserve(count*4);
// Parse language characters and build index and data.
while (!ZRCola::DBSource::IsEOF(rs)) {
// Read language characters from the database.
if (src.GetLanguageCharacter(rs, lc)) {
// Add language characters to index and data.
unsigned __int32 idx = db.data.size();
db.data.push_back(lc.chr);
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::langid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)lc.lang.data)[i]);
db.idxChr.push_back(idx);
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
db.idxLng.push_back(idx);
#endif
} else
has_errors = true;
wxVERIFY(SUCCEEDED(rs->MoveNext()));
}
// Sort indices.
db.idxChr .sort();
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
db.idxLng.sort();
#endif
// Write language characters to file.
dst << ZRCola::langchar_rec(db);
} else {
_ftprintf(stderr, wxT("%s: error ZCC0011: Error getting language characters count from database or too many langchars.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
} else {
_ftprintf(stderr, wxT("%s: error ZCC0010: Error getting language characters from database. Please make sure the file is ZRCola.zrc compatible.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
}
{
// Get character groups.
ATL::CComPtr<ADORecordset> rs;
if (src.SelectCharacterGroups(rs)) {
size_t count = src.GetRecordsetCount(rs);
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::chrgrp cg;
ZRCola::chrgrp_db db;
// Preallocate memory.
db.idxRnk.reserve(count);
db.data .reserve(count*4);
// Parse character groups and build index and data.
while (!ZRCola::DBSource::IsEOF(rs)) {
// Read character group from the database.
if (src.GetCharacterGroup(rs, cg)) {
// Add character group to index and data.
unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= cg.id && cg.id <= (int)0x00007fff, wxT("character group ID out of bounds"));
db.data.push_back((unsigned __int16)cg.id);
wxASSERT_MSG((int)0xffff8000 <= cg.rank && cg.rank <= (int)0x00007fff, wxT("character group rank out of bounds"));
db.data.push_back((unsigned __int16)cg.rank);
std::wstring::size_type n_name = cg.name.length();
wxASSERT_MSG(n_name <= 0xffff, wxT("character group name too long"));
db.data.push_back((unsigned __int16)n_name);
std::wstring::size_type n_char = cg.chars.length();
wxASSERT_MSG(n_char <= 0xffff, wxT("too many character group characters"));
db.data.push_back((unsigned __int16)n_char);
for (std::wstring::size_type i = 0; i < n_name; i++)
db.data.push_back(cg.name[i]);
for (std::wstring::size_type i = 0; i < n_char; i++)
db.data.push_back(cg.chars[i]);
db.idxRnk.push_back(idx);
if (build_pot)
pot.insert(cg.name);
} else
has_errors = true;
wxVERIFY(SUCCEEDED(rs->MoveNext()));
}
// Sort indices.
db.idxRnk.sort();
// Write character groups to file.
dst << ZRCola::chrgrp_rec(db);
} else {
_ftprintf(stderr, wxT("%s: error ZCC0015: Error getting character group count from database or too many character groups.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
} else {
_ftprintf(stderr, wxT("%s: error ZCC0014: Error getting character groups from database. Please make sure the file is ZRCola.zrc compatible.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
}
{
// Get characters.
ATL::CComPtr<ADORecordset> rs;
if (src.SelectCharacters(rs)) {
size_t count = src.GetRecordsetCount(rs);
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::character chr;
ZRCola::character_db db;
ZRCola::DBSource::character_desc_idx idxChrDsc, idxChrDscSub;
// Preallocate memory.
db.idxChr.reserve(count);
db.data .reserve(count*4);
// Parse characters and build index and data.
while (!ZRCola::DBSource::IsEOF(rs)) {
// Read character from the database.
if (src.GetCharacter(rs, chr)) {
// Add character to index and data.
unsigned __int32 idx = db.data.size();
db.data.push_back((unsigned __int16)chr.chr);
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)chr.cat.data)[i]);
std::wstring::size_type n_desc = chr.desc.length();
wxASSERT_MSG(n_desc <= 0xffff, wxT("character description too long"));
db.data.push_back((unsigned __int16)n_desc);
std::wstring::size_type n_rel = chr.rel.length();
wxASSERT_MSG(n_rel <= 0xffff, wxT("too many related characters"));
db.data.push_back((unsigned __int16)n_rel);
for (std::wstring::size_type i = 0; i < n_desc; i++)
db.data.push_back(chr.desc[i]);
for (std::wstring::size_type i = 0; i < n_rel; i++)
db.data.push_back(chr.rel[i]);
db.idxChr.push_back(idx);
// Add description (and keywords) to index.
idxChrDsc .add_keywords(chr.desc .c_str(), chr.chr, 0);
idxChrDsc .add_keywords(chr.keywords.c_str(), chr.chr, 0);
idxChrDscSub.add_keywords(chr.desc .c_str(), chr.chr, 3);
idxChrDscSub.add_keywords(chr.keywords.c_str(), chr.chr, 3);
} else
has_errors = true;
wxVERIFY(SUCCEEDED(rs->MoveNext()));
}
// Sort indices.
db.idxChr.sort();
// Save text indices.
idxChrDsc .save(db.idxDsc );
idxChrDscSub.save(db.idxDscSub);
// Write characters to file.
dst << ZRCola::character_rec(db);
} else {
_ftprintf(stderr, wxT("%s: error ZCC0017: Error getting character count from database or too many characters.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
} else {
_ftprintf(stderr, wxT("%s: error ZCC0016: Error getting characters from database. Please make sure the file is ZRCola.zrc compatible.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
}
{
// Get character categories.
ATL::CComPtr<ADORecordset> rs;
if (src.SelectCharacterCategories(rs)) {
size_t count = src.GetRecordsetCount(rs);
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::chrcat cc;
ZRCola::chrcat_db db;
// Preallocate memory.
db.idxChrCat.reserve(count);
db.idxRnk .reserve(count);
db.data .reserve(count*4);
// Parse character categories and build index and data.
while (!ZRCola::DBSource::IsEOF(rs)) {
// Read character category from the database.
if (src.GetCharacterCategory(rs, cc)) {
// Add character category to index and data.
unsigned __int32 idx = db.data.size();
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)cc.id.data)[i]);
wxASSERT_MSG((int)0xffff8000 <= cc.rank && cc.rank <= (int)0x00007fff, wxT("character category rank out of bounds"));
db.data.push_back((unsigned __int16)cc.rank);
std::wstring::size_type n_name = cc.name.length();
wxASSERT_MSG(n_name <= 0xffff, wxT("character category name too long"));
db.data.push_back((unsigned __int16)n_name);
for (std::wstring::size_type i = 0; i < n_name; i++)
db.data.push_back(cc.name[i]);
db.idxChrCat.push_back(idx);
db.idxRnk .push_back(idx);
if (build_pot)
pot.insert(cc.name);
} else
has_errors = true;
wxVERIFY(SUCCEEDED(rs->MoveNext()));
}
// Sort indices.
db.idxChrCat.sort();
db.idxRnk .sort();
// Write character categories to file.
dst << ZRCola::chrcat_rec(db);
} else {
_ftprintf(stderr, wxT("%s: error ZCC0019: Error getting character category count from database or too many character categories.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
} else {
_ftprintf(stderr, wxT("%s: error ZCC0018: Error getting character categories from database. Please make sure the file is ZRCola.zrc compatible.\n"), (LPCTSTR)filenameIn.c_str());
has_errors = true;
}
}
stdex::idrec::close<ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dst, dst_start);
if (dst.fail()) {
@@ -336,6 +510,50 @@ int _tmain(int argc, _TCHAR *argv[])
has_errors = true;
}
if (!has_errors && build_pot) {
const wxString& filenamePot = parser.GetParam(2);
std::fstream dst((LPCTSTR)filenamePot, std::ios_base::out | std::ios_base::trunc);
if (dst.good()) {
dst << "msgid \"\"" << std::endl
<< "msgstr \"\"" << std::endl
<< "\"Project-Id-Version: ZRCola.zrcdb\\n\"" << std::endl
<< "\"Language: en\\n\"" << std::endl
<< "\"MIME-Version: 1.0\\n\"" << std::endl
<< "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl
<< "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl
<< "\"X-Generator: ZRColaCompile " << ZRCOLA_VERSION_STR << "\\n\"" << std::endl;
std::wstring_convert<std::codecvt_utf8<wchar_t>> conv;
for (std::set<std::wstring>::const_iterator i = pot.cbegin(); i != pot.cend(); ++i) {
// Convert UTF-16 to UTF-8 and escape.
std::string t(conv.to_bytes(*i)), u;
for (size_t i = 0, n = t.size(); i < n; i++) {
char c = t[i];
switch (c) {
case '\'': u += "\\\'"; break;
case '\"': u += "\\\""; break;
case '\n': u += "\\\n"; break;
case '\t': u += "\\\t"; break;
default : u += c;
}
}
dst << std::endl
<< "msgid \"" << u << "\"" << std::endl
<< "msgstr \"\"" << std::endl;
}
if (dst.fail()) {
_ftprintf(stderr, wxT("%s: error ZCC0013: Writing to POT catalog failed.\n"), (LPCTSTR)filenameOut.c_str());
has_errors = true;
}
dst.close();
} else {
_ftprintf(stderr, wxT("%s: error ZCC0012: Error opening POT catalog.\n"), filenameOut.fn_str());
has_errors = true;
}
}
if (has_errors) {
dst.close();
wxRemoveFile(filenameOut);

View File

@@ -24,7 +24,9 @@
#include "../include/zrcola.h"
#include "dbsource.h"
#include <zrcola/language.h>
#include <zrcola/translate.h>
#include <zrcolaui/chargroup.h>
#include <zrcolaui/keyboard.h>
#include <wx/app.h>
@@ -40,9 +42,14 @@
#include <initguid.h> // GUID helper to prevent LNK2001 errors (unresolved external symbol IID_IADO...)
#include <adoint.h>
#include <adoid.h>
#include <atlcomcli.h>
#include <tchar.h>
#include <stdlib.h>
#include <algorithm>
#include <codecvt>
#include <cwctype>
#include <fstream>
#include <set>

668
bin/ZRCUpdate.wsf Normal file
View File

@@ -0,0 +1,668 @@
<?xml version="1.0"?>
<!--
Copyright 2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
-->
<package>
<job id="CharImport">
<runtime>
<description>Unicode Character Description Update - Amebis, Copyright © 2016</description>
<unnamed name="&lt;ZRCola.mdb&gt;" required="true" helpstring="ZRCola database"/>
<unnamed name="&lt;UnicodeData.txt&gt;" required="true" helpstring="Unicode character database (from http://www.unicode.org/Public/UNIDATA/UnicodeData.txt)"/>
<named name="F" type="simple" required="false" helpstring="Force overwrite of existing data"/>
</runtime>
<reference object="ADODB.Connection"/>
<reference object="ADODB.Command"/>
<reference object="ADODB.Recordset"/>
<reference object="Scripting.FileSystemObject"/>
<script language="JScript"><![CDATA[
if (WScript.Arguments.Unnamed.Length < 2) {
WScript.Arguments.ShowUsage();
WScript.Quit(1);
}
var force = WScript.Arguments.Named.Exists("F") ? true : false;
// Open ZRCola database.
var db = WScript.CreateObject("ADODB.Connection");
db.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=" + WScript.Arguments.Unnamed(0) + ";Uid=;Pwd=;");
try {
// Open Unicode Data file.
var
fso = WScript.CreateObject("Scripting.FileSystemObject"),
f = fso.OpenTextFile(WScript.Arguments.Unnamed(1), ForReading);
try {
var
now = new Date(),
com = WScript.CreateObject("ADODB.Command"), param_znak,
rs = WScript.CreateObject("ADODB.Recordset");
com.Prepared = true;
com.ActiveConnection = db;
com.CommandType = adCmdText;
com.CommandText = "SELECT TOP 1 * FROM [VRS_CharList] WHERE [znak]=?";
com.Parameters.Append(param_znak = com.CreateParameter("znak", adChar, adParamInput, 4));
rs.CursorLocation = adUseClient;
rs.CursorType = adOpenDynamic;
rs.LockType = adLockOptimistic;
db.BeginTrans();
try {
// Parse Unicode Data file.
while (!f.AtEndOfStream) {
var
line = f.ReadLine(),
fields = line.split(";"),
unicode = parseInt(fields[0], 16),
v;
if (unicode < 0x0020 || 0xffff < unicode) {
// Skip characters outside of 0020-FFFF range.
continue;
}
// Convert Unicode HEX code to uppercase for consistent database experience.
fields[ 0] = fields[ 0].toUpperCase();
fields[12] = fields[12] != "" ? fields[12].toUpperCase() : fields[ 0];
fields[13] = fields[13] != "" ? fields[13].toUpperCase() : fields[ 0];
fields[14] = fields[14] != "" ? fields[14].toUpperCase() : fields[12];
var
desc_en = fields[1] != "<control>" ? fields[1] : fields[10],
dig_dec = fields[6] != "" ? parseInt(fields[6], 10) : null,
digit = fields[7] != "" ? parseInt(fields[7], 10) : null,
mirror = fields[9] == "Y" || fields[9] == "y";
if (fields[1].charAt(0) == "<") {
// Skip range start and stop descriptors.
continue;
}
// Search the character.
param_znak.Value = fields[0];
rs.Open(com);
try {
if (rs.EOF) {
// If a character does not exist yet, create it.
rs.AddNew();
rs("znak" ).Value = fields[0];
rs("znakZRCOLA" ).Value = String.fromCharCode(unicode);
rs("opis_en" ).Value = desc_en;
rs("kat" ).Value = fields[2];
rs("komb" ).Value = parseInt(fields[3], 10);
rs("stevka10" ).Value = dig_dec;
rs("stevka" ).Value = digit;
rs("stevilo" ).Value = fields[8];
rs("zrcali" ).Value = mirror ? 1 : 0;
rs("znak_v" ).Value = fields[12];
rs("znakZRCOLA_v" ).Value = String.fromCharCode(parseInt(fields[12], 16));
rs("znak_m" ).Value = fields[13];
rs("znakZRCOLA_m" ).Value = String.fromCharCode(parseInt(fields[13], 16));
rs("znak_tc" ).Value = fields[14];
rs("znakZRCOLA_tc").Value = String.fromCharCode(parseInt(fields[14], 16));
rs.Update();
} else {
var updated = false;
if (force || (v = rs("opis_en").Value) == null || v == "") { rs("opis_en" ).Value = desc_en; updated = true; }
if (force || (v = rs("kat" ).Value) == null || v == "") { rs("kat" ).Value = fields[2]; updated = true; }
if (force || (v = rs("komb" ).Value) == null ) { rs("komb" ).Value = parseInt(fields[3], 10); updated = true; }
if (force ) { rs("stevka10").Value = dig_dec; updated = true; }
if (force ) { rs("stevka" ).Value = digit; updated = true; }
if (force ) { rs("stevilo" ).Value = fields[8]; updated = true; }
if (force ) { rs("zrcali" ).Value = mirror ? 1 : 0; updated = true; }
if (force ) { rs("znak_v" ).Value = fields[12]; rs("znakZRCOLA_v" ).Value = String.fromCharCode(parseInt(fields[12], 16)); updated = true; }
if (force ) { rs("znak_m" ).Value = fields[13]; rs("znakZRCOLA_m" ).Value = String.fromCharCode(parseInt(fields[13], 16)); updated = true; }
if (force ) { rs("znak_tc" ).Value = fields[14]; rs("znakZRCOLA_tc").Value = String.fromCharCode(parseInt(fields[14], 16)); updated = true; }
if (updated) {
// Changing [updat] field causes Microsoft Cursor Engine: Row cannot be located for updating. Some values may have been changed since it was last read.
//rs("updat").Value = (new Date(now.getTime() + now.getTimezoneOffset()*60*1000)).getVarDate();
rs.Update();
}
}
} finally {
rs.Close();
}
}
db.CommitTrans();
} catch (err) {
db.RollbackTrans();
throw err;
}
} finally {
f.Close();
}
} finally {
db.Close();
}
WScript.Quit(0);
]]></script>
</job>
<job id="CharDescGenerate">
<runtime>
<description>Dynamic Character Description Generator - Amebis, Copyright © 2016</description>
<unnamed name="&lt;ZRCola.mdb&gt;" required="true" helpstring="ZRCola database"/>
<named name="F" type="simple" required="false" helpstring="Force overwrite of existing data"/>
</runtime>
<reference object="ADODB.Connection"/>
<reference object="ADODB.Command"/>
<reference object="ADODB.Recordset"/>
<script language="JScript"><![CDATA[
if (WScript.Arguments.Unnamed.Length < 1) {
WScript.Arguments.ShowUsage();
WScript.Quit(1);
}
function ZRColaDecompositionParser(db)
{
// Prepare query for existing character description search.
this.com_desc = WScript.CreateObject("ADODB.Command");
this.com_desc.Prepared = true;
this.com_desc.ActiveConnection = db;
this.com_desc.CommandType = adCmdText;
this.com_desc.CommandText = "SELECT TOP 1 [opis_en] FROM [VRS_CharList] WHERE [znak]=?";
this.com_desc.Parameters.Append(this.param_desc_znak = this.com_desc.CreateParameter("znak", adChar, adParamInput, 4));
this.rs_desc = WScript.CreateObject("ADODB.Recordset");
this.rs_desc.CursorLocation = adUseClient;
this.rs_desc.CursorType = adOpenStatic;
this.rs_desc.LockType = adLockReadOnly;
}
ZRColaDecompositionParser.prototype.nextChar = function()
{
if (!this.decomposed.length) {
this.sym = null;
this.desc = null;
return;
}
// Get next character.
this.sym = this.decomposed.shift();
// Get character's description.
this.param_desc_znak.Value = this.sym;
this.rs_desc.Open(this.com_desc);
try {
if (!this.rs_desc.EOF) {
var v;
if ((v = this.rs_desc("opis_en").Value) != null && v != "")
this.desc = v;
else
throw new Error(this.sym + " character has no description.");
} else
throw new Error(this.sym + " character not found.");
} finally {
this.rs_desc.Close();
}
}
ZRColaDecompositionParser.prototype.modifiers = function()
{
var desc = "";
for (;;) {
if (
this.sym >= "E000" && this.sym <= "E05B" || // 1st Set of Modifiers
this.sym >= "E063" && this.sym <= "E0BB" || // 2nd Set of Modifiers
this.sym == "003A" || // Colon
this.sym == "02DE" || // Rhotic Hook
this.sym == "2019") // Right Single Quotation Mark
{
desc += (desc.length ? " AND " : "") + this.desc;
this.nextChar();
} else if (this.sym >= "02B0" && this.sym <= "02FF") {
// Standard Unicode Modifiers
if (this.desc.indexOf("MODIFIER LETTER ") == 0)
this.desc = this.desc.substring(16);
desc += (desc.length ? " AND " : "") + this.desc;
this.nextChar();
} else
break;
}
return desc.length ? desc : null;
}
ZRColaDecompositionParser.prototype.envelopes = function()
{
var desc = "";
for (;;) {
if (
this.sym == "E0C0" || // Circle
//this.sym == "E0C1" || // Two Characters in Circle
this.sym == "E0C2" || // Square
//this.sym == "E0C3" || // Two Characters in Square
this.sym == "E0CA" || // Diamond
this.sym == "E0CD") // Not Circle
{
desc += (desc.length ? " AND " : "") + this.desc;
this.nextChar();
} else
break;
}
return desc.length ? desc : null;
}
ZRColaDecompositionParser.prototype.parentheses = function(open, close, desc)
{
if (this.sym == open) {
// Parenthesis Start
this.nextChar();
var desc_p = desc + " " + this.expression();
if (this.sym == close) {
// Parenthesis End
this.nextChar();
} else
throw new Error(this.sym + " is unexpected. Should end with " + close + ".");
return desc_p;
} else
return null;
}
ZRColaDecompositionParser.prototype.character = function()
{
var desc;
if (desc = this.parentheses("E0C5", "E0C6", "SUPERSCRIPTED")) {
// Superscript
return desc;
} else if (desc = this.parentheses("E0CE", "E0CF", "SUBSCRIPTED")) {
// Subscript
return desc;
} else if (desc = this.parentheses("E2E0", "E2E1", "EVA DOUBLED")) {
// EVA Double
return desc;
} else if (desc = this.parentheses("E2E2", "E2E3", "EVA CONDENSED")) {
// EVA Condensed
return desc;
} else if (desc = this.parentheses("E2E4", "E2E5", "EVA EMPHASIZED")) {
// EVA Emphasis
return desc;
} else if (desc = this.parentheses("E2E6", "E2E7", "EVA STRIKED")) {
// EVA Strike
return desc;
} else if (desc = this.parentheses("E2E8", "E2E9", "EVA UNDEALED")) {
// EVA Undeal
return desc;
} else if (desc = this.parentheses("E2EA", "E2EB", "EVA ITALIC")) {
// EVA Italic
return desc;
} else if (desc = this.parentheses("E2EC", "E2ED", "EVA SUPERSCRIPTED")) {
// EVA Superscript
return desc;
} else if (desc = this.parentheses("E2EE", "E2EF", "EVA SUBSCRIPTED")) {
// EVA Subscript
return desc;
} else if (this.sym < "E000" || this.sym > "E0FC") {
// Base Character
desc = this.desc;
this.nextChar();
var has_with = desc.indexOf(" WITH ") >= 0;
for (;;) {
var desc2;
if (desc2 = this.modifiers()) {
desc += (has_with ? " AND " : " WITH ") + desc2;
has_with = true;
} else if (desc2 = this.envelopes()) {
desc += " IN " + desc2;
has_with = false;
} else
break;
}
return desc;
} else
throw new Error("Syntax error");
}
ZRColaDecompositionParser.prototype.term = function()
{
var desc = new Array(this.character());
while (this.sym == "E0C4") {
// Ligature
this.nextChar();
desc.push(this.character());
}
if (desc.length == 1) {
return desc[0];
} else if (desc.length == 2) {
if (desc[0] == desc[1])
return "DOUBLE " + desc[0];
} else if (desc.length == 3) {
if (desc[0] == desc[1] && desc[0] == desc[2])
return "TRIPLE " + desc[0];
}
return desc.join(" AND ") + " LIGATURE";
}
ZRColaDecompositionParser.prototype.expression = function()
{
if (this.sym >= "E0F0" && this.sym <= "E0F3" || this.sym >= "E0F8" && this.sym <= "E0FC") {
// Prefix modifier (with prefix description)
var desc = this.desc;
this.nextChar();
return desc + " " + this.expression();
} else if (this.sym == "E0F6") {
// Prefix modifier (with postfix description)
var desc = this.desc;
this.nextChar();
return this.expression() + " " + desc;
} else {
var desc = this.term();
while (
this.sym >= "E05C" && this.sym <= "E062" ||
this.sym == "E0C7" || this.sym == "E0CB" || this.sym >= "E0D0" && this.sym <= "E0D5")
{
// Joiner
desc += " " + this.desc + " WITH ";
this.nextChar();
var desc2 = "";
for (;;) {
var desc3;
if (desc3 = this.modifiers())
desc2 += (desc2.length ? " AND " : " WITH ") + desc3;
else if (desc3 = this.envelopes())
desc2 += " IN " + desc3;
else
break;
}
desc += this.term();
desc += desc2;
}
return desc;
}
}
ZRColaDecompositionParser.prototype.parse = function(decomposed)
{
this.decomposed = decomposed.slice(0); // Duplicate array.
this.nextChar();
var desc = this.expression();
if (this.sym != null)
throw new Error("Unexpected trailing characters.");
return desc;
}
var force = WScript.Arguments.Named.Exists("F") ? true : false;
// Open ZRCola database.
var db = WScript.CreateObject("ADODB.Connection");
db.Open("Driver={Microsoft Access Driver (*.mdb)};Dbq=" + WScript.Arguments.Unnamed(0) + ";Uid=;Pwd=;");
try {
// Prepare query for character decomposition.
var com_comp = WScript.CreateObject("ADODB.Command"), param_comp_znak;
com_comp.Prepared = true;
com_comp.ActiveConnection = db;
com_comp.CommandType = adCmdText;
com_comp.CommandText = "SELECT UCase([komb]) AS [kombUC] FROM [VRS_ReplChar] WHERE [znak]=? ORDER BY [rang_znak] ASC";
com_comp.Parameters.Append(param_comp_znak = com_comp.CreateParameter("znak", adChar, adParamInput, 4));
db.BeginTrans();
try {
// Query all private-use characters.
var rs = WScript.CreateObject("ADODB.Recordset");
rs.CursorLocation = adUseClient;
rs.Open("SELECT * FROM [VRS_CharList] WHERE 'E000'<=[znak] AND [znak]<='F8FF' AND [kat] IS NULL", db, adOpenDynamic, adLockOptimistic, adCmdText);
try {
var rs_comp = WScript.CreateObject("ADODB.Recordset");
rs_comp.CursorLocation = adUseClient;
rs_comp.CursorType = adOpenStatic;
rs_comp.LockType = adLockReadOnly;
var parser = new ZRColaDecompositionParser(db);
for (; !rs.EOF; rs.MoveNext()) {
var v;
if (!force && (v = rs("opis_en").Value) != null && v != "") {
// This character already has the description.
continue;
}
// Decompose character.
var chr = rs("znak").Value;
param_comp_znak.Value = chr;
rs_comp.Open(com_comp);
try {
for (; !rs_comp.EOF; rs_comp.MoveNext()) {
var
decomposed = (v = rs_comp("kombUC").Value) != null ? (new String(v)).split("+") : new Array(),
n = decomposed.length;
if (n > 0) {
try {
var desc = parser.parse(decomposed);
rs("opis_en").value = desc;
rs.update();
break;
} catch (err) {
// We couldn't generate character description according to decomposition.
WScript.Echo(chr + " >> " + decomposed.join("+") + ": " + err.message);
}
};
}
} finally {
rs_comp.Close();
}
}
} finally {
rs.Close();
}
db.CommitTrans();
} catch (err) {
db.RollbackTrans();
throw err;
}
} finally {
db.Close();
}
WScript.Quit(0);
]]></script>
</job>
<signature>
** SIG ** MIIXmAYJKoZIhvcNAQcCoIIXiTCCF4UCAQExCzAJBgUr
** SIG ** DgMCGgUAMGcGCisGAQQBgjcCAQSgWTBXMDIGCisGAQQB
** SIG ** gjcCAR4wJAIBAQQQcAVhGs441BGiowAQS9NQkAIBAAIB
** SIG ** AAIBAAIBAAIBADAhMAkGBSsOAwIaBQAEFNaLZyoVIc+t
** SIG ** sxdD6hEodLtsntTAoIISyDCCA+4wggNXoAMCAQICEH6T
** SIG ** 6/t8xk5Z6kuad9QG/DswDQYJKoZIhvcNAQEFBQAwgYsx
** SIG ** CzAJBgNVBAYTAlpBMRUwEwYDVQQIEwxXZXN0ZXJuIENh
** SIG ** cGUxFDASBgNVBAcTC0R1cmJhbnZpbGxlMQ8wDQYDVQQK
** SIG ** EwZUaGF3dGUxHTAbBgNVBAsTFFRoYXd0ZSBDZXJ0aWZp
** SIG ** Y2F0aW9uMR8wHQYDVQQDExZUaGF3dGUgVGltZXN0YW1w
** SIG ** aW5nIENBMB4XDTEyMTIyMTAwMDAwMFoXDTIwMTIzMDIz
** SIG ** NTk1OVowXjELMAkGA1UEBhMCVVMxHTAbBgNVBAoTFFN5
** SIG ** bWFudGVjIENvcnBvcmF0aW9uMTAwLgYDVQQDEydTeW1h
** SIG ** bnRlYyBUaW1lIFN0YW1waW5nIFNlcnZpY2VzIENBIC0g
** SIG ** RzIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
** SIG ** AQCxrLNJVEuXHBIK2CV5kSJXKm/cuCbEQ3Nrwr8uUFr7
** SIG ** FMJ2jkMBJUO0oeJF9Oi3e8N0zCLXtJQAAvdN7b+0t0Qk
** SIG ** a81fRTvRRM5DEnMXgotptCvLmR6schsmTXEfsTHd+1Fh
** SIG ** AlOmqvVJLAV4RaUvic7nmef+jOJXPz3GktxK+Hsz5HkK
** SIG ** +/B1iEGc/8UDUZmq12yfk2mHZSmDhcJgFMTIyTsU2sCB
** SIG ** 8B8NdN6SIqvK9/t0fCfm90obf6fDni2uiuqm5qonFn1h
** SIG ** 95hxEbziUKFL5V365Q6nLJ+qZSDT2JboyHylTkhE/xni
** SIG ** RAeSC9dohIBdanhkRc1gRn5UwRN8xXnxycFxAgMBAAGj
** SIG ** gfowgfcwHQYDVR0OBBYEFF+a9W5czMx0mtTdfe8/2+xM
** SIG ** gC7dMDIGCCsGAQUFBwEBBCYwJDAiBggrBgEFBQcwAYYW
** SIG ** aHR0cDovL29jc3AudGhhd3RlLmNvbTASBgNVHRMBAf8E
** SIG ** CDAGAQH/AgEAMD8GA1UdHwQ4MDYwNKAyoDCGLmh0dHA6
** SIG ** Ly9jcmwudGhhd3RlLmNvbS9UaGF3dGVUaW1lc3RhbXBp
** SIG ** bmdDQS5jcmwwEwYDVR0lBAwwCgYIKwYBBQUHAwgwDgYD
** SIG ** VR0PAQH/BAQDAgEGMCgGA1UdEQQhMB+kHTAbMRkwFwYD
** SIG ** VQQDExBUaW1lU3RhbXAtMjA0OC0xMA0GCSqGSIb3DQEB
** SIG ** BQUAA4GBAAMJm495739ZMKrvaLX64wkdu0+CBl03X6ZS
** SIG ** nxaN6hySCURu9W3rWHww6PlpjSNzCxJvR6muORH4KrGb
** SIG ** sBrDjutZlgCtzgxNstAxpghcKnr84nodV0yoZRjpeUBi
** SIG ** JZZux8c3aoMhCI5B6t3ZVz8dd0mHKhYGXqY4aiISo1EZ
** SIG ** g362MIIEozCCA4ugAwIBAgIQDs/0OMj+vzVuBNhqmBsa
** SIG ** UDANBgkqhkiG9w0BAQUFADBeMQswCQYDVQQGEwJVUzEd
** SIG ** MBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24xMDAu
** SIG ** BgNVBAMTJ1N5bWFudGVjIFRpbWUgU3RhbXBpbmcgU2Vy
** SIG ** dmljZXMgQ0EgLSBHMjAeFw0xMjEwMTgwMDAwMDBaFw0y
** SIG ** MDEyMjkyMzU5NTlaMGIxCzAJBgNVBAYTAlVTMR0wGwYD
** SIG ** VQQKExRTeW1hbnRlYyBDb3Jwb3JhdGlvbjE0MDIGA1UE
** SIG ** AxMrU3ltYW50ZWMgVGltZSBTdGFtcGluZyBTZXJ2aWNl
** SIG ** cyBTaWduZXIgLSBHNDCCASIwDQYJKoZIhvcNAQEBBQAD
** SIG ** ggEPADCCAQoCggEBAKJjCzlEuLsjp0RJuw7/ofBhClOT
** SIG ** sJjbrSwPSsVu/4Y8U1UPFc4EPyv9qZaW2b5heQtbyUyG
** SIG ** duXgQ0sile7CK0PBn9hotI5AT+6FOLkRxSPyZFjwFTJv
** SIG ** TlehroikAtcqHs1L4d1j1ReJMluwXplaqJ0oUA4X7pbb
** SIG ** YTtFUR3PElYLkkf8q672Zj1HrHBy55LnX80QucSDZJQZ
** SIG ** vSWA4ejSIqXQugJ6oXeTW2XD7hd0vEGGKtwITIySjJEt
** SIG ** nndEH2jWqHR32w5bMotWizO92WPISZ06xcXqMwvS8aMb
** SIG ** 9Iu+2bNXizveBKd6IrIkri7HcMW+ToMmCPsLvalPmQjh
** SIG ** EChyqs0CAwEAAaOCAVcwggFTMAwGA1UdEwEB/wQCMAAw
** SIG ** FgYDVR0lAQH/BAwwCgYIKwYBBQUHAwgwDgYDVR0PAQH/
** SIG ** BAQDAgeAMHMGCCsGAQUFBwEBBGcwZTAqBggrBgEFBQcw
** SIG ** AYYeaHR0cDovL3RzLW9jc3Aud3Muc3ltYW50ZWMuY29t
** SIG ** MDcGCCsGAQUFBzAChitodHRwOi8vdHMtYWlhLndzLnN5
** SIG ** bWFudGVjLmNvbS90c3MtY2EtZzIuY2VyMDwGA1UdHwQ1
** SIG ** MDMwMaAvoC2GK2h0dHA6Ly90cy1jcmwud3Muc3ltYW50
** SIG ** ZWMuY29tL3Rzcy1jYS1nMi5jcmwwKAYDVR0RBCEwH6Qd
** SIG ** MBsxGTAXBgNVBAMTEFRpbWVTdGFtcC0yMDQ4LTIwHQYD
** SIG ** VR0OBBYEFEbGaaMOShQe1UzaUmMXP142vA3mMB8GA1Ud
** SIG ** IwQYMBaAFF+a9W5czMx0mtTdfe8/2+xMgC7dMA0GCSqG
** SIG ** SIb3DQEBBQUAA4IBAQB4O7SRKgBM8I9iMDd4o4QnB28Y
** SIG ** st4l3KDUlAOqhk4ln5pAAxzdzuN5yyFoBtq2MrRtv/Qs
** SIG ** JmMz5ElkbQ3mw2cO9wWkNWx8iRbG6bLfsundIMZxD82V
** SIG ** dNy2XN69Nx9DeOZ4tc0oBCCjqvFLxIgpkQ6A0RH83Vx2
** SIG ** bk9eDkVGQW4NsOo4mrE62glxEPwcebSAe6xp9P2ctgwW
** SIG ** K/F/Wwk9m1viFsoTgW0ALjgNqCmPLOGy9FqpAa8VnCwv
** SIG ** SRvbIrvD/niUUcOGsYKIXfA9tFGheTMrLnu53CAJE3Hr
** SIG ** ahlbz+ilMFcsiUk/uc9/yb8+ImhjU5q9aXSsxR08f5Lg
** SIG ** w7wc2AR1MIIEzjCCA7agAwIBAgIQMHo2eqo+aIGm+U8I
** SIG ** yzs5ZDANBgkqhkiG9w0BAQsFADB/MQswCQYDVQQGEwJV
** SIG ** UzEdMBsGA1UEChMUU3ltYW50ZWMgQ29ycG9yYXRpb24x
** SIG ** HzAdBgNVBAsTFlN5bWFudGVjIFRydXN0IE5ldHdvcmsx
** SIG ** MDAuBgNVBAMTJ1N5bWFudGVjIENsYXNzIDMgU0hBMjU2
** SIG ** IENvZGUgU2lnbmluZyBDQTAeFw0xNTEwMDkwMDAwMDBa
** SIG ** Fw0xODExMDcyMzU5NTlaMGExCzAJBgNVBAYTAlNJMREw
** SIG ** DwYDVQQIEwhTbG92ZW5pYTEPMA0GA1UEBxMGS2Ftbmlr
** SIG ** MRYwFAYDVQQKFA1BbWViaXMgZC5vLm8uMRYwFAYDVQQD
** SIG ** FA1BbWViaXMgZC5vLm8uMIIBIjANBgkqhkiG9w0BAQEF
** SIG ** AAOCAQ8AMIIBCgKCAQEAl/LoF3DHaSrIaG1pgBmBwDyl
** SIG ** Yt7sRvIuoEdGr/yMhV9RfUIft+xsTPVQOAirvgG+KUbc
** SIG ** E3KMnGH+VuK7Y+vYzRp3dYTLinSQz1NKYAELyTdVzmmY
** SIG ** mU3LX764yk3ABtSZsZwPoiCy+TXE9ZsCkugB2c7Qp9N/
** SIG ** O9EjjQDRwZlUa3nLoY96Y3qNPwkCn04ppYiqPeIXTRz8
** SIG ** XBLs4Nl/bD9wymEuNSV75vzobJ7BUYQwRU7lmNL2SwRY
** SIG ** ENaf0DpdiyFLBsNafHjGYiXQHgNxZUBpj7OoRDNBvMQY
** SIG ** L+LM8OrjhGIK1uGL5CqBD/p81ebeFsAZVxg9hrgnkPVQ
** SIG ** w77U0LZw8wIDAQABo4IBYjCCAV4wCQYDVR0TBAIwADAO
** SIG ** BgNVHQ8BAf8EBAMCB4AwKwYDVR0fBCQwIjAgoB6gHIYa
** SIG ** aHR0cDovL3N2LnN5bWNiLmNvbS9zdi5jcmwwZgYDVR0g
** SIG ** BF8wXTBbBgtghkgBhvhFAQcXAzBMMCMGCCsGAQUFBwIB
** SIG ** FhdodHRwczovL2Quc3ltY2IuY29tL2NwczAlBggrBgEF
** SIG ** BQcCAjAZDBdodHRwczovL2Quc3ltY2IuY29tL3JwYTAT
** SIG ** BgNVHSUEDDAKBggrBgEFBQcDAzBXBggrBgEFBQcBAQRL
** SIG ** MEkwHwYIKwYBBQUHMAGGE2h0dHA6Ly9zdi5zeW1jZC5j
** SIG ** b20wJgYIKwYBBQUHMAKGGmh0dHA6Ly9zdi5zeW1jYi5j
** SIG ** b20vc3YuY3J0MB8GA1UdIwQYMBaAFJY7U/B5M5evfYPv
** SIG ** LivMyreGHnJmMB0GA1UdDgQWBBT3B72WgJotdMR/DD09
** SIG ** J93UkAqfzDANBgkqhkiG9w0BAQsFAAOCAQEAinEvQC+1
** SIG ** yttKEsqAjt2YufpYlul3OQH17YKbUy4AAiKiAsUXWfTu
** SIG ** XRVdkT6CrEYcHyOLaHfe36jVHw8vLIiR2cyEcB3vweyr
** SIG ** JnNpt+Za4I/XZMoG/vvCJmSltOj8C/7PRKWklGgynPNe
** SIG ** HI8+0d1vLzRtK77hFeV7CIMIfnpoYThJKTSLxdr0kn+j
** SIG ** M8otfdLN2aDonnxe0Mf+2rkrX8AFIIHPpIXZj2X2VEmk
** SIG ** ZdyFINgI+KlJVQY/RY9BFMM2htLAIkNcDP1QVzFajhGH
** SIG ** yj+C+UtZQf5PceGYtJHNeq3cm6omjnEfyzi8/NwYFlkW
** SIG ** hvzJEH3woPqKgUramNFFLD0W5zCCBVkwggRBoAMCAQIC
** SIG ** ED141/l2SWCyYX308B7KhiowDQYJKoZIhvcNAQELBQAw
** SIG ** gcoxCzAJBgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2ln
** SIG ** biwgSW5jLjEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3Qg
** SIG ** TmV0d29yazE6MDgGA1UECxMxKGMpIDIwMDYgVmVyaVNp
** SIG ** Z24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s
** SIG ** eTFFMEMGA1UEAxM8VmVyaVNpZ24gQ2xhc3MgMyBQdWJs
** SIG ** aWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0
** SIG ** eSAtIEc1MB4XDTEzMTIxMDAwMDAwMFoXDTIzMTIwOTIz
** SIG ** NTk1OVowfzELMAkGA1UEBhMCVVMxHTAbBgNVBAoTFFN5
** SIG ** bWFudGVjIENvcnBvcmF0aW9uMR8wHQYDVQQLExZTeW1h
** SIG ** bnRlYyBUcnVzdCBOZXR3b3JrMTAwLgYDVQQDEydTeW1h
** SIG ** bnRlYyBDbGFzcyAzIFNIQTI1NiBDb2RlIFNpZ25pbmcg
** SIG ** Q0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
** SIG ** AQCXgx4AFq8ssdIIxNdok1FgHnH24ke021hNI2JqtL9a
** SIG ** G1H3ow0Yd2i72DarLyFQ2p7z518nTgvCl8gJcJOp2lwN
** SIG ** TqQNkaC07BTOkXJULs6j20TpUhs/QTzKSuSqwOg5q1PM
** SIG ** IdDMz3+b5sLMWGqCFe49Ns8cxZcHJI7xe74xLT1u3LWZ
** SIG ** Qp9LYZVfHHDuF33bi+VhiXjHaBuvEXgamK7EVUdT2bMy
** SIG ** 1qEORkDFl5KK0VOnmVuFNVfT6pNiYSAKxzB3JBFNYoO2
** SIG ** untogjHuZcrf+dWNsjXcjCtvanJcYISc8gyUXsBWUgBI
** SIG ** zNP4pX3eL9cT5DiohNVGuBOGwhud6lo43ZvbAgMBAAGj
** SIG ** ggGDMIIBfzAvBggrBgEFBQcBAQQjMCEwHwYIKwYBBQUH
** SIG ** MAGGE2h0dHA6Ly9zMi5zeW1jYi5jb20wEgYDVR0TAQH/
** SIG ** BAgwBgEB/wIBADBsBgNVHSAEZTBjMGEGC2CGSAGG+EUB
** SIG ** BxcDMFIwJgYIKwYBBQUHAgEWGmh0dHA6Ly93d3cuc3lt
** SIG ** YXV0aC5jb20vY3BzMCgGCCsGAQUFBwICMBwaGmh0dHA6
** SIG ** Ly93d3cuc3ltYXV0aC5jb20vcnBhMDAGA1UdHwQpMCcw
** SIG ** JaAjoCGGH2h0dHA6Ly9zMS5zeW1jYi5jb20vcGNhMy1n
** SIG ** NS5jcmwwHQYDVR0lBBYwFAYIKwYBBQUHAwIGCCsGAQUF
** SIG ** BwMDMA4GA1UdDwEB/wQEAwIBBjApBgNVHREEIjAgpB4w
** SIG ** HDEaMBgGA1UEAxMRU3ltYW50ZWNQS0ktMS01NjcwHQYD
** SIG ** VR0OBBYEFJY7U/B5M5evfYPvLivMyreGHnJmMB8GA1Ud
** SIG ** IwQYMBaAFH/TZafC3ey78DAJ80M5+gKvMzEzMA0GCSqG
** SIG ** SIb3DQEBCwUAA4IBAQAThRoeaak396C9pK9+HWFT/p2M
** SIG ** XgymdR54FyPd/ewaA1U5+3GVx2Vap44w0kRaYdtwb9oh
** SIG ** BcIuc7pJ8dGT/l3JzV4D4ImeP3Qe1/c4i6nWz7s1LzNY
** SIG ** qJJW0chNO4LmeYQW/CiwsUfzHaI+7ofZpn+kVqU/rYQu
** SIG ** Kd58vKiqoz0EAeq6k6IOUCIpF0yH5DoRX9akJYmbBWsv
** SIG ** tMkBTCd7C6wZBSKgYBU/2sn7TUyP+3Jnd/0nlMe6NQ6I
** SIG ** Sf6N/SivShK9DbOXBd5EDBX6NisD3MFQAfGhEV0U5eK9
** SIG ** J0tUviuEXg+mw3QFCu+Xw4kisR93873NQ9TxTKk/tYuE
** SIG ** r2Ty0BQhMYIEPDCCBDgCAQEwgZMwfzELMAkGA1UEBhMC
** SIG ** VVMxHTAbBgNVBAoTFFN5bWFudGVjIENvcnBvcmF0aW9u
** SIG ** MR8wHQYDVQQLExZTeW1hbnRlYyBUcnVzdCBOZXR3b3Jr
** SIG ** MTAwLgYDVQQDEydTeW1hbnRlYyBDbGFzcyAzIFNIQTI1
** SIG ** NiBDb2RlIFNpZ25pbmcgQ0ECEDB6NnqqPmiBpvlPCMs7
** SIG ** OWQwCQYFKw4DAhoFAKBwMBAGCisGAQQBgjcCAQwxAjAA
** SIG ** MBkGCSqGSIb3DQEJAzEMBgorBgEEAYI3AgEEMBwGCisG
** SIG ** AQQBgjcCAQsxDjAMBgorBgEEAYI3AgEVMCMGCSqGSIb3
** SIG ** DQEJBDEWBBTw/5NU88DZc1q0NRNEX/ex3ZH8kTANBgkq
** SIG ** hkiG9w0BAQEFAASCAQAWqfI4RLtBRhqUJ1mx60ulXzEy
** SIG ** Bp2RJ0lh7PU5LJ9gnqpYjCWRbU7XjPeZlokwJ834QHQa
** SIG ** wTCSC5aY6YTxXaQlzdYRo3MgBy9YfCer3HVsKvGlnBcb
** SIG ** ZfS/13vLIECiLZ4wyRwoNuOGIrnGChhFeSBuB0471TyV
** SIG ** rOyn/2oL6kUGvdRDUe7vozwogspEB1zm7hJBLEsr0fbq
** SIG ** NzaL4C8h42tjbeZSrYsMhRlZfi5jyZwY5a7Ajtww+5tV
** SIG ** ZjO/Zm9y/CkhaF7ABMhAR8bLVruTPKIYCzDtuXovz1kL
** SIG ** DpWlDfAPxRUF48j4SHY2PCwkW253jVD2bNb45A+xz3nn
** SIG ** rupT/PrToYICCzCCAgcGCSqGSIb3DQEJBjGCAfgwggH0
** SIG ** AgEBMHIwXjELMAkGA1UEBhMCVVMxHTAbBgNVBAoTFFN5
** SIG ** bWFudGVjIENvcnBvcmF0aW9uMTAwLgYDVQQDEydTeW1h
** SIG ** bnRlYyBUaW1lIFN0YW1waW5nIFNlcnZpY2VzIENBIC0g
** SIG ** RzICEA7P9DjI/r81bgTYapgbGlAwCQYFKw4DAhoFAKBd
** SIG ** MBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZI
** SIG ** hvcNAQkFMQ8XDTE2MDQzMDEyNTUxNFowIwYJKoZIhvcN
** SIG ** AQkEMRYEFLyuXHqtrvRBTc1FKNCGvsgH18wHMA0GCSqG
** SIG ** SIb3DQEBAQUABIIBAEIKtkLAxMugTbzm7q7S0koc3Z0V
** SIG ** SL9Dv3YB5pMBo6v/ELUldEl+I3Oa2hDFacC1UXvh1wS8
** SIG ** 9utLmVxkT/NpRgnCGRF8Qo46NwXi2z8z8kAuzp05RQlg
** SIG ** e1vDmCDMHAA8WZh9AK90ne/XDHsQIdPdnndS3xxNiRBy
** SIG ** G1wu2VSPHOseCNjIGFJUNP/jOvuOMzC0SLKJBcDV+0Yk
** SIG ** ucb9XXF064kWW00Ve/jOi9kAvO23CzZaW/B8pTgfVx6V
** SIG ** BgW9xX9OkFuU/0KD9KxIcLzez6lJ4YRb8HkrfEub0qSd
** SIG ** doGBzSCBvcNq1RIjIn7FVcJGWJ8VOSmJ3AbDF2w5qYEr
** SIG ** 5ALpFdk=
</signature>
</package>

2
desktop.ini Normal file
View File

@@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=ZRCola\res\zrcola.ico,0

View File

@@ -34,6 +34,9 @@
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ResourceCompile>
<Link>
<EnableCOMDATFolding>false</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup />
<Target Name="Sign" Condition="'$(ManifestCertificateThumbprint)' != '' and ('$(ConfigurationType)' == 'Application' or '$(ConfigurationType)' == 'DynamicLibrary')" AfterTargets="_Manifest" BeforeTargets="RegisterOutput" Inputs="$(OutDir)$(TargetName)$(TargetExt)" Outputs="$(IntDir)$(TargetName).sign">

Binary file not shown.

View File

@@ -30,7 +30,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup>

View File

@@ -23,7 +23,7 @@
// Product version as a single DWORD
// Note: Used for version comparison within C/C++ code.
//
#define ZRCOLA_VERSION 0x01ff0100
#define ZRCOLA_VERSION 0x01ff0800
//
// Product version by components
@@ -33,26 +33,26 @@
//
#define ZRCOLA_VERSION_MAJ 1
#define ZRCOLA_VERSION_MIN 255
#define ZRCOLA_VERSION_REV 1
#define ZRCOLA_VERSION_REV 8
#define ZRCOLA_VERSION_BUILD 0
//
// Human readable product version and build year for UI
//
#define ZRCOLA_VERSION_STR "2.0-alpha1"
#define ZRCOLA_VERSION_STR "2.0-beta"
#define ZRCOLA_BUILD_YEAR_STR "2016"
//
// Numerical version presentation for ProductVersion propery in
// MSI packages (syntax: N.N[.N[.N]])
//
#define ZRCOLA_VERSION_INST "1.255.1"
#define ZRCOLA_VERSION_INST "1.255.8"
//
// The product code for ProductCode property in MSI packages
// Replace with new on every version change, regardless how minor it is.
//
#define ZRCOLA_VERSION_GUID "{3A1032A5-E9D0-4603-94A7-C7D31AB4CB89}"
#define ZRCOLA_VERSION_GUID "{9ABAB2D1-7A6B-4D99-B362-D98D53930367}"
//
// The product vendor and application name for configuration keeping.

View File

@@ -19,6 +19,8 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\src\character.cpp" />
<ClCompile Include="..\src\language.cpp" />
<ClCompile Include="..\src\mapping.cpp" />
<ClCompile Include="..\src\normalize.cpp" />
<ClCompile Include="..\src\stdafx.cpp">
@@ -30,7 +32,9 @@
<ClCompile Include="..\src\translate.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\include\zrcola\character.h" />
<ClInclude Include="..\include\zrcola\common.h" />
<ClInclude Include="..\include\zrcola\language.h" />
<ClInclude Include="..\include\zrcola\normalize.h" />
<ClInclude Include="..\include\zrcola\translate.h" />
<ClInclude Include="..\src\stdafx.h" />

View File

@@ -27,6 +27,12 @@
<ClCompile Include="..\src\translate.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\language.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\src\character.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\stdafx.h">
@@ -41,6 +47,12 @@
<ClInclude Include="..\include\zrcola\translate.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\zrcola\language.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\zrcola\character.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\res\libZRCola.rc">

View File

@@ -0,0 +1,542 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common.h"
#include <stdex/idrec.h>
#include <istream>
#include <map>
#include <ostream>
#include <vector>
#include <set>
#include <string>
#pragma warning(push)
#pragma warning(disable: 4200)
#pragma warning(disable: 4251)
#pragma warning(disable: 4512)
namespace ZRCola {
///
/// Character category ID type
/// Two letter abbreviation, non-terminated
///
struct chrcatid_t {
char data[2];
inline chrcatid_t& operator=(const chrcatid_t &src)
{
data[0] = src.data[0];
data[1] = src.data[1];
return *this;
}
inline chrcatid_t& operator=(const char *src)
{
data[1] = (data[0] = src[0]) != 0 ? src[1] : 0;
return *this;
}
};
///
/// Blank character category
///
const chrcatid_t chrcatid_t_blank = {};
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a == \p b
/// - false otherwise
///
inline bool operator==(const chrcatid_t &a, const chrcatid_t & b)
{
return
a.data[0] == b.data[0] &&
(a.data[0] == 0 || a.data[1] == b.data[1]);
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a != \p b
/// - false otherwise
///
inline bool operator!=(const chrcatid_t &a, const chrcatid_t & b)
{
return !operator==(a, b);
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a < \p b
/// - false otherwise
///
inline bool operator<(const chrcatid_t& a, const chrcatid_t& b)
{
if (a.data[0] < b.data[0]) return true;
else if (a.data[0] > b.data[0]) return false;
else if (a.data[1] < b.data[1]) return true;
else return false;
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a > \p b
/// - false otherwise
///
inline bool operator>(const chrcatid_t& a, const chrcatid_t& b)
{
return operator<(b, a);
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a <= \p b
/// - false otherwise
///
inline bool operator<=(const chrcatid_t &a, const chrcatid_t & b)
{
return !operator>(a, b);
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a >= \p b
/// - false otherwise
///
inline bool operator>=(const chrcatid_t &a, const chrcatid_t & b)
{
return !operator<(a, b);
}
///
/// Character Database
///
class ZRCOLA_API character_db {
public:
#pragma pack(push)
#pragma pack(2)
///
/// Character data
///
struct character {
wchar_t chr; ///> Character
chrcatid_t cat; ///> Category ID
unsigned __int16 desc_len; ///< Character description length in \c data
unsigned __int16 rel_len; ///< Related character count in \c data
wchar_t data[]; ///< Character description and list of related characters
};
#pragma pack(pop)
///
/// Character index
///
class indexChar : public index<unsigned __int16, unsigned __int32, character>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexChar(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, character>(h) {}
///
/// Compares two characters by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const character &a, _In_ const character &b) const
{
if (a.chr < b.chr) return -1;
else if (a.chr > b.chr) return 1;
return 0;
}
} idxChr; ///< Character index
textindex<wchar_t, wchar_t, unsigned __int32> idxDsc; ///< Description index
textindex<wchar_t, wchar_t, unsigned __int32> idxDscSub; ///< Description index (sub-terms)
std::vector<unsigned __int16> data; ///< Character data
public:
///
/// Constructs the database
///
inline character_db() : idxChr(data) {}
///
/// Search for characters by description in given categories
///
/// \param[in ] str Search string
/// \param[in ] cats Set of categories, character must be a part of
/// \param[inout] hits (character, count) map to append full-word hits to
/// \param[inout] hits_sub (character, count) map to append partial-word hits to
/// \param[in] fn_abort Pointer to function to periodically test for search cancellation
/// \param[in] cookie Cookie for \p fn_abort call
///
bool Search(_In_z_ const wchar_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, unsigned long> &hits, _Inout_ std::map<wchar_t, unsigned long> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie) = NULL, _In_opt_ void *cookie = NULL) const;
///
/// Get character category
///
/// \param[in] c Character
///
/// \returns
/// - Character category if character found
/// - `ZRCola::chrcatid_t_blank` otherwise
///
inline chrcatid_t GetCharCat(wchar_t c) const
{
char _chr[sizeof(character)];
((character *)_chr)->chr = c;
indexChar::size_type start;
return idxChr.find(*((character *)_chr), start) ? idxChr[start].cat : chrcatid_t_blank;
}
};
typedef ZRCOLA_API stdex::idrec::record<character_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> character_rec;
///
/// Character category database
///
class ZRCOLA_API chrcat_db {
public:
#pragma pack(push)
#pragma pack(2)
///
/// Character category data
///
struct chrcat {
chrcatid_t id; ///< Character category ID
unsigned __int16 rank; ///< Character category rank
unsigned __int16 name_len; ///< \c name length (in characters)
wchar_t name[]; ///< Character category name
};
#pragma pack(pop)
///
/// Character category index
///
class indexChrCat : public index<unsigned __int16, unsigned __int32, chrcat>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexChrCat(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {}
///
/// Compares two character categories by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
{
if (a.id < b.id) return -1;
else if (a.id > b.id) return 1;
else return 0;
}
} idxChrCat; ///< Character category index
///
/// Rank index
///
class indexRank : public index<unsigned __int16, unsigned __int32, chrcat>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexRank(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, chrcat>(h) {}
///
/// Compares two character categories by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
{
if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1;
return 0;
}
///
/// Compares two character categories by rank (for sorting)
///
/// \param[in] a Pointer to character category
/// \param[in] b Pointer to second character category
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare_sort(_In_ const chrcat &a, _In_ const chrcat &b) const
{
if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1;
int r = _wcsncoll(a.name, b.name, std::min<unsigned __int16>(a.name_len, b.name_len));
if (r != 0) return r;
if (a.name_len < b.name_len) return -1;
else if (a.name_len > b.name_len) return +1;
return 0;
}
} idxRnk; ///< Rank index
std::vector<unsigned __int16> data; ///< Character category data
public:
///
/// Constructs the database
///
inline chrcat_db() : idxChrCat(data), idxRnk(data) {}
};
typedef ZRCOLA_API stdex::idrec::record<chrcat_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> chrcat_rec;
};
const ZRCola::recordid_t stdex::idrec::record<ZRCola::character_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"CHR";
const ZRCola::recordid_t stdex::idrec::record<ZRCola::chrcat_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"CCT";
///
/// Reads character database from a stream
///
/// \param[in ] stream Input stream
/// \param[out] db Character database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::character_db &db)
{
// Read character index.
stream >> db.idxChr;
if (!stream.good()) return stream;
// Read description index.
stream >> db.idxDsc;
if (!stream.good()) return stream;
// Read sub-term description index.
stream >> db.idxDscSub;
if (!stream.good()) return stream;
// Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
///
/// Writes character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::character_db &db)
{
// Write character index.
if (stream.fail()) return stream;
stream << db.idxChr;
// Write description index.
if (!stream.good()) return stream;
stream << db.idxDsc;
// Write sub-term description index.
if (!stream.good()) return stream;
stream << db.idxDscSub;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes character category database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character category database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrcat_db &db)
{
// Write character category index.
if (stream.fail()) return stream;
stream << db.idxChrCat;
// Write rank index.
if (stream.fail()) return stream;
stream << db.idxRnk;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Reads character category database from a stream
///
/// \param[in ] stream Input stream
/// \param[out] db Character category database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat_db &db)
{
// Read character category index.
stream >> db.idxChrCat;
if (!stream.good()) return stream;
// Read rank index.
stream >> db.idxRnk;
if (!stream.good()) return stream;
// Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
#pragma warning(pop)

View File

@@ -19,7 +19,13 @@
#pragma once
#include <istream>
#include <ostream>
#include <utility>
#include <vector>
#ifdef _WIN32
#include <Windows.h>
#endif
///
@@ -44,7 +50,7 @@
///
/// Database IDs
///
#define ZRCOLA_DB_ID (*(ZRCola::recordid_t*)"ZRC")
#define ZRCOLA_DB_ID (*(ZRCola::recordid_t*)"ZRC")
namespace ZRCola {
@@ -52,6 +58,174 @@ namespace ZRCola {
typedef unsigned __int32 recordsize_t;
///
/// Key-value index pair for mappings
///
#pragma pack(push)
#pragma pack(2)
template <class T>
struct mappair_t
{
T idx_key; ///< Index of key
T idx_val; ///< Index of value
};
#pragma pack(pop)
///
/// Language ID type
/// Three letter abbreviation, zero terminated
///
struct langid_t {
char data[4];
inline langid_t& operator=(const langid_t &src)
{
data[0] = src.data[0];
data[1] = src.data[1];
data[2] = src.data[2];
data[3] = src.data[3];
return *this;
}
inline langid_t& operator=(const char *src)
{
data[3] = (
data[2] = (
data[1] = (
data[0] = src[0] ) != 0 ?
src[1] : 0) != 0 ?
src[2] : 0) != 0 ?
src[3] : 0;
return *this;
}
};
///
/// Blank language ID
///
const langid_t langid_t_blank = {};
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a == \p b
/// - false otherwise
///
inline bool operator==(const langid_t &a, const langid_t & b)
{
return
a.data[0] == b.data[0] &&
(a.data[0] == 0 || (a.data[1] == b.data[1] &&
(a.data[1] == 0 || (a.data[2] == b.data[2] &&
(a.data[2] == 0 || a.data[3] == b.data[3])))));
}
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a != \p b
/// - false otherwise
///
inline bool operator!=(const langid_t &a, const langid_t & b)
{
return !operator==(a, b);
}
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a < \p b
/// - false otherwise
///
inline bool operator<(const langid_t& a, const langid_t& b)
{
if (a.data[0] < b.data[0]) return true;
else if (a.data[0] > b.data[0]) return false;
else if (a.data[1] < b.data[1]) return true;
else if (a.data[1] > b.data[1]) return false;
else if (a.data[2] < b.data[2]) return true;
else if (a.data[2] > b.data[2]) return false;
else if (a.data[3] < b.data[3]) return true;
else return false;
}
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a > \p b
/// - false otherwise
///
inline bool operator>(const langid_t& a, const langid_t& b)
{
return operator<(b, a);
}
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a <= \p b
/// - false otherwise
///
inline bool operator<=(const langid_t &a, const langid_t & b)
{
return !operator>(a, b);
}
///
/// Compares two language IDs
///
/// \param[in] a First language ID
/// \param[in] b Second language ID
///
/// \returns
/// - true when \p a >= \p b
/// - false otherwise
///
inline bool operator>=(const langid_t &a, const langid_t & b)
{
return !operator<(a, b);
}
#ifdef _WIN32
///
/// Converts language from Windows to ZRCola notation.
///
/// \param[in] lang_win Windows language ID
/// \param[in,out] lang ZRCola language ID
///
void ZRCOLA_API LangConvert(_In_ LANGID lang_win, _Inout_ langid_t &lang);
#endif
///
/// Memory index
///
@@ -156,7 +330,11 @@ namespace ZRCola {
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare_sort(_In_ const T_data &a, _In_ const T_data &b) const = 0;
virtual int compare_sort(_In_ const T_data &a, _In_ const T_data &b) const
{
// Revert to `compare()` by default.
return compare(a, b);
}
///
@@ -168,8 +346,8 @@ namespace ZRCola {
/// \param[out] end Index of the first non-matching element found
///
/// \returns
/// - true if found
/// - false otherwise
/// - \c true if found
/// - \c false otherwise
///
bool find(_In_ const T_data &el, _Out_ size_type &start, _Out_ size_type &end) const
{
@@ -177,7 +355,7 @@ namespace ZRCola {
for (start = 0, end = size(); start < end; ) {
size_type m = (start + end) / 2;
int r = compare(el, at(m));
if (r < 0) end = m;
if (r < 0) end = m;
else if (r > 0) start = m + 1;
else {
// Narrow the search area on the left to start at the first element in the run.
@@ -201,6 +379,40 @@ namespace ZRCola {
return false;
}
///
/// Search for the first element in the index
///
/// \param[in] el Element we are looking for (needle)
/// \param[out] start Index of the first matching element found
///
/// \returns
/// - \c true if found
/// - \c false otherwise
///
bool find(_In_ const T_data &el, _Out_ size_type &start) const
{
// Start with the full search area.
size_t end;
for (start = 0, end = size(); start < end; ) {
size_type m = (start + end) / 2;
int r = compare(el, at(m));
if (r < 0) end = m;
else if (r > 0) start = m + 1;
else {
// Narrow the search area on the left to start at the first element in the run.
for (size_type end2 = m; start < end2;) {
size_type m = (start + end2) / 2;
int r = compare(el, at(m));
if (r <= 0) end2 = m; else start = m + 1;
}
return true;
}
}
return false;
}
private:
static int __cdecl compare_s(void *p, const void *a, const void *b)
{
@@ -211,15 +423,89 @@ namespace ZRCola {
///
/// Composed-decomposed index transformation mapping
/// Memory text index
///
template <class T_key, class T_val, class T_idx = unsigned __int32>
class textindex : public std::vector< mappair_t<T_idx> >
{
public:
typedef std::vector< mappair_t<T_idx> > base_t;
std::vector<T_key> keys; ///< Key data
std::vector<T_val> values; ///< Index values
public:
///
/// Constructs the index
///
textindex() {}
///
/// Finds data for given key
///
/// \param[in ] key Pointer to key
/// \param[in ] key_len Count of \p key elements
/// \param[out] val Pointer to receive pointer to key's values
/// \param[out] val_len Pointer to receive count of \p val elements
///
/// \returns
/// - \c true if found
/// - \c false otherwise
///
bool find(_In_count_(key_len) const T_key *key, _In_ size_t key_len, _Out_ const T_val **val, _Out_ size_t *val_len) const
{
for (size_type start = 0, end = size(); start < end; ) {
size_type m = (start + end) / 2;
int r = compare(key, key_len, m);
if (r < 0) end = m;
else if (r > 0) start = m + 1;
else {
// Get values at position m.
size_t start = base_t::at(m ).idx_val;
*val_len = (m < size() ? base_t::at(m + 1).idx_val : values.size()) - start;
*val = &values.at(start);
return true;
}
}
return false;
}
protected:
inline int compare(_In_count_(key_len) const T_key *key, _In_ size_t key_len, size_type pos) const
{
// Get key at position pos.
size_t
start = base_t::at(pos ).idx_key,
key2_len = (pos < size() ? base_t::at(pos + 1).idx_key : keys.size()) - start;
std::vector<T_key>::const_pointer key2 = &keys.at(start);
// Compare keys.
int r = memcmp(key, key2, sizeof(T_key)*std::min<size_t>(key_len, key2_len));
if (r != 0 ) return r;
else if (key_len < key2_len) return -1;
else if (key_len > key2_len) return 1;
return 0;
}
};
///
/// Source-destination index transformation mapping
///
class ZRCOLA_NOVTABLE ZRCOLA_API mapping {
public:
size_t cmp; ///< Character index in composed string
size_t decmp; ///< Character index in decomposed string
size_t src; ///< Character index in source string
size_t dst; ///< Character index in destination string
inline mapping() {};
inline mapping(_In_ size_t c, _In_ size_t d) : cmp(c), decmp(d) {}
inline mapping(_In_ size_t s, _In_ size_t d) : src(s), dst(d) {}
///
/// Reverses source and destination indexes
///
inline void invert() { size_t tmp = src; src = dst; dst = tmp; }
};
@@ -229,23 +515,212 @@ namespace ZRCola {
class ZRCOLA_API mapping_vector : public std::vector<mapping> {
public:
///
/// Transforms character index of decomposed to composed string
/// Transforms character index of destination to source
///
/// \param[in] decmp Character index in decomposed string
/// \param[in] decmp Character index in destination string
///
/// \returns Character index in composed string
/// \returns Character index in source string
///
size_t to_composed(_In_ size_t decmp) const;
size_t to_src(_In_ size_t dst) const;
///
/// Transforms destination index to source index
/// Transforms source index to destination index
///
/// \param[in] cmp Character index in composed string
/// \param[in] cmp Character index in source string
///
/// \returns Character index in decomposed string
/// \returns Character index in destination string
///
size_t to_decomposed(_In_ size_t cmp) const;
size_t to_dst(_In_ size_t src) const;
///
/// Reverses source and destination indexes
///
inline void invert()
{
for (iterator i = begin(), iEnd = end(); i != iEnd; ++i)
i->invert();
}
};
};
///
/// Writes index to a stream
///
/// \param[in] stream Output stream
/// \param[in] idx Index
///
/// \returns The stream \p stream
///
template <class T, class T_idx, class T_data>
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::index<T, T_idx, T_data> &idx)
{
// Write index count.
ZRCola::index<T, T_idx, T_data>::size_type idx_count = idx.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)idx_count;
stream.write((const char*)&count, sizeof(count));
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(T_idx)*count);
return stream;
}
///
/// Reads index from a stream
///
/// \param[in] stream Input stream
/// \param[out] idx Index
///
/// \returns The stream \p stream
///
template <class T, class T_idx, class T_data>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<T, T_idx, T_data> &idx)
{
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read index data.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(T_idx)*count);
} else
idx.clear();
return stream;
}
///
/// Writes text index to a stream
///
/// \param[in] stream Output stream
/// \param[in] idx Text index
///
/// \returns The stream \p stream
///
template <class T_key, class T_val, class T_idx>
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::textindex<T_key, T_val, T_idx> &idx)
{
unsigned __int32 count;
// Write index count.
ZRCola::textindex<T_key, T_val, T_idx>::size_type idx_count = idx.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)idx_count;
stream.write((const char*)&count, sizeof(count));
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
// Write key count.
std::vector<T_key>::size_type key_count = idx.keys.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)key_count;
stream.write((const char*)&count, sizeof(count));
// Write key data.
if (stream.fail()) return stream;
stream.write((const char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
// Write value count.
std::vector<T_val>::size_type value_count = idx.values.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)value_count;
stream.write((const char*)&count, sizeof(count));
// Write value data.
if (stream.fail()) return stream;
stream.write((const char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
return stream;
}
///
/// Reads text index from a stream
///
/// \param[in] stream Input stream
/// \param[out] idx Text index
///
/// \returns The stream \p stream
///
template <class T_key, class T_val, class T_idx>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textindex<T_key, T_val, T_idx> &idx)
{
unsigned __int32 count;
// Read text index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read text index.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
if (!stream.good()) return stream;
} else
idx.clear();
// Read keys count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read keys.
idx.keys.resize(count);
stream.read((char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
if (!stream.good()) return stream;
} else
idx.keys.clear();
// Read value count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read values.
idx.values.resize(count);
stream.read((char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
} else
idx.values.clear();
return stream;
}
#pragma warning(pop)

View File

@@ -0,0 +1,403 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "common.h"
#include <stdex/idrec.h>
#include <istream>
#include <ostream>
#include <vector>
#include <string>
#pragma warning(push)
#pragma warning(disable: 4200)
#pragma warning(disable: 4251)
#pragma warning(disable: 4512)
namespace ZRCola {
///
/// Language Character Database
///
class ZRCOLA_API langchar_db {
public:
#pragma pack(push)
#pragma pack(2)
///
/// Character data
///
struct langchar {
wchar_t chr; ///> Character
langid_t lang; ///< Language ID
};
#pragma pack(pop)
///
/// Character index
///
class indexChar : public index<unsigned __int16, unsigned __int32, langchar>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexChar(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
///
/// Compares two characters by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const langchar &a, _In_ const langchar &b) const
{
if (a.chr < b.chr) return -1;
else if (a.chr > b.chr) return 1;
return 0;
}
///
/// Compares two characters by ID (for sorting)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare_sort(_In_ const langchar &a, _In_ const langchar &b) const
{
if (a.chr < b.chr) return -1;
else if (a.chr > b.chr) return 1;
if (a.lang < b.lang) return -1;
else if (a.lang > b.lang) return 1;
return 0;
}
} idxChr; ///< Character index
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
///
/// Character Language Index
///
class indexCharLang : public index<unsigned __int16, unsigned __int32, langchar>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexCharLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, langchar>(h) {}
///
/// Compares two languages by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const langchar &a, _In_ const langchar &b) const
{
int r = memcmp(a.lang, b.lang, sizeof(langid_t));
if (r != 0) return r;
return 0;
}
///
/// Compares two languages by ID (for sorting)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare_sort(_In_ const langchar &a, _In_ const langchar &b) const
{
int r = memcmp(a.lang, b.lang, sizeof(langid_t));
if (r != 0) return r;
if (a.chr < b.chr) return -1;
else if (a.chr > b.chr) return 1;
return 0;
}
} idxLng; ///< Character language index
#endif
std::vector<unsigned __int16> data; ///< Character data
public:
///
/// Constructs the database
///
inline langchar_db() : idxChr(data)
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
, idxLng(data)
#endif
{}
///
/// Tests presence of character in the given language
///
/// \param[in] chr Character (UTF-16)
/// \param[in] lang Language
///
/// \returns
/// - \c true when character is used in language
/// - \c false otherwise
bool IsLocalCharacter(_In_ wchar_t chr, _In_ langid_t lang) const;
};
typedef ZRCOLA_API stdex::idrec::record<langchar_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> langchar_rec;
///
/// Language database
///
class ZRCOLA_API language_db {
public:
#pragma pack(push)
#pragma pack(2)
///
/// Language data
///
struct language {
langid_t id; ///< Language ID
unsigned __int16 name_len; ///< \c name length (in characters)
wchar_t name[]; ///< Language name
};
#pragma pack(pop)
///
/// Language index
///
class indexLang : public index<unsigned __int16, unsigned __int32, language>
{
public:
///
/// Constructs the index
///
/// \param[in] h Reference to vector holding the data
///
indexLang(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, language>(h) {}
///
/// Compares two languages by ID (for searching)
///
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
/// - =0 when a == b
/// - >0 when a > b
///
virtual int compare(_In_ const language &a, _In_ const language &b) const
{
if (a.id < b.id) return -1;
else if (a.id > b.id) return 1;
return 0;
}
} idxLng; ///< Language index
std::vector<unsigned __int16> data; ///< Language data
public:
///
/// Constructs the database
///
inline language_db() : idxLng(data) {}
};
typedef ZRCOLA_API stdex::idrec::record<language_db, recordid_t, recordsize_t, ZRCOLA_RECORD_ALIGN> language_rec;
};
const ZRCola::recordid_t stdex::idrec::record<ZRCola::langchar_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"L-C";
const ZRCola::recordid_t stdex::idrec::record<ZRCola::language_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"LNG";
///
/// Writes language character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::langchar_db &db)
{
// Write character index.
if (stream.fail()) return stream;
stream << db.idxChr;
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
// Write language index.
if (stream.fail()) return stream;
stream << db.idxLng;
#endif
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Reads language character database from a stream
///
/// \param[in ] stream Input stream
/// \param[out] db Language character database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langchar_db &db)
{
// Read character index.
stream >> db.idxChr;
if (!stream.good()) return stream;
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
// Read language index.
stream >> db.idxLng;
if (!stream.good()) return stream;
#endif
// Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
///
/// Writes language database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::language_db &db)
{
// Write language index.
if (stream.fail()) return stream;
stream << db.idxLng;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Reads language database from a stream
///
/// \param[in ] stream Input stream
/// \param[out] db Language database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::language_db &db)
{
// Read language index.
stream >> db.idxLng;
if (!stream.good()) return stream;
// Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
#pragma warning(pop)

View File

@@ -20,9 +20,11 @@
#pragma once
#include "common.h"
#include "language.h"
#include <stdex/idrec.h>
#include <istream>
#include <ostream>
#include <vector>
#include <string>
@@ -45,6 +47,7 @@ namespace ZRCola {
///
struct translation {
wchar_t chr; ///< Composed character
unsigned __int16 rank; ///< Decomposition rank
unsigned __int16 str_len; ///< \c str length (in characters)
wchar_t str[]; ///< Decomposed string
@@ -94,8 +97,8 @@ namespace ZRCola {
///
/// Compares two transformations by string (for searching)
///
/// \param[in] a Pointer to key sequence
/// \param[in] b Pointer to second key sequence
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
@@ -150,8 +153,8 @@ namespace ZRCola {
///
/// Compares two transformations by character (for searching)
///
/// \param[in] a Pointer to key sequence
/// \param[in] b Pointer to second key sequence
/// \param[in] a Pointer to first element
/// \param[in] b Pointer to second element
///
/// \returns
/// - <0 when a < b
@@ -182,6 +185,9 @@ namespace ZRCola {
if (a.chr < b.chr) return -1;
else if (a.chr > b.chr) return +1;
if (a.rank < b.rank) return -1;
else if (a.rank > b.rank) return +1;
int r = translation::CompareString(a.str, a.str_len, b.str, b.str_len);
if (r != 0) return r;
@@ -216,7 +222,22 @@ namespace ZRCola {
/// \param[out] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional)
///
void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const
{
Decompose(input, inputMax, NULL, langid_t_blank, output, map);
}
///
/// Decomposes string according ommiting language specific characters
///
/// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.
/// \param[in] lc_db Language character database
/// \param[in] lang Language ID
/// \param[out] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional)
///
void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
};
@@ -227,39 +248,74 @@ namespace ZRCola {
const ZRCola::recordid_t stdex::idrec::record<ZRCola::translation_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"TRN";
///
/// Writes translation database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Translation database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::translation_db &db)
{
// Write composition index.
if (stream.fail()) return stream;
stream << db.idxComp;
// Write decomposition index.
if (stream.fail()) return stream;
stream << db.idxDecomp;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Reads translation database from a stream
///
/// \param[in] stream Input stream
/// \param[in ] stream Input stream
/// \param[out] db Translation database
///
/// \returns The stream \p stream
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db)
{
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read composition index.
db.idxComp.resize(count);
stream.read((char*)db.idxComp.data(), sizeof(unsigned __int32)*count);
stream >> db.idxComp;
if (!stream.good()) return stream;
// Read decomposition index.
db.idxDecomp.resize(count);
stream.read((char*)db.idxDecomp.data(), sizeof(unsigned __int32)*count);
stream >> db.idxDecomp;
if (!stream.good()) return stream;
// Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
if (count) {
// Read data.
db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}

View File

@@ -0,0 +1,113 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
bool ZRCola::character_db::Search(_In_z_ const wchar_t *str, _In_ const std::set<chrcatid_t> &cats, _Inout_ std::map<wchar_t, unsigned long> &hits, _Inout_ std::map<wchar_t, unsigned long> &hits_sub, _In_opt_ bool (__cdecl *fn_abort)(void *cookie), _In_opt_ void *cookie) const
{
assert(str);
while (*str) {
if (fn_abort && fn_abort(cookie)) return false;
// Skip white space.
for (;;) {
if (*str == 0)
return true;
else if (!iswspace(*str))
break;
else
str++;
}
// Get term.
std::wstring term;
if (*str == L'"') {
const wchar_t *str_end = ++str;
for (;;) {
if (*str_end == 0) {
term.assign(str, str_end);
break;
} else if (*str_end == L'"') {
term.assign(str, str_end);
str_end++;
break;
} else
str_end++;
}
str = str_end;
} else {
const wchar_t *str_end = str + 1;
for (; *str_end && !iswspace(*str_end); str_end++);
term.assign(str, str_end);
str = str_end;
}
if (!term.empty()) {
if (fn_abort && fn_abort(cookie)) return false;
// Find the term.
std::transform(term.begin(), term.end(), term.begin(), std::towlower);
if (fn_abort && fn_abort(cookie)) return false;
const wchar_t *data;
size_t len;
if (idxDsc.find(term.c_str(), term.size(), &data, &len)) {
// The term was found.
for (size_t i = 0; i < len; i++) {
if (fn_abort && fn_abort(cookie)) return false;
wchar_t c = data[i];
if (cats.find(GetCharCat(c)) != cats.end()) {
std::map<wchar_t, unsigned long>::iterator idx = hits.find(c);
if (idx == hits.end()) {
// New character.
hits.insert(std::make_pair(data[i], 1));
} else {
// Increment existing character.
idx->second++;
}
}
}
}
if (idxDscSub.find(term.c_str(), term.size(), &data, &len)) {
// The term was found in the sub-term index.
for (size_t i = 0; i < len; i++) {
if (fn_abort && fn_abort(cookie)) return false;
wchar_t c = data[i];
if (cats.find(GetCharCat(c)) != cats.end()) {
std::map<wchar_t, unsigned long>::iterator idx = hits_sub.find(c);
if (idx == hits_sub.end()) {
// New character.
hits_sub.insert(std::make_pair(data[i], 1));
} else {
// Increment existing character.
idx->second++;
}
}
}
}
}
}
return true;
}

Some files were not shown because too many files have changed in this diff Show More