"Composition" and "Decomposition" renamed to more general terms "Translation" and "Inverse translation" to extend its use for transliteration

This commit is contained in:
Simon Rozman 2017-03-27 14:10:43 +02:00
parent 7cb0317544
commit 155642a3f9
27 changed files with 536 additions and 536 deletions

View File

@ -245,14 +245,14 @@
<property name="permission">none</property>
</object>
<object class="wxMenuItem" expanded="0">
<property name="bitmap">Load From Icon Resource; send_composed.ico; [16; 16]</property>
<property name="bitmap">Load From Icon Resource; send_destination.ico; [16; 16]</property>
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Send composed text to source window</property>
<property name="id">wxID_SEND_COMPOSED</property>
<property name="id">wxID_SEND_DESTINATION</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">&amp;Send Composed</property>
<property name="name">m_menuItemSendComposed</property>
<property name="name">m_menuItemSendDestination</property>
<property name="permission">none</property>
<property name="shortcut">F5</property>
<property name="unchecked_bitmap"></property>
@ -260,14 +260,14 @@
<event name="OnUpdateUI"></event>
</object>
<object class="wxMenuItem" expanded="0">
<property name="bitmap">Load From Icon Resource; copy_composed_and_return.ico; [16; 16]</property>
<property name="bitmap">Load From Icon Resource; copy_destination_and_return.ico; [16; 16]</property>
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Copy composed text to clipboard and return focus to source window</property>
<property name="id">wxID_COPY_COMPOSED_AND_RETURN</property>
<property name="id">wxID_COPY_DESTINATION_AND_RETURN</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Copy Composed and &amp;Return</property>
<property name="name">m_menuItemCopyComposedAndReturn</property>
<property name="name">m_menuItemCopyDestinationAndReturn</property>
<property name="permission">none</property>
<property name="shortcut">Ctrl+F5</property>
<property name="unchecked_bitmap"></property>
@ -275,14 +275,14 @@
<event name="OnUpdateUI"></event>
</object>
<object class="wxMenuItem" expanded="0">
<property name="bitmap">Load From Icon Resource; send_decomposed.ico; [16; 16]</property>
<property name="bitmap">Load From Icon Resource; send_source.ico; [16; 16]</property>
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Send decomposed text to source window</property>
<property name="id">wxID_SEND_DECOMPOSED</property>
<property name="id">wxID_SEND_SOURCE</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Send &amp;Decomposed</property>
<property name="name">m_menuItemSendDecomposed</property>
<property name="name">m_menuItemSendSource</property>
<property name="permission">none</property>
<property name="shortcut">F6</property>
<property name="unchecked_bitmap"></property>
@ -290,14 +290,14 @@
<event name="OnUpdateUI"></event>
</object>
<object class="wxMenuItem" expanded="0">
<property name="bitmap">Load From Icon Resource; copy_decomposed_and_return.ico; [16; 16]</property>
<property name="bitmap">Load From Icon Resource; copy_source_and_return.ico; [16; 16]</property>
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Copy decomposed text to clipboard and return focus to source window</property>
<property name="id">wxID_COPY_DECOMPOSED_AND_RETURN</property>
<property name="id">wxID_COPY_SOURCE_AND_RETURN</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Copy Decomposed and Re&amp;turn</property>
<property name="name">m_menuItemCopyDecomposedAndReturn</property>
<property name="name">m_menuItemCopySourceAndReturn</property>
<property name="permission">none</property>
<property name="shortcut">Ctrl+F6</property>
<property name="unchecked_bitmap"></property>
@ -363,7 +363,7 @@
<property name="checked">0</property>
<property name="enabled">1</property>
<property name="help">Toggle compose toolbar</property>
<property name="id">wxID_TOOLBAR_COMPOSE</property>
<property name="id">wxID_TOOLBAR_TRANSLATE</property>
<property name="kind">wxITEM_CHECK</property>
<property name="label">&amp;Compose Toolbar</property>
<property name="name">m_menuItemToolbarCompose</property>
@ -666,7 +666,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_toolbarCompose</property>
<property name="name">m_toolbarTranslate</property>
<property name="packing">1</property>
<property name="pane_border">1</property>
<property name="pane_position">-1,-1</property>
@ -732,12 +732,12 @@
<event name="OnUpdateUI"></event>
</object>
<object class="tool" expanded="0">
<property name="bitmap">Load From Icon Resource; send_composed.ico; [24; 24]</property>
<property name="bitmap">Load From Icon Resource; send_destination.ico; [24; 24]</property>
<property name="context_menu">0</property>
<property name="id">wxID_SEND_COMPOSED</property>
<property name="id">wxID_SEND_DESTINATION</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Send Composed</property>
<property name="name">m_toolSendComposed</property>
<property name="name">m_toolSendDestination</property>
<property name="permission">protected</property>
<property name="statusbar">Send composed text to source window</property>
<property name="tooltip">Send Composed</property>
@ -753,12 +753,12 @@
<event name="OnUpdateUI"></event>
</object>
<object class="tool" expanded="0">
<property name="bitmap">Load From Icon Resource; send_decomposed.ico; [24; 24]</property>
<property name="bitmap">Load From Icon Resource; send_source.ico; [24; 24]</property>
<property name="context_menu">0</property>
<property name="id">wxID_SEND_DECOMPOSED</property>
<property name="id">wxID_SEND_SOURCE</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Send Decomposed</property>
<property name="name">m_toolSendDecomposed</property>
<property name="name">m_toolSendSource</property>
<property name="permission">protected</property>
<property name="statusbar">Send decomposed text to source window</property>
<property name="tooltip">Send Decomposed</property>
@ -1078,7 +1078,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_splitterDecomposed</property>
<property name="name">m_splitterSource</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1162,7 +1162,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelDecomposedEdit</property>
<property name="name">m_panelSourceEdit</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1203,7 +1203,7 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerDecomposedEdit</property>
<property name="name">bSizerSourceEdit</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
@ -1214,7 +1214,7 @@
<property name="id">wxID_ANY</property>
<property name="label">Decomposed Text</property>
<property name="minimum_size"></property>
<property name="name">bSizerDecomposedEdit2</property>
<property name="name">bSizerSourceEdit2</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
@ -1258,7 +1258,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size">100,25</property>
<property name="moveable">1</property>
<property name="name">m_decomposed</property>
<property name="name">m_source</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1296,13 +1296,13 @@
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint">OnDecomposedPaint</event>
<event name="OnPaint">OnSourcePaint</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText">OnDecomposedText</event>
<event name="OnText">OnSourceText</event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
@ -1350,7 +1350,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelDecomposedHex</property>
<property name="name">m_panelSourceHex</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1391,7 +1391,7 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerDecomposedHex</property>
<property name="name">bSizerSourceHex</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
@ -1402,7 +1402,7 @@
<property name="id">wxID_ANY</property>
<property name="label">Decomposed Unicode Dump</property>
<property name="minimum_size"></property>
<property name="name">bSizerDecomposedHex2</property>
<property name="name">bSizerSourceHex2</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
@ -1446,7 +1446,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_decomposedHex</property>
<property name="name">m_sourceHex</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1484,7 +1484,7 @@
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint">OnDecomposedHexPaint</event>
<event name="OnPaint">OnSourceHexPaint</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
@ -1544,7 +1544,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_splitterComposed</property>
<property name="name">m_splitterDestination</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1628,7 +1628,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelComposedEdit</property>
<property name="name">m_panelDestinationEdit</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1669,7 +1669,7 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerComposedEdit</property>
<property name="name">bSizerDestinationEdit</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
@ -1680,7 +1680,7 @@
<property name="id">wxID_ANY</property>
<property name="label">Composed Text</property>
<property name="minimum_size"></property>
<property name="name">bSizerComposedEdit2</property>
<property name="name">bSizerDestinationEdit2</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
@ -1724,7 +1724,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size">100,25</property>
<property name="moveable">1</property>
<property name="name">m_composed</property>
<property name="name">m_destination</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1762,13 +1762,13 @@
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint">OnComposedPaint</event>
<event name="OnPaint">OnDestinationPaint</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText">OnComposedText</event>
<event name="OnText">OnDestinationText</event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
@ -1816,7 +1816,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_panelComposedHex</property>
<property name="name">m_panelDestinationHex</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1857,7 +1857,7 @@
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property>
<property name="name">bSizerComposedHex</property>
<property name="name">bSizerDestinationHex</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="0">
@ -1868,7 +1868,7 @@
<property name="id">wxID_ANY</property>
<property name="label">Composed Unicode Dump</property>
<property name="minimum_size"></property>
<property name="name">bSizerComposedHex2</property>
<property name="name">bSizerDestinationHex2</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
@ -1912,7 +1912,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_composedHex</property>
<property name="name">m_destinationHex</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -1950,7 +1950,7 @@
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint">OnComposedHexPaint</event>
<event name="OnPaint">OnDestinationHexPaint</event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -25,7 +25,7 @@
//////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxZRColaCharacterCatalogPanel, wxZRColaCharacterCatalogPanelBase)
EVT_MENU(wxZRColaCharacterCatalogPanel::wxID_FOCUS_DECOMPOSED, wxZRColaCharacterCatalogPanel::OnFocusDecomposed)
EVT_MENU(wxZRColaCharacterCatalogPanel::wxID_FOCUS_SOURCE, wxZRColaCharacterCatalogPanel::OnFocusSource)
END_EVENT_TABLE()
@ -70,7 +70,7 @@ wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
// Register frame specific hotkey(s).
{
wxAcceleratorEntry entries[1];
entries[0].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_FOCUS_DECOMPOSED);
entries[0].Set(wxACCEL_NORMAL, WXK_ESCAPE, wxID_FOCUS_SOURCE);
SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
}
}
@ -98,8 +98,8 @@ void wxZRColaCharacterCatalogPanel::OnGridClick(wxGridEvent& event)
{
auto app = dynamic_cast<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();
app->m_mainWnd->m_panel->m_source->WriteText(m_grid->GetCellValue(event.GetRow(), event.GetCol()));
app->m_mainWnd->m_panel->m_source->SetFocus();
}
event.Skip();
@ -113,8 +113,8 @@ void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event)
case WXK_NUMPAD_ENTER:
auto app = dynamic_cast<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();
app->m_mainWnd->m_panel->m_source->WriteText(m_grid->GetCellValue(m_grid->GetCursorRow(), m_grid->GetCursorColumn()));
app->m_mainWnd->m_panel->m_source->SetFocus();
event.StopPropagation();
return;
@ -135,11 +135,11 @@ void wxZRColaCharacterCatalogPanel::OnShowAll(wxCommandEvent& event)
}
void wxZRColaCharacterCatalogPanel::OnFocusDecomposed(wxCommandEvent& event)
void wxZRColaCharacterCatalogPanel::OnFocusSource(wxCommandEvent& event)
{
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
if (app->m_mainWnd) {
app->m_mainWnd->m_panel->m_decomposed->SetFocus();
app->m_mainWnd->m_panel->m_source->SetFocus();
event.StopPropagation();
return;

View File

@ -38,7 +38,7 @@ class wxZRColaCharacterCatalogPanel : public wxZRColaCharacterCatalogPanelBase
public:
enum
{
wxID_FOCUS_DECOMPOSED = 6000,
wxID_FOCUS_SOURCE = 6000,
};
wxZRColaCharacterCatalogPanel(wxWindow* parent);
@ -51,7 +51,7 @@ protected:
virtual void OnGridClick(wxGridEvent& event);
virtual void OnGridKeyDown(wxKeyEvent& event);
virtual void OnShowAll(wxCommandEvent& event);
void OnFocusDecomposed(wxCommandEvent& event);
void OnFocusSource(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
void Update();

View File

@ -25,42 +25,42 @@
//////////////////////////////////////////////////////////////////////////
wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
m_decomposedChanged(false),
m_composedChanged(false),
m_selDecomposed(0, 0),
m_selComposed(0, 0),
m_sourceChanged(false),
m_destinationChanged(false),
m_selSource(0, 0),
m_selDestination(0, 0),
wxZRColaComposerPanelBase(parent)
{
m_decomposed->PushEventHandler(&m_keyhandler);
m_source->PushEventHandler(&m_keyhandler);
// Restore the previously saved state (if exists).
wxString fileName(GetStateFileName());
if (wxFileExists(fileName)) {
wxFFile file(fileName, wxT("rb"));
if (file.IsOpened()) {
// Load decomposed text.
// Load source text.
unsigned __int64 n;
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString decomposed;
file.Read(wxStringBuffer(decomposed, n), sizeof(wchar_t)*n);
wxString source;
file.Read(wxStringBuffer(source, n), sizeof(wchar_t)*n);
if (!file.Error()) {
// Load composed text.
// Load destination text.
file.Read(&n, sizeof(n));
if (!file.Error()) {
wxString composed;
file.Read(wxStringBuffer(composed, n), sizeof(wchar_t)*n);
wxString destination;
file.Read(wxStringBuffer(destination, n), sizeof(wchar_t)*n);
if (!file.Error()) {
// Restore state.
m_decomposed->SetValue(decomposed);
m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second);
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, decomposed.GetData(), decomposed.Length(), m_selDecomposed.first, m_selDecomposed.second);
m_decomposedChanged = false;
m_source->SetValue(source);
m_source->GetSelection(&m_selSource.first, &m_selSource.second);
SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, source.GetData(), source.Length(), m_selSource.first, m_selSource.second);
m_sourceChanged = false;
m_composed->SetValue(composed);
m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second);
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, composed.GetData(), composed.Length(), m_selComposed.first, m_selComposed.second);
m_composedChanged = false;
m_destination->SetValue(destination);
m_destination->GetSelection(&m_selDestination.first, &m_selDestination.second);
SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, destination.GetData(), destination.Length(), m_selDestination.first, m_selDestination.second);
m_destinationChanged = false;
}
}
}
@ -72,7 +72,7 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
wxZRColaComposerPanel::~wxZRColaComposerPanel()
{
m_decomposed->PopEventHandler();
m_source->PopEventHandler();
// This is a controlled exit. Purge saved state.
wxString fileName(GetStateFileName());
@ -83,195 +83,195 @@ wxZRColaComposerPanel::~wxZRColaComposerPanel()
void wxZRColaComposerPanel::SynchronizePanels()
{
if (m_decomposedChanged) {
if (m_sourceChanged) {
m_timerSave.Stop();
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
wxString src;
size_t len = GetValue(m_decomposed, src);
size_t len = GetValue(m_source, src);
std::wstring norm;
app->m_t_db.Decompose(src.data(), len, norm, &m_mapping1);
app->m_t_db.TranslateInv(src.data(), len, norm, &m_mapping1);
std::wstring dst;
app->m_t_db.Compose(norm.data(), norm.size(), dst, &m_mapping2);
app->m_t_db.Translate(norm.data(), norm.size(), dst, &m_mapping2);
m_decomposed->GetSelection(&m_selDecomposed.first, &m_selDecomposed.second);
m_source->GetSelection(&m_selSource.first, &m_selSource.second);
// Update decomposed HEX dump.
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, src.data(), len, m_selDecomposed.first, m_selDecomposed.second);
// Update source HEX dump.
SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, src.data(), len, m_selSource.first, m_selSource.second);
// Update composed text, and its HEX dump.
m_composed->SetValue(dst);
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second)));
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, dst.data(), dst.length(), m_selComposed.first, m_selComposed.second);
// Update destination text, and its HEX dump.
m_destination->SetValue(dst);
m_destination->SetSelection(
m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.first )),
m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.second)));
SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, dst.data(), dst.length(), m_selDestination.first, m_selDestination.second);
// Schedule state save after 3s.
m_timerSave.Start(3000, true);
} else if (m_composedChanged) {
} else if (m_destinationChanged) {
m_timerSave.Stop();
wxString src;
size_t len = GetValue(m_composed, src);
size_t len = GetValue(m_destination, src);
auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
std::wstring dst;
wxZRColaFrame *mainWnd = dynamic_cast<wxZRColaFrame*>(wxGetActiveWindow());
if (mainWnd)
app->m_t_db.Decompose(src.data(), len, &app->m_lc_db, mainWnd->m_settings->m_lang, dst, &m_mapping2);
app->m_t_db.TranslateInv(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);
app->m_t_db.TranslateInv(src.data(), len, dst, &m_mapping2);
m_mapping1.clear();
m_mapping2.invert();
m_composed->GetSelection(&m_selComposed.first, &m_selComposed.second);
m_destination->GetSelection(&m_selDestination.first, &m_selDestination.second);
// Update composed HEX dump.
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, src.data(), len, m_selComposed.first, m_selComposed.second);
// Update destination HEX dump.
SetHexValue(m_destinationHex, m_selDestinationHex, m_mappingDestinationHex, src.data(), len, m_selDestination.first, m_selDestination.second);
// Update decomposed text, and its HEX dump.
m_decomposed->SetValue(dst);
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second)));
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, dst.data(), dst.length(), m_selDecomposed.first, m_selDecomposed.second);
// Update source text, and its HEX dump.
m_source->SetValue(dst);
m_source->SetSelection(
m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.first )),
m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.second)));
SetHexValue(m_sourceHex, m_selSourceHex, m_mappingSourceHex, dst.data(), dst.length(), m_selSource.first, m_selSource.second);
// Schedule state save after 3s.
m_timerSave.Start(3000, true);
}
m_decomposedChanged = false;
m_composedChanged = false;
m_sourceChanged = false;
m_destinationChanged = false;
}
void wxZRColaComposerPanel::OnDecomposedPaint(wxPaintEvent& event)
void wxZRColaComposerPanel::OnSourcePaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_decomposed->GetSelection(&from, &to);
m_source->GetSelection(&from, &to);
if (m_selDecomposed.first != from || m_selDecomposed.second != to) {
if (m_selSource.first != from || m_selSource.second != to) {
// Save new selection first, to avoid loop.
m_selDecomposed.first = from;
m_selDecomposed.second = to;
m_selSource.first = from;
m_selSource.second = to;
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(from),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(to ));
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(from),
m_selSourceHex.second = m_mappingSourceHex.to_dst(to ));
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(from)),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(to )));
m_destination->SetSelection(
m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(from)),
m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(to )));
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ),
m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second));
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second));
}
}
void wxZRColaComposerPanel::OnDecomposedHexPaint(wxPaintEvent& event)
void wxZRColaComposerPanel::OnSourceHexPaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_decomposedHex->GetSelection(&from, &to);
m_sourceHex->GetSelection(&from, &to);
if (m_selDecomposedHex.first != from || m_selDecomposedHex.second != to) {
if (m_selSourceHex.first != from || m_selSourceHex.second != to) {
// Save new selection first, to avoid loop.
m_selDecomposedHex.first = from;
m_selDecomposedHex.second = to;
m_selSourceHex.first = from;
m_selSourceHex.second = to;
m_decomposed->SetSelection(
m_selDecomposed.first = m_mappingDecomposedHex.to_src(from),
m_selDecomposed.second = m_mappingDecomposedHex.to_src(to ));
m_source->SetSelection(
m_selSource.first = m_mappingSourceHex.to_src(from),
m_selSource.second = m_mappingSourceHex.to_src(to ));
m_composed->SetSelection(
m_selComposed.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.first )),
m_selComposed.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selDecomposed.second)));
m_destination->SetSelection(
m_selDestination.first = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.first )),
m_selDestination.second = m_mapping2.to_dst(m_mapping1.to_dst(m_selSource.second)));
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(m_selComposed.first ),
m_selComposedHex.second = m_mappingComposedHex.to_dst(m_selComposed.second));
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(m_selDestination.first ),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(m_selDestination.second));
}
}
void wxZRColaComposerPanel::OnDecomposedText(wxCommandEvent& event)
void wxZRColaComposerPanel::OnSourceText(wxCommandEvent& event)
{
event.Skip();
// Set the flag the decomposed text changed to trigger idle-time composition.
m_decomposedChanged = true;
// Set the flag the source text changed to trigger idle-time translation.
m_sourceChanged = true;
}
void wxZRColaComposerPanel::OnComposedPaint(wxPaintEvent& event)
void wxZRColaComposerPanel::OnDestinationPaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_composed->GetSelection(&from, &to);
m_destination->GetSelection(&from, &to);
if (m_selComposed.first != from || m_selComposed.second != to) {
if (m_selDestination.first != from || m_selDestination.second != to) {
// Save new selection first, to avoid loop.
m_selComposed.first = from;
m_selComposed.second = to;
m_selDestination.first = from;
m_selDestination.second = to;
m_composedHex->SetSelection(
m_selComposedHex.first = m_mappingComposedHex.to_dst(from),
m_selComposedHex.second = m_mappingComposedHex.to_dst(to ));
m_destinationHex->SetSelection(
m_selDestinationHex.first = m_mappingDestinationHex.to_dst(from),
m_selDestinationHex.second = m_mappingDestinationHex.to_dst(to ));
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(from)),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(to )));
m_source->SetSelection(
m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(from)),
m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(to )));
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second));
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second));
}
}
void wxZRColaComposerPanel::OnComposedHexPaint(wxPaintEvent& event)
void wxZRColaComposerPanel::OnDestinationHexPaint(wxPaintEvent& event)
{
event.Skip();
long from, to;
m_composedHex->GetSelection(&from, &to);
m_destinationHex->GetSelection(&from, &to);
if (m_selComposedHex.first != from || m_selComposedHex.second != to) {
if (m_selDestinationHex.first != from || m_selDestinationHex.second != to) {
// Save new selection first, to avoid loop.
m_selComposedHex.first = from;
m_selComposedHex.second = to;
m_selDestinationHex.first = from;
m_selDestinationHex.second = to;
m_composed->SetSelection(
m_selComposed.first = m_mappingComposedHex.to_src(from),
m_selComposed.second = m_mappingComposedHex.to_src(to ));
m_destination->SetSelection(
m_selDestination.first = m_mappingDestinationHex.to_src(from),
m_selDestination.second = m_mappingDestinationHex.to_src(to ));
m_decomposed->SetSelection(
m_selDecomposed.first = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.first )),
m_selDecomposed.second = m_mapping1.to_src(m_mapping2.to_src(m_selComposed.second)));
m_source->SetSelection(
m_selSource.first = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.first )),
m_selSource.second = m_mapping1.to_src(m_mapping2.to_src(m_selDestination.second)));
m_decomposedHex->SetSelection(
m_selDecomposedHex.first = m_mappingDecomposedHex.to_dst(m_selDecomposed.first ),
m_selDecomposedHex.second = m_mappingDecomposedHex.to_dst(m_selDecomposed.second));
m_sourceHex->SetSelection(
m_selSourceHex.first = m_mappingSourceHex.to_dst(m_selSource.first ),
m_selSourceHex.second = m_mappingSourceHex.to_dst(m_selSource.second));
}
}
void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event)
void wxZRColaComposerPanel::OnDestinationText(wxCommandEvent& event)
{
event.Skip();
// Set the flag the composed text changed to trigger idle-time decomposition.
m_composedChanged = true;
// Set the flag the destination text changed to trigger idle-time inverse translation.
m_destinationChanged = true;
}
@ -283,13 +283,13 @@ void wxZRColaComposerPanel::OnSaveTimer(wxTimerEvent& event)
wxString text;
size_t len;
// Save decomposed text.
len = GetValue(m_decomposed, text);
// Save source text.
len = GetValue(m_source, text);
file.Write(&len, sizeof(len));
file.Write((const wchar_t*)text, sizeof(wchar_t)*len);
// Save composed text.
len = GetValue(m_composed, text);
// Save destination text.
len = GetValue(m_destination, text);
file.Write(&len, sizeof(len));
file.Write((const wchar_t*)text, sizeof(wchar_t)*len);
}
@ -385,8 +385,8 @@ void wxPersistentZRColaComposerPanel::Save() const
{
auto const wnd = static_cast<const wxZRColaComposerPanel*>(GetWindow()); // dynamic_cast is not reliable as we are typically called late in the wxTopLevelWindowMSW destructor.
SaveValue(wxT("splitDecomposed"), wnd->m_splitterDecomposed->GetSashPosition());
SaveValue(wxT("splitComposed" ), wnd->m_splitterComposed ->GetSashPosition());
SaveValue(wxT("splitDecomposed"), wnd->m_splitterSource->GetSashPosition());
SaveValue(wxT("splitComposed" ), wnd->m_splitterDestination ->GetSashPosition());
}
@ -398,14 +398,14 @@ bool wxPersistentZRColaComposerPanel::Restore()
if (RestoreValue(wxT("splitDecomposed"), &sashVal)) {
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
wnd->m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, wnd );
wnd->m_splitterDecomposed->SetSashPosition(sashVal);
wnd->m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, wnd );
wnd->m_splitterSource->SetSashPosition(sashVal);
}
if (RestoreValue(wxT("splitComposed"), &sashVal)) {
// wxFormBuilder sets initial splitter stash in idle event handler after GUI settles. Overriding our loaded value. Disconnect it's idle event handler.
wnd->m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, wnd );
wnd->m_splitterComposed->SetSashPosition(sashVal);
wnd->m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, wnd );
wnd->m_splitterDestination->SetSashPosition(sashVal);
}
return true;

