"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> <property name="permission">none</property>
</object> </object>
<object class="wxMenuItem" expanded="0"> <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="checked">0</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="help">Send composed text to source window</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="kind">wxITEM_NORMAL</property>
<property name="label">&amp;Send Composed</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="permission">none</property>
<property name="shortcut">F5</property> <property name="shortcut">F5</property>
<property name="unchecked_bitmap"></property> <property name="unchecked_bitmap"></property>
@ -260,14 +260,14 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
<object class="wxMenuItem" expanded="0"> <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="checked">0</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="help">Copy composed text to clipboard and return focus to source window</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="kind">wxITEM_NORMAL</property>
<property name="label">Copy Composed and &amp;Return</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="permission">none</property>
<property name="shortcut">Ctrl+F5</property> <property name="shortcut">Ctrl+F5</property>
<property name="unchecked_bitmap"></property> <property name="unchecked_bitmap"></property>
@ -275,14 +275,14 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
<object class="wxMenuItem" expanded="0"> <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="checked">0</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="help">Send decomposed text to source window</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="kind">wxITEM_NORMAL</property>
<property name="label">Send &amp;Decomposed</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="permission">none</property>
<property name="shortcut">F6</property> <property name="shortcut">F6</property>
<property name="unchecked_bitmap"></property> <property name="unchecked_bitmap"></property>
@ -290,14 +290,14 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
<object class="wxMenuItem" expanded="0"> <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="checked">0</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="help">Copy decomposed text to clipboard and return focus to source window</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="kind">wxITEM_NORMAL</property>
<property name="label">Copy Decomposed and Re&amp;turn</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="permission">none</property>
<property name="shortcut">Ctrl+F6</property> <property name="shortcut">Ctrl+F6</property>
<property name="unchecked_bitmap"></property> <property name="unchecked_bitmap"></property>
@ -363,7 +363,7 @@
<property name="checked">0</property> <property name="checked">0</property>
<property name="enabled">1</property> <property name="enabled">1</property>
<property name="help">Toggle compose toolbar</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="kind">wxITEM_CHECK</property>
<property name="label">&amp;Compose Toolbar</property> <property name="label">&amp;Compose Toolbar</property>
<property name="name">m_menuItemToolbarCompose</property> <property name="name">m_menuItemToolbarCompose</property>
@ -666,7 +666,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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="packing">1</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
<property name="pane_position">-1,-1</property> <property name="pane_position">-1,-1</property>
@ -732,12 +732,12 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
<object class="tool" expanded="0"> <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="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="kind">wxITEM_NORMAL</property>
<property name="label">Send Composed</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="permission">protected</property>
<property name="statusbar">Send composed text to source window</property> <property name="statusbar">Send composed text to source window</property>
<property name="tooltip">Send Composed</property> <property name="tooltip">Send Composed</property>
@ -753,12 +753,12 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
<object class="tool" expanded="0"> <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="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="kind">wxITEM_NORMAL</property>
<property name="label">Send Decomposed</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="permission">protected</property>
<property name="statusbar">Send decomposed text to source window</property> <property name="statusbar">Send decomposed text to source window</property>
<property name="tooltip">Send Decomposed</property> <property name="tooltip">Send Decomposed</property>
@ -1078,7 +1078,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1162,7 +1162,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1203,7 +1203,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerDecomposedEdit</property> <property name="name">bSizerSourceEdit</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
@ -1214,7 +1214,7 @@
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Decomposed Text</property> <property name="label">Decomposed Text</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerDecomposedEdit2</property> <property name="name">bSizerSourceEdit2</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
@ -1258,7 +1258,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">100,25</property> <property name="minimum_size">100,25</property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1296,13 +1296,13 @@
<event name="OnMotion"></event> <event name="OnMotion"></event>
<event name="OnMouseEvents"></event> <event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event> <event name="OnMouseWheel"></event>
<event name="OnPaint">OnDecomposedPaint</event> <event name="OnPaint">OnSourcePaint</event>
<event name="OnRightDClick"></event> <event name="OnRightDClick"></event>
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText">OnDecomposedText</event> <event name="OnText">OnSourceText</event>
<event name="OnTextEnter"></event> <event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event> <event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event> <event name="OnTextURL"></event>
@ -1350,7 +1350,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1391,7 +1391,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerDecomposedHex</property> <property name="name">bSizerSourceHex</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
@ -1402,7 +1402,7 @@
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Decomposed Unicode Dump</property> <property name="label">Decomposed Unicode Dump</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerDecomposedHex2</property> <property name="name">bSizerSourceHex2</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
@ -1446,7 +1446,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1484,7 +1484,7 @@
<event name="OnMotion"></event> <event name="OnMotion"></event>
<event name="OnMouseEvents"></event> <event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event> <event name="OnMouseWheel"></event>
<event name="OnPaint">OnDecomposedHexPaint</event> <event name="OnPaint">OnSourceHexPaint</event>
<event name="OnRightDClick"></event> <event name="OnRightDClick"></event>
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
@ -1544,7 +1544,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1628,7 +1628,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1669,7 +1669,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerComposedEdit</property> <property name="name">bSizerDestinationEdit</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
@ -1680,7 +1680,7 @@
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Composed Text</property> <property name="label">Composed Text</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerComposedEdit2</property> <property name="name">bSizerDestinationEdit2</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
@ -1724,7 +1724,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size">100,25</property> <property name="minimum_size">100,25</property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1762,13 +1762,13 @@
<event name="OnMotion"></event> <event name="OnMotion"></event>
<event name="OnMouseEvents"></event> <event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event> <event name="OnMouseWheel"></event>
<event name="OnPaint">OnComposedPaint</event> <event name="OnPaint">OnDestinationPaint</event>
<event name="OnRightDClick"></event> <event name="OnRightDClick"></event>
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></event> <event name="OnRightUp"></event>
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText">OnComposedText</event> <event name="OnText">OnDestinationText</event>
<event name="OnTextEnter"></event> <event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event> <event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event> <event name="OnTextURL"></event>
@ -1816,7 +1816,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1857,7 +1857,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="0"> <object class="wxBoxSizer" expanded="0">
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerComposedHex</property> <property name="name">bSizerDestinationHex</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
@ -1868,7 +1868,7 @@
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Composed Unicode Dump</property> <property name="label">Composed Unicode Dump</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">bSizerComposedHex2</property> <property name="name">bSizerDestinationHex2</property>
<property name="orient">wxVERTICAL</property> <property name="orient">wxVERTICAL</property>
<property name="permission">none</property> <property name="permission">none</property>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
@ -1912,7 +1912,7 @@
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="moveable">1</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_border">1</property>
<property name="pane_position"></property> <property name="pane_position"></property>
<property name="pane_size"></property> <property name="pane_size"></property>
@ -1950,7 +1950,7 @@
<event name="OnMotion"></event> <event name="OnMotion"></event>
<event name="OnMouseEvents"></event> <event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event> <event name="OnMouseWheel"></event>
<event name="OnPaint">OnComposedHexPaint</event> <event name="OnPaint">OnDestinationHexPaint</event>
<event name="OnRightDClick"></event> <event name="OnRightDClick"></event>
<event name="OnRightDown"></event> <event name="OnRightDown"></event>
<event name="OnRightUp"></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) BEGIN_EVENT_TABLE(wxZRColaCharacterCatalogPanel, wxZRColaCharacterCatalogPanelBase)
EVT_MENU(wxZRColaCharacterCatalogPanel::wxID_FOCUS_DECOMPOSED, wxZRColaCharacterCatalogPanel::OnFocusDecomposed) EVT_MENU(wxZRColaCharacterCatalogPanel::wxID_FOCUS_SOURCE, wxZRColaCharacterCatalogPanel::OnFocusSource)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -70,7 +70,7 @@ wxZRColaCharacterCatalogPanel::wxZRColaCharacterCatalogPanel(wxWindow* parent) :
// Register frame specific hotkey(s). // Register frame specific hotkey(s).
{ {
wxAcceleratorEntry entries[1]; 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)); SetAcceleratorTable(wxAcceleratorTable(_countof(entries), entries));
} }
} }
@ -98,8 +98,8 @@ void wxZRColaCharacterCatalogPanel::OnGridClick(wxGridEvent& event)
{ {
auto app = dynamic_cast<ZRColaApp*>(wxTheApp); auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
if (app->m_mainWnd) { 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_source->WriteText(m_grid->GetCellValue(event.GetRow(), event.GetCol()));
app->m_mainWnd->m_panel->m_decomposed->SetFocus(); app->m_mainWnd->m_panel->m_source->SetFocus();
} }
event.Skip(); event.Skip();
@ -113,8 +113,8 @@ void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event)
case WXK_NUMPAD_ENTER: case WXK_NUMPAD_ENTER:
auto app = dynamic_cast<ZRColaApp*>(wxTheApp); auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
if (app->m_mainWnd) { 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_source->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->SetFocus();
event.StopPropagation(); event.StopPropagation();
return; 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); auto app = dynamic_cast<ZRColaApp*>(wxTheApp);
if (app->m_mainWnd) { if (app->m_mainWnd) {
app->m_mainWnd->m_panel->m_decomposed->SetFocus(); app->m_mainWnd->m_panel->m_source->SetFocus();
event.StopPropagation(); event.StopPropagation();
return; return;

View File

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

View File

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

View File

@ -46,12 +46,12 @@ public:
friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state. friend class wxPersistentZRColaComposerPanel; // Allow saving/restoring window state.
protected: protected:
virtual void OnDecomposedPaint(wxPaintEvent& event); virtual void OnSourcePaint(wxPaintEvent& event);
virtual void OnDecomposedHexPaint(wxPaintEvent& event); virtual void OnSourceHexPaint(wxPaintEvent& event);
virtual void OnDecomposedText(wxCommandEvent& event); virtual void OnSourceText(wxCommandEvent& event);
virtual void OnComposedPaint(wxPaintEvent& event); virtual void OnDestinationPaint(wxPaintEvent& event);
virtual void OnComposedHexPaint(wxPaintEvent& event); virtual void OnDestinationHexPaint(wxPaintEvent& event);
virtual void OnComposedText(wxCommandEvent& event); virtual void OnDestinationText(wxCommandEvent& event);
virtual void OnSaveTimer(wxTimerEvent& event); virtual void OnSaveTimer(wxTimerEvent& event);
static wxString GetStateFileName(); 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); 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: protected:
bool m_decomposedChanged; ///< Boolean flag to mark decomposed text "dirty" to trigger composition bool m_sourceChanged; ///< Boolean flag to mark source text "dirty" to trigger translation
bool m_composedChanged; ///< Boolean flag to mark composed text "dirty" to trigger decomposition bool m_destinationChanged; ///< Boolean flag to mark destination text "dirty" to trigger inverse translation
ZRCola::mapping_vector m_mapping1; ///< Character index mapping vector between decomposed and normalized text 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 composed text ZRCola::mapping_vector m_mapping2; ///< Character index mapping vector between normalized and destination text
std::pair<long, long> std::pair<long, long>
m_selDecomposed, ///< Character index of selected text in decomposed text control m_selSource, ///< Character index of selected text in source text control
m_selDecomposedHex, ///< Character index of selected text in decomposed HEX dump text control m_selSourceHex, ///< Character index of selected text in source HEX dump text control
m_selComposed, ///< Character index of selected text in composed text control m_selDestination, ///< Character index of selected text in destination text control
m_selComposedHex; ///< Character index of selected text in composed HEX dump text control m_selDestinationHex; ///< Character index of selected text in destination HEX dump text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window wxZRColaKeyHandler m_keyhandler; ///< Key handler for source window
ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump ZRCola::mapping_vector m_mappingSourceHex; ///< Character index mapping vector between source text and its HEX dump
ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed 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_MENU (wxID_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter )
EVT_UPDATE_UI_RANGE(wxID_SEND_COMPOSED , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate ) EVT_UPDATE_UI_RANGE(wxID_SEND_DESTINATION , wxID_SEND_ABORT, wxZRColaFrame::OnSendUpdate )
EVT_MENU (wxID_COPY_COMPOSED_AND_RETURN , wxZRColaFrame::OnCopyComposedAndReturn ) EVT_MENU (wxID_COPY_DESTINATION_AND_RETURN , wxZRColaFrame::OnCopyDestinationAndReturn )
EVT_MENU (wxID_SEND_COMPOSED , wxZRColaFrame::OnSendComposed ) EVT_MENU (wxID_SEND_DESTINATION , wxZRColaFrame::OnSendDestination )
EVT_MENU (wxID_COPY_DECOMPOSED_AND_RETURN , wxZRColaFrame::OnCopyDecomposedAndReturn ) EVT_MENU (wxID_COPY_SOURCE_AND_RETURN , wxZRColaFrame::OnCopySourceAndReturn )
EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed ) EVT_MENU (wxID_SEND_SOURCE , wxZRColaFrame::OnSendSource )
EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort ) EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort )
EVT_MENU (wxID_SETTINGS , wxZRColaFrame::OnSettings ) EVT_MENU (wxID_SETTINGS , wxZRColaFrame::OnSettings )
EVT_UPDATE_UI (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEditUpdate ) EVT_UPDATE_UI (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEditUpdate )
EVT_MENU (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEdit ) EVT_MENU (wxID_TOOLBAR_EDIT , wxZRColaFrame::OnToolbarEdit )
EVT_UPDATE_UI (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarComposeUpdate ) EVT_UPDATE_UI (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslateUpdate )
EVT_MENU (wxID_TOOLBAR_COMPOSE , wxZRColaFrame::OnToolbarCompose ) EVT_MENU (wxID_TOOLBAR_TRANSLATE , wxZRColaFrame::OnToolbarTranslate )
EVT_UPDATE_UI (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalogUpdate) EVT_UPDATE_UI (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalogUpdate)
EVT_MENU (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalog ) EVT_MENU (wxID_PANEL_CHRGRPS , wxZRColaFrame::OnPanelCharacterCatalog )
EVT_MENU (wxID_FOCUS_CHARACTER_CATALOG , wxZRColaFrame::OnPanelCharacterCatalogFocus ) 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. // 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.LeftDockable(false);
paneInfo.RightDockable(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. // Load main window icons.
@ -106,7 +106,7 @@ wxZRColaFrame::wxZRColaFrame() :
wxPersistentRegisterAndRestore<wxZRColaCharRequest>(m_chrReq); wxPersistentRegisterAndRestore<wxZRColaCharRequest>(m_chrReq);
// Set focus. // Set focus.
m_panel->m_decomposed->SetFocus(); m_panel->m_source->SetFocus();
#if defined(__WXMSW__) #if defined(__WXMSW__)
// Register notification sink for language detection. // Register notification sink for language detection.
@ -139,9 +139,9 @@ wxZRColaFrame::wxZRColaFrame() :
wxPersistentAuiManager(&m_mgr).Restore(); wxPersistentAuiManager(&m_mgr).Restore();
// Register global hotkey(s). // 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); 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); 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() wxZRColaFrame::~wxZRColaFrame()
{ {
// Unregister global hotkey(s). // Unregister global hotkey(s).
UnregisterHotKey(wxZRColaHKID_INVOKE_DECOMPOSE); UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE_INV);
UnregisterHotKey(wxZRColaHKID_INVOKE_COMPOSE); UnregisterHotKey(wxZRColaHKID_INVOKE_TRANSLATE );
#if defined(__WXMSW__) #if defined(__WXMSW__)
if (m_tfSource) { if (m_tfSource) {
@ -214,8 +214,8 @@ void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event)
void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event) void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event)
{ {
if (m_chrSelect->ShowModal() == wxID_OK && !m_chrSelect->m_char.empty()) { if (m_chrSelect->ShowModal() == wxID_OK && !m_chrSelect->m_char.empty()) {
m_panel->m_decomposed->WriteText(m_chrSelect->m_char); m_panel->m_source->WriteText(m_chrSelect->m_char);
m_panel->m_decomposed->SetFocus(); 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) if (m_hWndSource)
DoSend(m_panel->m_composed->GetValue()); DoSend(m_panel->m_destination->GetValue());
event.Skip(); event.Skip();
} }
void wxZRColaFrame::OnCopyComposedAndReturn(wxCommandEvent& event) void wxZRColaFrame::OnCopyDestinationAndReturn(wxCommandEvent& event)
{ {
if (m_hWndSource) if (m_hWndSource)
DoCopyAndReturn(m_panel->m_composed->GetValue()); DoCopyAndReturn(m_panel->m_destination->GetValue());
event.Skip(); event.Skip();
} }
void wxZRColaFrame::OnSendDecomposed(wxCommandEvent& event) void wxZRColaFrame::OnSendSource(wxCommandEvent& event)
{ {
if (m_hWndSource) if (m_hWndSource)
DoSend(m_panel->m_decomposed->GetValue()); DoSend(m_panel->m_source->GetValue());
event.Skip(); event.Skip();
} }
void wxZRColaFrame::OnCopyDecomposedAndReturn(wxCommandEvent& event) void wxZRColaFrame::OnCopySourceAndReturn(wxCommandEvent& event)
{ {
if (m_hWndSource) if (m_hWndSource)
DoCopyAndReturn(m_panel->m_decomposed->GetValue()); DoCopyAndReturn(m_panel->m_source->GetValue());
event.Skip(); event.Skip();
} }
@ -272,8 +272,8 @@ void wxZRColaFrame::OnSendAbort(wxCommandEvent& event)
} }
// Select all input in composer to prepare for the overwrite next time. // Select all input in composer to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll(); m_panel->m_source ->SelectAll();
m_panel->m_composed->SelectAll(); m_panel->m_destination->SelectAll();
event.Skip(); 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()); paneInfo.Show(!paneInfo.IsShown());
m_mgr.Update(); m_mgr.Update();
} }
@ -503,9 +503,9 @@ void wxZRColaFrame::DoSend(const wxString& str)
::SendInput(input.size(), input.data(), sizeof(INPUT)); ::SendInput(input.size(), input.data(), sizeof(INPUT));
m_hWndSource = NULL; m_hWndSource = NULL;
// Select all input in composer and decomposed to prepare for the overwrite next time. // Select all input in source and destination to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll(); m_panel->m_source ->SelectAll();
m_panel->m_composed->SelectAll(); m_panel->m_destination->SelectAll();
} }
@ -521,9 +521,9 @@ void wxZRColaFrame::DoCopyAndReturn(const wxString& str)
::SetForegroundWindow(m_hWndSource); ::SetForegroundWindow(m_hWndSource);
m_hWndSource = NULL; m_hWndSource = NULL;
// Select all input in composer and decomposed to prepare for the overwrite next time. // Select all input in composer and source to prepare for the overwrite next time.
m_panel->m_decomposed->SelectAll(); m_panel->m_source ->SelectAll();
m_panel->m_composed->SelectAll(); m_panel->m_destination->SelectAll();
} }
@ -536,8 +536,8 @@ WXLRESULT wxZRColaFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM
WXHWND hWndSource = ::GetForegroundWindow(); WXHWND hWndSource = ::GetForegroundWindow();
switch (wParam) { switch (wParam) {
case wxZRColaHKID_INVOKE_COMPOSE : m_panel->m_decomposed->SetFocus(); break; case wxZRColaHKID_INVOKE_TRANSLATE : m_panel->m_source ->SetFocus(); break;
case wxZRColaHKID_INVOKE_DECOMPOSE: m_panel->m_composed ->SetFocus(); break; case wxZRColaHKID_INVOKE_TRANSLATE_INV: m_panel->m_destination->SetFocus(); break;
default: default:
wxFAIL_MSG(wxT("not our registered shortcut")); wxFAIL_MSG(wxT("not our registered shortcut"));
return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam); return wxZRColaFrameBase::MSWWindowProc(message, wParam, lParam);

View File

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

View File

@ -85,41 +85,41 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_menuEdit->AppendSeparator(); m_menuEdit->AppendSeparator();
wxMenuItem* m_menuItemSendComposed; wxMenuItem* m_menuItemSendDestination;
m_menuItemSendComposed = new wxMenuItem( m_menuEdit, wxID_SEND_COMPOSED, wxString( _("&Send Composed") ) + wxT('\t') + wxT("F5"), _("Send composed text to source window"), wxITEM_NORMAL ); 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__ #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__ )) #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 #endif
m_menuEdit->Append( m_menuItemSendComposed ); m_menuEdit->Append( m_menuItemSendDestination );
wxMenuItem* m_menuItemCopyComposedAndReturn; wxMenuItem* m_menuItemCopyDestinationAndReturn;
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 ); 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__ #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__ )) #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 #endif
m_menuEdit->Append( m_menuItemCopyComposedAndReturn ); m_menuEdit->Append( m_menuItemCopyDestinationAndReturn );
wxMenuItem* m_menuItemSendDecomposed; wxMenuItem* m_menuItemSendSource;
m_menuItemSendDecomposed = new wxMenuItem( m_menuEdit, wxID_SEND_DECOMPOSED, wxString( _("Send &Decomposed") ) + wxT('\t') + wxT("F6"), _("Send decomposed text to source window"), wxITEM_NORMAL ); 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__ #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__ )) #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 #endif
m_menuEdit->Append( m_menuItemSendDecomposed ); m_menuEdit->Append( m_menuItemSendSource );
wxMenuItem* m_menuItemCopyDecomposedAndReturn; wxMenuItem* m_menuItemCopySourceAndReturn;
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 ); 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__ #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__ )) #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 #endif
m_menuEdit->Append( m_menuItemCopyDecomposedAndReturn ); m_menuEdit->Append( m_menuItemCopySourceAndReturn );
wxMenuItem* m_menuItemSendAbort; 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 ); 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 ); m_menuView->Append( m_menuItemToolbarEdit );
wxMenuItem* m_menuItemToolbarCompose; 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->Append( m_menuItemToolbarCompose );
m_menuView->AppendSeparator(); m_menuView->AppendSeparator();
@ -194,15 +194,15 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_toolbarEdit->Realize(); 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_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_toolbarTranslate = 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_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_toolbarTranslate->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_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 ); m_panelChrCat = new wxZRColaCharacterCatalogPanel( this );
@ -239,99 +239,99 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
wxBoxSizer* bSizerMain; wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL ); bSizerMain = new wxBoxSizer( wxVERTICAL );
m_splitterDecomposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); m_splitterSource = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterDecomposed->SetSashGravity( 1 ); m_splitterSource->SetSashGravity( 1 );
m_splitterDecomposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); m_splitterSource->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this );
m_splitterDecomposed->SetMinimumPaneSize( 5 ); m_splitterSource->SetMinimumPaneSize( 5 );
m_panelDecomposedEdit = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelSourceEdit = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedEdit; wxBoxSizer* bSizerSourceEdit;
bSizerDecomposedEdit = new wxBoxSizer( wxVERTICAL ); bSizerSourceEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedEdit2; wxStaticBoxSizer* bSizerSourceEdit2;
bSizerDecomposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedEdit, wxID_ANY, _("Decomposed Text") ), wxVERTICAL ); 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_source = new wxTextCtrl( bSizerSourceEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_decomposed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); m_source->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_decomposed->SetMinSize( wxSize( 100,25 ) ); 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_panelSourceEdit->SetSizer( bSizerSourceEdit );
m_panelDecomposedEdit->Layout(); m_panelSourceEdit->Layout();
bSizerDecomposedEdit->Fit( m_panelDecomposedEdit ); bSizerSourceEdit->Fit( m_panelSourceEdit );
m_panelDecomposedHex = new wxPanel( m_splitterDecomposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelSourceHex = new wxPanel( m_splitterSource, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerDecomposedHex; wxBoxSizer* bSizerSourceHex;
bSizerDecomposedHex = new wxBoxSizer( wxVERTICAL ); bSizerSourceHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerDecomposedHex2; wxStaticBoxSizer* bSizerSourceHex2;
bSizerDecomposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelDecomposedHex, wxID_ANY, _("Decomposed Unicode Dump") ), wxVERTICAL ); 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_sourceHex = new wxTextCtrl( bSizerSourceHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_decomposedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); 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_panelSourceHex->SetSizer( bSizerSourceHex );
m_panelDecomposedHex->Layout(); m_panelSourceHex->Layout();
bSizerDecomposedHex->Fit( m_panelDecomposedHex ); bSizerSourceHex->Fit( m_panelSourceHex );
m_splitterDecomposed->SplitVertically( m_panelDecomposedEdit, m_panelDecomposedHex, -5 ); m_splitterSource->SplitVertically( m_panelSourceEdit, m_panelSourceHex, -5 );
bSizerMain->Add( m_splitterDecomposed, 50, wxALL|wxEXPAND, 5 ); bSizerMain->Add( m_splitterSource, 50, wxALL|wxEXPAND, 5 );
m_splitterComposed = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE ); m_splitterDestination = new wxSplitterWindow( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE );
m_splitterComposed->SetSashGravity( 1 ); m_splitterDestination->SetSashGravity( 1 );
m_splitterComposed->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); m_splitterDestination->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDestinationOnIdle ), NULL, this );
m_splitterComposed->SetMinimumPaneSize( 5 ); m_splitterDestination->SetMinimumPaneSize( 5 );
m_panelComposedEdit = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelDestinationEdit = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedEdit; wxBoxSizer* bSizerDestinationEdit;
bSizerComposedEdit = new wxBoxSizer( wxVERTICAL ); bSizerDestinationEdit = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedEdit2; wxStaticBoxSizer* bSizerDestinationEdit2;
bSizerComposedEdit2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedEdit, wxID_ANY, _("Composed Text") ), wxVERTICAL ); 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_destination = new wxTextCtrl( bSizerDestinationEdit2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE );
m_composed->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) ); m_destination->SetFont( wxFont( 20, 70, 90, 90, false, wxT("ZRCola") ) );
m_composed->SetMinSize( wxSize( 100,25 ) ); 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_panelDestinationEdit->SetSizer( bSizerDestinationEdit );
m_panelComposedEdit->Layout(); m_panelDestinationEdit->Layout();
bSizerComposedEdit->Fit( m_panelComposedEdit ); bSizerDestinationEdit->Fit( m_panelDestinationEdit );
m_panelComposedHex = new wxPanel( m_splitterComposed, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panelDestinationHex = new wxPanel( m_splitterDestination, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizerComposedHex; wxBoxSizer* bSizerDestinationHex;
bSizerComposedHex = new wxBoxSizer( wxVERTICAL ); bSizerDestinationHex = new wxBoxSizer( wxVERTICAL );
wxStaticBoxSizer* bSizerComposedHex2; wxStaticBoxSizer* bSizerDestinationHex2;
bSizerComposedHex2 = new wxStaticBoxSizer( new wxStaticBox( m_panelComposedHex, wxID_ANY, _("Composed Unicode Dump") ), wxVERTICAL ); 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_destinationHex = new wxTextCtrl( bSizerDestinationHex2->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_composedHex->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 76, 90, 90, false, wxEmptyString ) ); 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_panelDestinationHex->SetSizer( bSizerDestinationHex );
m_panelComposedHex->Layout(); m_panelDestinationHex->Layout();
bSizerComposedHex->Fit( m_panelComposedHex ); bSizerDestinationHex->Fit( m_panelDestinationHex );
m_splitterComposed->SplitVertically( m_panelComposedEdit, m_panelComposedHex, -5 ); m_splitterDestination->SplitVertically( m_panelDestinationEdit, m_panelDestinationHex, -5 );
bSizerMain->Add( m_splitterComposed, 50, wxALL|wxEXPAND, 5 ); bSizerMain->Add( m_splitterDestination, 50, wxALL|wxEXPAND, 5 );
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );
@ -340,24 +340,24 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
m_timerSave.SetOwner( this, wxID_TIMER_SAVE ); m_timerSave.SetOwner( this, wxID_TIMER_SAVE );
// Connect Events // Connect Events
m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); m_source->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this );
m_decomposed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); m_source->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this );
m_decomposedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); m_sourceHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this );
m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_destination->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this );
m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); m_destination->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this );
m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); m_destinationHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this );
this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) ); this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
} }
wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
{ {
// Disconnect Events // Disconnect Events
m_decomposed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); m_source->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourcePaint ), NULL, this );
m_decomposed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDecomposedText ), NULL, this ); m_source->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnSourceText ), NULL, this );
m_decomposedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedHexPaint ), NULL, this ); m_sourceHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnSourceHexPaint ), NULL, this );
m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_destination->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationPaint ), NULL, this );
m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); m_destination->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnDestinationText ), NULL, this );
m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); m_destinationHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDestinationHexPaint ), NULL, this );
this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) ); this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
} }

