From e4fb91e30574198be6e4729c74bc8515cbebd58f Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 13 May 2016 16:22:51 +0200 Subject: [PATCH] Settings moved from menu(s) to configuration dialog (closes #21) --- ZRCola/ZRCola.fbp | 1024 ++++++++++++++++++++++++++++----- ZRCola/ZRCola.vcxproj | 2 + ZRCola/ZRCola.vcxproj.filters | 6 + ZRCola/locale/sl_SI.po | 204 ++++--- ZRCola/stdafx.h | 1 + ZRCola/zrcolaapp.h | 2 +- ZRCola/zrcolachrgrid.cpp | 8 +- ZRCola/zrcolachrslct.cpp | 7 +- ZRCola/zrcolachrslct.h | 2 +- ZRCola/zrcolacomppnl.cpp | 2 +- ZRCola/zrcolafrm.cpp | 232 ++------ ZRCola/zrcolafrm.h | 17 +- ZRCola/zrcolagui.cpp | 126 +++- ZRCola/zrcolagui.h | 52 +- ZRCola/zrcolasettings.cpp | 190 ++++++ ZRCola/zrcolasettings.h | 72 +++ 16 files changed, 1485 insertions(+), 462 deletions(-) create mode 100644 ZRCola/zrcolasettings.cpp create mode 100644 ZRCola/zrcolasettings.h diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp index bdf79b6..2213abf 100644 --- a/ZRCola/ZRCola.fbp +++ b/ZRCola/ZRCola.fbp @@ -137,25 +137,6 @@ &Program m_menuProgram protected - - - 0 - 1 - Start this program automatically on logon - wxID_AUTOSTART - wxITEM_CHECK - &Start on Logon - m_menuItemAutoStart - none - - - - - - - separator - none - 0 @@ -308,30 +289,24 @@ - + + separator4 + none + + - &Language - m_menuDecompLanguage - protected - - - 0 - 1 - Set language according to keyboard layout automatically - wxID_DECOMP_LANG_AUTO - wxITEM_CHECK - &Automatic - m_menuDecompLanguageAuto - none - - - - - - - m_separatorDecompLanguage1 - none - + 0 + 1 + Open program configuration dialog + wxID_SETTINGS + wxITEM_NORMAL + &Settings... + m_menuSettings + none + + + + @@ -719,92 +694,6 @@ - - protected - - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - - 0 - - - 0 - - 1 - m_toolDecompLanguage - 1 - - - protected - 1 - - Resizable - 0 - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - OnDecompLanguageChoice - - - - - - - - - - - - - - - - - - - - - - - 1 @@ -3617,5 +3506,884 @@ + + 0 + wxAUI_MGR_DEFAULT + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + -1,-1 + + wxZRColaSettingsBase + + -1,-1 + wxDEFAULT_DIALOG_STYLE + + Settings + + + ZRColaSettings + + + + + + + + + + + + + + + + + OnInitDialog + + + + + + + + + + + + + + + + + + + + + + + bSizerContent + wxVERTICAL + none + + 5 + wxEXPAND | wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,-1 + 1 + m_listbook + 1 + + + protected + 1 + + Resizable + 1 + + wxLB_DEFAULT + + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Text Language + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelLanguage + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerLanguage + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Some character native to specific language you are working with should not decompose to primitives. For optimal decomposition you should set the language correctly. + + 0 + + + 0 + + 1 + m_langLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Select language &automatically according to selected keyboard + + 0 + + + 0 + + 1 + m_langAuto + 1 + + + protected + 1 + + Resizable + 1 + + wxRB_GROUP + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnLangAuto + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + &Manually select the language from the list below: + + 0 + + + 0 + + 1 + m_langManual + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + 0 + + + + + + + + + + + + + + + + + + + + + OnLangManual + + + + + + + + + + 5 + wxALL|wxEXPAND + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + -1,150 + 1 + m_languages + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Startup + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_panelAutoStart + 1 + + + protected + 1 + + Resizable + 1 + + + 0 + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + bSizerAutoStart + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + ZRCola can be launched every time you log in to your computer. It will be available on the system tray and via registered shortcuts Win+F5 and Win+F6. + + 0 + + + 0 + + 1 + m_autoStartLabel + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Start ZRCola &automatically on logon + + 0 + + + 0 + + 1 + m_autoStart + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 0 + protected + 0 + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 0 + 0 + 0 + 1 + 0 + 0 + + m_sdbSizerButtons + protected + OnApplyButtonClick + + + + + OnOKButtonClick + + + + + + diff --git a/ZRCola/ZRCola.vcxproj b/ZRCola/ZRCola.vcxproj index 6b5abd5..e5d4988 100644 --- a/ZRCola/ZRCola.vcxproj +++ b/ZRCola/ZRCola.vcxproj @@ -88,6 +88,7 @@ + @@ -99,6 +100,7 @@ + diff --git a/ZRCola/ZRCola.vcxproj.filters b/ZRCola/ZRCola.vcxproj.filters index f328a27..b0b6baf 100644 --- a/ZRCola/ZRCola.vcxproj.filters +++ b/ZRCola/ZRCola.vcxproj.filters @@ -46,6 +46,9 @@ Source Files + + Source Files + @@ -75,6 +78,9 @@ Header Files + + Header Files + diff --git a/ZRCola/locale/sl_SI.po b/ZRCola/locale/sl_SI.po index e7d0c20..111ea56 100644 --- a/ZRCola/locale/sl_SI.po +++ b/ZRCola/locale/sl_SI.po @@ -1,8 +1,8 @@ msgid "" msgstr "" "Project-Id-Version: ZRCola\n" -"POT-Creation-Date: 2016-05-13 13:33+0200\n" -"PO-Revision-Date: 2016-05-13 13:34+0200\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 \n" "Language-Team: Amebis, d. o. o., Kamnik \n" "Language: sl_SI\n" @@ -17,19 +17,14 @@ msgstr "" "X-Poedit-KeywordsList: _\n" "X-Poedit-SearchPath-0: .\n" -#: zrcolafrm.cpp:96 zrcolagui.h:97 MSIBuild/En.Win32.Release.Feature-2.idtx:4 +#: 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:107 -#, c-format -msgid "Select %s language for decomposition" -msgstr "Izberi jezik %s za razstavljanje" - -#: zrcolafrm.cpp:129 +#: zrcolafrm.cpp:108 msgid "" "ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality " "will not be available." @@ -37,11 +32,11 @@ msgstr "" "ZRColine bližnjice na tipkovnici Win+F5 ni mogoče registrirati. Nekaj " "funkcionalnosti ne bo na voljo." -#: zrcolafrm.cpp:129 zrcolafrm.cpp:131 +#: zrcolafrm.cpp:108 zrcolafrm.cpp:110 msgid "Warning" msgstr "Opozorilo" -#: zrcolafrm.cpp:131 +#: zrcolafrm.cpp:110 msgid "" "ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality " "will not be available." @@ -49,15 +44,11 @@ msgstr "" "ZRColine bližnjice na tipkovnici Win+F6 ni mogoče registrirati. Nekaj " "funkcionalnosti ne bo na voljo." -#: zrcolafrm.cpp:214 -msgid "Start ZRCola automatically on logon" -msgstr "Samodejno zaženi ZRColo ob prijavi" - -#: zrcolafrm.cpp:464 +#: zrcolafrm.cpp:336 msgid "http://zrcola-2.amebis.si/en/contact/" msgstr "http://zrcola-2.amebis.si/contact/" -#: zrcolafrm.cpp:470 +#: zrcolafrm.cpp:342 #, c-format msgid "" "ZRCola v%s\n" @@ -66,214 +57,242 @@ msgstr "" "ZRCola v%s\n" "Vse pravice pridržane 2015-%s Amebis" -#: zrcolafrm.cpp:470 +#: zrcolafrm.cpp:342 msgid "About ZRCola" msgstr "O ZRColi" #: zrcolagui.cpp:36 -msgid "&Start on Logon" -msgstr "Z&aženi ob prijavi" - -#: zrcolagui.cpp:36 -msgid "Start this program automatically on logon" -msgstr "Samodejno zaženi ta program ob prijavi" - -#: zrcolagui.cpp:42 msgid "E&xit" msgstr "I&zhod" -#: zrcolagui.cpp:42 +#: zrcolagui.cpp:36 msgid "Quit this program" msgstr "Zapri ta program" -#: zrcolagui.cpp:45 +#: zrcolagui.cpp:39 msgid "&Program" msgstr "&Program" -#: zrcolagui.cpp:78 +#: zrcolagui.cpp:72 msgid "Select &All" msgstr "Izberi &vse" -#: zrcolagui.cpp:78 +#: zrcolagui.cpp:72 msgid "Select all text" msgstr "Izberi celotno besedilo" -#: zrcolagui.cpp:84 +#: zrcolagui.cpp:78 msgid "C&haracter Selector..." msgstr "Izbirnik &znaka ..." -#: zrcolagui.cpp:84 zrcolagui.cpp:176 +#: 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:95 +#: zrcolagui.cpp:89 msgid "&Send Composed" msgstr "Pošlji &sestavljeno" -#: zrcolagui.cpp:95 zrcolagui.cpp:178 +#: zrcolagui.cpp:89 zrcolagui.cpp:168 msgid "Send composed text to source window" msgstr "Pošlji sestavljeno besedilo izvornemu oknu" -#: zrcolagui.cpp:104 +#: zrcolagui.cpp:98 msgid "Send &Decomposed" msgstr "Pošlji &razstavljeno" -#: zrcolagui.cpp:104 zrcolagui.cpp:180 +#: zrcolagui.cpp:98 zrcolagui.cpp:170 msgid "Send decomposed text to source window" msgstr "Pošlji razstavljeno besedilo izvornemu oknu" -#: zrcolagui.cpp:113 +#: zrcolagui.cpp:107 msgid "Abort (De)composition" msgstr "Prekini raz/sestavljanje" -#: zrcolagui.cpp:113 +#: zrcolagui.cpp:107 msgid "Abort composition and return focus to source window" msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu" -#: zrcolagui.cpp:122 -msgid "&Language" -msgstr "&Jezik" +#: zrcolagui.cpp:118 +msgid "&Settings..." +msgstr "Na&stavitve ..." -#: zrcolagui.cpp:124 -msgid "&Automatic" -msgstr "S&amodejno" +#: zrcolagui.cpp:118 +msgid "Open program configuration dialog" +msgstr "Odpri nastavitveni dialog programa" -#: zrcolagui.cpp:124 -msgid "Set language according to keyboard layout automatically" -msgstr "Samodejno nastavi jezik glede na izbrano tipkovnico" - -#: zrcolagui.cpp:131 +#: zrcolagui.cpp:121 msgid "&Edit" msgstr "Ur&edi" -#: zrcolagui.cpp:135 +#: zrcolagui.cpp:125 msgid "&Edit Toolbar" msgstr "Orodna vrstica za ur&ejanje" -#: zrcolagui.cpp:135 +#: zrcolagui.cpp:125 msgid "Toggle edit toolbar" msgstr "Prikaži/skrij orodno vrstico za urejanje" -#: zrcolagui.cpp:139 +#: zrcolagui.cpp:129 msgid "&Compose Toolbar" msgstr "Orodna vrsti&ca za sestavljanje" -#: zrcolagui.cpp:139 +#: zrcolagui.cpp:129 msgid "Toggle compose toolbar" msgstr "Prikaži/skrij orodno vrstico za sestavljanje" -#: zrcolagui.cpp:145 +#: zrcolagui.cpp:135 msgid "Character Catalo&g" msgstr "Katalo&g znakov" -#: zrcolagui.cpp:145 +#: zrcolagui.cpp:135 msgid "Toggle character catalog panel" msgstr "Prikaži/skrij katalog znakov" -#: zrcolagui.cpp:148 +#: zrcolagui.cpp:138 msgid "&View" msgstr "Po&gled" -#: zrcolagui.cpp:152 +#: zrcolagui.cpp:142 msgid "&Request a new character..." msgstr "&Zahtevaj nov znak ..." -#: zrcolagui.cpp:152 +#: 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:161 +#: zrcolagui.cpp:151 msgid "&Help" msgstr "Po&moč" -#: zrcolagui.cpp:166 +#: zrcolagui.cpp:156 msgid "Cut" msgstr "Izreži" -#: zrcolagui.cpp:166 +#: zrcolagui.cpp:156 msgid "Cut selection" msgstr "Izreži izbor" -#: zrcolagui.cpp:168 +#: zrcolagui.cpp:158 msgid "Copy" msgstr "Kopiraj" -#: zrcolagui.cpp:168 +#: zrcolagui.cpp:158 msgid "Copy selection" msgstr "Kopiraj izbor" -#: zrcolagui.cpp:170 +#: zrcolagui.cpp:160 msgid "Paste" msgstr "Prilepi" -#: zrcolagui.cpp:170 +#: zrcolagui.cpp:160 msgid "Paste selection" msgstr "Prilepi izbor" -#: zrcolagui.cpp:173 +#: zrcolagui.cpp:163 msgid "Edit" msgstr "Urejanje" -#: zrcolagui.cpp:176 zrcolagui.h:221 +#: zrcolagui.cpp:166 zrcolagui.h:222 msgid "Character Selector" msgstr "Izbirnik znaka" -#: zrcolagui.cpp:178 +#: zrcolagui.cpp:168 msgid "Send Composed" msgstr "Pošlji sestavljeno" -#: zrcolagui.cpp:180 +#: zrcolagui.cpp:170 msgid "Send Decomposed" msgstr "Pošlji razstavljeno" -#: zrcolagui.cpp:189 +#: zrcolagui.cpp:173 msgid "Compose" msgstr "Sestavljanje" -#: zrcolagui.cpp:193 +#: zrcolagui.cpp:177 msgid "Character Catalog" msgstr "Katalog znakov" -#: zrcolagui.cpp:197 +#: zrcolagui.cpp:181 msgid "(De)Composer" msgstr "Raz/Sestavljalnik" -#: zrcolagui.cpp:236 +#: zrcolagui.cpp:218 msgid "Decomposed Text" msgstr "Razstavljeno besedilo" -#: zrcolagui.cpp:256 +#: zrcolagui.cpp:238 msgid "Decomposed Unicode Dump" msgstr "Unicode razstavljenega" -#: zrcolagui.cpp:283 +#: zrcolagui.cpp:265 msgid "Composed Text" msgstr "Sestavljeno besedilo" -#: zrcolagui.cpp:303 +#: zrcolagui.cpp:285 msgid "Composed Unicode Dump" msgstr "Unicode sestavljenega" -#: zrcolagui.cpp:423 +#: zrcolagui.cpp:405 msgid "&Browse" msgstr "Pre&brskaj" -#: zrcolagui.cpp:471 +#: zrcolagui.cpp:453 msgid "Re¢ly Used" msgstr "Nedavno &uporabljeni" -#: zrcolagui.cpp:512 +#: zrcolagui.cpp:494 msgid "Preview" msgstr "Predogled" -#: zrcolagui.cpp:517 +#: zrcolagui.cpp:499 msgid "U+" msgstr "U+" -#: zrcolagui.cpp:568 +#: 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 " @@ -282,6 +301,14 @@ 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.Release.Feature-2.idtx:3 #: MSIBuild/En.Win32.Release.Shortcut-2.idtx:3 @@ -297,6 +324,21 @@ msgstr "1250" 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" diff --git a/ZRCola/stdafx.h b/ZRCola/stdafx.h index 58ae859..8c88ba5 100644 --- a/ZRCola/stdafx.h +++ b/ZRCola/stdafx.h @@ -48,3 +48,4 @@ #include "zrcolacomppnl.h" #include "zrcolafrm.h" #include "zrcolakeyhndlr.h" +#include "zrcolasettings.h" diff --git a/ZRCola/zrcolaapp.h b/ZRCola/zrcolaapp.h index b7c83b6..77339d9 100644 --- a/ZRCola/zrcolaapp.h +++ b/ZRCola/zrcolaapp.h @@ -69,7 +69,7 @@ public: wxZRColaFrame *m_mainWnd; ///< Main window protected: - wxLocale m_locale; ///< Current locale + wxLocale m_locale; ///< Current locale }; diff --git a/ZRCola/zrcolachrgrid.cpp b/ZRCola/zrcolachrgrid.cpp index 16555c9..73d7700 100644 --- a/ZRCola/zrcolachrgrid.cpp +++ b/ZRCola/zrcolachrgrid.cpp @@ -88,11 +88,9 @@ wxString wxZRColaCharGrid::GetToolTipText(int idx) // See if this character has a key sequence registered. ZRCola::keyseq_db::indexKey::size_type start; bool found; - ZRCola::keyseq_db::keyseq *ks = (ZRCola::keyseq_db::keyseq*)new char[sizeof(ZRCola::keyseq_db::keyseq)]; - ks->chr = m_chars[idx]; - ks->seq_len = 0; - found = app->m_ks_db.idxChr.find(*ks, start); - delete ks; + 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]; diff --git a/ZRCola/zrcolachrslct.cpp b/ZRCola/zrcolachrslct.cpp index 2cb3436..331706e 100644 --- a/ZRCola/zrcolachrslct.cpp +++ b/ZRCola/zrcolachrslct.cpp @@ -71,10 +71,10 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event) m_gridPreview->SetCellValue(wxString(1, m_char), 0, 0); { - ZRCola::character_db::character *chr = (ZRCola::character_db::character*)new char[sizeof(ZRCola::character_db::character)]; - chr->chr = m_char; + 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(*chr, 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)); { @@ -94,7 +94,6 @@ void wxZRColaCharSelect::OnIdle(wxIdleEvent& event) m_gridRelated->ClearGrid(); } m_gridRelated->Scroll(0, 0); - delete chr; } } diff --git a/ZRCola/zrcolachrslct.h b/ZRCola/zrcolachrslct.h index 2646ad6..e23c3a7 100644 --- a/ZRCola/zrcolachrslct.h +++ b/ZRCola/zrcolachrslct.h @@ -17,11 +17,11 @@ along with ZRCola. If not, see . */ - /// /// Forward declarations /// class wxZRColaCharSelect; +class wxPersistentZRColaCharSelect; #pragma once diff --git a/ZRCola/zrcolacomppnl.cpp b/ZRCola/zrcolacomppnl.cpp index f34aeab..6dd5ccc 100644 --- a/ZRCola/zrcolacomppnl.cpp +++ b/ZRCola/zrcolacomppnl.cpp @@ -119,7 +119,7 @@ void wxZRColaComposerPanel::SynchronizePanels() std::wstring dst; wxZRColaFrame *mainWnd = dynamic_cast(wxGetActiveWindow()); if (mainWnd) - app->m_t_db.Decompose(src.data(), len, &app->m_lc_db, mainWnd->m_lang, dst, &m_mapping2); + 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); diff --git a/ZRCola/zrcolafrm.cpp b/ZRCola/zrcolafrm.cpp index 3645973..e1c3602 100644 --- a/ZRCola/zrcolafrm.cpp +++ b/ZRCola/zrcolafrm.cpp @@ -25,46 +25,40 @@ ////////////////////////////////////////////////////////////////////////// wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase) - EVT_UPDATE_UI (wxID_AUTOSTART , wxZRColaFrame::OnAutostartUpdate ) - EVT_MENU (wxID_AUTOSTART , wxZRColaFrame::OnAutostart ) - EVT_MENU (wxID_EXIT , wxZRColaFrame::OnExit ) + EVT_MENU (wxID_EXIT , wxZRColaFrame::OnExit ) - 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_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_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_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter ) - 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_UPDATE_UI (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAutoUpdate) - EVT_MENU (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAuto ) - EVT_UPDATE_UI_RANGE(wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguageUpdate ) - EVT_MENU_RANGE (wxID_DECOMP_LANGUAGE_START, wxID_DECOMP_LANGUAGE_END, wxZRColaFrame::OnDecomposedLanguage ) + 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_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_HELP_REQCHAR , wxZRColaFrame::OnHelpReqChar ) - EVT_MENU (wxID_ABOUT , wxZRColaFrame::OnAbout ) + EVT_MENU (wxID_ABOUT , wxZRColaFrame::OnAbout ) wxEND_EVENT_TABLE() wxZRColaFrame::wxZRColaFrame() : - m_lang_auto(true), - m_lang(ZRCola::langid_t_blank), m_hWndSource(NULL), m_chrSelect(NULL), + m_settings(NULL), wxZRColaFrameBase(NULL) { { @@ -100,30 +94,15 @@ wxZRColaFrame::wxZRColaFrame() : delete m_taskBarIcon; } - { - // Populate language lists. - ZRColaApp *app = ((ZRColaApp*)wxTheApp); - m_toolDecompLanguage->Clear(); - wxString label1_tran(_("Select %s language for decomposition")); - 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_tran2(wxGetTranslation(label, wxT("ZRCola-zrcdb"))); - if (i < wxID_DECOMP_LANGUAGE_END - wxID_DECOMP_LANGUAGE_START + 1) - m_menuDecompLanguage->AppendRadioItem(wxID_DECOMP_LANGUAGE_START + i, label_tran2, wxString::Format(label1_tran, (const wxStringCharType*)label_tran2)); - m_toolDecompLanguage->Insert(label_tran2, i); - if (m_lang == lang.id) - m_toolDecompLanguage->Select(i); - } - } - - // Set focus. - m_panel->m_decomposed->SetFocus(); + m_settings = new wxZRColaSettings(this); + wxPersistentRegisterAndRestore(m_settings); m_chrSelect = new wxZRColaCharSelect(this); wxPersistentRegisterAndRestore(m_chrSelect); + // Set focus. + m_panel->m_decomposed->SetFocus(); + // Register global hotkey(s). if (!RegisterHotKey(wxZRColaHKID_INVOKE_COMPOSE, wxMOD_WIN, VK_F5)) wxMessageBox(_("ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING); @@ -175,6 +154,9 @@ wxZRColaFrame::~wxZRColaFrame() 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; @@ -186,51 +168,6 @@ wxZRColaFrame::~wxZRColaFrame() } -void wxZRColaFrame::OnAutostartUpdate(wxUpdateUIEvent& event) -{ -#if defined(__WXMSW__) - wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk")); - event.Check(wxFileExists(linkName)); -#else - event.Enable(false); -#endif -} - - -void wxZRColaFrame::OnAutostart(wxCommandEvent& event) -{ -#if defined(__WXMSW__) - wxString linkName(wxExpandEnvVars("%APPDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\ZRCola.lnk")); - if (wxFileExists(linkName)) { - // The shortcut already exists. Remove it. - wxRemoveFile(linkName); - } else { - // 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(); - } - } -#endif -} - - void wxZRColaFrame::OnExit(wxCommandEvent& event) { Close(); @@ -307,74 +244,9 @@ void wxZRColaFrame::OnSendAbort(wxCommandEvent& event) } -void wxZRColaFrame::OnDecomposedLanguageAutoUpdate(wxUpdateUIEvent& event) +void wxZRColaFrame::OnSettings(wxCommandEvent& event) { -#if defined(__WXMSW__) - event.Check(m_lang_auto); -#else - event.Enable(false); -#endif -} - - -void wxZRColaFrame::OnDecomposedLanguageAuto(wxCommandEvent& event) -{ - // Toggle auto language flag. - m_lang_auto = !m_lang_auto; - - if (m_lang_auto) { -#if defined(__WXMSW__) - // Set keyboard language. - HKL hkl = ::GetKeyboardLayout(0); - ZRCola::LangConvert(LOWORD(hkl), m_lang); - UpdateDecomposedLanguage(); -#endif - } -} - - -void wxZRColaFrame::OnDecomposedLanguageUpdate(wxUpdateUIEvent& event) -{ - ZRColaApp *app = ((ZRColaApp*)wxTheApp); - const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[event.GetId() - wxID_DECOMP_LANGUAGE_START]; - event.Check(m_lang == lang.id); -} - - -void wxZRColaFrame::OnDecomposedLanguage(wxCommandEvent& event) -{ - ZRColaApp *app = ((ZRColaApp*)wxTheApp); - size_t i = event.GetId() - wxID_DECOMP_LANGUAGE_START; - const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[i]; - - if (m_lang != lang.id) { - m_lang = lang.id; - m_toolDecompLanguage->Select(i); - - // Notify composed text something changed and should re-decompose. - wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED); - m_panel->m_composed->ProcessWindowEvent(event2); - m_lang_auto = false; - } -} - - -void wxZRColaFrame::OnDecompLanguageChoice(wxCommandEvent& event) -{ - ZRColaApp *app = ((ZRColaApp*)wxTheApp); - size_t i = event.GetSelection(); - const ZRCola::language_db::language &lang = app->m_lang_db.idxLng[i]; - - if (m_lang != lang.id) { - m_lang = lang.id; - - // Notify composed text something changed and should re-decompose. - wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED); - m_panel->m_composed->ProcessWindowEvent(event2); - m_lang_auto = false; - } - - event.Skip(); + m_settings->ShowModal(); } @@ -482,11 +354,10 @@ HRESULT STDMETHODCALLTYPE wxZRColaFrame::OnLanguageChange(LANGID langid, __RPC__ HRESULT STDMETHODCALLTYPE wxZRColaFrame::OnLanguageChanged() { - if (m_lang_auto) { + if (m_settings->m_lang_auto) { // Set keyboard language. HKL hkl = ::GetKeyboardLayout(0); - ZRCola::LangConvert(LOWORD(hkl), m_lang); - UpdateDecomposedLanguage(); + ZRCola::LangConvert(LOWORD(hkl), m_settings->m_lang); } return S_OK; @@ -565,20 +436,6 @@ void wxZRColaFrame::DoSend(const wxString& str) } -void wxZRColaFrame::UpdateDecomposedLanguage() -{ - ZRColaApp *app = ((ZRColaApp*)wxTheApp); - - // Find language on the language list. - ZRCola::language_db::language *l = new ZRCola::language_db::language; - l->id = m_lang; - l->name_len = 0; - ZRCola::language_db::indexLang::size_type start; - m_toolDecompLanguage->SetSelection(app->m_lang_db.idxLng.find(*l, start) ? start : -1); - delete l; -} - - #ifdef __WXMSW__ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) @@ -646,8 +503,6 @@ void wxPersistentZRColaFrame::Save() const wxPersistentZRColaComposerPanel(wnd->m_panel).Save(); wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Save(); - SaveValue(wxT("langAuto" ), wnd->m_lang_auto); - SaveValue(wxT("lang" ), wxString::FromAscii(wnd->m_lang.data, _countof(wnd->m_lang.data))); wxPersistentTLW::Save(); } @@ -658,27 +513,6 @@ bool wxPersistentZRColaFrame::Restore() wxZRColaFrame * const wnd = static_cast(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; - wnd->UpdateDecomposedLanguage(); - wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Restore(); wxPersistentZRColaComposerPanel(wnd->m_panel).Restore(); diff --git a/ZRCola/zrcolafrm.h b/ZRCola/zrcolafrm.h index e6dd222..0bd9e02 100644 --- a/ZRCola/zrcolafrm.h +++ b/ZRCola/zrcolafrm.h @@ -27,6 +27,7 @@ class wxZRColaFrame; #include "zrcolagui.h" #include "zrcolachrslct.h" +#include "zrcolasettings.h" #include #include #include @@ -54,9 +55,7 @@ class wxZRColaFrame : public: enum { - wxID_DECOMP_LANGUAGE_START = 6000, - wxID_DECOMP_LANGUAGE_END = 6099, - wxID_FOCUS_CHARACTER_CATALOG, + wxID_FOCUS_CHARACTER_CATALOG = 2000, }; wxZRColaFrame(); @@ -66,8 +65,6 @@ public: friend class wxZRColaComposerPanel; protected: - void OnAutostartUpdate(wxUpdateUIEvent& event); - void OnAutostart(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnForwardEventUpdate(wxUpdateUIEvent& event); void OnForwardEvent(wxCommandEvent& event); @@ -76,11 +73,7 @@ protected: void OnSendComposed(wxCommandEvent& event); void OnSendDecomposed(wxCommandEvent& event); void OnSendAbort(wxCommandEvent& event); - void OnDecomposedLanguageAutoUpdate(wxUpdateUIEvent& event); - void OnDecomposedLanguageAuto(wxCommandEvent& event); - void OnDecomposedLanguageUpdate(wxUpdateUIEvent& event); - void OnDecomposedLanguage(wxCommandEvent& event); - virtual void OnDecompLanguageChoice(wxCommandEvent& event); + void OnSettings(wxCommandEvent& event); virtual void OnIdle(wxIdleEvent& event); void OnTaskbarIconClick(wxTaskBarIconEvent& event); virtual void OnIconize(wxIconizeEvent& event); @@ -113,7 +106,6 @@ protected: private: void DoSend(const wxString& str); - void UpdateDecomposedLanguage(); protected: #ifdef __WXMSW__ @@ -121,11 +113,10 @@ protected: #endif protected: - bool m_lang_auto; ///< Automatic language selection according to keyboard layout - ZRCola::langid_t m_lang; ///< Language for decomposing 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 }; diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp index 9d26af2..a5f5b5b 100644 --- a/ZRCola/zrcolagui.cpp +++ b/ZRCola/zrcolagui.cpp @@ -32,12 +32,6 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS m_menubar = new wxMenuBar( 0 ); m_menuProgram = new wxMenu(); - wxMenuItem* m_menuItemAutoStart; - m_menuItemAutoStart = new wxMenuItem( m_menuProgram, wxID_AUTOSTART, wxString( _("&Start on Logon") ) , _("Start this program automatically on logon"), wxITEM_CHECK ); - m_menuProgram->Append( m_menuItemAutoStart ); - - m_menuProgram->AppendSeparator(); - wxMenuItem* 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 ); @@ -118,15 +112,11 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS #endif m_menuEdit->Append( m_menuItemSendAbort ); - m_menuDecompLanguage = new wxMenu(); - wxMenuItem* m_menuDecompLanguageItem = new wxMenuItem( m_menuEdit, wxID_ANY, _("&Language"), wxEmptyString, wxITEM_NORMAL, m_menuDecompLanguage ); - wxMenuItem* m_menuDecompLanguageAuto; - m_menuDecompLanguageAuto = new wxMenuItem( m_menuDecompLanguage, wxID_DECOMP_LANG_AUTO, wxString( _("&Automatic") ) , _("Set language according to keyboard layout automatically"), wxITEM_CHECK ); - m_menuDecompLanguage->Append( m_menuDecompLanguageAuto ); + m_menuEdit->AppendSeparator(); - m_menuDecompLanguage->AppendSeparator(); - - m_menuEdit->Append( m_menuDecompLanguageItem ); + 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") ); @@ -179,12 +169,6 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS 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->AddSeparator(); - - wxArrayString m_toolDecompLanguageChoices; - m_toolDecompLanguage = new wxChoice( m_toolbarCompose, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_toolDecompLanguageChoices, 0 ); - m_toolDecompLanguage->SetSelection( 0 ); - m_toolbarCompose->AddControl( m_toolDecompLanguage ); 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() ); @@ -204,7 +188,6 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS // Connect Events this->Connect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) ); this->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) ); - m_toolDecompLanguage->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( wxZRColaFrameBase::OnDecompLanguageChoice ), NULL, this ); } wxZRColaFrameBase::~wxZRColaFrameBase() @@ -212,7 +195,6 @@ wxZRColaFrameBase::~wxZRColaFrameBase() // Disconnect Events this->Disconnect( wxEVT_ICONIZE, wxIconizeEventHandler( wxZRColaFrameBase::OnIconize ) ); this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaFrameBase::OnIdle ) ); - m_toolDecompLanguage->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( wxZRColaFrameBase::OnDecompLanguageChoice ), NULL, this ); m_mgr.UnInit(); @@ -652,3 +634,103 @@ wxZRColaCharSelectBase::~wxZRColaCharSelectBase() 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 ); + +} diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h index e0b3cc4..09c2efb 100644 --- a/ZRCola/zrcolagui.h +++ b/ZRCola/zrcolagui.h @@ -25,7 +25,6 @@ class wxZRColaCharGrid; #include #include #include -#include class wxZRColaCharacterCatalogPanel; class wxZRColaComposerPanel; #include @@ -36,12 +35,18 @@ class wxZRColaComposerPanel; #include #include #include +#include #include #include #include #include #include #include +#include +#include +#include +#include +#include /////////////////////////////////////////////////////////////////////////// @@ -55,12 +60,11 @@ class wxZRColaFrameBase : public wxFrame protected: enum { - wxID_AUTOSTART = 1000, - wxID_CHARACTER_SELECTOR, + wxID_CHARACTER_SELECTOR = 1000, wxID_SEND_COMPOSED, wxID_SEND_DECOMPOSED, wxID_SEND_ABORT, - wxID_DECOMP_LANG_AUTO, + wxID_SETTINGS, wxID_TOOLBAR_EDIT, wxID_TOOLBAR_COMPOSE, wxID_PANEL_CHRGRPS, @@ -70,7 +74,6 @@ class wxZRColaFrameBase : public wxFrame wxMenuBar* m_menubar; wxMenu* m_menuProgram; wxMenu* m_menuEdit; - wxMenu* m_menuDecompLanguage; wxMenu* m_menuView; wxMenu* m_menuHelp; wxAuiToolBar* m_toolbarEdit; @@ -81,14 +84,12 @@ class wxZRColaFrameBase : public wxFrame wxAuiToolBarItem* m_toolCharSelect; wxAuiToolBarItem* m_toolSendComposed; wxAuiToolBarItem* m_toolSendDecomposed; - wxChoice* m_toolDecompLanguage; 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(); } - virtual void OnDecompLanguageChoice( wxCommandEvent& event ) { event.Skip(); } public: @@ -223,4 +224,41 @@ class wxZRColaCharSelectBase : public wxDialog }; +/////////////////////////////////////////////////////////////////////////////// +/// 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(); + +}; + #endif //__ZRCOLAGUI_H__ diff --git a/ZRCola/zrcolasettings.cpp b/ZRCola/zrcolasettings.cpp new file mode 100644 index 0000000..a657f8e --- /dev/null +++ b/ZRCola/zrcolasettings.cpp @@ -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 . +*/ + +#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(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(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(); +} diff --git a/ZRCola/zrcolasettings.h b/ZRCola/zrcolasettings.h new file mode 100644 index 0000000..743617a --- /dev/null +++ b/ZRCola/zrcolasettings.h @@ -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 . +*/ + +/// +/// Forward declarations +/// +class wxZRColaSettings; +class wxPersistentZRColaSettings; + + +#pragma once + +#include "zrcolagui.h" +#include + + +/// +/// 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); +}