View File

@ -46,12 +46,12 @@ public:
friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state.
protected:
virtual void OnDecomposedPaint(wxPaintEvent& event);
virtual void OnDecomposedHexPaint(wxPaintEvent& event);
virtual void OnDecomposedText(wxCommandEvent& event);
virtual void OnComposedPaint(wxPaintEvent& event);
virtual void OnComposedHexPaint(wxPaintEvent& event);
virtual void OnComposedText(wxCommandEvent& event);
virtual void OnSourcePaint(wxPaintEvent& event);
virtual void OnSourceHexPaint(wxPaintEvent& event);
virtual void OnSourceText(wxCommandEvent& event);
virtual void OnDestinationPaint(wxPaintEvent& event);
virtual void OnDestinationHexPaint(wxPaintEvent& event);
virtual void OnDestinationText(wxCommandEvent& event);
virtual void OnSaveTimer(wxTimerEvent& event);
static wxString GetStateFileName();
@ -59,18 +59,18 @@ protected:
static void SetHexValue(wxTextCtrl *wnd, std::pair<long, long> &range, ZRCola::mapping_vector &mapping, const wchar_t *src, size_t len, long from, long to);
protected:
bool m_decomposedChanged; ///< Boolean flag to mark decomposed text "dirty" to trigger composition
bool m_composedChanged; ///< Boolean flag to mark composed text "dirty" to trigger decomposition
ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text
ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and composed text
bool m_sourceChanged; ///< Boolean flag to mark source text "dirty" to trigger translation
bool m_destinationChanged; ///< Boolean flag to mark destination text "dirty" to trigger inverse translation
ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between source and normalized text
ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and destination text
std::pair<long, long>
m_selDecomposed, ///< Character index of selected text in decomposed text control
m_selDecomposedHex, ///< Character index of selected text in decomposed HEX dump text control
m_selComposed, ///< Character index of selected text in composed text control
m_selComposedHex; ///< Character index of selected text in composed HEX dump text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window
ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump
ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump
m_selSource, ///< Character index of selected text in source text control
m_selSourceHex, ///< Character index of selected text in source HEX dump text control
m_selDestination, ///< Character index of selected text in destination text control
m_selDestinationHex; ///< Character index of selected text in destination HEX dump text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for source window
ZRCola::mapping_vector m_mappingSourceHex; ///< Character index mapping vector between source text and its HEX dump
ZRCola::mapping_vector m_mappingDestinationHex; ///< Character index mapping vector between destination text and its HEX dump
};

