Temporary special character insertion replaced with a first version of a dynamic one
This commit is contained in:
parent
72c03af0c5
commit
c6f1e8a251
@ -153,75 +153,6 @@
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxMenu" expanded="1">
|
||||
<property name="label">&Accents</property>
|
||||
<property name="name">m_menuAccents</property>
|
||||
<property name="permission">protected</property>
|
||||
<object class="wxMenuItem" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="checked">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="help"></property>
|
||||
<property name="id">wxID_INSERT_GRAVE</property>
|
||||
<property name="kind">wxITEM_NORMAL</property>
|
||||
<property name="label">Grave	&7</property>
|
||||
<property name="name">m_menuItemGrave</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="shortcut"></property>
|
||||
<property name="unchecked_bitmap"></property>
|
||||
<event name="OnMenuSelection"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
<object class="wxMenuItem" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="checked">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="help"></property>
|
||||
<property name="id">wxID_INSERT_ACUTE</property>
|
||||
<property name="kind">wxITEM_NORMAL</property>
|
||||
<property name="label">Acute	&9</property>
|
||||
<property name="name">m_menuItemAcute</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="shortcut"></property>
|
||||
<property name="unchecked_bitmap"></property>
|
||||
<event name="OnMenuSelection"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
<object class="wxMenuItem" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="checked">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="help"></property>
|
||||
<property name="id">wxID_INSERT_CIRCUMFLEX</property>
|
||||
<property name="kind">wxITEM_NORMAL</property>
|
||||
<property name="label">Circumflex	&3</property>
|
||||
<property name="name">m_menuItemCircumflex</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="shortcut"></property>
|
||||
<property name="unchecked_bitmap"></property>
|
||||
<event name="OnMenuSelection"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
<object class="separator" expanded="1">
|
||||
<property name="name">m_separator2</property>
|
||||
<property name="permission">none</property>
|
||||
</object>
|
||||
<object class="wxMenuItem" expanded="1">
|
||||
<property name="bitmap"></property>
|
||||
<property name="checked">0</property>
|
||||
<property name="enabled">1</property>
|
||||
<property name="help"></property>
|
||||
<property name="id">wxID_INSERT_INV_BREVE_BELOW</property>
|
||||
<property name="kind">wxITEM_NORMAL</property>
|
||||
<property name="label">Inverted &breve</property>
|
||||
<property name="name">m_menuItemInvBreveBelow</property>
|
||||
<property name="permission">none</property>
|
||||
<property name="shortcut"></property>
|
||||
<property name="unchecked_bitmap"></property>
|
||||
<event name="OnMenuSelection"></event>
|
||||
<event name="OnUpdateUI"></event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxMenu" expanded="1">
|
||||
<property name="label">&Help</property>
|
||||
<property name="name">m_menuHelp</property>
|
||||
|
@ -93,6 +93,9 @@
|
||||
<ClInclude Include="zrcolagui.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\lib\libZRColaUI\build\libZRColaUI.vcxproj">
|
||||
<Project>{c0a84bd2-3870-4cd6-b281-0ab322e3c579}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\lib\libZRCola\build\libZRCola.vcxproj">
|
||||
<Project>{3c61929e-7289-4101-8d0a-da22d6e1aea8}</Project>
|
||||
</ProjectReference>
|
||||
|
@ -20,6 +20,32 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// wxZRColaComposerPanelEvtHandler
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
wxZRColaComposerPanelEvtHandler::wxZRColaComposerPanelEvtHandler(wxZRColaComposerPanel *target) :
|
||||
m_target(target),
|
||||
wxEvtHandler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool wxZRColaComposerPanelEvtHandler::ProcessEvent(wxEvent& event)
|
||||
{
|
||||
if (m_target && event.IsCommandEvent()) {
|
||||
int id = event.GetId();
|
||||
if (wxZRColaComposerPanel::wxID_ACCEL <= id && id < wxZRColaComposerPanel::wxID_ACCEL + m_target->m_ks_db.idxKey.size()) {
|
||||
const ZRCola::keyseq_db::keyseq &ks = (const ZRCola::keyseq_db::keyseq&)m_target->m_ks_db.data[m_target->m_ks_db.idxKey[id - wxZRColaComposerPanel::wxID_ACCEL]];
|
||||
m_target->m_decomposed->WriteText(ks.chr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return wxEvtHandler::ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// wxZRColaComposerPanel
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -28,6 +54,7 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
|
||||
m_progress(false),
|
||||
m_selDecomposed(0, 0),
|
||||
m_selComposed(0, 0),
|
||||
eh(this),
|
||||
wxZRColaComposerPanelBase(parent)
|
||||
{
|
||||
wxString sPath(wxPathOnly(wxTheApp->argv[0]));
|
||||
@ -39,26 +66,63 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
|
||||
ZRCola::recordsize_t size;
|
||||
dat.read((char*)&size, sizeof(ZRCola::recordsize_t));
|
||||
if (dat.good()) {
|
||||
ZRCola::translation_rec r_rec(m_t_db);
|
||||
if (r_rec.find(dat, size)) {
|
||||
dat >> r_rec;
|
||||
if (!dat.good()) {
|
||||
bool has_translation_data = false;
|
||||
|
||||
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
|
||||
} else if (id == ZRCola::keyseq_rec::id) {
|
||||
dat >> ZRCola::keyseq_rec(m_ks_db);
|
||||
if (!dat.good()) {
|
||||
wxFAIL_MSG(wxT("Error reading key sequence data from ZRCola.zrcdb."));
|
||||
m_ks_db.idxChr.clear();
|
||||
m_ks_db.idxKey.clear();
|
||||
m_ks_db.data .clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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."));
|
||||
}
|
||||
|
||||
std::vector<unsigned __int32>::size_type n = m_ks_db.idxKey.size();
|
||||
std::vector<wxAcceleratorEntry> entries;
|
||||
entries.reserve(n);
|
||||
for (std::vector<unsigned __int32>::size_type i = 0; i < n; i++) {
|
||||
const ZRCola::keyseq_db::keyseq &ks = (const ZRCola::keyseq_db::keyseq&)m_ks_db.data[m_ks_db.idxKey[i]];
|
||||
if (ks.seq_len == 1) {
|
||||
// The key sequence is trivial.
|
||||
entries.push_back(wxAcceleratorEntry(
|
||||
((ks.seq[0].modifiers & ZRCola::keyseq_db::keyseq::SHIFT) ? wxACCEL_SHIFT : 0) |
|
||||
((ks.seq[0].modifiers & ZRCola::keyseq_db::keyseq::CTRL ) ? wxACCEL_CTRL : 0) |
|
||||
((ks.seq[0].modifiers & ZRCola::keyseq_db::keyseq::ALT ) ? wxACCEL_ALT : 0), ks.seq[0].key, wxID_ACCEL + i));
|
||||
}
|
||||
}
|
||||
wxAcceleratorTable accel(entries.size(), entries.data());
|
||||
SetAcceleratorTable(accel);
|
||||
|
||||
PushEventHandler(&eh);
|
||||
}
|
||||
|
||||
|
||||
wxZRColaComposerPanel::~wxZRColaComposerPanel()
|
||||
{
|
||||
PopEventHandler();
|
||||
}
|
||||
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
///
|
||||
/// Forward declarations
|
||||
///
|
||||
class wxZRColaComposerPanelEvtHandler;
|
||||
class wxZRColaComposerPanel;
|
||||
|
||||
|
||||
@ -27,20 +28,40 @@ class wxZRColaComposerPanel;
|
||||
|
||||
#include "zrcolagui.h"
|
||||
#include <zrcola/translate.h>
|
||||
#include <zrcolaui/keyboard.h>
|
||||
#include <utility>
|
||||
|
||||
|
||||
///
|
||||
/// ZRCola composer panel event handler
|
||||
///
|
||||
class wxZRColaComposerPanelEvtHandler : public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
wxZRColaComposerPanelEvtHandler(wxZRColaComposerPanel *target);
|
||||
|
||||
virtual bool ProcessEvent(wxEvent& event);
|
||||
|
||||
public:
|
||||
wxZRColaComposerPanel *m_target; ///< Composer panel window
|
||||
};
|
||||
|
||||
|
||||
///
|
||||
/// ZRCola composer panel
|
||||
///
|
||||
class wxZRColaComposerPanel : public wxZRColaComposerPanelBase
|
||||
{
|
||||
enum {
|
||||
wxID_ACCEL = wxID_HIGHEST
|
||||
};
|
||||
|
||||
public:
|
||||
wxZRColaComposerPanel(wxWindow* parent);
|
||||
virtual ~wxZRColaComposerPanel();
|
||||
|
||||
// Allow main frame direct access to our members.
|
||||
friend class wxZRColaFrame;
|
||||
friend class wxZRColaFrame; // Allow main frame direct access to our members.
|
||||
friend class wxZRColaComposerPanelEvtHandler; // Allow own event handler direct access to our members.
|
||||
|
||||
protected:
|
||||
virtual void OnDecomposedPaint(wxPaintEvent& event);
|
||||
@ -50,9 +71,11 @@ protected:
|
||||
|
||||
protected:
|
||||
ZRCola::translation_db m_t_db; ///< Translation database
|
||||
ZRCola::keyseq_db m_ks_db; ///< Key sequence 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
|
||||
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
|
||||
wxZRColaComposerPanelEvtHandler eh; ///< Event handler
|
||||
};
|
||||
|
@ -32,10 +32,6 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
|
||||
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_INSERT_GRAVE , wxZRColaFrame::OnInsertGrave )
|
||||
EVT_MENU( wxID_INSERT_ACUTE , wxZRColaFrame::OnInsertAcute )
|
||||
EVT_MENU( wxID_INSERT_CIRCUMFLEX , wxZRColaFrame::OnInsertCircumflex )
|
||||
EVT_MENU( wxID_INSERT_INV_BREVE_BELOW, wxZRColaFrame::OnInsertInvertedBreveBelow)
|
||||
EVT_MENU( wxID_ABOUT , wxZRColaFrame::OnAbout )
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
@ -139,30 +135,6 @@ void wxZRColaFrame::OnExit(wxCommandEvent& event)
|
||||
}
|
||||
|
||||
|
||||
void wxZRColaFrame::OnInsertGrave(wxCommandEvent& event)
|
||||
{
|
||||
m_panel->m_decomposed->WriteText(L"\xE000");
|
||||
}
|
||||
|
||||
|
||||
void wxZRColaFrame::OnInsertAcute(wxCommandEvent& event)
|
||||
{
|
||||
m_panel->m_decomposed->WriteText(L"\xE001");
|
||||
}
|
||||
|
||||
|
||||
void wxZRColaFrame::OnInsertCircumflex(wxCommandEvent& event)
|
||||
{
|
||||
m_panel->m_decomposed->WriteText(L"\xE002");
|
||||
}
|
||||
|
||||
|
||||
void wxZRColaFrame::OnInsertInvertedBreveBelow(wxCommandEvent& event)
|
||||
{
|
||||
m_panel->m_decomposed->WriteText(L"\xE02F");
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
@ -60,10 +60,6 @@ protected:
|
||||
void OnSendDecomposed(wxCommandEvent& event);
|
||||
void OnSendAbort(wxCommandEvent& event);
|
||||
void OnExit(wxCommandEvent& event);
|
||||
void OnInsertGrave(wxCommandEvent& event);
|
||||
void OnInsertAcute(wxCommandEvent& event);
|
||||
void OnInsertCircumflex(wxCommandEvent& event);
|
||||
void OnInsertInvertedBreveBelow(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
|
||||
|
@ -34,27 +34,6 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
|
||||
|
||||
m_menubar->Append( m_menuFile, _("&File") );
|
||||
|
||||
m_menuAccents = new wxMenu();
|
||||
wxMenuItem* m_menuItemGrave;
|
||||
m_menuItemGrave = new wxMenuItem( m_menuAccents, wxID_INSERT_GRAVE, wxString( _("Grave\t&7") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuAccents->Append( m_menuItemGrave );
|
||||
|
||||
wxMenuItem* m_menuItemAcute;
|
||||
m_menuItemAcute = new wxMenuItem( m_menuAccents, wxID_INSERT_ACUTE, wxString( _("Acute\t&9") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuAccents->Append( m_menuItemAcute );
|
||||
|
||||
wxMenuItem* m_menuItemCircumflex;
|
||||
m_menuItemCircumflex = new wxMenuItem( m_menuAccents, wxID_INSERT_CIRCUMFLEX, wxString( _("Circumflex\t&3") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuAccents->Append( m_menuItemCircumflex );
|
||||
|
||||
m_menuAccents->AppendSeparator();
|
||||
|
||||
wxMenuItem* m_menuItemInvBreveBelow;
|
||||
m_menuItemInvBreveBelow = new wxMenuItem( m_menuAccents, wxID_INSERT_INV_BREVE_BELOW, wxString( _("Inverted &breve") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
m_menuAccents->Append( m_menuItemInvBreveBelow );
|
||||
|
||||
m_menubar->Append( m_menuAccents, _("&Accents") );
|
||||
|
||||
m_menuHelp = new wxMenu();
|
||||
wxMenuItem* m_menuItemAbout;
|
||||
m_menuItemAbout = new wxMenuItem( m_menuHelp, wxID_ABOUT, wxString( _("&About") ) , wxEmptyString, wxITEM_NORMAL );
|
||||
|
@ -37,17 +37,8 @@ class wxZRColaFrameBase : public wxFrame
|
||||
private:
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
wxID_INSERT_GRAVE = 1000,
|
||||
wxID_INSERT_ACUTE,
|
||||
wxID_INSERT_CIRCUMFLEX,
|
||||
wxID_INSERT_INV_BREVE_BELOW
|
||||
};
|
||||
|
||||
wxMenuBar* m_menubar;
|
||||
wxMenu* m_menuFile;
|
||||
wxMenu* m_menuAccents;
|
||||
wxMenu* m_menuHelp;
|
||||
wxZRColaComposerPanel* m_panel;
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit fbb20a204206e644140a653d518c3257bc872c47
|
||||
Subproject commit f413026bbc51ad960b731f12cb7cb2b1c2feeacc
|
Loading…
x
Reference in New Issue
Block a user