diff --git a/ZRCola/ZRCola.fbp b/ZRCola/ZRCola.fbp
index e7f87b9..cb08ac2 100644
--- a/ZRCola/ZRCola.fbp
+++ b/ZRCola/ZRCola.fbp
@@ -153,7 +153,7 @@
+
+
+
+
diff --git a/ZRCola/ZRCola.vcxproj b/ZRCola/ZRCola.vcxproj
index 2509f21..d6beaaf 100644
--- a/ZRCola/ZRCola.vcxproj
+++ b/ZRCola/ZRCola.vcxproj
@@ -81,6 +81,8 @@
Create
+
+
@@ -89,6 +91,8 @@
+
+
diff --git a/ZRCola/ZRCola.vcxproj.filters b/ZRCola/ZRCola.vcxproj.filters
index 0e7ebea..0303d60 100644
--- a/ZRCola/ZRCola.vcxproj.filters
+++ b/ZRCola/ZRCola.vcxproj.filters
@@ -37,6 +37,12 @@
Source Files
+
+ Source Files
+
+
+ Source Files
+
@@ -57,6 +63,12 @@
Header Files
+
+ Header Files
+
+
+ Header Files
+
diff --git a/ZRCola/locale/sl_SI.po b/ZRCola/locale/sl_SI.po
index a4939ea..af96b90 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-03 13:27+0200\n"
-"PO-Revision-Date: 2016-05-03 13:27+0200\n"
+"POT-Creation-Date: 2016-05-05 15:23+0200\n"
+"PO-Revision-Date: 2016-05-05 15:23+0200\n"
"Last-Translator: Simon Rozman \n"
"Language-Team: Amebis, d. o. o., Kamnik \n"
"Language: sl_SI\n"
@@ -17,12 +17,12 @@ msgstr ""
"X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n"
-#: zrcolafrm.cpp:93
+#: zrcolafrm.cpp:91
#, c-format
msgid "Select %s language for decomposition"
msgstr "Izberi jezik %s za razstavljanje"
-#: zrcolafrm.cpp:104
+#: zrcolafrm.cpp:110
msgid ""
"ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality "
"will not be available."
@@ -30,11 +30,11 @@ msgstr ""
"ZRColine bližnjice na tipkovnici Win+F5 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo."
-#: zrcolafrm.cpp:104 zrcolafrm.cpp:106
+#: zrcolafrm.cpp:110 zrcolafrm.cpp:112
msgid "Warning"
msgstr "Opozorilo"
-#: zrcolafrm.cpp:106
+#: zrcolafrm.cpp:112
msgid ""
"ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality "
"will not be available."
@@ -42,11 +42,11 @@ msgstr ""
"ZRColine bližnjice na tipkovnici Win+F6 ni mogoče registrirati. Nekaj "
"funkcionalnosti ne bo na voljo."
-#: zrcolafrm.cpp:174
+#: zrcolafrm.cpp:187
msgid "Start ZRCola automatically on logon"
msgstr "Samodejno zaženi ZRColo ob prijavi"
-#: zrcolafrm.cpp:360
+#: zrcolafrm.cpp:399
#, c-format
msgid ""
"ZRCola v%s\n"
@@ -55,159 +55,171 @@ msgstr ""
"ZRCola v%s\n"
"Vse pravice pridržane 2015-%s Amebis"
-#: zrcolafrm.cpp:360
+#: zrcolafrm.cpp:399
msgid "About ZRCola"
msgstr "O ZRColi"
-#: zrcolagui.cpp:34
+#: zrcolagui.cpp:36
msgid "&Start on Logon"
msgstr "Z&aženi ob prijavi"
-#: zrcolagui.cpp:34
+#: zrcolagui.cpp:36
msgid "Start this program automatically on logon"
msgstr "Samodejno zaženi ta program ob prijavi"
-#: zrcolagui.cpp:40
+#: zrcolagui.cpp:42
msgid "E&xit"
msgstr "I&zhod"
-#: zrcolagui.cpp:40
+#: zrcolagui.cpp:42
msgid "Quit this program"
msgstr "Zapri ta program"
-#: zrcolagui.cpp:43
+#: zrcolagui.cpp:45
msgid "&Program"
msgstr "&Program"
-#: zrcolagui.cpp:76
+#: zrcolagui.cpp:78
msgid "Select &All"
msgstr "Izberi &vse"
-#: zrcolagui.cpp:76
+#: zrcolagui.cpp:78
msgid "Select all text"
msgstr "Izberi celotno besedilo"
-#: zrcolagui.cpp:82
+#: zrcolagui.cpp:84
msgid "&Send Composed"
msgstr "Pošlji &sestavljeno"
-#: zrcolagui.cpp:82 zrcolagui.cpp:151
+#: zrcolagui.cpp:84 zrcolagui.cpp:159
msgid "Send composed text to source window"
msgstr "Pošlji sestavljeno besedilo izvornemu oknu"
-#: zrcolagui.cpp:91
+#: zrcolagui.cpp:93
msgid "Send &Decomposed"
msgstr "Pošlji &razstavljeno"
-#: zrcolagui.cpp:91 zrcolagui.cpp:153
+#: zrcolagui.cpp:93 zrcolagui.cpp:161
msgid "Send decomposed text to source window"
msgstr "Pošlji razstavljeno besedilo izvornemu oknu"
-#: zrcolagui.cpp:100
+#: zrcolagui.cpp:102
msgid "Abort (De)composition"
msgstr "Prekini raz/sestavljanje"
-#: zrcolagui.cpp:100
+#: zrcolagui.cpp:102
msgid "Abort composition and return focus to source window"
msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu"
-#: zrcolagui.cpp:109
+#: zrcolagui.cpp:111
msgid "&Language"
msgstr "&Jezik"
-#: zrcolagui.cpp:111
+#: zrcolagui.cpp:113
msgid "&Automatic"
msgstr "S&amodejno"
-#: zrcolagui.cpp:111
+#: zrcolagui.cpp:113
msgid "Set language according to keyboard layout automatically"
msgstr "Samodejno nastavi jezik glede na izbrano tipkovnico"
-#: zrcolagui.cpp:118
+#: zrcolagui.cpp:120
msgid "&Edit"
msgstr "Ur&edi"
-#: zrcolagui.cpp:122
-msgid "Edit Toolbar"
-msgstr "Orodna vrstica za urejanje"
+#: zrcolagui.cpp:124
+msgid "&Edit Toolbar"
+msgstr "Orodna vrstica za ur&ejanje"
-#: zrcolagui.cpp:122
+#: zrcolagui.cpp:124
msgid "Toggle edit toolbar"
msgstr "Prikaži/skrij orodno vrstico za urejanje"
-#: zrcolagui.cpp:126
-msgid "Compose Toolbar"
-msgstr "Orodna vrstica za sestavljanje"
+#: zrcolagui.cpp:128
+msgid "&Compose Toolbar"
+msgstr "Orodna vrsti&ca za sestavljanje"
-#: zrcolagui.cpp:126
+#: zrcolagui.cpp:128
msgid "Toggle compose toolbar"
msgstr "Prikaži/skrij orodno vrstico za sestavljanje"
-#: zrcolagui.cpp:129
+#: zrcolagui.cpp:134
+msgid "Character Catalo&g"
+msgstr "Katalo&g znakov"
+
+#: zrcolagui.cpp:134
+msgid "Toggle character catalog panel"
+msgstr "Prikaži/skrij katalog znakov"
+
+#: zrcolagui.cpp:137
msgid "&View"
msgstr "Po&gled"
-#: zrcolagui.cpp:136
+#: zrcolagui.cpp:144
msgid "&Help"
msgstr "Po&moč"
-#: zrcolagui.cpp:141
+#: zrcolagui.cpp:149
msgid "Cut"
msgstr "Izreži"
-#: zrcolagui.cpp:141
+#: zrcolagui.cpp:149
msgid "Cut selection"
msgstr "Izreži izbor"
-#: zrcolagui.cpp:143
+#: zrcolagui.cpp:151
msgid "Copy"
msgstr "Kopiraj"
-#: zrcolagui.cpp:143
+#: zrcolagui.cpp:151
msgid "Copy selection"
msgstr "Kopiraj izbor"
-#: zrcolagui.cpp:145
+#: zrcolagui.cpp:153
msgid "Paste"
msgstr "Prilepi"
-#: zrcolagui.cpp:145
+#: zrcolagui.cpp:153
msgid "Paste selection"
msgstr "Prilepi izbor"
-#: zrcolagui.cpp:148
+#: zrcolagui.cpp:156
msgid "Edit"
msgstr "Urejanje"
-#: zrcolagui.cpp:151
+#: zrcolagui.cpp:159
msgid "Send Composed"
msgstr "Pošlji sestavljeno"
-#: zrcolagui.cpp:153
+#: zrcolagui.cpp:161
msgid "Send Decomposed"
msgstr "Pošlji razstavljeno"
-#: zrcolagui.cpp:162
+#: zrcolagui.cpp:170
msgid "Compose"
msgstr "Sestavljanje"
-#: zrcolagui.cpp:166
+#: zrcolagui.cpp:174
+msgid "Character Catalog"
+msgstr "Katalog znakov"
+
+#: zrcolagui.cpp:178
msgid "(De)Composer"
msgstr "Raz/Sestavljalnik"
-#: zrcolagui.cpp:201
+#: zrcolagui.cpp:213
msgid "Decomposed Text"
msgstr "Razstavljeno besedilo"
-#: zrcolagui.cpp:221
+#: zrcolagui.cpp:233
msgid "Decomposed Unicode Dump"
msgstr "Unicode razstavljenega"
-#: zrcolagui.cpp:248
+#: zrcolagui.cpp:260
msgid "Composed Text"
msgstr "Sestavljeno besedilo"
-#: zrcolagui.cpp:268
+#: zrcolagui.cpp:280
msgid "Composed Unicode Dump"
msgstr "Unicode sestavljenega"
@@ -215,7 +227,7 @@ msgstr "Unicode sestavljenega"
msgid "INS"
msgstr "INS"
-#: zrcolagui.h:80 MSIBuild/En.Win32.Debug.Feature-2.idtx:4
+#: zrcolagui.h:86 MSIBuild/En.Win32.Debug.Feature-2.idtx:4
#: MSIBuild/En.Win32.Debug.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Debug.Feature-2.idtx:4
#: MSIBuild/En.x64.Debug.Shortcut-2.idtx:4
@@ -237,6 +249,9 @@ msgstr "1250"
msgid "Input system for linguistic use"
msgstr "Vnašalni sistem za jezikoslovno rabo"
+#~ msgid "Character &Groups"
+#~ msgstr "Skupine &znakov"
+
#~ msgid "Language:"
#~ msgstr "Jezik:"
diff --git a/ZRCola/stdafx.h b/ZRCola/stdafx.h
index 1551680..44638e2 100644
--- a/ZRCola/stdafx.h
+++ b/ZRCola/stdafx.h
@@ -19,12 +19,6 @@
#pragma once
-#include "../include/zrcola.h"
-#include "zrcolaapp.h"
-#include "zrcolacomppnl.h"
-#include "zrcolafrm.h"
-#include "zrcolakeyhndlr.h"
-
#include
#include
#include
@@ -43,3 +37,11 @@
#include
#include
#endif
+
+#include "../include/zrcola.h"
+#include "zrcolaapp.h"
+#include "zrcolachrgrid.h"
+#include "zrcolachrcatpnl.h"
+#include "zrcolacomppnl.h"
+#include "zrcolafrm.h"
+#include "zrcolakeyhndlr.h"
diff --git a/ZRCola/zrcolaapp.cpp b/ZRCola/zrcolaapp.cpp
index eb31691..48904be 100644
--- a/ZRCola/zrcolaapp.cpp
+++ b/ZRCola/zrcolaapp.cpp
@@ -30,7 +30,9 @@
wxIMPLEMENT_APP(ZRColaApp);
-ZRColaApp::ZRColaApp() : wxApp()
+ZRColaApp::ZRColaApp() :
+ m_mainWnd(NULL),
+ wxApp()
{
}
@@ -112,9 +114,9 @@ bool ZRColaApp::OnInit()
wxFAIL_MSG(wxT("ZRCola.zrcdb is not a valid ZRCola database."));
}
- wxZRColaFrame* mainFrame = new wxZRColaFrame();
- wxPersistentRegisterAndRestore(mainFrame);
- mainFrame->Show();
+ m_mainWnd = new wxZRColaFrame();
+ wxPersistentRegisterAndRestore(m_mainWnd);
+ m_mainWnd->Show();
return true;
}
diff --git a/ZRCola/zrcolaapp.h b/ZRCola/zrcolaapp.h
index 0190842..1a0f01d 100644
--- a/ZRCola/zrcolaapp.h
+++ b/ZRCola/zrcolaapp.h
@@ -25,6 +25,7 @@ class ZRColaApp;
#pragma once
+#include "zrcolafrm.h"
#include
#include
#include
@@ -61,6 +62,8 @@ public:
ZRCola::langchar_db m_lc_db; ///< Language character database
ZRCola::language_db m_lang_db; ///< Language database
+ wxZRColaFrame *m_mainWnd; ///< Main window
+
protected:
wxLocale m_locale; ///< Current locale
};
diff --git a/ZRCola/zrcolachrcatpnl.cpp b/ZRCola/zrcolachrcatpnl.cpp
new file mode 100644
index 0000000..1eab092
--- /dev/null
+++ b/ZRCola/zrcolachrcatpnl.cpp
@@ -0,0 +1,191 @@
+/*
+ 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"
+
+
+//////////////////////////////////////////////////////////////////////////
+// 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(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)
+{
+ if (event.GetKeyCode() == WXK_RETURN) {
+ 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(wnd)
+{
+}
+
+
+wxString wxPersistentZRColaCharacterCatalogPanel::GetKind() const
+{
+ return wxT(wxPERSIST_TLW_KIND);
+}
+
+
+void wxPersistentZRColaCharacterCatalogPanel::Save() const
+{
+ const wxZRColaCharacterCatalogPanel * const wnd = static_cast(GetWindow());
+
+ SaveValue(wxT("charGroup"), wnd->m_cg_id);
+}
+
+
+bool wxPersistentZRColaCharacterCatalogPanel::Restore()
+{
+ wxZRColaCharacterCatalogPanel * const wnd = static_cast(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;
+}
diff --git a/ZRCola/zrcolachrcatpnl.h b/ZRCola/zrcolachrcatpnl.h
new file mode 100644
index 0000000..791c855
--- /dev/null
+++ b/ZRCola/zrcolachrcatpnl.h
@@ -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 .
+*/
+
+///
+/// Forward declarations
+///
+class wxZRColaCharacterCatalogPanel;
+
+
+#pragma once
+
+#include "zrcolagui.h"
+#include
+#include
+
+
+///
+/// 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
+{
+public:
+ wxPersistentZRColaCharacterCatalogPanel(wxZRColaCharacterCatalogPanel *wnd);
+
+ virtual wxString GetKind() const;
+ virtual void Save() const;
+ virtual bool Restore();
+};
+
+
+inline wxPersistentObject *wxCreatePersistentObject(wxZRColaCharacterCatalogPanel *wnd)
+{
+ return new wxPersistentZRColaCharacterCatalogPanel(wnd);
+}
diff --git a/ZRCola/zrcolachrgrid.cpp b/ZRCola/zrcolachrgrid.cpp
new file mode 100644
index 0000000..78bd8e8
--- /dev/null
+++ b/ZRCola/zrcolachrgrid.cpp
@@ -0,0 +1,108 @@
+/*
+ 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"
+
+
+//////////////////////////////////////////////////////////////////////////
+// wxZRColaCharGrid
+//////////////////////////////////////////////////////////////////////////
+
+BEGIN_EVENT_TABLE(wxZRColaCharGrid, wxGrid)
+ EVT_SIZE(wxZRColaCharGrid::OnSize)
+END_EVENT_TABLE()
+
+
+wxZRColaCharGrid::wxZRColaCharGrid() :
+ m_isResizing(false),
+ wxGrid()
+{
+}
+
+
+wxZRColaCharGrid::wxZRColaCharGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) :
+ m_isResizing(false),
+ wxGrid(parent, id, pos, size, wxWANTS_CHARS, name)
+{
+ // Cell Defaults
+ SetDefaultRowSize(wxZRColaCharacterGridRowHeight);
+}
+
+
+void wxZRColaCharGrid::SetCharacters(const wxString &chars)
+{
+ m_chars = chars;
+
+ // Build and set new grid data.
+ size_t char_len = m_chars.Length();
+ int rows = std::max((char_len + m_numCols - 1) / m_numCols, 1);
+ wxGridStringTable *table = new wxGridStringTable(rows, m_numCols);
+ for (int r = 0, i = 0; r < rows; r++)
+ for (int c = 0; c < m_numCols; c++, i++)
+ table->SetValue(r, c, i < char_len ? wxString(1, m_chars[i]) : wxEmptyString);
+ SetTable(table, true);
+}
+
+
+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(width / wxZRColaCharacterGridColumnWidth, 1),
+ rows = std::max((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(width - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X, this), 0);
+ cols = std::max(width / wxZRColaCharacterGridColumnWidth, 1);
+ rows = std::max((char_len + cols - 1) / cols, 1);
+ }
+
+ BeginBatch();
+
+ if (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);
+ }
+
+ // 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;
+}
diff --git a/ZRCola/zrcolachrgrid.h b/ZRCola/zrcolachrgrid.h
new file mode 100644
index 0000000..805d15d
--- /dev/null
+++ b/ZRCola/zrcolachrgrid.h
@@ -0,0 +1,64 @@
+/*
+ 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 wxZRColaCharGrid;
+
+
+#pragma once
+
+#include
+
+
+///
+/// Character grid layout
+///
+#define wxZRColaCharacterGridColumnWidth 35
+#define wxZRColaCharacterGridRowHeight 35
+
+
+///
+/// ZRCola character grid
+///
+
+class wxZRColaCharGrid : public wxGrid
+{
+public:
+ wxZRColaCharGrid();
+ wxZRColaCharGrid(wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxGridNameStr);
+
+ ///
+ /// Sets new array of characters to display
+ ///
+ /// \param[in] chars The string containing characters to display
+ ///
+ void SetCharacters(const wxString &chars);
+
+protected:
+ void OnSize(wxSizeEvent& event);
+ DECLARE_EVENT_TABLE()
+
+protected:
+ wxString m_chars; ///< Array of Unicode characters to display in the grid
+
+private:
+ bool m_isResizing; ///< Prevents nesting of OnSize() method.
+};
diff --git a/ZRCola/zrcolacomppnl.h b/ZRCola/zrcolacomppnl.h
index 12fd3ce..8c5ba1c 100644
--- a/ZRCola/zrcolacomppnl.h
+++ b/ZRCola/zrcolacomppnl.h
@@ -46,7 +46,6 @@ public:
wxZRColaComposerPanel(wxWindow* parent);
virtual ~wxZRColaComposerPanel();
- friend class wxZRColaFrame; // Allow main frame direct access to our members.
friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state.
protected:
diff --git a/ZRCola/zrcolafrm.cpp b/ZRCola/zrcolafrm.cpp
index 5d87d4b..4978928 100644
--- a/ZRCola/zrcolafrm.cpp
+++ b/ZRCola/zrcolafrm.cpp
@@ -48,6 +48,9 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
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_ABOUT , wxZRColaFrame::OnAbout )
wxEND_EVENT_TABLE()
@@ -127,6 +130,13 @@ wxZRColaFrame::wxZRColaFrame() :
pProfiles->Release();
}
#endif
+
+ // Register frame specific hotkey(s).
+ {
+ wxAcceleratorEntry entries[1];
+ entries[0].Set(wxACCEL_NORMAL, WXK_F4, wxID_FOCUS_CHARACTER_CATALOG);
+ SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
+ }
}
@@ -144,7 +154,7 @@ wxZRColaFrame::~wxZRColaFrame()
UnregisterHotKey(wxZRColaHKID_INVOKE_COMPOSE);
// Save wxAuiManager's state before return to parent's destructor.
- // Since the later calls m_mgr.UnInit() the regular persistence mechanizm is useless to save wxAuiManager's state.
+ // Since the later calls m_mgr.UnInit() the regular persistence mechanism is useless to save wxAuiManager's state.
wxPersistentAuiManager((wxAuiManager*)&m_mgr).Save();
}
@@ -358,6 +368,32 @@ void wxZRColaFrame::OnToolbarCompose(wxCommandEvent& event)
}
+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::OnAbout(wxCommandEvent& event)
{
wxMessageBox(wxString::Format(_("ZRCola v%s\nCopyright 2015-%s Amebis"), wxT(ZRCOLA_VERSION_STR), wxT(ZRCOLA_BUILD_YEAR_STR)), _("About ZRCola"), wxOK | wxICON_INFORMATION);
@@ -537,8 +573,10 @@ void wxPersistentZRColaFrame::Save() const
const wxZRColaFrame * const wnd = static_cast(GetWindow());
wxPersistentZRColaComposerPanel(wnd->m_panel).Save();
- SaveValue(wxT("langAuto"), wnd->m_lang_auto);
- SaveValue(wxT("lang" ), wxString::FromAscii(wnd->m_lang, sizeof(wnd->m_lang)));
+ wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Save();
+
+ SaveValue(wxT("langAuto" ), wnd->m_lang_auto);
+ SaveValue(wxT("lang" ), wxString::FromAscii(wnd->m_lang, sizeof(wnd->m_lang)));
wxPersistentTLW::Save();
}
@@ -570,6 +608,7 @@ bool wxPersistentZRColaFrame::Restore()
memcpy(wnd->m_lang, ZRCOLA_LANG_VOID, sizeof(wnd->m_lang));
wnd->UpdateDecomposedLanguage();
+ wxPersistentZRColaCharacterCatalogPanel(wnd->m_panelChrCat).Restore();
wxPersistentZRColaComposerPanel(wnd->m_panel).Restore();
return r;
diff --git a/ZRCola/zrcolafrm.h b/ZRCola/zrcolafrm.h
index 12636c2..101f25c 100644
--- a/ZRCola/zrcolafrm.h
+++ b/ZRCola/zrcolafrm.h
@@ -17,7 +17,6 @@
along with ZRCola. If not, see .
*/
-
///
/// Forward declarations
///
@@ -53,8 +52,9 @@ class wxZRColaFrame :
public:
enum
{
- wxID_DECOMP_LANGUAGE_START = 6000,
- wxID_DECOMP_LANGUAGE_END = 6099,
+ wxID_DECOMP_LANGUAGE_START = 6000,
+ wxID_DECOMP_LANGUAGE_END = 6099,
+ wxID_FOCUS_CHARACTER_CATALOG,
};
wxZRColaFrame();
@@ -82,6 +82,9 @@ protected:
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 OnAbout(wxCommandEvent& event);
wxDECLARE_EVENT_TABLE();
diff --git a/ZRCola/zrcolagui.cpp b/ZRCola/zrcolagui.cpp
index 112557b..29b1114 100644
--- a/ZRCola/zrcolagui.cpp
+++ b/ZRCola/zrcolagui.cpp
@@ -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
@@ -119,13 +121,19 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
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_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_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();
@@ -161,6 +169,10 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
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 );
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 ) );
@@ -307,3 +319,63 @@ wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
}
+
+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 );
+
+}
diff --git a/ZRCola/zrcolagui.h b/ZRCola/zrcolagui.h
index 17465a9..4cd9472 100644
--- a/ZRCola/zrcolagui.h
+++ b/ZRCola/zrcolagui.h
@@ -12,6 +12,8 @@
#include
#include
#include
+class wxZRColaCharGrid;
+
#include
#include
#include
@@ -24,7 +26,8 @@
#include
#include
#include
-#include "zrcolacomppnl.h"
+class wxZRColaCharacterCatalogPanel;
+class wxZRColaComposerPanel;
#include
#include
#include
@@ -32,6 +35,7 @@
#include
#include
#include
+#include
///////////////////////////////////////////////////////////////////////////
@@ -51,7 +55,8 @@ class wxZRColaFrameBase : public wxFrame
wxID_SEND_ABORT,
wxID_DECOMP_LANG_AUTO,
wxID_TOOLBAR_EDIT,
- wxID_TOOLBAR_COMPOSE
+ wxID_TOOLBAR_COMPOSE,
+ wxID_PANEL_CHRGRPS
};
wxMenuBar* m_menubar;
@@ -68,7 +73,7 @@ class wxZRColaFrameBase : public wxFrame
wxAuiToolBarItem* m_toolSendComposed;
wxAuiToolBarItem* m_toolSendDecomposed;
wxChoice* m_toolDecompLanguage;
- wxZRColaComposerPanel* m_panel;
+ wxZRColaCharacterCatalogPanel* m_panelChrCat;
wxStatusBar* m_statusBar;
// Virtual event handlers, overide them in your derived class
@@ -76,6 +81,7 @@ class wxZRColaFrameBase : public wxFrame
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, const wxString& name = wxT("ZRCola") );
wxAuiManager m_mgr;
@@ -94,12 +100,10 @@ class wxZRColaComposerPanelBase : public wxPanel
protected:
wxSplitterWindow* m_splitterDecomposed;
wxPanel* m_panelDecomposedEdit;
- wxTextCtrl* m_decomposed;
wxPanel* m_panelDecomposedHex;
wxTextCtrl* m_decomposedHex;
wxSplitterWindow* m_splitterComposed;
wxPanel* m_panelComposedEdit;
- wxTextCtrl* m_composed;
wxPanel* m_panelComposedHex;
wxTextCtrl* m_composedHex;
@@ -113,6 +117,8 @@ class wxZRColaComposerPanelBase : public wxPanel
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();
@@ -131,4 +137,28 @@ class wxZRColaComposerPanelBase : public wxPanel
};
+///////////////////////////////////////////////////////////////////////////////
+/// 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:
+
+ 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();
+
+};
+
#endif //__ZRCOLAGUI_H__