View File

@ -34,19 +34,19 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
EVT_MENU (wxID_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter )
EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate )
EVT_MENU (wxID_COPY_COMPOSED_AND_RETURN , wxZRColaFrame::OnCopyComposedAndReturn )
EVT_MENU (wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed )
EVT_MENU (wxID_COPY_DECOMPOSED_AND_RETURN , wxZRColaFrame::OnCopyDecomposedAndReturn )
EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed )
EVT_UPDATE_UI_RANGE(wxID_SEND_DESTINATION , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate )
EVT_MENU (wxID_COPY_DESTINATION_AND_RETURN , wxZRColaFrame::OnCopyDestinationAndReturn )
EVT_MENU (wxID_SEND_DESTINATION , wxZRColaFrame::OnSendDestination )
EVT_MENU (wxID_COPY_SOURCE_AND_RETURN , wxZRColaFrame::OnCopySourceAndReturn )
EVT_MENU (wxID_SEND_SOURCE , wxZRColaFrame::OnSendSource )
EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort )
EVT_MENU (wxID_SETTINGS , wxZRColaFrame::OnSettings )
EVT_UPDATE_UI (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEditUpdate )
EVT_MENU (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEdit )
EVT_UPDATE_UI (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarComposeUpdate )
EVT_MENU (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarCompose )
EVT_UPDATE_UI (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslateUpdate )
EVT_MENU (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslate )
EVT_UPDATE_UI (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalogUpdate)
EVT_MENU (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalog )
EVT_MENU (wxID_FOCUS_CHARACTER_CATALOG , wxZRColaFrame::OnPanelCharacterCatalogFocus )
@ -69,10 +69,10 @@ wxZRColaFrame::wxZRColaFrame() :
{
{
// wxFrameBuilder 3.5 does not support wxAUI_TB_HORIZONTAL flag. Add it manually.
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose);
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarTranslate);
paneInfo.LeftDockable(false);
paneInfo.RightDockable(false);
m_toolbarCompose->SetWindowStyleFlag(m_toolbarCompose->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL);
m_toolbarTranslate->SetWindowStyleFlag(m_toolbarTranslate->GetWindowStyleFlag() | wxAUI_TB_HORIZONTAL);
}
// Load main window icons.
@ -106,7 +106,7 @@ wxZRColaFrame::wxZRColaFrame() :
wxPersistentRegisterAndRestore<wxZRColaCharRequest>(m_chrReq);
// Set focus.
m_panel->m_decomposed->SetFocus();
m_panel->m_source->SetFocus();
#if defined(__WXMSW__)
// Register notification sink for language detection.
@ -139,9 +139,9 @@ wxZRColaFrame::wxZRColaFrame() :
wxPersistentAuiManager(&m_mgr).Restore();
// Register global hotkey(s).
if (!RegisterHotKey(wxZRColaHKID_INVOKE_COMPOSE, wxMOD_WIN, VK_F5))
if (!RegisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE, wxMOD_WIN, VK_F5))
wxMessageBox(_("ZRCola keyboard shortcut Win+F5 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING);
if (!RegisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE, wxMOD_WIN, VK_F6))
if (!RegisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE_INV, wxMOD_WIN, VK_F6))
wxMessageBox(_("ZRCola keyboard shortcut Win+F6 could not be registered. Some functionality will not be available."), _("Warning"), wxOK | wxICON_WARNING);
}
@ -149,8 +149,8 @@ wxZRColaFrame::wxZRColaFrame() :
wxZRColaFrame::~wxZRColaFrame()
{
// Unregister global hotkey(s).
UnregisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE);
UnregisterHotKey(wxZRColaHKID_INVOKE_COMPOSE);
UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE_INV);
UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE );
#if defined(__WXMSW__)
if (m_tfSource) {
@ -214,8 +214,8 @@ void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event)
void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event)
{
if (m_chrSelect->ShowModal() == wxID_OK && !m_chrSelect->m_char.empty()) {
m_panel->m_decomposed->WriteText(m_chrSelect->m_char);
m_panel->m_decomposed->SetFocus();
m_panel->m_source->WriteText(m_chrSelect->m_char);
m_panel->m_source->SetFocus();
}
}
@ -226,37 +226,37 @@ void wxZRColaFrame::OnSendUpdate(wxUpdateUIEvent& event)
}
void wxZRColaFrame::OnSendComposed(wxCommandEvent& event)
void wxZRColaFrame::OnSendDestination(wxCommandEvent& event)
{
if (m_hWndSource)
DoSend(m_panel->m_composed->GetValue());
DoSend(m_panel->m_destination->GetValue());
event.Skip();
}
void wxZRColaFrame::OnCopyComposedAndReturn(wxCommandEvent& event)
void wxZRColaFrame::OnCopyDestinationAndReturn(wxCommandEvent& event)
{
if (m_hWndSource)
DoCopyAndReturn(m_panel->m_composed->GetValue());
DoCopyAndReturn(m_panel->m_destination->GetValue());
event.Skip();
}
void wxZRColaFrame::OnSendDecomposed(wxCommandEvent& event)
void wxZRColaFrame::OnSendSource(wxCommandEvent& event)
{
if (m_hWndSource)
DoSend(m_panel->m_decomposed->GetValue());
DoSend(m_panel->m_source->GetValue());
event.Skip();
}
void wxZRColaFrame::OnCopyDecomposedAndReturn(wxCommandEvent& event)
void wxZRColaFrame::OnCopySourceAndReturn(wxCommandEvent& event)
{
if (m_hWndSource)
DoCopyAndReturn(m_panel->m_decomposed->GetValue());
DoCopyAndReturn(m_panel->m_source->GetValue());
event.Skip();
}
@ -272,8 +272,8 @@ void wxZRColaFrame::OnSendAbort(wxCommandEvent& event)
}
// Select all input in composer to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll();
m_panel->m_composed->SelectAll();
m_panel->m_source ->SelectAll();
m_panel->m_destination->SelectAll();
event.Skip();
}
@ -326,15 +326,15 @@ void wxZRColaFrame::OnToolbarEdit(wxCommandEvent& event)
}
void wxZRColaFrame::OnToolbarComposeUpdate(wxUpdateUIEvent& event)
void wxZRColaFrame::OnToolbarTranslateUpdate(wxUpdateUIEvent& event)
{
event.Check(m_mgr.GetPane(m_toolbarCompose).IsShown());
event.Check(m_mgr.GetPane(m_toolbarTranslate).IsShown());
}
void wxZRColaFrame::OnToolbarCompose(wxCommandEvent& event)
void wxZRColaFrame::OnToolbarTranslate(wxCommandEvent& event)
{
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarCompose);
wxAuiPaneInfo &paneInfo = m_mgr.GetPane(m_toolbarTranslate);
paneInfo.Show(!paneInfo.IsShown());
m_mgr.Update();
}
@ -503,9 +503,9 @@ void wxZRColaFrame::DoSend(const wxString& str)
::SendInput(input.size(), input.data(), sizeof(INPUT));
m_hWndSource = NULL;
// Select all input in composer and decomposed to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll();
m_panel->m_composed->SelectAll();
// Select all input in source and destination to prepare for the overwrite next time.
m_panel->m_source ->SelectAll();
m_panel->m_destination->SelectAll();
}
@ -521,9 +521,9 @@ void wxZRColaFrame::DoCopyAndReturn(const wxString& str)
::SetForegroundWindow(m_hWndSource);
m_hWndSource = NULL;
// Select all input in composer and decomposed to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll();
m_panel->m_composed->SelectAll();
// Select all input in composer and source to prepare for the overwrite next time.
m_panel->m_source ->SelectAll();
m_panel->m_destination->SelectAll();
}
@ -536,8 +536,8 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM
WXHWND hWndSource = ::GetForegroundWindow();
switch (wParam) {
case wxZRColaHKID_INVOKE_COMPOSE : m_panel->m_decomposed->SetFocus(); break;
case wxZRColaHKID_INVOKE_DECOMPOSE: m_panel->m_composed ->SetFocus(); break;
case wxZRColaHKID_INVOKE_TRANSLATE : m_panel->m_source ->SetFocus(); break;
case wxZRColaHKID_INVOKE_TRANSLATE_INV: m_panel->m_destination->SetFocus(); break;
default:
wxFAIL_MSG(wxT("not our registered shortcut"));
return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam);