View File

@ -63,14 +63,14 @@ class wxZRColaFrameBase : public wxFrame
enum enum
{ {
wxID_CHARACTER_SELECTOR = 1000, wxID_CHARACTER_SELECTOR = 1000,
wxID_SEND_COMPOSED, wxID_SEND_DESTINATION,
wxID_COPY_COMPOSED_AND_RETURN, wxID_COPY_DESTINATION_AND_RETURN,
wxID_SEND_DECOMPOSED, wxID_SEND_SOURCE,
wxID_COPY_DECOMPOSED_AND_RETURN, wxID_COPY_SOURCE_AND_RETURN,
wxID_SEND_ABORT, wxID_SEND_ABORT,
wxID_SETTINGS, wxID_SETTINGS,
wxID_TOOLBAR_EDIT, wxID_TOOLBAR_EDIT,
wxID_TOOLBAR_COMPOSE, wxID_TOOLBAR_TRANSLATE,
wxID_PANEL_CHRGRPS, wxID_PANEL_CHRGRPS,
wxID_HELP_INSTRUCTIONS, wxID_HELP_INSTRUCTIONS,
wxID_HELP_SHORTCUTS, wxID_HELP_SHORTCUTS,
@ -87,10 +87,10 @@ class wxZRColaFrameBase : public wxFrame
wxAuiToolBarItem* m_toolEditCut; wxAuiToolBarItem* m_toolEditCut;
wxAuiToolBarItem* m_toolEditCopy; wxAuiToolBarItem* m_toolEditCopy;
wxAuiToolBarItem* m_toolEditPaste; wxAuiToolBarItem* m_toolEditPaste;
wxAuiToolBar* m_toolbarCompose; wxAuiToolBar* m_toolbarTranslate;
wxAuiToolBarItem* m_toolCharSelect; wxAuiToolBarItem* m_toolCharSelect;
wxAuiToolBarItem* m_toolSendComposed; wxAuiToolBarItem* m_toolSendDestination;
wxAuiToolBarItem* m_toolSendDecomposed; wxAuiToolBarItem* m_toolSendSource;
wxZRColaCharacterCatalogPanel* m_panelChrCat; wxZRColaCharacterCatalogPanel* m_panelChrCat;
wxStatusBar* m_statusBar; wxStatusBar* m_statusBar;
@ -123,43 +123,43 @@ class wxZRColaComposerPanelBase : public wxPanel
wxID_TIMER_SAVE = 1000 wxID_TIMER_SAVE = 1000
}; };
wxSplitterWindow* m_splitterDecomposed; wxSplitterWindow* m_splitterSource;
wxPanel* m_panelDecomposedEdit; wxPanel* m_panelSourceEdit;
wxPanel* m_panelDecomposedHex; wxPanel* m_panelSourceHex;
wxTextCtrl* m_decomposedHex; wxTextCtrl* m_sourceHex;
wxSplitterWindow* m_splitterComposed; wxSplitterWindow* m_splitterDestination;
wxPanel* m_panelComposedEdit; wxPanel* m_panelDestinationEdit;
wxPanel* m_panelComposedHex; wxPanel* m_panelDestinationHex;
wxTextCtrl* m_composedHex; wxTextCtrl* m_destinationHex;
wxTimer m_timerSave; wxTimer m_timerSave;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnSourcePaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnDecomposedText( wxCommandEvent& event ) { event.Skip(); } virtual void OnSourceText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnDecomposedHexPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnSourceHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnDestinationPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); } virtual void OnDestinationText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnDestinationHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); } virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); }
public: public:
wxTextCtrl* m_decomposed; wxTextCtrl* m_source;
wxTextCtrl* m_composed; 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( 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(); ~wxZRColaComposerPanelBase();
void m_splitterDecomposedOnIdle( wxIdleEvent& ) void m_splitterSourceOnIdle( wxIdleEvent& )
{ {
m_splitterDecomposed->SetSashPosition( -5 ); m_splitterSource->SetSashPosition( -5 );
m_splitterDecomposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterDecomposedOnIdle ), NULL, this ); m_splitterSource->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterSourceOnIdle ), NULL, this );
} }
void m_splitterComposedOnIdle( wxIdleEvent& ) void m_splitterDestinationOnIdle( wxIdleEvent& )
{ {
m_splitterComposed->SetSashPosition( -5 ); m_splitterDestination->SetSashPosition( -5 );
m_splitterComposed->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaComposerPanelBase::m_splitterComposedOnIdle ), NULL, this ); 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) { if (m_lang != lang.id) {
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); 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); virtual void OnOKButtonClick(wxCommandEvent& event);
public: public:
bool m_lang_auto; ///< Is language for decomposing resolved using currently selected keyboard bool m_lang_auto; ///< Is language for inverse translation resolved using currently selected keyboard
ZRCola::langid_t m_lang; ///< Language for decomposing 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; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"komb"), &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; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_komb"), &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; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"rang_znak"), &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; com_obj<ADOField> f;
wxVERIFY(SUCCEEDED(flds->get_Item(variant(L"znak"), &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; return true;

View File

@ -66,8 +66,8 @@ namespace ZRCola {
/// ///
class translation { class translation {
public: public:
charseq dec; ///< Decomposed sequence charseq src; ///< Source sequence
charseq com; ///< Composed character 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; 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; 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; set<wstring> res;
if (*str) { if (*str) {
// Decompose remainder first. // Inverse translate remainder first.
auto rem = decompose(db, str + 1, path); auto rem = translate_inv(db, str + 1, path);
if (rem.empty()) if (rem.empty())
return res; return res;
translation_db::key_type _str(1, *str); translation_db::key_type _str(1, *str);
auto const t = db.find(_str); auto const t = db.find(_str);
if (t != db.end()) { 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); auto p = path.insert(_str);
if (!p.second) { if (!p.second) {
// Path already contains this character: Cycle detected! // Path already contains this character: Cycle detected!
return res; return res;
} }
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) { 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); auto src = translate_inv(db, d->second.str.c_str(), path);
if (!dec.empty()) { if (!src.empty()) {
for (auto dd = dec.cbegin(), dd_end = dec.cend(); dd != dd_end; ++dd) { 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) for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(*dd + *r); res.insert(*dd + *r);
} }
} else { } 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) for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(_str + *r); res.insert(_str + *r);
} }
} }
path.erase(p.first); path.erase(p.first);
} else { } 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) for (auto r = rem.cbegin(), r_end = rem.cend(); r != r_end; ++r)
res.insert(_str + *r); res.insert(_str + *r);
} }
} else { } else {
// Empty string results in empty decomposition. // Empty string results in empty inverse translation.
res.insert(L""); res.insert(L"");
} }
@ -187,25 +187,25 @@ int _tmain(int argc, _TCHAR *argv[])
ZRCola::DBSource::translation trans; ZRCola::DBSource::translation trans;
if (src.GetTranslation(rs, trans)) { if (src.GetTranslation(rs, trans)) {
// Add translation to temporary database. // 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()) 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 { else {
translation_db::mapped_type d; translation_db::mapped_type d;
d.insert(com_translation(trans.com.rank, std::move(trans.dec))); 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.com.str, std::move(d)))); db_temp1.insert(std::move(pair<translation_db::key_type, translation_db::mapped_type>(trans.dst.str, std::move(d))));
} }
} else } else
has_errors = true; has_errors = true;
} }
// Decompose decompositions down to non-decomposable characters. // Inverse translate source sequences down to non-inverse translatable characters.
translation_db db_temp2; translation_db db_temp2;
for (auto t1 = db_temp1.cbegin(), t1_end = db_temp1.cend(); t1 != t1_end; ++t1) { 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) { for (auto d1 = t1->second.cbegin(), d1_end = t1->second.cend(); d1 != d1_end; ++d1) {
set<translation_db::key_type> path; set<translation_db::key_type> path;
path.insert(t1->first); 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()); assert(!str.empty());
// Add translation to temporary database. // Add translation to temporary database.
@ -225,8 +225,8 @@ int _tmain(int argc, _TCHAR *argv[])
ZRCola::translation_db db; ZRCola::translation_db db;
// Preallocate memory. // Preallocate memory.
db.idxComp .reserve(count); db.idxTrans .reserve(count);
db.idxDecomp.reserve(count); db.idxTransInv.reserve(count);
db.data .reserve(count*5); db.data .reserve(count*5);
// Parse translations and build index and data. // Parse translations and build index and data.
@ -234,26 +234,26 @@ int _tmain(int argc, _TCHAR *argv[])
// Add translation to index and data. // Add translation to index and data.
for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) { for (auto d = t->second.cbegin(), d_end = t->second.cend(); d != d_end; ++d) {
unsigned __int32 idx = db.data.size(); 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); 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); db.data.push_back((unsigned __int16)d->second.rank);
wstring::size_type n = t->first.length(); 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); db.data.push_back((unsigned __int16)n);
n += d->second.str.length(); 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.push_back((unsigned __int16)n);
db.data.insert(db.data.end(), t->first .cbegin(), t->first .cend()); 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.data.insert(db.data.end(), d->second.str.cbegin(), d->second.str.cend());
db.idxComp .push_back(idx); db.idxTrans .push_back(idx);
db.idxDecomp.push_back(idx); db.idxTransInv.push_back(idx);
} }
} }
// Sort indices. // Sort indices.
db.idxComp .sort(); db.idxTrans .sort();
db.idxDecomp.sort(); db.idxTransInv.sort();
// Write translations to file. // Write translations to file.
dst << ZRCola::translation_rec(db); 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> { class ZRCOLA_API mapping_vector : public std::vector<mapping> {
public: public:

View File

@ -24,7 +24,7 @@
namespace ZRCola { namespace ZRCola {
/// ///
/// Normalizes a decomposed string /// Normalizes a source string
/// ///
/// \param[in] input Input string (UTF-16) /// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[in] 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 { struct translation {
public: public:
unsigned __int16 com_rank; ///< Composed character rank unsigned __int16 dst_rank; ///< Destination character rank
unsigned __int16 dec_rank; ///< Decomposed character rank unsigned __int16 src_rank; ///< Source character rank
protected: protected:
unsigned __int16 com_to; ///< Composed character end in \c data unsigned __int16 dst_to; ///< Destination character end in \c data
unsigned __int16 dec_to; ///< Decomposed string end in \c data unsigned __int16 src_to; ///< Source string end in \c data
wchar_t data[]; ///< Decomposed string and composed character wchar_t data[]; ///< Destination string and source character
private: private:
inline translation(_In_ const translation &other); inline translation(_In_ const translation &other);
@ -63,58 +63,58 @@ namespace ZRCola {
/// ///
/// Constructs the translation /// Constructs the translation
/// ///
/// \param[in] com_rank Composed character rank /// \param[in] dst_rank Destination character rank
/// \param[in] com Composed character /// \param[in] dst Destination character
/// \param[in] com_len Number of UTF-16 characters in \p com /// \param[in] dst_len Number of UTF-16 characters in \p dst
/// \param[in] dec_rank Decomposed character rank /// \param[in] src_rank Source character rank
/// \param[in] dec Decomposed character /// \param[in] src Source character
/// \param[in] dec_len Number of UTF-16 characters in \p dec /// \param[in] src_len Number of UTF-16 characters in \p src
/// ///
inline translation( inline translation(
_In_opt_ unsigned __int16 com_rank = 0, _In_opt_ unsigned __int16 dst_rank = 0,
_In_opt_z_count_(com_len) const wchar_t *com = NULL, _In_opt_z_count_(dst_len) const wchar_t *dst = NULL,
_In_opt_ size_t com_len = 0, _In_opt_ size_t dst_len = 0,
_In_opt_ unsigned __int16 dec_rank = 0, _In_opt_ unsigned __int16 src_rank = 0,
_In_opt_z_count_(dec_len) const wchar_t *dec = NULL, _In_opt_z_count_(src_len) const wchar_t *src = NULL,
_In_opt_ size_t dec_len = 0) _In_opt_ size_t src_len = 0)
{ {
this->com_rank = com_rank; this->dst_rank = dst_rank;
this->dec_rank = dec_rank; this->src_rank = src_rank;
this->com_to = static_cast<unsigned __int16>(com_len); this->dst_to = static_cast<unsigned __int16>(dst_len);
if (com_len) memcpy(this->data, com, sizeof(wchar_t)*com_len); if (dst_len) memcpy(this->data, dst, sizeof(wchar_t)*dst_len);
this->dec_to = static_cast<unsigned __int16>(this->com_to + dec_len); this->src_to = static_cast<unsigned __int16>(this->dst_to + src_len);
if (dec_len) memcpy(this->data + this->com_to, dec, sizeof(wchar_t)*dec_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 const wchar_t* dst () const { return data; };
inline wchar_t* com () { return data; }; inline wchar_t* dst () { return data; };
inline const wchar_t* com_end() const { return data + com_to; }; inline const wchar_t* dst_end() const { return data + dst_to; };
inline wchar_t* com_end() { return data + com_to; }; inline wchar_t* dst_end() { return data + dst_to; };
inline unsigned __int16 com_len() const { return com_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 const wchar_t* src () const { return data + dst_to; };
inline wchar_t* dec () { return data + com_to; }; inline wchar_t* src () { return data + dst_to; };
inline const wchar_t* dec_end() const { return data + dec_to; }; inline const wchar_t* src_end() const { return data + src_to; };
inline wchar_t* dec_end() { return data + dec_to; }; inline wchar_t* src_end() { return data + src_to; };
inline unsigned __int16 dec_len() const { return dec_to - com_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 size_t ii = i + dst_to; // absolute index
return ii < dec_to ? data[ii] : 0; return ii < src_to ? data[ii] : 0;
} }
}; };
#pragma pack(pop) #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: public:
/// ///
@ -122,7 +122,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \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) /// 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 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; if (r != 0) return r;
return 0; return 0;
@ -156,24 +156,24 @@ namespace ZRCola {
/// ///
virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const 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 (r != 0) return r;
if (a.dec_rank < b.dec_rank) return -1; if (a.src_rank < b.src_rank) return -1;
else if (a.dec_rank > b.dec_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; if (r != 0) return r;
return 0; 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: public:
/// ///
@ -181,7 +181,7 @@ namespace ZRCola {
/// ///
/// \param[in] h Reference to vector holding the data /// \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) /// 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 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; if (r != 0) return r;
return 0; return 0;
@ -215,18 +215,18 @@ namespace ZRCola {
/// ///
virtual int compare_sort(_In_ const translation &a, _In_ const translation &b) const 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 (r != 0) return r;
if (a.com_rank < b.com_rank) return -1; if (a.dst_rank < b.dst_rank) return -1;
else if (a.com_rank > b.com_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; if (r != 0) return r;
return 0; return 0;
} }
} idxDecomp; ///< Decomposition index } idxTransInv; ///< Inverse translation index
std::vector<unsigned __int16> data; ///< Transformation data std::vector<unsigned __int16> data; ///< Transformation data
@ -235,43 +235,43 @@ namespace ZRCola {
/// ///
/// Constructs the database /// Constructs the database
/// ///
inline translation_db() : idxComp(data), idxDecomp(data) {} inline translation_db() : idxTrans(data), idxTransInv(data) {}
/// ///
/// Clears the database /// Clears the database
/// ///
inline void clear() inline void clear()
{ {
idxComp .clear(); idxTrans .clear();
idxDecomp.clear(); idxTransInv.clear();
data .clear(); data .clear();
} }
/// ///
/// Composes string /// Translates string
/// ///
/// \param[in] input Input string (UTF-16) /// \param[in] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[in] 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] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional) /// \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] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[in] 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] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional) /// \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] input Input string (UTF-16)
/// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. /// \param[in] 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] output Output string (UTF-16)
/// \param[out] map The vector of source to destination index mappings (optional) /// \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) 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; if (stream.fail()) return stream;
stream << db.idxComp; stream << db.idxTrans;
// Write decomposition index. // Write inverse translation index.
if (stream.fail()) return stream; if (stream.fail()) return stream;
stream << db.idxDecomp; stream << db.idxTransInv;
// Write data count. // Write data count.
auto data_count = db.data.size(); 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) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::translation_db &db)
{ {
// Read composition index. // Read translation index.
stream >> db.idxComp; stream >> db.idxTrans;
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read decomposition index. // Read inverse translation index.
stream >> db.idxDecomp; stream >> db.idxTransInv;
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.

View File

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