View File

@ -40,8 +40,8 @@ class wxZRColaFrame;
///
/// Global hotkey message identifiers
///
#define wxZRColaHKID_INVOKE_COMPOSE 0
#define wxZRColaHKID_INVOKE_DECOMPOSE 1
#define wxZRColaHKID_INVOKE_TRANSLATE 0
#define wxZRColaHKID_INVOKE_TRANSLATE_INV 1
///
@ -72,10 +72,10 @@ protected:
void OnForwardEvent(wxCommandEvent& event);
void OnInsertCharacter(wxCommandEvent& event);
void OnSendUpdate(wxUpdateUIEvent& event);
void OnSendComposed(wxCommandEvent& event);
void OnCopyComposedAndReturn(wxCommandEvent& event);
void OnSendDecomposed(wxCommandEvent& event);
void OnCopyDecomposedAndReturn(wxCommandEvent& event);
void OnSendDestination(wxCommandEvent& event);
void OnCopyDestinationAndReturn(wxCommandEvent& event);
void OnSendSource(wxCommandEvent& event);
void OnCopySourceAndReturn(wxCommandEvent& event);
void OnSendAbort(wxCommandEvent& event);
void OnSettings(wxCommandEvent& event);
virtual void OnIdle(wxIdleEvent& event);
@ -83,8 +83,8 @@ protected:
virtual void OnIconize(wxIconizeEvent& event);
void OnToolbarEditUpdate(wxUpdateUIEvent& event);
void OnToolbarEdit(wxCommandEvent& event);
void OnToolbarComposeUpdate(wxUpdateUIEvent& event);
void OnToolbarCompose(wxCommandEvent& event);
void OnToolbarTranslateUpdate(wxUpdateUIEvent& event);
void OnToolbarTranslate(wxCommandEvent& event);
void OnPanelCharacterCatalogUpdate(wxUpdateUIEvent& event);
void OnPanelCharacterCatalog(wxCommandEvent& event);
void OnPanelCharacterCatalogFocus(wxCommandEvent& event);

View File

@ -85,41 +85,41 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_menuEdit->AppendSeparator();
wxMenuItem* m_menuItemSendComposed;
m_menuItemSendComposed = new wxMenuItem( m_menuEdit, wxID_SEND_COMPOSED, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL );
wxMenuItem* m_menuItemSendDestination;
m_menuItemSendDestination = new wxMenuItem( m_menuEdit, wxID_SEND_DESTINATION, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemSendComposed->SetBitmaps( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemSendDestination->SetBitmaps( wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemSendComposed->SetBitmap( wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemSendDestination->SetBitmap( wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemSendComposed );
m_menuEdit->Append( m_menuItemSendDestination );
wxMenuItem* m_menuItemCopyComposedAndReturn;
m_menuItemCopyComposedAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_COMPOSED_AND_RETURN, wxString( _("Copy Composed and &Return") ) + wxT('\t') + wxT("Ctrl+F5"), _("Copy composed text to clipboard and return focus to source window"), wxITEM_NORMAL );
wxMenuItem* m_menuItemCopyDestinationAndReturn;
m_menuItemCopyDestinationAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_DESTINATION_AND_RETURN, wxString( _("Copy Composed and &Return") ) + wxT('\t') + wxT("Ctrl+F5"), _("Copy composed text to clipboard and return focus to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemCopyComposedAndReturn->SetBitmaps( wxIcon( wxT("copy_composed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemCopyDestinationAndReturn->SetBitmaps( wxIcon( wxT("copy_destination_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemCopyComposedAndReturn->SetBitmap( wxIcon( wxT("copy_composed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemCopyDestinationAndReturn->SetBitmap( wxIcon( wxT("copy_destination_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemCopyComposedAndReturn );
m_menuEdit->Append( m_menuItemCopyDestinationAndReturn );
wxMenuItem* m_menuItemSendDecomposed;
m_menuItemSendDecomposed = new wxMenuItem( m_menuEdit, wxID_SEND_DECOMPOSED, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL );
wxMenuItem* m_menuItemSendSource;
m_menuItemSendSource = new wxMenuItem( m_menuEdit, wxID_SEND_SOURCE, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemSendDecomposed->SetBitmaps( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemSendSource->SetBitmaps( wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemSendDecomposed->SetBitmap( wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemSendSource->SetBitmap( wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemSendDecomposed );
m_menuEdit->Append( m_menuItemSendSource );
wxMenuItem* m_menuItemCopyDecomposedAndReturn;
m_menuItemCopyDecomposedAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_DECOMPOSED_AND_RETURN, wxString( _("Copy Decomposed and Re&turn") ) + wxT('\t') + wxT("Ctrl+F6"), _("Copy decomposed text to clipboard and return focus to source window"), wxITEM_NORMAL );
wxMenuItem* m_menuItemCopySourceAndReturn;
m_menuItemCopySourceAndReturn = new wxMenuItem( m_menuEdit, wxID_COPY_SOURCE_AND_RETURN, wxString( _("Copy Decomposed and Re&turn") ) + wxT('\t') + wxT("Ctrl+F6"), _("Copy decomposed text to clipboard and return focus to source window"), wxITEM_NORMAL );
#ifdef __WXMSW__
m_menuItemCopyDecomposedAndReturn->SetBitmaps( wxIcon( wxT("copy_decomposed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemCopySourceAndReturn->SetBitmaps( wxIcon( wxT("copy_source_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuItemCopyDecomposedAndReturn->SetBitmap( wxIcon( wxT("copy_decomposed_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
m_menuItemCopySourceAndReturn->SetBitmap( wxIcon( wxT("copy_source_and_return.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuItemCopyDecomposedAndReturn );
m_menuEdit->Append( m_menuItemCopySourceAndReturn );
wxMenuItem* m_menuItemSendAbort;
m_menuItemSendAbort = new wxMenuItem( m_menuEdit, wxID_SEND_ABORT, wxString( _("Abort (De)composition") ) + wxT('\t') + wxT("Esc"), _("Abort composition and return focus to source window"), wxITEM_NORMAL );
@ -144,7 +144,7 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
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_TRANSLATE, wxString( _("&Compose Toolbar") ) , _("Toggle compose toolbar"), wxITEM_CHECK );
m_menuView->Append( m_menuItemToolbarCompose );
m_menuView->AppendSeparator();
@ -194,15 +194,15 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_toolbarEdit->Realize();
m_mgr.AddPane( m_toolbarEdit, wxAuiPaneInfo().Name( wxT("toolbarEdit") ).Top().Caption( _("Edit") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() );
m_toolbarCompose = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT );
m_toolCharSelect = m_toolbarCompose->AddTool( wxID_CHARACTER_SELECTOR, _("Find Character"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Find Character"), _("Display character search to select character to insert into text"), NULL );
m_toolbarTranslate = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT );
m_toolCharSelect = m_toolbarTranslate->AddTool( wxID_CHARACTER_SELECTOR, _("Find Character"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Find Character"), _("Display character search to select character to insert into text"), NULL );
m_toolSendComposed = m_toolbarCompose->AddTool( wxID_SEND_COMPOSED, _("Send Composed"), wxIcon( wxT("send_composed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Composed"), _("Send composed text to source window"), NULL );
m_toolSendDestination = m_toolbarTranslate->AddTool( wxID_SEND_DESTINATION, _("Send Composed"), wxIcon( wxT("send_destination.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Composed"), _("Send composed text to source window"), NULL );
m_toolSendDecomposed = m_toolbarCompose->AddTool( wxID_SEND_DECOMPOSED, _("Send Decomposed"), wxIcon( wxT("send_decomposed.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Decomposed"), _("Send decomposed text to source window"), NULL );
m_toolSendSource = m_toolbarTranslate->AddTool( wxID_SEND_SOURCE, _("Send Decomposed"), wxIcon( wxT("send_source.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Send Decomposed"), _("Send decomposed text to source window"), NULL );
m_toolbarCompose->Realize();
m_mgr.AddPane( m_toolbarCompose, wxAuiPaneInfo().Name( wxT("toolbarCompose") ).Top().Caption( _("Compose") ).PinButton( true ).Dock().Resizable().FloatingSize( wxSize( -1,-1 ) ).LeftDockable( false ).RightDockable( false ).Row( 0 ).Layer( 1 ).ToolbarPane() );
m_toolbarTranslate->Realize();
m_mgr.AddPane( m_toolbarTranslate, 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 );
@ -239,99 +239,99 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_splitterDecomposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterDecomposed->SetSashGravity( 1 );
m_splitterDecomposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this );
m_splitterDecomposed->SetMinimumPaneSize( 5 );
m_splitterSource = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterSource->SetSashGravity( 1 );
m_splitterSource->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this );
m_splitterSource->SetMinimumPaneSize( 5 );
m_panelDecomposedEdit = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedEdit;
bSizerDecomposedEdit = new wxBoxSizer( wxVERTICAL );
m_panelSourceEdit = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerSourceEdit;
bSizerSourceEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedEdit2;
bSizerDecomposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL );
wxStaticBoxSizer* bSizerSourceEdit2;
bSizerSourceEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelSourceEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL );
m_decomposed = new wxTextCtrl( bSizerDecomposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_decomposed->SetMinSize( wxSize( 100,25 ) );
m_source = new wxTextCtrl( bSizerSourceEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_source->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_source->SetMinSize( wxSize( 100,25 ) );
bSizerDecomposedEdit2->Add( m_decomposed, 1, wxEXPAND, 5 );
bSizerSourceEdit2->Add( m_source, 1, wxEXPAND, 5 );
bSizerDecomposedEdit->Add( bSizerDecomposedEdit2, 1, wxEXPAND, 5 );
bSizerSourceEdit->Add( bSizerSourceEdit2, 1, wxEXPAND, 5 );
m_panelDecomposedEdit->SetSizer( bSizerDecomposedEdit );
m_panelDecomposedEdit->Layout();
bSizerDecomposedEdit->Fit( m_panelDecomposedEdit );
m_panelDecomposedHex = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedHex;
bSizerDecomposedHex = new wxBoxSizer( wxVERTICAL );
m_panelSourceEdit->SetSizer( bSizerSourceEdit );
m_panelSourceEdit->Layout();
bSizerSourceEdit->Fit( m_panelSourceEdit );
m_panelSourceHex = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerSourceHex;
bSizerSourceHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedHex2;
bSizerDecomposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL );
wxStaticBoxSizer* bSizerSourceHex2;
bSizerSourceHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelSourceHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL );
m_decomposedHex = new wxTextCtrl( bSizerDecomposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_decomposedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
m_sourceHex = new wxTextCtrl( bSizerSourceHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_sourceHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
bSizerDecomposedHex2->Add( m_decomposedHex, 1, wxEXPAND, 5 );
bSizerSourceHex2->Add( m_sourceHex, 1, wxEXPAND, 5 );
bSizerDecomposedHex->Add( bSizerDecomposedHex2, 1, wxEXPAND, 5 );
bSizerSourceHex->Add( bSizerSourceHex2, 1, wxEXPAND, 5 );
m_panelDecomposedHex->SetSizer( bSizerDecomposedHex );
m_panelDecomposedHex->Layout();
bSizerDecomposedHex->Fit( m_panelDecomposedHex );
m_splitterDecomposed->SplitVertically( m_panelDecomposedEdit, m_panelDecomposedHex, -5 );
bSizerMain->Add( m_splitterDecomposed, 50, wxALL|wxEXPAND, 5 );
m_panelSourceHex->SetSizer( bSizerSourceHex );
m_panelSourceHex->Layout();
bSizerSourceHex->Fit( m_panelSourceHex );
m_splitterSource->SplitVertically( m_panelSourceEdit, m_panelSourceHex, -5 );
bSizerMain->Add( m_splitterSource, 50, wxALL|wxEXPAND, 5 );
m_splitterComposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterComposed->SetSashGravity( 1 );
m_splitterComposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this );
m_splitterComposed->SetMinimumPaneSize( 5 );
m_splitterDestination = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterDestination->SetSashGravity( 1 );
m_splitterDestination->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, this );
m_splitterDestination->SetMinimumPaneSize( 5 );
m_panelComposedEdit = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedEdit;
bSizerComposedEdit = new wxBoxSizer( wxVERTICAL );
m_panelDestinationEdit = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDestinationEdit;
bSizerDestinationEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedEdit2;
bSizerComposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL );
wxStaticBoxSizer* bSizerDestinationEdit2;
bSizerDestinationEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDestinationEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL );
m_composed = new wxTextCtrl( bSizerComposedEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_composed->SetMinSize( wxSize( 100,25 ) );
m_destination = new wxTextCtrl( bSizerDestinationEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_destination->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_destination->SetMinSize( wxSize( 100,25 ) );
bSizerComposedEdit2->Add( m_composed, 1, wxEXPAND, 5 );
bSizerDestinationEdit2->Add( m_destination, 1, wxEXPAND, 5 );
bSizerComposedEdit->Add( bSizerComposedEdit2, 1, wxEXPAND, 5 );
bSizerDestinationEdit->Add( bSizerDestinationEdit2, 1, wxEXPAND, 5 );
m_panelComposedEdit->SetSizer( bSizerComposedEdit );
m_panelComposedEdit->Layout();
bSizerComposedEdit->Fit( m_panelComposedEdit );
m_panelComposedHex = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedHex;
bSizerComposedHex = new wxBoxSizer( wxVERTICAL );
m_panelDestinationEdit->SetSizer( bSizerDestinationEdit );
m_panelDestinationEdit->Layout();
bSizerDestinationEdit->Fit( m_panelDestinationEdit );
m_panelDestinationHex = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDestinationHex;
bSizerDestinationHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedHex2;
bSizerComposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL );
wxStaticBoxSizer* bSizerDestinationHex2;
bSizerDestinationHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDestinationHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL );
m_composedHex = new wxTextCtrl( bSizerComposedHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_composedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
m_destinationHex = new wxTextCtrl( bSizerDestinationHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_destinationHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) );
bSizerComposedHex2->Add( m_composedHex, 1, wxEXPAND, 5 );
bSizerDestinationHex2->Add( m_destinationHex, 1, wxEXPAND, 5 );
bSizerComposedHex->Add( bSizerComposedHex2, 1, wxEXPAND, 5 );
bSizerDestinationHex->Add( bSizerDestinationHex2, 1, wxEXPAND, 5 );
m_panelComposedHex->SetSizer( bSizerComposedHex );
m_panelComposedHex->Layout();
bSizerComposedHex->Fit( m_panelComposedHex );
m_splitterComposed->SplitVertically( m_panelComposedEdit, m_panelComposedHex, -5 );
bSizerMain->Add( m_splitterComposed, 50, wxALL|wxEXPAND, 5 );
m_panelDestinationHex->SetSizer( bSizerDestinationHex );
m_panelDestinationHex->Layout();
bSizerDestinationHex->Fit( m_panelDestinationHex );
m_splitterDestination->SplitVertically( m_panelDestinationEdit, m_panelDestinationHex, -5 );
bSizerMain->Add( m_splitterDestination, 50, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain );
@ -340,24 +340,24 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
m_timerSave.SetOwner( this, wxID_TIMER_SAVE );
// Connect Events
m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this );
m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this );
m_decomposedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this );
m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
m_source->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this );
m_source->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this );
m_sourceHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this );
m_destination->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this );
m_destination->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this );
m_destinationHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this );
this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
}
wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
{
// Disconnect Events
m_decomposed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this );
m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this );
m_decomposedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this );
m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
m_source->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this );
m_source->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this );
m_sourceHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this );
m_destination->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this );
m_destination->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this );
m_destinationHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this );
this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
}

View File

@ -63,14 +63,14 @@ class wxZRColaFrameBase : public wxFrame
enum
{
wxID_CHARACTER_SELECTOR = 1000,
wxID_SEND_COMPOSED,
wxID_COPY_COMPOSED_AND_RETURN,
wxID_SEND_DECOMPOSED,
wxID_COPY_DECOMPOSED_AND_RETURN,
wxID_SEND_DESTINATION,
wxID_COPY_DESTINATION_AND_RETURN,
wxID_SEND_SOURCE,
wxID_COPY_SOURCE_AND_RETURN,
wxID_SEND_ABORT,
wxID_SETTINGS,
wxID_TOOLBAR_EDIT,
wxID_TOOLBAR_COMPOSE,
wxID_TOOLBAR_TRANSLATE,
wxID_PANEL_CHRGRPS,
wxID_HELP_INSTRUCTIONS,
wxID_HELP_SHORTCUTS,
@ -87,10 +87,10 @@ class wxZRColaFrameBase : public wxFrame
wxAuiToolBarItem* m_toolEditCut;
wxAuiToolBarItem* m_toolEditCopy;
wxAuiToolBarItem* m_toolEditPaste;
wxAuiToolBar* m_toolbarCompose;
wxAuiToolBar* m_toolbarTranslate;
wxAuiToolBarItem* m_toolCharSelect;
wxAuiToolBarItem* m_toolSendComposed;
wxAuiToolBarItem* m_toolSendDecomposed;
wxAuiToolBarItem* m_toolSendDestination;
wxAuiToolBarItem* m_toolSendSource;
wxZRColaCharacterCatalogPanel* m_panelChrCat;
wxStatusBar* m_statusBar;
@ -123,43 +123,43 @@ class wxZRColaComposerPanelBase : public wxPanel
wxID_TIMER_SAVE = 1000
};
wxSplitterWindow* m_splitterDecomposed;
wxPanel* m_panelDecomposedEdit;
wxPanel* m_panelDecomposedHex;
wxTextCtrl* m_decomposedHex;
wxSplitterWindow* m_splitterComposed;
wxPanel* m_panelComposedEdit;
wxPanel* m_panelComposedHex;
wxTextCtrl* m_composedHex;
wxSplitterWindow* m_splitterSource;
wxPanel* m_panelSourceEdit;
wxPanel* m_panelSourceHex;
wxTextCtrl* m_sourceHex;
wxSplitterWindow* m_splitterDestination;
wxPanel* m_panelDestinationEdit;
wxPanel* m_panelDestinationHex;
wxTextCtrl* m_destinationHex;
wxTimer m_timerSave;
// Virtual event handlers, overide them in your derived class
virtual void OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDecomposedHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSourcePaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSourceText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSourceHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnDestinationPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnDestinationText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDestinationHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); }
public:
wxTextCtrl* m_decomposed;
wxTextCtrl* m_composed;
wxTextCtrl* m_source;
wxTextCtrl* m_destination;
wxZRColaComposerPanelBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxT("ZRColaComposerPanel") );
~wxZRColaComposerPanelBase();
void m_splitterDecomposedOnIdle( wxIdleEvent& )
void m_splitterSourceOnIdle( wxIdleEvent& )
{
m_splitterDecomposed->SetSashPosition( -5 );
m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this );
m_splitterSource->SetSashPosition( -5 );
m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this );
}
void m_splitterComposedOnIdle( wxIdleEvent& )
void m_splitterDestinationOnIdle( wxIdleEvent& )
{
m_splitterComposed->SetSashPosition( -5 );
m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this );
m_splitterDestination->SetSashPosition( -5 );
m_splitterDestination->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, this );
}
};

View File

@ -127,9 +127,9 @@ void wxZRColaSettings::OnApplyButtonClick(wxCommandEvent& event)
if (m_lang != lang.id) {
m_lang = lang.id;
// Notify composed text something changed and should re-decompose.
// Notify destination text something changed and should re-inverse translate.
wxCommandEvent event2(wxEVT_COMMAND_TEXT_UPDATED);
app->m_mainWnd->m_panel->m_composed->ProcessWindowEvent(event2);
app->m_mainWnd->m_panel->m_destination->ProcessWindowEvent(event2);
}
}
}

View File

@ -48,8 +48,8 @@ protected:
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
bool m_lang_auto; ///< Is language for inverse translation resolved using currently selected keyboard
ZRCola::langid_t m_lang; ///< Language for inverse translation
};

View File

@ -610,25 +610,25 @@ bool ZRCola::DBSource::GetTranslation(const com_obj<ADORecordset>& rs, ZRCola::D
{
com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"komb"), &f)));
wxCHECK(GetUnicodeString(f, t.dec.str), false);
wxCHECK(GetUnicodeString(f, t.src.str), false);
}
{
com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_komb"), &f)));
wxCHECK(GetValue(f, t.dec.rank), false);
wxCHECK(GetValue(f, t.src.rank), false);
}
{
com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_znak"), &f)));
wxCHECK(GetValue(f, t.com.rank), false);
wxCHECK(GetValue(f, t.dst.rank), false);
}
{
com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"znak"), &f)));
wxCHECK(GetUnicodeString(f, t.com.str), false);
wxCHECK(GetUnicodeString(f, t.dst.str), false);
}
return true;

View File

@ -66,8 +66,8 @@ namespace ZRCola {
///
class translation {
public:
charseq dec; ///< Decomposed sequence
charseq com; ///< Composed character
charseq src; ///< Source sequence
charseq dst; ///< Destination sequence
};

View File

@ -25,7 +25,7 @@ using namespace winstd;
///
/// (composed character rank, (decomposed character rank, decomposed character)) data holder
/// (destination character rank, (source character rank, source character)) data holder
///
typedef pair<int, ZRCola::DBSource::charseq> com_translation;
@ -49,46 +49,46 @@ struct translation_set_less {
typedef map<wstring, set<com_translation, translation_set_less> > translation_db;
static set<wstring> decompose(_In_ const translation_db &db, _In_z_ const wchar_t *str, _Inout_ set<translation_db::key_type> &path)
static set<wstring> translate_inv(_In_ const translation_db &db, _In_z_ const wchar_t *str, _Inout_ set<translation_db::key_type> &path)
{
set<wstring> res;
if (*str) {
// Decompose remainder first.
auto rem = decompose(db, str + 1, path);
// Inverse translate remainder first.
auto rem = translate_inv(db, str + 1, path);
if (rem.empty())
return res;
translation_db::key_type _str(1, *str);
auto const t = db.find(_str);
if (t != db.end()) {
// Current characted decomposed. Iterate all possible decompositions and combine them with the remainder.
// Current characted inverse translated. Iterate all possible inverse translations and combine them with the remainder.
auto p = path.insert(_str);
if (!p.second) {
// Path already contains this character: Cycle detected!
return res;
}
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) {
auto dec = decompose(db, d->second.str.c_str(), path);
if (!dec.empty()) {
for (auto dd = dec.cbegin(), dd_end = dec.cend(); dd != dd_end; ++dd) {
auto src = translate_inv(db, d->second.str.c_str(), path);
if (!src.empty()) {
for (auto dd = src.cbegin(), dd_end = src.cend(); dd != dd_end; ++dd) {
for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(*dd + *r);
}
} else {
// Cycle detected. Do not continue decomposition.
// Cycle detected. Do not continue inverse translation.
for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(_str + *r);
}
}
path.erase(p.first);
} else {
// Current character is non-decomposable. Combine it with the remainder(s).
// Current character is non-inverse translatable. Combine it with the remainder(s).
for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(_str + *r);
}
} else {
// Empty string results in empty decomposition.
// Empty string results in empty inverse translation.
res.insert(L"");
}
@ -187,25 +187,25 @@ int _tmain(int argc, _TCHAR *argv[])
ZRCola::DBSource::translation trans;
if (src.GetTranslation(rs, trans)) {
// Add translation to temporary database.
auto const t = db_temp1.find(trans.com.str);
auto const t = db_temp1.find(trans.dst.str);
if (t != db_temp1.end())
t->second.insert(com_translation(trans.com.rank, std::move(trans.dec)));
t->second.insert(com_translation(trans.dst.rank, std::move(trans.src)));
else {
translation_db::mapped_type d;
d.insert(com_translation(trans.com.rank, std::move(trans.dec)));
db_temp1.insert(std::move(pair<translation_db::key_type, translation_db::mapped_type>(trans.com.str, std::move(d))));
d.insert(com_translation(trans.dst.rank, std::move(trans.src)));
db_temp1.insert(std::move(pair<translation_db::key_type, translation_db::mapped_type>(trans.dst.str, std::move(d))));
}
} else
has_errors = true;
}
// Decompose decompositions down to non-decomposable characters.
// Inverse translate source sequences down to non-inverse translatable characters.
translation_db db_temp2;
for (auto t1 = db_temp1.cbegin(), t1_end = db_temp1.cend(); t1 != t1_end; ++t1) {
for (auto d1 = t1->second.cbegin(), d1_end = t1->second.cend(); d1 != d1_end; ++d1) {
set<translation_db::key_type> path;
path.insert(t1->first);
auto str = decompose(db_temp1, d1->second.str.c_str(), path);
auto str = translate_inv(db_temp1, d1->second.str.c_str(), path);
assert(!str.empty());
// Add translation to temporary database.
@ -225,35 +225,35 @@ int _tmain(int argc, _TCHAR *argv[])
ZRCola::translation_db db;
// Preallocate memory.
db.idxComp .reserve(count);
db.idxDecomp.reserve(count);
db.data .reserve(count*5);
db.idxTrans .reserve(count);
db.idxTransInv.reserve(count);
db.data .reserve(count*5);
// Parse translations and build index and data.
for (auto t = db_temp2.cbegin(), t_end = db_temp2.cend(); t != t_end; ++t) {
// Add translation to index and data.
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) {
unsigned __int32 idx = db.data.size();
wxASSERT_MSG((int)0xffff8000 <= d->first && d->first <= (int)0x00007fff, wxT("composed character rank out of bounds"));
wxASSERT_MSG((int)0xffff8000 <= d->first && d->first <= (int)0x00007fff, wxT("destination character rank out of bounds"));
db.data.push_back((unsigned __int16)d->first);
wxASSERT_MSG((int)0xffff8000 <= d->second.rank && d->second.rank <= (int)0x00007fff, wxT("decomposed character rank out of bounds"));
wxASSERT_MSG((int)0xffff8000 <= d->second.rank && d->second.rank <= (int)0x00007fff, wxT("source character rank out of bounds"));
db.data.push_back((unsigned __int16)d->second.rank);
wstring::size_type n = t->first.length();
wxASSERT_MSG(n <= 0xffff, wxT("composition overflow"));
wxASSERT_MSG(n <= 0xffff, wxT("destination overflow"));
db.data.push_back((unsigned __int16)n);
n += d->second.str.length();
wxASSERT_MSG(n <= 0xffff, wxT("decomposition overflow"));
wxASSERT_MSG(n <= 0xffff, wxT("source overflow"));
db.data.push_back((unsigned __int16)n);
db.data.insert(db.data.end(), t->first .cbegin(), t->first .cend());
db.data.insert(db.data.end(), d->second.str.cbegin(), d->second.str.cend());
db.idxComp .push_back(idx);
db.idxDecomp.push_back(idx);
db.idxTrans .push_back(idx);
db.idxTransInv.push_back(idx);
}
}
// Sort indices.
db.idxComp .sort();
db.idxDecomp.sort();
db.idxTrans .sort();
db.idxTransInv.sort();
// Write translations to file.
dst << ZRCola::translation_rec(db);

View File

@ -528,7 +528,7 @@ namespace ZRCola {
///
/// A vector for composed-decomposed index transformation mapping
/// A vector for destination-source index transformation mapping
///
class ZRCOLA_API mapping_vector : public std::vector<mapping> {
public:

View File

@ -24,7 +24,7 @@
namespace ZRCola {
///
/// Normalizes a decomposed string
/// Normalizes a source string
///
/// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.

View File

@ -47,13 +47,13 @@ namespace ZRCola {
///
struct translation {
public:
unsigned __int16 com_rank; ///< Composed character rank
unsigned __int16 dec_rank; ///< Decomposed character rank
unsigned __int16 dst_rank; ///< Destination character rank
unsigned __int16 src_rank; ///< Source character rank
protected:
unsigned __int16 com_to; ///< Composed character end in \c data
unsigned __int16 dec_to; ///< Decomposed string end in \c data
wchar_t data[]; ///< Decomposed string and composed character
unsigned __int16 dst_to; ///< Destination character end in \c data
unsigned __int16 src_to; ///< Source string end in \c data
wchar_t data[]; ///< Destination string and source character
private:
inline translation(_In_ const translation &other);
@ -63,58 +63,58 @@ namespace ZRCola {
///
/// Constructs the translation
///
/// \param[in] com_rank Composed character rank
/// \param[in] com Composed character
/// \param[in] com_len Number of UTF-16 characters in \p com
/// \param[in] dec_rank Decomposed character rank
/// \param[in] dec Decomposed character
/// \param[in] dec_len Number of UTF-16 characters in \p dec
/// \param[in] dst_rank Destination character rank
/// \param[in] dst Destination character
/// \param[in] dst_len Number of UTF-16 characters in \p dst
/// \param[in] src_rank Source character rank
/// \param[in] src Source character
/// \param[in] src_len Number of UTF-16 characters in \p src
///
inline translation(
_In_opt_ unsigned __int16 com_rank = 0,
_In_opt_z_count_(com_len) const wchar_t *com = NULL,
_In_opt_ size_t com_len = 0,
_In_opt_ unsigned __int16 dec_rank = 0,
_In_opt_z_count_(dec_len) const wchar_t *dec = NULL,
_In_opt_ size_t dec_len = 0)
_In_opt_ unsigned __int16 dst_rank = 0,
_In_opt_z_count_(dst_len) const wchar_t *dst = NULL,
_In_opt_ size_t dst_len = 0,
_In_opt_ unsigned __int16 src_rank = 0,
_In_opt_z_count_(src_len) const wchar_t *src = NULL,
_In_opt_ size_t src_len = 0)
{
this->com_rank = com_rank;
this->dec_rank = dec_rank;
this->com_to = static_cast<unsigned __int16>(com_len);
if (com_len) memcpy(this->data, com, sizeof(wchar_t)*com_len);
this->dec_to = static_cast<unsigned __int16>(this->com_to + dec_len);
if (dec_len) memcpy(this->data + this->com_to, dec, sizeof(wchar_t)*dec_len);
this->dst_rank = dst_rank;
this->src_rank = src_rank;
this->dst_to = static_cast<unsigned __int16>(dst_len);
if (dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len);
this->src_to = static_cast<unsigned __int16>(this->dst_to + src_len);
if (src_len) memcpy(this->data + this->dst_to, src, sizeof(wchar_t)*src_len);
}
inline const wchar_t* com () const { return data; };
inline wchar_t* com () { return data; };
inline const wchar_t* com_end() const { return data + com_to; };
inline wchar_t* com_end() { return data + com_to; };
inline unsigned __int16 com_len() const { return com_to; };
inline const wchar_t* dst () const { return data; };
inline wchar_t* dst () { return data; };
inline const wchar_t* dst_end() const { return data + dst_to; };
inline wchar_t* dst_end() { return data + dst_to; };
inline unsigned __int16 dst_len() const { return dst_to; };
inline wchar_t com_at(_In_ size_t i) const
inline wchar_t dst_at(_In_ size_t i) const
{
return i < com_to ? data[i] : 0;
return i < dst_to ? data[i] : 0;
}
inline const wchar_t* dec () const { return data + com_to; };
inline wchar_t* dec () { return data + com_to; };
inline const wchar_t* dec_end() const { return data + dec_to; };
inline wchar_t* dec_end() { return data + dec_to; };
inline unsigned __int16 dec_len() const { return dec_to - com_to; };
inline const wchar_t* src () const { return data + dst_to; };
inline wchar_t* src () { return data + dst_to; };
inline const wchar_t* src_end() const { return data + src_to; };
inline wchar_t* src_end() { return data + src_to; };
inline unsigned __int16 src_len() const { return src_to - dst_to; };
inline wchar_t dec_at(_In_ size_t i) const
inline wchar_t src_at(_In_ size_t i) const
{
size_t ii = i + com_to; // absolute index
return ii < dec_to ? data[ii] : 0;
size_t ii = i + dst_to; // absolute index
return ii < src_to ? data[ii] : 0;
}
};
#pragma pack(pop)
///
/// Composition index
/// Translation index
///
class indexComp : public index<unsigned __int16, unsigned __int32, translation>
class indexTrans : public index<unsigned __int16, unsigned __int32, translation>
{
public:
///
@ -122,7 +122,7 @@ namespace ZRCola {
///
/// \param[in] h Reference to vector holding the data
///
indexComp(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
indexTrans(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
///
/// Compares two transformations by string (for searching)
@ -137,7 +137,7 @@ namespace ZRCola {
///
virtual int compare(_In_ const translation &a, _In_ const translation &b) const
{
int r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len());
int r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len());
if (r != 0) return r;
return 0;
@ -156,24 +156,24 @@ namespace ZRCola {
///
virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const
{
int r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len());
int r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len());
if (r != 0) return r;
if (a.dec_rank < b.dec_rank) return -1;
else if (a.dec_rank > b.dec_rank) return +1;
if (a.src_rank < b.src_rank) return -1;
else if (a.src_rank > b.src_rank) return +1;
r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len());
r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len());
if (r != 0) return r;
return 0;
}
} idxComp; ///< Composition index
} idxTrans; ///< Translation index
///
/// Decomposition index
/// Inverse translation index
///
class indexDecomp : public index<unsigned __int16, unsigned __int32, translation>
class indexTransInv : public index<unsigned __int16, unsigned __int32, translation>
{
public:
///
@ -181,7 +181,7 @@ namespace ZRCola {
///
/// \param[in] h Reference to vector holding the data
///
indexDecomp(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
indexTransInv(_In_ std::vector<unsigned __int16> &h) : index<unsigned __int16, unsigned __int32, translation>(h) {}
///
/// Compares two transformations by character (for searching)
@ -196,7 +196,7 @@ namespace ZRCola {
///
virtual int compare(_In_ const translation &a, _In_ const translation &b) const
{
int r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len());
int r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len());
if (r != 0) return r;
return 0;
@ -215,18 +215,18 @@ namespace ZRCola {
///
virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const
{
int r = ZRCola::CompareString(a.com(), a.com_len(), b.com(), b.com_len());
int r = ZRCola::CompareString(a.dst(), a.dst_len(), b.dst(), b.dst_len());
if (r != 0) return r;
if (a.com_rank < b.com_rank) return -1;
else if (a.com_rank > b.com_rank) return +1;
if (a.dst_rank < b.dst_rank) return -1;
else if (a.dst_rank > b.dst_rank) return +1;
r = ZRCola::CompareString(a.dec(), a.dec_len(), b.dec(), b.dec_len());
r = ZRCola::CompareString(a.src(), a.src_len(), b.src(), b.src_len());
if (r != 0) return r;
return 0;
}
} idxDecomp; ///< Decomposition index
} idxTransInv; ///< Inverse translation index
std::vector<unsigned __int16> data; ///< Transformation data
@ -235,43 +235,43 @@ namespace ZRCola {
///
/// Constructs the database
///
inline translation_db() : idxComp(data), idxDecomp(data) {}
inline translation_db() : idxTrans(data), idxTransInv(data) {}
///
/// Clears the database
///
inline void clear()
{
idxComp .clear();
idxDecomp.clear();
data .clear();
idxTrans .clear();
idxTransInv.clear();
data .clear();
}
///
/// Composes string
/// Translates string
///
/// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.
/// \param[out] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional)
///
void Compose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
void Translate(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
///
/// Decomposes string
/// Inverse translates string
///
/// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.
/// \param[out] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional)
///
inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const
inline void TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const
{
Decompose(input, inputMax, NULL, langid_t::blank, output, map);
TranslateInv(input, inputMax, NULL, langid_t::blank, output, map);
}
///
/// Decomposes string according ommiting language specific characters
/// Inverse translates string according ommiting language specific characters
///
/// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated.
@ -280,7 +280,7 @@ namespace ZRCola {
/// \param[out] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional)
///
void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
void TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map = NULL) const;
};
@ -301,13 +301,13 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::translation_db, ZRCola::re
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::translation_db &db)
{
// Write composition index.
// Write translation index.
if (stream.fail()) return stream;
stream << db.idxComp;
stream << db.idxTrans;
// Write decomposition index.
// Write inverse translation index.
if (stream.fail()) return stream;
stream << db.idxDecomp;
stream << db.idxTransInv;
// Write data count.
auto data_count = db.data.size();
@ -340,12 +340,12 @@ inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::t
///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db)
{
// Read composition index.
stream >> db.idxComp;
// Read translation index.
stream >> db.idxTrans;
if (!stream.good()) return stream;
// Read decomposition index.
stream >> db.idxDecomp;
// Read inverse translation index.
stream >> db.idxTransInv;
if (!stream.good()) return stream;
// Read data count.

View File

@ -20,7 +20,7 @@
#include "stdafx.h"
void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
void ZRCola::translation_db::Translate(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
{
assert(input || inputMax == 0);
@ -33,22 +33,22 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input
if (map)
map->clear();
auto compositionsCount = idxComp.size();
auto count = idxTrans.size();
for (size_t i = 0; i < inputMax;) {
// Find the longest matching composition at i-th character.
// Find the longest matching translation at i-th character.
size_t l_match = (size_t)-1;
for (size_t l = 0, r = compositionsCount, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) {
for (size_t l = 0, r = count, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) {
wchar_t c = input[ii];
while (l < r) {
// Test the composition in the middle of the search area.
// Test the translation in the middle of the search area.
size_t m = (l + r) / 2;
// Get the j-th character of the composition.
// All compositions that get short on characters are lexically ordered before.
// Get the j-th character of the translation.
// All translations that get short on characters are lexically ordered before.
// Thus the j-th character is considered 0.
const translation &trans = idxComp[m];
wchar_t s = trans.dec_at(j);
const translation &trans = idxTrans[m];
wchar_t s = trans.src_at(j);
// Do the bisection test.
if (c < s) r = m;
@ -56,25 +56,25 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input
else {
// Character found.
// Narrow the search area on the left to start at the first composition in the run.
// Narrow the search area on the left to start at the first translation in the run.
for (size_t rr = m; l < rr;) {
size_t m = (l + rr) / 2;
const translation &trans = idxComp[m];
wchar_t s = trans.dec_at(j);
const translation &trans = idxTrans[m];
wchar_t s = trans.src_at(j);
if (c <= s) rr = m; else l = m + 1;
}
// Narrow the search area on the right to end at the first composition not in the run.
// Narrow the search area on the right to end at the first translation not in the run.
for (size_t ll = m + 1; ll < r;) {
size_t m = (ll + r) / 2;
const translation &trans = idxComp[m];
wchar_t s = trans.dec_at(j);
const translation &trans = idxTrans[m];
wchar_t s = trans.src_at(j);
if (s <= c) ll = m + 1; else r = m;
}
const translation &trans = idxComp[l];
if (j + 1 == trans.dec_len()) {
// The first composition of the run was a match (thus far). Save it.
const translation &trans = idxTrans[l];
if (j + 1 == trans.src_len()) {
// The first translation of the run was a match (thus far). Save it.
l_match = l;
}
@ -83,12 +83,12 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input
}
}
if (l_match < compositionsCount) {
// The saved composition was an exact match.
const translation &trans = idxComp[l_match];
output.append(trans.com(), trans.com_end());
i += trans.dec_len();
if (trans.dec_len() != trans.com_len() && map) {
if (l_match < count) {
// The saved translation was an exact match.
const translation &trans = idxTrans[l_match];
output.append(trans.dst(), trans.dst_end());
i += trans.src_len();
if (trans.src_len() != trans.dst_len() && map) {
// Mapping changed.
map->push_back(ZRCola::mapping(i, output.length()));
}
@ -101,7 +101,7 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input
}
void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
void ZRCola::translation_db::TranslateInv(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector<mapping>* map) const
{
assert(input || inputMax == 0);
@ -114,22 +114,22 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp
if (map)
map->clear();
auto decompositionsCount = idxDecomp.size();
auto count = idxTransInv.size();
for (size_t i = 0; i < inputMax;) {
// Find the longest matching decomposition at i-th character.
// Find the longest matching inverse translation at i-th character.
size_t l_match = (size_t)-1;
for (size_t l = 0, r = decompositionsCount, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) {
for (size_t l = 0, r = count, ii = i, j = 0; ii < inputMax && l < r; ii++, j++) {
wchar_t c = input[ii];
while (l < r) {
// Test the decomposition in the middle of the search area.
// Test the inverse translation in the middle of the search area.
size_t m = (l + r) / 2;
// Get the j-th character of the decomposition.
// All decompositions that get short on characters are lexically ordered before.
// Get the j-th character of the inverse translation.
// All inverse translations that get short on characters are lexically ordered before.
// Thus the j-th character is considered 0.
const translation &trans = idxDecomp[m];
wchar_t s = trans.com_at(j);
const translation &trans = idxTransInv[m];
wchar_t s = trans.dst_at(j);
// Do the bisection test.
if (c < s) r = m;
@ -137,25 +137,25 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp
else {
// Character found.
// Narrow the search area on the left to start at the first decomposition in the run.
// Narrow the search area on the left to start at the first inverse translation in the run.
for (size_t rr = m; l < rr;) {
size_t m = (l + rr) / 2;
const translation &trans = idxDecomp[m];
wchar_t s = trans.com_at(j);
const translation &trans = idxTransInv[m];
wchar_t s = trans.dst_at(j);
if (c <= s) rr = m; else l = m + 1;
}
// Narrow the search area on the right to end at the first decomposition not in the run.
// Narrow the search area on the right to end at the first inverse translation not in the run.
for (size_t ll = m + 1; ll < r;) {
size_t m = (ll + r) / 2;
const translation &trans = idxDecomp[m];
wchar_t s = trans.com_at(j);
const translation &trans = idxTransInv[m];
wchar_t s = trans.dst_at(j);
if (s <= c) ll = m + 1; else r = m;
}
const translation &trans = idxDecomp[l];
if (j + 1 == trans.com_len()) {
// The first decomposition of the run was a match (thus far). Save it.
const translation &trans = idxTransInv[l];
if (j + 1 == trans.dst_len()) {
// The first inverse translation of the run was a match (thus far). Save it.
l_match = l;
}
@ -164,21 +164,21 @@ void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* inp
}
}
if (l_match < decompositionsCount) {
// The saved decomposition was an exact match.
const translation &trans = idxDecomp[l_match];
if (trans.dec_len() && trans.dec()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.com(), trans.com_end(), lang))) {
// Append decomposed sequence.
output.append(trans.dec(), trans.dec_end());
i += trans.com_len();
if (trans.com_len() != trans.dec_len() && map) {
if (l_match < count) {
// The saved inverse translation was an exact match.
const translation &trans = idxTransInv[l_match];
if (trans.src_len() && trans.src()[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(trans.dst(), trans.dst_end(), lang))) {
// Append source sequence.
output.append(trans.src(), trans.src_end());
i += trans.dst_len();
if (trans.dst_len() != trans.src_len() && map) {
// Mapping changed.
map->push_back(ZRCola::mapping(i, output.length()));
}
} else {
// Character is inhibited to decompose.
output.append(trans.com(), trans.com_end());
i += trans.com_len();
// Character is inhibited to inverse translate.
output.append(trans.dst(), trans.dst_end());
i += trans.dst_len();
}
} else {
// The match was not found.