Character Select finished

(closes #11)
This commit is contained in:
Simon Rozman 2016-05-13 03:44:28 +02:00
parent 53ce3a2411
commit 9c3c1585d5
34 changed files with 3380 additions and 763 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"></property> <property name="bitmap">Load From Icon Resource; char_select.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">Display character selector to select character to insert into text</property> <property name="help">Display character selector to select character to insert into text</property>
<property name="id">wxID_INSERT_CHARACTER</property> <property name="id">wxID_CHARACTER_SELECTOR</property>
<property name="kind">wxITEM_NORMAL</property> <property name="kind">wxITEM_NORMAL</property>
<property name="label">&amp;Insert Character...</property> <property name="label">C&amp;haracter Selector...</property>
<property name="name">m_menuInsertCharacter</property> <property name="name">m_menuCharSelect</property>
<property name="permission">none</property> <property name="permission">none</property>
<property name="shortcut">F8</property> <property name="shortcut">F8</property>
<property name="unchecked_bitmap"></property> <property name="unchecked_bitmap"></property>
@ -637,6 +637,27 @@
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="tool" expanded="0">
<property name="bitmap">Load From Icon Resource; char_select.ico; [24; 24]</property>
<property name="context_menu">0</property>
<property name="id">wxID_CHARACTER_SELECTOR</property>
<property name="kind">wxITEM_NORMAL</property>
<property name="label">Character Selector</property>
<property name="name">m_toolCharSelect</property>
<property name="permission">protected</property>
<property name="statusbar">Display character selector to select character to insert into text</property>
<property name="tooltip">Character Selector</property>
<event name="OnAuiToolBarBeginDrag"></event>
<event name="OnAuiToolBarMiddleClick"></event>
<event name="OnAuiToolBarOverflowClick"></event>
<event name="OnAuiToolBarRightClick"></event>
<event name="OnAuiToolBarToolDropDown"></event>
<event name="OnMenuSelection"></event>
<event name="OnToolClicked"></event>
<event name="OnToolEnter"></event>
<event name="OnToolRClicked"></event>
<event name="OnUpdateUI"></event>
</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_composed.ico; [24; 24]</property>
<property name="context_menu">0</property> <property name="context_menu">0</property>
@ -1963,6 +1984,15 @@
</object> </object>
</object> </object>
</object> </object>
<object class="wxTimer" expanded="0">
<property name="enabled">0</property>
<property name="id">wxID_TIMER_SAVE</property>
<property name="name">m_timerSave</property>
<property name="oneshot">1</property>
<property name="period">1000</property>
<property name="permission">protected</property>
<event name="OnTimer">OnSaveTimer</event>
</object>
</object> </object>
<object class="Panel" expanded="0"> <object class="Panel" expanded="0">
<property name="aui_managed">0</property> <property name="aui_managed">0</property>
@ -2294,7 +2324,7 @@
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnHibernate"></event> <event name="OnHibernate"></event>
<event name="OnIconize"></event> <event name="OnIconize"></event>
<event name="OnIdle"></event> <event name="OnIdle">OnIdle</event>
<event name="OnInitDialog"></event> <event name="OnInitDialog"></event>
<event name="OnKeyDown"></event> <event name="OnKeyDown"></event>
<event name="OnKeyUp"></event> <event name="OnKeyUp"></event>
@ -2342,7 +2372,7 @@
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">1</property>
<object class="wxStaticBoxSizer" expanded="0"> <object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">&amp;Browse</property> <property name="label">&amp;Browse</property>
@ -2402,7 +2432,7 @@
<property name="search_button">1</property> <property name="search_button">1</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size"></property>
<property name="style"></property> <property name="style">wxTE_PROCESS_ENTER</property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
@ -2439,7 +2469,7 @@
<event name="OnSetFocus"></event> <event name="OnSetFocus"></event>
<event name="OnSize"></event> <event name="OnSize"></event>
<event name="OnText">OnSearchText</event> <event name="OnText">OnSearchText</event>
<event name="OnTextEnter"></event> <event name="OnTextEnter">OnSearchEnter</event>
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
</object> </object>
</object> </object>
@ -2478,7 +2508,7 @@
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size">-1,59</property> <property name="maximum_size">-1,-1</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -2492,7 +2522,7 @@
<property name="pos"></property> <property name="pos"></property>
<property name="resize">Resizable</property> <property name="resize">Resizable</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size">-1,60</property>
<property name="style"></property> <property name="style"></property>
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
@ -2507,7 +2537,7 @@
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnCheckListBox"></event> <event name="OnCheckListBox"></event>
<event name="OnCheckListBoxDClick"></event> <event name="OnCheckListBoxDClick"></event>
<event name="OnCheckListBoxToggled"></event> <event name="OnCheckListBoxToggled">OnCategoriesToggle</event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event> <event name="OnKeyDown"></event>
@ -2535,7 +2565,7 @@
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">1</property>
<object class="wxGrid" expanded="0"> <object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
@ -2562,8 +2592,8 @@
<property name="col_label_size">0</property> <property name="col_label_size">0</property>
<property name="col_label_values"></property> <property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property> <property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">16</property> <property name="cols">0</property>
<property name="column_sizes">35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35</property> <property name="column_sizes"></property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>
@ -2580,7 +2610,7 @@
<property name="floatable">1</property> <property name="floatable">1</property>
<property name="font">,90,90,-1,70,0</property> <property name="font">,90,90,-1,70,0</property>
<property name="grid_line_color"></property> <property name="grid_line_color"></property>
<property name="grid_lines">1</property> <property name="grid_lines">0</property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
@ -2591,10 +2621,10 @@
<property name="margin_width">0</property> <property name="margin_width">0</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size">560,-1</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size">560,35</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_gridResults</property> <property name="name">m_gridResults</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -2608,22 +2638,22 @@
<property name="row_label_size">0</property> <property name="row_label_size">0</property>
<property name="row_label_values"></property> <property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property> <property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes">35,35,35,35,35,35,35</property> <property name="row_sizes"></property>
<property name="rows">7</property> <property name="rows">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size">-1,-1</property>
<property name="subclass"></property> <property name="subclass">wxZRColaCharGrid; zrcolachrgrid.h</property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style">wxSTATIC_BORDER</property>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event> <event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick"></event> <event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event> <event name="OnGridCellLeftDClick">OnResultCellDClick</event>
<event name="OnGridCellRightClick"></event> <event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event> <event name="OnGridCellRightDClick"></event>
<event name="OnGridCmdCellChange"></event> <event name="OnGridCmdCellChange"></event>
@ -2653,7 +2683,7 @@
<event name="OnGridRangeSelect"></event> <event name="OnGridRangeSelect"></event>
<event name="OnGridRowSize"></event> <event name="OnGridRowSize"></event>
<event name="OnGridSelectCell">OnResultSelectCell</event> <event name="OnGridSelectCell">OnResultSelectCell</event>
<event name="OnKeyDown"></event> <event name="OnKeyDown">OnResultsKeyDown</event>
<event name="OnKeyUp"></event> <event name="OnKeyUp"></event>
<event name="OnKillFocus"></event> <event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event> <event name="OnLeaveWindow"></event>
@ -2691,7 +2721,7 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxGrid" expanded="0"> <object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -2719,8 +2749,8 @@
<property name="col_label_size">0</property> <property name="col_label_size">0</property>
<property name="col_label_values"></property> <property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property> <property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">16</property> <property name="cols">0</property>
<property name="column_sizes">35,35,35,35,35,35,35,35,35,35,35,35,35,35,35,35</property> <property name="column_sizes"></property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>
@ -2737,7 +2767,7 @@
<property name="floatable">1</property> <property name="floatable">1</property>
<property name="font">,90,90,-1,70,0</property> <property name="font">,90,90,-1,70,0</property>
<property name="grid_line_color"></property> <property name="grid_line_color"></property>
<property name="grid_lines">1</property> <property name="grid_lines">0</property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
@ -2748,10 +2778,10 @@
<property name="margin_width">0</property> <property name="margin_width">0</property>
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size">-1,-1</property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size">-1,-1</property>
<property name="moveable">1</property> <property name="moveable">1</property>
<property name="name">m_gridRecent</property> <property name="name">m_gridRecent</property>
<property name="pane_border">1</property> <property name="pane_border">1</property>
@ -2765,22 +2795,22 @@
<property name="row_label_size">0</property> <property name="row_label_size">0</property>
<property name="row_label_values"></property> <property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property> <property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes">35</property> <property name="row_sizes"></property>
<property name="rows">1</property> <property name="rows">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size">-1,35</property>
<property name="subclass"></property> <property name="subclass">wxZRColaCharGrid; zrcolachrgrid.h</property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style">wxSTATIC_BORDER</property>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event> <event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick"></event> <event name="OnGridCellLeftClick"></event>
<event name="OnGridCellLeftDClick"></event> <event name="OnGridCellLeftDClick">OnRecentCellDClick</event>
<event name="OnGridCellRightClick"></event> <event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event> <event name="OnGridCellRightDClick"></event>
<event name="OnGridCmdCellChange"></event> <event name="OnGridCmdCellChange"></event>
@ -2810,7 +2840,7 @@
<event name="OnGridRangeSelect"></event> <event name="OnGridRangeSelect"></event>
<event name="OnGridRowSize"></event> <event name="OnGridRowSize"></event>
<event name="OnGridSelectCell">OnRecentSelectCell</event> <event name="OnGridSelectCell">OnRecentSelectCell</event>
<event name="OnKeyDown"></event> <event name="OnKeyDown">OnRecentKeyDown</event>
<event name="OnKeyUp"></event> <event name="OnKeyUp"></event>
<event name="OnKillFocus"></event> <event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event> <event name="OnLeaveWindow"></event>
@ -2848,7 +2878,7 @@
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">70</property>
<object class="wxStaticBoxSizer" expanded="0"> <object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Preview</property> <property name="label">Preview</property>
@ -2984,7 +3014,7 @@
<property name="max_size"></property> <property name="max_size"></property>
<property name="maximize_button">0</property> <property name="maximize_button">0</property>
<property name="maximum_size"></property> <property name="maximum_size"></property>
<property name="maxlength">4</property> <property name="maxlength"></property>
<property name="min_size"></property> <property name="min_size"></property>
<property name="minimize_button">0</property> <property name="minimize_button">0</property>
<property name="minimum_size"></property> <property name="minimum_size"></property>
@ -3003,10 +3033,10 @@
<property name="subclass"></property> <property name="subclass"></property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="validator_data_type">wxString</property> <property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_INCLUDE_CHAR_LIST</property> <property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxTextValidator</property> <property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable">m_unicodeValid</property> <property name="validator_variable"></property>
<property name="value"></property> <property name="value"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
@ -3044,7 +3074,7 @@
</object> </object>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER|wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">0</property>
<object class="wxGrid" expanded="0"> <object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
@ -3058,11 +3088,11 @@
<property name="autosize_cols">0</property> <property name="autosize_cols">0</property>
<property name="autosize_rows">0</property> <property name="autosize_rows">0</property>
<property name="best_size"></property> <property name="best_size"></property>
<property name="bg"></property> <property name="bg">wxSYS_COLOUR_WINDOW</property>
<property name="caption"></property> <property name="caption"></property>
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="cell_bg"></property> <property name="cell_bg"></property>
<property name="cell_font">00 ZRCola,90,90,180,70,0</property> <property name="cell_font">00 ZRCola,90,90,120,70,0</property>
<property name="cell_horiz_alignment">wxALIGN_CENTRE</property> <property name="cell_horiz_alignment">wxALIGN_CENTRE</property>
<property name="cell_text"></property> <property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_CENTRE</property> <property name="cell_vert_alignment">wxALIGN_CENTRE</property>
@ -3073,7 +3103,7 @@
<property name="col_label_values"></property> <property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property> <property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">1</property> <property name="cols">1</property>
<property name="column_sizes">210</property> <property name="column_sizes">200</property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>
@ -3090,7 +3120,7 @@
<property name="floatable">1</property> <property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="grid_line_color"></property> <property name="grid_line_color"></property>
<property name="grid_lines">1</property> <property name="grid_lines">0</property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
@ -3127,7 +3157,7 @@
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style">wxSTATIC_BORDER</property>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
@ -3281,7 +3311,7 @@
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">1</property> <property name="proportion">30</property>
<object class="wxStaticBoxSizer" expanded="0"> <object class="wxStaticBoxSizer" expanded="0">
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
<property name="label">Re&amp;lated</property> <property name="label">Re&amp;lated</property>
@ -3292,8 +3322,8 @@
<event name="OnUpdateUI"></event> <event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="0"> <object class="sizeritem" expanded="0">
<property name="border">5</property> <property name="border">5</property>
<property name="flag">wxALIGN_CENTER|wxALL</property> <property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property> <property name="proportion">1</property>
<object class="wxGrid" expanded="0"> <object class="wxGrid" expanded="0">
<property name="BottomDockable">1</property> <property name="BottomDockable">1</property>
<property name="LeftDockable">1</property> <property name="LeftDockable">1</property>
@ -3311,17 +3341,17 @@
<property name="caption_visible">1</property> <property name="caption_visible">1</property>
<property name="cell_bg"></property> <property name="cell_bg"></property>
<property name="cell_font">00 ZRCola,90,90,20,70,0</property> <property name="cell_font">00 ZRCola,90,90,20,70,0</property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property> <property name="cell_horiz_alignment">wxALIGN_CENTRE</property>
<property name="cell_text"></property> <property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property> <property name="cell_vert_alignment">wxALIGN_CENTRE</property>
<property name="center_pane">0</property> <property name="center_pane">0</property>
<property name="close_button">1</property> <property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property> <property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="col_label_size">0</property> <property name="col_label_size">0</property>
<property name="col_label_values"></property> <property name="col_label_values"></property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property> <property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">6</property> <property name="cols">0</property>
<property name="column_sizes">35,35,35,35,35,35</property> <property name="column_sizes"></property>
<property name="context_help"></property> <property name="context_help"></property>
<property name="context_menu">1</property> <property name="context_menu">1</property>
<property name="default_pane">0</property> <property name="default_pane">0</property>
@ -3338,7 +3368,7 @@
<property name="floatable">1</property> <property name="floatable">1</property>
<property name="font"></property> <property name="font"></property>
<property name="grid_line_color"></property> <property name="grid_line_color"></property>
<property name="grid_lines">1</property> <property name="grid_lines">0</property>
<property name="gripper">0</property> <property name="gripper">0</property>
<property name="hidden">0</property> <property name="hidden">0</property>
<property name="id">wxID_ANY</property> <property name="id">wxID_ANY</property>
@ -3366,16 +3396,16 @@
<property name="row_label_size">0</property> <property name="row_label_size">0</property>
<property name="row_label_values"></property> <property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property> <property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes">35,35,35</property> <property name="row_sizes"></property>
<property name="rows">3</property> <property name="rows">0</property>
<property name="show">1</property> <property name="show">1</property>
<property name="size"></property> <property name="size">-1,-1</property>
<property name="subclass"></property> <property name="subclass">wxZRColaCharGrid; zrcolachrgrid.h</property>
<property name="toolbar_pane">0</property> <property name="toolbar_pane">0</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
<property name="window_name"></property> <property name="window_name"></property>
<property name="window_style"></property> <property name="window_style">wxSTATIC_BORDER</property>
<event name="OnChar"></event> <event name="OnChar"></event>
<event name="OnEnterWindow"></event> <event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event> <event name="OnEraseBackground"></event>
@ -3470,12 +3500,21 @@
<event name="OnContextHelpButtonClick"></event> <event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event> <event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event> <event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick"></event> <event name="OnOKButtonClick">OnOKButtonClick</event>
<event name="OnSaveButtonClick"></event> <event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event> <event name="OnYesButtonClick"></event>
</object> </object>
</object> </object>
</object> </object>
<object class="wxTimer" expanded="0">
<property name="enabled">0</property>
<property name="id">wxID_TIMER_SEARCH</property>
<property name="name">m_timerSearch</property>
<property name="oneshot">1</property>
<property name="period">1000</property>
<property name="permission">protected</property>
<event name="OnTimer">OnSearchTimer</event>
</object>
</object> </object>
</object> </object>
</wxFormBuilder_Project> </wxFormBuilder_Project>

Binary file not shown.

View File

@ -112,6 +112,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="res\char_select.ico" />
<None Include="res\edit_copy.ico" /> <None Include="res\edit_copy.ico" />
<None Include="res\edit_cut.ico" /> <None Include="res\edit_cut.ico" />
<None Include="res\edit_paste.ico" /> <None Include="res\edit_paste.ico" />

View File

@ -101,6 +101,9 @@
<None Include="ZRCola.fbp"> <None Include="ZRCola.fbp">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</None> </None>
<None Include="res\char_select.ico">
<Filter>Resource Files</Filter>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="ZRCola.rc"> <ResourceCompile Include="ZRCola.rc">

View File

@ -1,8 +1,8 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ZRCola\n" "Project-Id-Version: ZRCola\n"
"POT-Creation-Date: 2016-05-11 14:39+0200\n" "POT-Creation-Date: 2016-05-13 03:37+0200\n"
"PO-Revision-Date: 2016-05-11 14:39+0200\n" "PO-Revision-Date: 2016-05-13 03:37+0200\n"
"Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n" "Last-Translator: Simon Rozman <simon.rozman@amebis.si>\n"
"Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n" "Language-Team: Amebis, d. o. o., Kamnik <info@amebis.si>\n"
"Language: sl_SI\n" "Language: sl_SI\n"
@ -17,7 +17,7 @@ msgstr ""
"X-Poedit-KeywordsList: _\n" "X-Poedit-KeywordsList: _\n"
"X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPath-0: .\n"
#: zrcolafrm.cpp:93 zrcolagui.h:95 MSIBuild/En.Win32.Release.Feature-2.idtx:4 #: zrcolafrm.cpp:93 zrcolagui.h:96 MSIBuild/En.Win32.Release.Feature-2.idtx:4
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4 #: MSIBuild/En.Win32.Release.Shortcut-2.idtx:4
#: MSIBuild/En.x64.Release.Feature-2.idtx:4 #: MSIBuild/En.x64.Release.Feature-2.idtx:4
#: MSIBuild/En.x64.Release.Shortcut-2.idtx:4 #: MSIBuild/En.x64.Release.Shortcut-2.idtx:4
@ -53,7 +53,7 @@ msgstr ""
msgid "Start ZRCola automatically on logon" msgid "Start ZRCola automatically on logon"
msgstr "Samodejno zaženi ZRColo ob prijavi" msgstr "Samodejno zaženi ZRColo ob prijavi"
#: zrcolafrm.cpp:459 #: zrcolafrm.cpp:462
#, c-format #, c-format
msgid "" msgid ""
"ZRCola v%s\n" "ZRCola v%s\n"
@ -62,7 +62,7 @@ msgstr ""
"ZRCola v%s\n" "ZRCola v%s\n"
"Vse pravice pridržane 2015-%s Amebis" "Vse pravice pridržane 2015-%s Amebis"
#: zrcolafrm.cpp:459 #: zrcolafrm.cpp:462
msgid "About ZRCola" msgid "About ZRCola"
msgstr "O ZRColi" msgstr "O ZRColi"
@ -95,166 +95,170 @@ msgid "Select all text"
msgstr "Izberi celotno besedilo" msgstr "Izberi celotno besedilo"
#: zrcolagui.cpp:84 #: zrcolagui.cpp:84
msgid "&Insert Character..." msgid "C&haracter Selector..."
msgstr "Vstav&i znak ..." msgstr "Izbirnik &znaka ..."
#: zrcolagui.cpp:84 #: zrcolagui.cpp:84 zrcolagui.cpp:170
msgid "Display character selector to select character to insert into text" msgid "Display character selector to select character to insert into text"
msgstr "Prikaži izbirnik znaka za izbor znaka za vstavljanje v besedilo" msgstr "Prikaži izbirnik znaka za izbor znaka za vstavljanje v besedilo"
#: zrcolagui.cpp:90 #: zrcolagui.cpp:95
msgid "&Send Composed" msgid "&Send Composed"
msgstr "Pošlji &sestavljeno" msgstr "Pošlji &sestavljeno"
#: zrcolagui.cpp:90 zrcolagui.cpp:165 #: zrcolagui.cpp:95 zrcolagui.cpp:172
msgid "Send composed text to source window" msgid "Send composed text to source window"
msgstr "Pošlji sestavljeno besedilo izvornemu oknu" msgstr "Pošlji sestavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:99 #: zrcolagui.cpp:104
msgid "Send &Decomposed" msgid "Send &Decomposed"
msgstr "Pošlji &razstavljeno" msgstr "Pošlji &razstavljeno"
#: zrcolagui.cpp:99 zrcolagui.cpp:167 #: zrcolagui.cpp:104 zrcolagui.cpp:174
msgid "Send decomposed text to source window" msgid "Send decomposed text to source window"
msgstr "Pošlji razstavljeno besedilo izvornemu oknu" msgstr "Pošlji razstavljeno besedilo izvornemu oknu"
#: zrcolagui.cpp:108 #: zrcolagui.cpp:113
msgid "Abort (De)composition" msgid "Abort (De)composition"
msgstr "Prekini raz/sestavljanje" msgstr "Prekini raz/sestavljanje"
#: zrcolagui.cpp:108 #: zrcolagui.cpp:113
msgid "Abort composition and return focus to source window" msgid "Abort composition and return focus to source window"
msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu" msgstr "Prekini sestavljanje in vrni fokus nazaj izvornemu oknu"
#: zrcolagui.cpp:117 #: zrcolagui.cpp:122
msgid "&Language" msgid "&Language"
msgstr "&Jezik" msgstr "&Jezik"
#: zrcolagui.cpp:119 #: zrcolagui.cpp:124
msgid "&Automatic" msgid "&Automatic"
msgstr "S&amodejno" msgstr "S&amodejno"
#: zrcolagui.cpp:119 #: zrcolagui.cpp:124
msgid "Set language according to keyboard layout automatically" msgid "Set language according to keyboard layout automatically"
msgstr "Samodejno nastavi jezik glede na izbrano tipkovnico" msgstr "Samodejno nastavi jezik glede na izbrano tipkovnico"
#: zrcolagui.cpp:126 #: zrcolagui.cpp:131
msgid "&Edit" msgid "&Edit"
msgstr "Ur&edi" msgstr "Ur&edi"
#: zrcolagui.cpp:130 #: zrcolagui.cpp:135
msgid "&Edit Toolbar" msgid "&Edit Toolbar"
msgstr "Orodna vrstica za ur&ejanje" msgstr "Orodna vrstica za ur&ejanje"
#: zrcolagui.cpp:130 #: zrcolagui.cpp:135
msgid "Toggle edit toolbar" msgid "Toggle edit toolbar"
msgstr "Prikaži/skrij orodno vrstico za urejanje" msgstr "Prikaži/skrij orodno vrstico za urejanje"
#: zrcolagui.cpp:134 #: zrcolagui.cpp:139
msgid "&Compose Toolbar" msgid "&Compose Toolbar"
msgstr "Orodna vrsti&ca za sestavljanje" msgstr "Orodna vrsti&ca za sestavljanje"
#: zrcolagui.cpp:134 #: zrcolagui.cpp:139
msgid "Toggle compose toolbar" msgid "Toggle compose toolbar"
msgstr "Prikaži/skrij orodno vrstico za sestavljanje" msgstr "Prikaži/skrij orodno vrstico za sestavljanje"
#: zrcolagui.cpp:140 #: zrcolagui.cpp:145
msgid "Character Catalo&g" msgid "Character Catalo&g"
msgstr "Katalo&g znakov" msgstr "Katalo&g znakov"
#: zrcolagui.cpp:140 #: zrcolagui.cpp:145
msgid "Toggle character catalog panel" msgid "Toggle character catalog panel"
msgstr "Prikaži/skrij katalog znakov" msgstr "Prikaži/skrij katalog znakov"
#: zrcolagui.cpp:143 #: zrcolagui.cpp:148
msgid "&View" msgid "&View"
msgstr "Po&gled" msgstr "Po&gled"
#: zrcolagui.cpp:150 #: zrcolagui.cpp:155
msgid "&Help" msgid "&Help"
msgstr "Po&moč" msgstr "Po&moč"
#: zrcolagui.cpp:155 #: zrcolagui.cpp:160
msgid "Cut" msgid "Cut"
msgstr "Izreži" msgstr "Izreži"
#: zrcolagui.cpp:155 #: zrcolagui.cpp:160
msgid "Cut selection" msgid "Cut selection"
msgstr "Izreži izbor" msgstr "Izreži izbor"
#: zrcolagui.cpp:157 #: zrcolagui.cpp:162
msgid "Copy" msgid "Copy"
msgstr "Kopiraj" msgstr "Kopiraj"
#: zrcolagui.cpp:157 #: zrcolagui.cpp:162
msgid "Copy selection" msgid "Copy selection"
msgstr "Kopiraj izbor" msgstr "Kopiraj izbor"
#: zrcolagui.cpp:159 #: zrcolagui.cpp:164
msgid "Paste" msgid "Paste"
msgstr "Prilepi" msgstr "Prilepi"
#: zrcolagui.cpp:159 #: zrcolagui.cpp:164
msgid "Paste selection" msgid "Paste selection"
msgstr "Prilepi izbor" msgstr "Prilepi izbor"
#: zrcolagui.cpp:162 #: zrcolagui.cpp:167
msgid "Edit" msgid "Edit"
msgstr "Urejanje" msgstr "Urejanje"
#: zrcolagui.cpp:165 #: zrcolagui.cpp:170 zrcolagui.h:227
msgid "Character Selector"
msgstr "Izbirnik znaka"
#: zrcolagui.cpp:172
msgid "Send Composed" msgid "Send Composed"
msgstr "Pošlji sestavljeno" msgstr "Pošlji sestavljeno"
#: zrcolagui.cpp:167 #: zrcolagui.cpp:174
msgid "Send Decomposed" msgid "Send Decomposed"
msgstr "Pošlji razstavljeno" msgstr "Pošlji razstavljeno"
#: zrcolagui.cpp:176 #: zrcolagui.cpp:183
msgid "Compose" msgid "Compose"
msgstr "Sestavljanje" msgstr "Sestavljanje"
#: zrcolagui.cpp:180 #: zrcolagui.cpp:187
msgid "Character Catalog" msgid "Character Catalog"
msgstr "Katalog znakov" msgstr "Katalog znakov"
#: zrcolagui.cpp:184 #: zrcolagui.cpp:191
msgid "(De)Composer" msgid "(De)Composer"
msgstr "Raz/Sestavljalnik" msgstr "Raz/Sestavljalnik"
#: zrcolagui.cpp:223 #: zrcolagui.cpp:230
msgid "Decomposed Text" msgid "Decomposed Text"
msgstr "Razstavljeno besedilo" msgstr "Razstavljeno besedilo"
#: zrcolagui.cpp:243 #: zrcolagui.cpp:250
msgid "Decomposed Unicode Dump" msgid "Decomposed Unicode Dump"
msgstr "Unicode razstavljenega" msgstr "Unicode razstavljenega"
#: zrcolagui.cpp:270 #: zrcolagui.cpp:277
msgid "Composed Text" msgid "Composed Text"
msgstr "Sestavljeno besedilo" msgstr "Sestavljeno besedilo"
#: zrcolagui.cpp:290 #: zrcolagui.cpp:297
msgid "Composed Unicode Dump" msgid "Composed Unicode Dump"
msgstr "Unicode sestavljenega" msgstr "Unicode sestavljenega"
#: zrcolagui.cpp:407 #: zrcolagui.cpp:417
msgid "&Browse" msgid "&Browse"
msgstr "Pre&brskaj" msgstr "Pre&brskaj"
#: zrcolagui.cpp:478 #: zrcolagui.cpp:465
msgid "Re&cently Used" msgid "Re&cently Used"
msgstr "Nedavno &uporabljeni" msgstr "Nedavno &uporabljeni"
#: zrcolagui.cpp:536 #: zrcolagui.cpp:506
msgid "Preview" msgid "Preview"
msgstr "Predogled" msgstr "Predogled"
#: zrcolagui.cpp:541 #: zrcolagui.cpp:511
msgid "U+" msgid "U+"
msgstr "U+" msgstr "U+"
#: zrcolagui.cpp:590 #: zrcolagui.cpp:559
msgid "Re&lated" msgid "Re&lated"
msgstr "&Sorodni" msgstr "&Sorodni"
@ -266,10 +270,6 @@ msgstr ""
"Pritisnjena tipka INS. Zdaj vtpikajte kodo Unicode želenega znaka (do štiri " "Pritisnjena tipka INS. Zdaj vtpikajte kodo Unicode želenega znaka (do štiri "
"šestnajstiške števke: 0-9, A-F), nato izpustite INS." "šestnajstiške števke: 0-9, A-F), nato izpustite INS."
#: zrcolagui.h:205
msgid "Character Selector"
msgstr "Izbirnik znaka"
# Windows charset for this language (decimal) # Windows charset for this language (decimal)
#: MSIBuild/En.Win32.Release.Feature-2.idtx:3 #: MSIBuild/En.Win32.Release.Feature-2.idtx:3
#: MSIBuild/En.Win32.Release.Shortcut-2.idtx:3 #: MSIBuild/En.Win32.Release.Shortcut-2.idtx:3
@ -285,6 +285,9 @@ msgstr "1250"
msgid "Input system for linguistic use" msgid "Input system for linguistic use"
msgstr "Vnašalni sistem za jezikoslovno rabo" msgstr "Vnašalni sistem za jezikoslovno rabo"
#~ msgid "&Insert Character..."
#~ msgstr "Vstav&i znak ..."
#~ msgid "&Unicode" #~ msgid "&Unicode"
#~ msgstr "&Unicode" #~ msgstr "&Unicode"

BIN
ZRCola/res/char_select.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

1794
ZRCola/res/char_select.pdf Normal file

File diff suppressed because one or more lines are too long

View File

@ -29,6 +29,7 @@
#include <fstream> #include <fstream>
#include <string> #include <string>
#include <utility>
#include <vector> #include <vector>
#include <stdex/idrec.h> #include <stdex/idrec.h>

View File

@ -60,7 +60,7 @@ bool ZRColaApp::OnInit()
if (wxConfigBase::Get()->Read(wxT("LocalizationRepositoryPath"), &sPath)) if (wxConfigBase::Get()->Read(wxT("LocalizationRepositoryPath"), &sPath))
m_locale.AddCatalogLookupPathPrefix(sPath); m_locale.AddCatalogLookupPathPrefix(sPath);
wxVERIFY(m_locale.Init(language)); wxVERIFY(m_locale.Init(language));
wxVERIFY(m_locale.AddCatalog(wxT("wxExtend"))); wxVERIFY(m_locale.AddCatalog(wxT("wxExtend") wxT(wxExtendVersion)));
wxVERIFY(m_locale.AddCatalog(wxT("libZRColaUI"))); wxVERIFY(m_locale.AddCatalog(wxT("libZRColaUI")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola"))); wxVERIFY(m_locale.AddCatalog(wxT("ZRCola")));
wxVERIFY(m_locale.AddCatalog(wxT("ZRCola-zrcdb"))); wxVERIFY(m_locale.AddCatalog(wxT("ZRCola-zrcdb")));
@ -128,7 +128,8 @@ bool ZRColaApp::OnInit()
m_cc_db.idxRnk .clear(); m_cc_db.idxRnk .clear();
m_cc_db.data .clear(); m_cc_db.data .clear();
} }
} } else
stdex::idrec::ignore<ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>(dat);
} }
if (!has_translation_data) if (!has_translation_data)

View File

@ -112,7 +112,9 @@ void wxZRColaCharacterCatalogPanel::OnGridClick(wxGridEvent& event)
void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event) void wxZRColaCharacterCatalogPanel::OnGridKeyDown(wxKeyEvent& event)
{ {
if (event.GetKeyCode() == WXK_RETURN) { switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
ZRColaApp *app = (ZRColaApp*)wxTheApp; ZRColaApp *app = (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_decomposed->WriteText(m_grid->GetCellValue(m_grid->GetCursorRow(), m_grid->GetCursorColumn()));

View File

@ -44,7 +44,7 @@ wxZRColaCharGrid::wxZRColaCharGrid(wxWindow *parent, wxWindowID id, const wxPoin
SetDefaultRowSize(wxZRColaCharacterGridRowHeight); SetDefaultRowSize(wxZRColaCharacterGridRowHeight);
// Create timer for saving the state. // Create timer for saving the state.
m_toolTipTimer = new wxTimer(this, wxID_TOOLTIP_TIMER); m_timerToolTip.SetOwner(this, wxID_TOOLTIP_TIMER);
// wxEVT_MOTION event must be connected to the wxGridWindow, not wxGrid itself. // wxEVT_MOTION event must be connected to the wxGridWindow, not wxGrid itself.
wxWindow *gridWnd = GetGridWindow(); wxWindow *gridWnd = GetGridWindow();
@ -56,16 +56,12 @@ wxZRColaCharGrid::~wxZRColaCharGrid()
{ {
wxWindow *gridWnd = GetGridWindow(); wxWindow *gridWnd = GetGridWindow();
gridWnd->Disconnect(gridWnd->GetId(), wxEVT_MOTION, wxMouseEventHandler(wxZRColaCharGrid::OnMotion), NULL, this); gridWnd->Disconnect(gridWnd->GetId(), wxEVT_MOTION, wxMouseEventHandler(wxZRColaCharGrid::OnMotion), NULL, this);
if (m_toolTipTimer)
delete m_toolTipTimer;
} }
void wxZRColaCharGrid::Init() void wxZRColaCharGrid::Init()
{ {
m_isResizing = false; m_isResizing = false;
m_toolTipTimer = NULL;
m_toolTipIdx = (size_t)-1; m_toolTipIdx = (size_t)-1;
} }
@ -147,12 +143,15 @@ void wxZRColaCharGrid::OnSize(wxSizeEvent& event)
SetTable(table, true); SetTable(table, true);
} }
// Set column widths to stretch to full width. for (int c = 0; c < cols; c++)
for (int c = 0, x_l = 0; c < cols; c++) { SetColSize(c, wxZRColaCharacterGridColumnWidth);
int x_r = (c + 1)*width/cols;
SetColSize(c, x_r - x_l); //// Set column widths to stretch to full width.
x_l = x_r; //for (int c = 0, x_l = 0; c < cols; c++) {
} // int x_r = (c + 1)*width/cols;
// SetColSize(c, x_r - x_l);
// x_l = x_r;
//}
EndBatch(); EndBatch();
m_isResizing = false; m_isResizing = false;
@ -193,7 +192,7 @@ void wxZRColaCharGrid::OnMotion(wxMouseEvent& event)
if (toolTipIdx >= m_chars.Length()) { if (toolTipIdx >= m_chars.Length()) {
// Index out of range. // Index out of range.
m_toolTipIdx = (size_t)-1; m_toolTipIdx = (size_t)-1;
m_toolTipTimer->Stop(); m_timerToolTip.Stop();
return; return;
} else if (toolTipIdx != m_toolTipIdx) { } else if (toolTipIdx != m_toolTipIdx) {
// Cell changed. // Cell changed.
@ -204,7 +203,7 @@ void wxZRColaCharGrid::OnMotion(wxMouseEvent& event)
gridWnd->SetToolTip(GetToolTipText(m_toolTipIdx)); gridWnd->SetToolTip(GetToolTipText(m_toolTipIdx));
} else { } else {
// This must be our initial entry. Schedule tooltip display after 1s. // This must be our initial entry. Schedule tooltip display after 1s.
m_toolTipTimer->Start(1000, true); m_timerToolTip.Start(1000, true);
} }
} }
} }

View File

@ -58,6 +58,16 @@ public:
/// ///
void SetCharacters(const wxString &chars); void SetCharacters(const wxString &chars);
///
/// Returns displayed characters
///
/// \returns The string containing displayed characters
///
inline wxString GetCharacters() const
{
return m_chars;
}
protected: protected:
virtual wxString GetToolTipText(int idx); virtual wxString GetToolTipText(int idx);
@ -75,6 +85,6 @@ protected:
private: private:
bool m_isResizing; ///< Prevents nesting of OnSize() method. bool m_isResizing; ///< Prevents nesting of OnSize() method.
wxTimer *m_toolTipTimer;///< Timer for displaying tooltip wxTimer m_timerToolTip; ///< Timer for displaying tooltip
size_t m_toolTipIdx; ///< Index of cell for tooltip display size_t m_toolTipIdx; ///< Index of cell for tooltip display
}; };

View File

@ -20,21 +20,301 @@
#include "stdafx.h" #include "stdafx.h"
static int __cdecl compare_hits(const void *a, const void *b)
{
const std::pair<unsigned long, wchar_t> *_a = (const std::pair<unsigned long, wchar_t>*)a;
const std::pair<unsigned long, wchar_t> *_b = (const std::pair<unsigned long, wchar_t>*)b;
if (_a->first > _b->first) return -1;
else if (_a->first < _b->first) return 1;
if (_a->second < _b->second) return -1;
else if (_a->second > _b->second) return 1;
return 0;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// wxZRColaCharSelect // wxZRColaCharSelect
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) : wxZRColaCharSelectBase(parent) wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) :
m_searchChanged(false),
m_unicodeChanged(false),
m_char(0),
wxZRColaCharSelectBase(parent)
{ {
wxTextValidator *validator = dynamic_cast<wxTextValidator*>(m_unicode->GetValidator()); m_unicode->SetValidator(wxHexValidator<wchar_t>(&m_char));
if (validator)
validator->SetCharIncludes(wxT("0123456789ABCDEFabcdef"));
// Fill categories.
ZRColaApp *app = (ZRColaApp*)wxTheApp; ZRColaApp *app = (ZRColaApp*)wxTheApp;
for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) { size_t i, n;
for (i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i]; const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
m_categories->Check(m_categories->Insert(wxGetTranslation(wxString(cc.name, cc.name_len), wxT("ZRCola-zrcdb")), i)); int idx = m_categories->Insert(wxGetTranslation(wxString(cc.name, cc.name_len), wxT("ZRCola-zrcdb")), i);
m_categories->Check(idx);
m_ccOrder.insert(std::make_pair(cc.id, idx));
} }
ResetResults();
}
void wxZRColaCharSelect::OnIdle(wxIdleEvent& event)
{
event.Skip();
if (m_unicodeChanged) {
if (m_unicode->GetValidator()->TransferFromWindow()) {
ZRColaApp *app = (ZRColaApp*)wxTheApp;
m_gridPreview->SetCellValue(wxString(1, m_char), 0, 0);
{
ZRCola::character_db::character *chr = (ZRCola::character_db::character*)new char[sizeof(ZRCola::character_db::character)];
chr->chr = m_char;
size_t start, end;
if (app->m_chr_db.idxChr.find(*chr, start, end)) {
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[start];
m_description->SetValue(wxString(chr.data, chr.desc_len));
m_gridRelated->SetCharacters(wxString(chr.data + chr.desc_len, chr.rel_len));
} else {
m_description->SetValue(wxEmptyString);
m_gridRelated->ClearGrid();
}
m_gridRelated->Scroll(0, 0);
delete chr;
}
}
m_unicodeChanged = false;
} else if (m_searchChanged) {
m_timerSearch.Start(1000, true);
m_searchChanged = false;
}
}
void wxZRColaCharSelect::OnSearchText(wxCommandEvent& event)
{
event.Skip();
m_timerSearch.Stop();
m_searchChanged = true;
}
void wxZRColaCharSelect::OnSearchEnter(wxCommandEvent& event)
{
event.Skip();
m_timerSearch.Stop();
wxTimerEvent e(m_timerSearch);
GetEventHandler()->ProcessEvent(e);
m_searchChanged = false;
}
void wxZRColaCharSelect::OnSearchTimer(wxTimerEvent& event)
{
wxString val(m_search->GetValue());
if (!val.IsEmpty()) {
ZRColaApp *app = (ZRColaApp*)wxTheApp;
std::map<wchar_t, unsigned long> hits;
{
// Search by indexes and merge results.
std::map<wchar_t, unsigned long> hits_sub;
app->m_chr_db.search_by_desc(val.c_str(), hits, hits_sub);
for (std::map<wchar_t, unsigned long>::const_iterator i = hits_sub.cbegin(), i_end = hits_sub.cend(); i != i_end; ++i) {
std::map<wchar_t, unsigned long>::iterator idx = hits.find(i->first);
if (idx == hits.end())
hits.insert(std::make_pair(i->first, i->second / 4));
else
idx->second += i->second / 4;
}
}
// Filter by categories.
ZRCola::character_db::character *chr = (ZRCola::character_db::character*)new char[sizeof(ZRCola::character_db::character)];
for (std::map<wchar_t, unsigned long>::const_iterator i = hits.cbegin(), i_end = hits.cend(); i != i_end;) {
chr->chr = i->first;
size_t start, end;
std::map<ZRCola::chrcatid_t, int>::const_iterator idx;
if (app->m_chr_db.idxChr.find(*chr, start, end) &&
((idx = m_ccOrder.find(app->m_chr_db.idxChr[start].cat)) == m_ccOrder.end() || m_categories->IsChecked(idx->second)))
{
// Character category approved.
++i;
} else {
// Character category not approved.
std::map<wchar_t, unsigned long>::const_iterator i_remove = i;
++i;
hits.erase(i_remove);
}
}
delete chr;
// Now sort the characters by rank.
std::vector< std::pair<unsigned long, wchar_t> > hits2;
hits2.reserve(hits.size());
for (std::map<wchar_t, unsigned long>::const_iterator i = hits.cbegin(), i_end = hits.cend(); i != i_end; ++i)
hits2.push_back(std::make_pair(i->second, i->first));
std::qsort(hits2.data(), hits2.size(), sizeof(std::pair<unsigned long, wchar_t>), compare_hits);
// Display results.
wxString chars;
chars.reserve(hits2.size());
for (std::vector< std::pair<unsigned long, wchar_t> >::const_iterator i = hits2.cbegin(), i_end = hits2.cend(); i != i_end; ++i)
chars += i->second;
m_gridResults->SetCharacters(chars);
} else
ResetResults();
m_gridResults->Scroll(0, 0);
}
void wxZRColaCharSelect::OnCategoriesToggle(wxCommandEvent& event)
{
m_timerSearch.Stop();
m_timerSearch.Start(500, true);
}
void wxZRColaCharSelect::OnResultSelectCell(wxGridEvent& event)
{
wxString val(m_gridResults->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnResultCellDClick(wxGridEvent& event)
{
event.Skip();
wxString val(m_gridResults->GetCellValue(event.GetRow(), event.GetCol()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
}
}
void wxZRColaCharSelect::OnResultsKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
wxString val(m_gridResults->GetCellValue(m_gridResults->GetCursorRow(), m_gridResults->GetCursorColumn()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
event.StopPropagation();
return;
}
}
event.Skip();
}
void wxZRColaCharSelect::OnRecentSelectCell(wxGridEvent& event)
{
wxString val(m_gridRecent->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnRecentCellDClick(wxGridEvent& event)
{
event.Skip();
wxString val(m_gridRecent->GetCellValue(event.GetRow(), event.GetCol()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
}
}
void wxZRColaCharSelect::OnRecentKeyDown(wxKeyEvent& event)
{
switch (event.GetKeyCode()) {
case WXK_RETURN:
case WXK_NUMPAD_ENTER:
wxString val(m_gridRecent->GetCellValue(m_gridRecent->GetCursorRow(), m_gridRecent->GetCursorColumn()));
if (!val.IsEmpty()) {
m_char = val[0];
wxCommandEvent e(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
m_sdbSizerButtonsOK->GetEventHandler()->ProcessEvent(e);
event.StopPropagation();
return;
}
}
event.Skip();
}
void wxZRColaCharSelect::OnRelatedSelectCell(wxGridEvent& event)
{
wxString val(m_gridRelated->GetCellValue(event.GetRow(), event.GetCol()));
m_char = val.IsEmpty() ? 0 : val[0];
m_unicode->GetValidator()->TransferToWindow();
}
void wxZRColaCharSelect::OnUnicodeText(wxCommandEvent& event)
{
event.Skip();
m_unicodeChanged = true;
}
void wxZRColaCharSelect::OnOKButtonClick(wxCommandEvent& event)
{
event.Skip();
wxString
recent(m_gridRecent->GetCharacters()),
val(1, m_char);
for (size_t i = 0, n = recent.Length(); i < n; i++) {
const wxStringCharType c = recent[i];
if (c != m_char)
val += c;
}
m_gridRecent->SetCharacters(val);
}
void wxZRColaCharSelect::ResetResults()
{
// Fill the results.
ZRColaApp *app = (ZRColaApp*)wxTheApp;
size_t i, n = app->m_chr_db.idxChr.size();
wxString val;
val.reserve(n);
for (i = 0; i < n; i++) {
const ZRCola::character_db::character &chr = app->m_chr_db.idxChr[i];
std::map<ZRCola::chrcatid_t, int>::const_iterator idx = m_ccOrder.find(chr.cat);
if (idx == m_ccOrder.end() || m_categories->IsChecked(idx->second))
val += chr.chr;
}
m_gridResults->SetCharacters(val);
} }
@ -42,25 +322,26 @@ wxZRColaCharSelect::wxZRColaCharSelect(wxWindow* parent) : wxZRColaCharSelectBas
// wxPersistentZRColaCharSelect // wxPersistentZRColaCharSelect
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentWindow<wxZRColaCharSelect>(wnd) wxPersistentZRColaCharSelect::wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd) : wxPersistentDialog(wnd)
{ {
} }
wxString wxPersistentZRColaCharSelect::GetKind() const
{
return wxT(wxPERSIST_TLW_KIND);
}
void wxPersistentZRColaCharSelect::Save() const void wxPersistentZRColaCharSelect::Save() const
{ {
wxPersistentDialog::Save();
const wxZRColaCharSelect * const wnd = static_cast<const wxZRColaCharSelect*>(GetWindow()); const wxZRColaCharSelect * const wnd = static_cast<const wxZRColaCharSelect*>(GetWindow());
// Code copied from wxPersistentTLW::Save() SaveValue(wxT("recentChars"), wnd->m_gridRecent->GetCharacters());
const wxPoint pos = wnd->GetScreenPosition();
SaveValue(wxPERSIST_TLW_X, pos.x); ZRColaApp *app = (ZRColaApp*)wxTheApp;
SaveValue(wxPERSIST_TLW_Y, pos.y); for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
wxString name(wxT("category"));
name.Append(cc.id.data, _countof(cc.id.data));
SaveValue(name, wnd->m_categories->IsChecked(i));
}
} }
@ -68,28 +349,20 @@ bool wxPersistentZRColaCharSelect::Restore()
{ {
wxZRColaCharSelect * const wnd = static_cast<wxZRColaCharSelect*>(GetWindow()); wxZRColaCharSelect * const wnd = static_cast<wxZRColaCharSelect*>(GetWindow());
// Code copied from wxPersistentTLW::Restore() wxString recent;
long if (RestoreValue(wxT("recentChars"), &recent))
x wxDUMMY_INITIALIZE(-1), wnd->m_gridRecent->SetCharacters(recent);
y wxDUMMY_INITIALIZE(-1);
const wxSize size = wnd->GetSize();
const bool hasPos = RestoreValue(wxPERSIST_TLW_X, &x) &&
RestoreValue(wxPERSIST_TLW_Y, &y);
if (hasPos) { ZRColaApp *app = (ZRColaApp*)wxTheApp;
// to avoid making the window completely invisible if it had been for (size_t i = 0, n = app->m_cc_db.idxRnk.size(); i < n; i++) {
// shown on a monitor which was disconnected since the last run const ZRCola::chrcat_db::chrcat &cc = app->m_cc_db.idxRnk[i];
// (this is pretty common for notebook with external displays) wxString name(wxT("category"));
// name.Append(cc.id.data, _countof(cc.id.data));
// NB: we should allow window position to be (slightly) off screen, bool val;
// it's not uncommon to position the window so that its upper if (RestoreValue(name, &val))
// left corner has slightly negative coordinate wnd->m_categories->Check(i, val);
if (wxDisplay::GetFromPoint(wxPoint(x , y )) != wxNOT_FOUND ||
wxDisplay::GetFromPoint(wxPoint(x + size.x, y + size.y)) != wxNOT_FOUND)
{
wnd->Move(x, y, wxSIZE_ALLOW_MINUS_ONE);
}
} }
wnd->ResetResults();
return true; return wxPersistentDialog::Restore();
} }

View File

@ -27,6 +27,10 @@ class wxZRColaCharSelect;
#pragma once #pragma once
#include "zrcolagui.h" #include "zrcolagui.h"
#include <zrcola/character.h>
#include <wxex/valhex.h>
#include <wxex/persist/dialog.h>
#include <map>
/// ///
@ -36,18 +40,45 @@ class wxZRColaCharSelect : public wxZRColaCharSelectBase
{ {
public: public:
wxZRColaCharSelect(wxWindow* parent); wxZRColaCharSelect(wxWindow* parent);
friend class wxPersistentZRColaCharSelect; // Allow saving/restoring window state.
protected:
virtual void OnIdle(wxIdleEvent& event);
virtual void OnSearchText(wxCommandEvent& event);
virtual void OnSearchEnter(wxCommandEvent& event);
virtual void OnSearchTimer(wxTimerEvent& event);
virtual void OnCategoriesToggle(wxCommandEvent& event);
virtual void OnResultSelectCell(wxGridEvent& event);
virtual void OnResultCellDClick(wxGridEvent& event);
virtual void OnResultsKeyDown(wxKeyEvent& event);
virtual void OnRecentSelectCell(wxGridEvent& event);
virtual void OnRecentCellDClick(wxGridEvent& event);
virtual void OnRecentKeyDown(wxKeyEvent& event);
virtual void OnRelatedSelectCell(wxGridEvent& event);
virtual void OnUnicodeText(wxCommandEvent& event);
virtual void OnOKButtonClick(wxCommandEvent& event);
void ResetResults();
public:
wchar_t m_char; ///< Currently selected character (0 when none)
protected:
bool m_searchChanged; ///< Did Search field change?
std::map<ZRCola::chrcatid_t, int> m_ccOrder; ///< Character category order
bool m_unicodeChanged; ///< Did Unicode field change?
}; };
/// ///
/// Supports saving/restoring wxZRColaCharSelect state /// Supports saving/restoring wxZRColaCharSelect state
/// ///
class wxPersistentZRColaCharSelect : public wxPersistentWindow<wxZRColaCharSelect> class wxPersistentZRColaCharSelect : public wxPersistentDialog
{ {
public: public:
wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd); wxPersistentZRColaCharSelect(wxZRColaCharSelect *wnd);
virtual wxString GetKind() const;
virtual void Save() const; virtual void Save() const;
virtual bool Restore(); virtual bool Restore();
}; };

View File

@ -24,11 +24,6 @@
// wxZRColaComposerPanel // wxZRColaComposerPanel
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
BEGIN_EVENT_TABLE(wxZRColaComposerPanel, wxZRColaComposerPanelBase)
EVT_TIMER(wxZRColaComposerPanel::wxID_CHECKPOINT_TIMER, wxZRColaComposerPanel::OnTimerTimeout)
END_EVENT_TABLE()
wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) : wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
m_decomposedChanged(false), m_decomposedChanged(false),
m_composedChanged(false), m_composedChanged(false),
@ -38,9 +33,6 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
{ {
m_decomposed->PushEventHandler(&m_keyhandler); m_decomposed->PushEventHandler(&m_keyhandler);
// Create timer for saving the state.
m_timer = new wxTimer(this, wxID_CHECKPOINT_TIMER);
// 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)) {
@ -80,9 +72,6 @@ wxZRColaComposerPanel::wxZRColaComposerPanel(wxWindow* parent) :
wxZRColaComposerPanel::~wxZRColaComposerPanel() wxZRColaComposerPanel::~wxZRColaComposerPanel()
{ {
if (m_timer)
delete m_timer;
m_decomposed->PopEventHandler(); m_decomposed->PopEventHandler();
// This is a controlled exit. Purge saved state. // This is a controlled exit. Purge saved state.
@ -95,7 +84,7 @@ wxZRColaComposerPanel::~wxZRColaComposerPanel()
void wxZRColaComposerPanel::SynchronizePanels() void wxZRColaComposerPanel::SynchronizePanels()
{ {
if (m_decomposedChanged) { if (m_decomposedChanged) {
m_timer->Stop(); m_timerSave.Stop();
wxString src; wxString src;
size_t len = GetValue(m_decomposed, src); size_t len = GetValue(m_decomposed, src);
@ -119,9 +108,9 @@ void wxZRColaComposerPanel::SynchronizePanels()
SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, dst.data(), dst.length(), m_selComposed.first, m_selComposed.second); SetHexValue(m_composedHex, m_selComposedHex, m_mappingComposedHex, dst.data(), dst.length(), m_selComposed.first, m_selComposed.second);
// Schedule state save after 3s. // Schedule state save after 3s.
m_timer->Start(3000, true); m_timerSave.Start(3000, true);
} else if (m_composedChanged) { } else if (m_composedChanged) {
m_timer->Stop(); m_timerSave.Stop();
wxString src; wxString src;
size_t len = GetValue(m_composed, src); size_t len = GetValue(m_composed, src);
@ -150,7 +139,7 @@ void wxZRColaComposerPanel::SynchronizePanels()
SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, dst.data(), dst.length(), m_selDecomposed.first, m_selDecomposed.second); SetHexValue(m_decomposedHex, m_selDecomposedHex, m_mappingDecomposedHex, dst.data(), dst.length(), m_selDecomposed.first, m_selDecomposed.second);
// Schedule state save after 3s. // Schedule state save after 3s.
m_timer->Start(3000, true); m_timerSave.Start(3000, true);
} }
m_decomposedChanged = false; m_decomposedChanged = false;
@ -285,7 +274,7 @@ void wxZRColaComposerPanel::OnComposedText(wxCommandEvent& event)
} }
void wxZRColaComposerPanel::OnTimerTimeout(wxTimerEvent& event) void wxZRColaComposerPanel::OnSaveTimer(wxTimerEvent& event)
{ {
wxString fileName(GetStateFileName()); wxString fileName(GetStateFileName());
wxFFile file(fileName, wxT("wb")); wxFFile file(fileName, wxT("wb"));

View File

@ -38,11 +38,6 @@ class wxZRColaComposerPanel;
class wxZRColaComposerPanel : public wxZRColaComposerPanelBase class wxZRColaComposerPanel : public wxZRColaComposerPanelBase
{ {
public: public:
enum
{
wxID_CHECKPOINT_TIMER = 2000,
};
wxZRColaComposerPanel(wxWindow* parent); wxZRColaComposerPanel(wxWindow* parent);
virtual ~wxZRColaComposerPanel(); virtual ~wxZRColaComposerPanel();
@ -57,8 +52,7 @@ protected:
virtual void OnComposedPaint(wxPaintEvent& event); virtual void OnComposedPaint(wxPaintEvent& event);
virtual void OnComposedHexPaint(wxPaintEvent& event); virtual void OnComposedHexPaint(wxPaintEvent& event);
virtual void OnComposedText(wxCommandEvent& event); virtual void OnComposedText(wxCommandEvent& event);
virtual void OnTimerTimeout(wxTimerEvent& event); virtual void OnSaveTimer(wxTimerEvent& event);
DECLARE_EVENT_TABLE()
static wxString GetStateFileName(); static wxString GetStateFileName();
static size_t GetValue(wxTextCtrl *wnd, wxString &text); static size_t GetValue(wxTextCtrl *wnd, wxString &text);
@ -75,7 +69,6 @@ protected:
m_selComposed, ///< Character index of selected text in composed text control m_selComposed, ///< Character index of selected text in composed text control
m_selComposedHex; ///< Character index of selected text in composed HEX dump text control m_selComposedHex; ///< Character index of selected text in composed HEX dump text control
wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window wxZRColaKeyHandler m_keyhandler; ///< Key handler for decomposed window
wxTimer *m_timer; ///< Timer to trigger the state save
ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump ZRCola::mapping_vector m_mappingDecomposedHex; ///< Character index mapping vector between decomposed text and its HEX dump
ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump ZRCola::mapping_vector m_mappingComposedHex; ///< Character index mapping vector between composed text and its HEX dump
}; };

View File

@ -39,7 +39,7 @@ wxBEGIN_EVENT_TABLE(wxZRColaFrame, wxZRColaFrameBase)
EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed ) EVT_MENU (wxID_SEND_DECOMPOSED , wxZRColaFrame::OnSendDecomposed )
EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort ) EVT_MENU (wxID_SEND_ABORT , wxZRColaFrame::OnSendAbort )
EVT_MENU (wxID_INSERT_CHARACTER , wxZRColaFrame::OnInsertCharacter ) EVT_MENU (wxID_CHARACTER_SELECTOR , wxZRColaFrame::OnInsertCharacter )
EVT_UPDATE_UI (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAutoUpdate) EVT_UPDATE_UI (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAutoUpdate)
EVT_MENU (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAuto ) EVT_MENU (wxID_DECOMP_LANG_AUTO , wxZRColaFrame::OnDecomposedLanguageAuto )
@ -257,7 +257,10 @@ void wxZRColaFrame::OnForwardEvent(wxCommandEvent& event)
void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event) void wxZRColaFrame::OnInsertCharacter(wxCommandEvent& event)
{ {
m_chrSelect->ShowModal(); if (m_chrSelect->ShowModal() == wxID_OK && m_chrSelect->m_char) {
m_panel->m_decomposed->WriteText(m_chrSelect->m_char);
m_panel->m_decomposed->SetFocus();
}
} }

View File

@ -80,9 +80,14 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
m_menuEdit->AppendSeparator(); m_menuEdit->AppendSeparator();
wxMenuItem* m_menuInsertCharacter; wxMenuItem* m_menuCharSelect;
m_menuInsertCharacter = new wxMenuItem( m_menuEdit, wxID_INSERT_CHARACTER, wxString( _("&Insert Character...") ) + wxT('\t') + wxT("F8"), _("Display character selector to select character to insert into text"), wxITEM_NORMAL ); m_menuCharSelect = new wxMenuItem( m_menuEdit, wxID_CHARACTER_SELECTOR, wxString( _("C&haracter Selector...") ) + wxT('\t') + wxT("F8"), _("Display character selector to select character to insert into text"), wxITEM_NORMAL );
m_menuEdit->Append( m_menuInsertCharacter ); #ifdef __WXMSW__
m_menuCharSelect->SetBitmaps( wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#elif (defined( __WXGTK__ ) || defined( __WXOSX__ ))
m_menuCharSelect->SetBitmap( wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 16, 16 ) );
#endif
m_menuEdit->Append( m_menuCharSelect );
m_menuEdit->AppendSeparator(); m_menuEdit->AppendSeparator();
@ -162,6 +167,8 @@ wxZRColaFrameBase::wxZRColaFrameBase( wxWindow* parent, wxWindowID id, const wxS
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_toolbarCompose = new wxAuiToolBar( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_TB_HORZ_LAYOUT );
m_toolCharSelect = m_toolbarCompose->AddTool( wxID_CHARACTER_SELECTOR, _("Character Selector"), wxIcon( wxT("char_select.ico"), wxBITMAP_TYPE_ICO_RESOURCE, 24, 24 ), wxNullBitmap, wxITEM_NORMAL, _("Character Selector"), _("Display character selector 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_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_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_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 );
@ -308,6 +315,7 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
this->SetSizer( bSizerMain ); this->SetSizer( bSizerMain );
this->Layout(); this->Layout();
bSizerMain->Fit( this ); bSizerMain->Fit( this );
m_timerSave.SetOwner( this, wxID_TIMER_SAVE );
// Connect Events // Connect Events
m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this ); m_decomposed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnDecomposedPaint ), NULL, this );
@ -316,6 +324,7 @@ wxZRColaComposerPanelBase::wxZRColaComposerPanelBase( wxWindow* parent, wxWindow
m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_composed->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); m_composed->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); m_composedHex->Connect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
this->Connect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
} }
wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase() wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
@ -327,6 +336,7 @@ wxZRColaComposerPanelBase::~wxZRColaComposerPanelBase()
m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this ); m_composed->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedPaint ), NULL, this );
m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this ); m_composed->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaComposerPanelBase::OnComposedText ), NULL, this );
m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this ); m_composedHex->Disconnect( wxEVT_PAINT, wxPaintEventHandler( wxZRColaComposerPanelBase::OnComposedHexPaint ), NULL, this );
this->Disconnect( wxID_TIMER_SAVE, wxEVT_TIMER, wxTimerEventHandler( wxZRColaComposerPanelBase::OnSaveTimer ) );
} }
@ -406,7 +416,7 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
wxStaticBoxSizer* sbSizerBrowse; wxStaticBoxSizer* sbSizerBrowse;
sbSizerBrowse = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("&Browse") ), wxVERTICAL ); sbSizerBrowse = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("&Browse") ), wxVERTICAL );
m_search = new wxSearchCtrl( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); m_search = new wxSearchCtrl( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
#ifndef __WXMAC__ #ifndef __WXMAC__
m_search->ShowSearchButton( true ); m_search->ShowSearchButton( true );
#endif #endif
@ -414,50 +424,25 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
sbSizerBrowse->Add( m_search, 0, wxALL|wxEXPAND, 5 ); sbSizerBrowse->Add( m_search, 0, wxALL|wxEXPAND, 5 );
wxArrayString m_categoriesChoices; wxArrayString m_categoriesChoices;
m_categories = new wxCheckListBox( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, m_categoriesChoices, 0 ); m_categories = new wxCheckListBox( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,60 ), m_categoriesChoices, 0 );
m_categories->SetMaxSize( wxSize( -1,59 ) );
sbSizerBrowse->Add( m_categories, 0, wxALL|wxEXPAND, 5 ); sbSizerBrowse->Add( m_categories, 0, wxALL|wxEXPAND, 5 );
m_gridResults = new wxGrid( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_gridResults = new wxZRColaCharGrid( sbSizerBrowse->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxSTATIC_BORDER );
// Grid // Grid
m_gridResults->CreateGrid( 7, 16 ); m_gridResults->CreateGrid( 0, 0 );
m_gridResults->EnableEditing( false ); m_gridResults->EnableEditing( false );
m_gridResults->EnableGridLines( true ); m_gridResults->EnableGridLines( false );
m_gridResults->EnableDragGridSize( false ); m_gridResults->EnableDragGridSize( false );
m_gridResults->SetMargins( 0, 0 ); m_gridResults->SetMargins( 0, 0 );
// Columns // Columns
m_gridResults->SetColSize( 0, 35 );
m_gridResults->SetColSize( 1, 35 );
m_gridResults->SetColSize( 2, 35 );
m_gridResults->SetColSize( 3, 35 );
m_gridResults->SetColSize( 4, 35 );
m_gridResults->SetColSize( 5, 35 );
m_gridResults->SetColSize( 6, 35 );
m_gridResults->SetColSize( 7, 35 );
m_gridResults->SetColSize( 8, 35 );
m_gridResults->SetColSize( 9, 35 );
m_gridResults->SetColSize( 10, 35 );
m_gridResults->SetColSize( 11, 35 );
m_gridResults->SetColSize( 12, 35 );
m_gridResults->SetColSize( 13, 35 );
m_gridResults->SetColSize( 14, 35 );
m_gridResults->SetColSize( 15, 35 );
m_gridResults->EnableDragColMove( false ); m_gridResults->EnableDragColMove( false );
m_gridResults->EnableDragColSize( false ); m_gridResults->EnableDragColSize( false );
m_gridResults->SetColLabelSize( 0 ); m_gridResults->SetColLabelSize( 0 );
m_gridResults->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridResults->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows // Rows
m_gridResults->SetRowSize( 0, 35 );
m_gridResults->SetRowSize( 1, 35 );
m_gridResults->SetRowSize( 2, 35 );
m_gridResults->SetRowSize( 3, 35 );
m_gridResults->SetRowSize( 4, 35 );
m_gridResults->SetRowSize( 5, 35 );
m_gridResults->SetRowSize( 6, 35 );
m_gridResults->EnableDragRowSize( false ); m_gridResults->EnableDragRowSize( false );
m_gridResults->SetRowLabelSize( 0 ); m_gridResults->SetRowLabelSize( 0 );
m_gridResults->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridResults->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
@ -468,48 +453,33 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
m_gridResults->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); m_gridResults->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridResults->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridResults->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_gridResults->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); m_gridResults->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
m_gridResults->SetMinSize( wxSize( 560,35 ) );
m_gridResults->SetMaxSize( wxSize( 560,-1 ) );
sbSizerBrowse->Add( m_gridResults, 0, wxALL|wxEXPAND, 5 ); sbSizerBrowse->Add( m_gridResults, 1, wxALL|wxEXPAND, 5 );
bSizerLeft->Add( sbSizerBrowse, 0, wxALL|wxEXPAND, 5 ); bSizerLeft->Add( sbSizerBrowse, 1, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerRecent; wxStaticBoxSizer* sbSizerRecent;
sbSizerRecent = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&cently Used") ), wxVERTICAL ); sbSizerRecent = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&cently Used") ), wxVERTICAL );
m_gridRecent = new wxGrid( sbSizerRecent->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_gridRecent = new wxZRColaCharGrid( sbSizerRecent->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,35 ), wxSTATIC_BORDER );
// Grid // Grid
m_gridRecent->CreateGrid( 1, 16 ); m_gridRecent->CreateGrid( 0, 0 );
m_gridRecent->EnableEditing( false ); m_gridRecent->EnableEditing( false );
m_gridRecent->EnableGridLines( true ); m_gridRecent->EnableGridLines( false );
m_gridRecent->EnableDragGridSize( false ); m_gridRecent->EnableDragGridSize( false );
m_gridRecent->SetMargins( 0, 0 ); m_gridRecent->SetMargins( 0, 0 );
// Columns // Columns
m_gridRecent->SetColSize( 0, 35 );
m_gridRecent->SetColSize( 1, 35 );
m_gridRecent->SetColSize( 2, 35 );
m_gridRecent->SetColSize( 3, 35 );
m_gridRecent->SetColSize( 4, 35 );
m_gridRecent->SetColSize( 5, 35 );
m_gridRecent->SetColSize( 6, 35 );
m_gridRecent->SetColSize( 7, 35 );
m_gridRecent->SetColSize( 8, 35 );
m_gridRecent->SetColSize( 9, 35 );
m_gridRecent->SetColSize( 10, 35 );
m_gridRecent->SetColSize( 11, 35 );
m_gridRecent->SetColSize( 12, 35 );
m_gridRecent->SetColSize( 13, 35 );
m_gridRecent->SetColSize( 14, 35 );
m_gridRecent->SetColSize( 15, 35 );
m_gridRecent->EnableDragColMove( false ); m_gridRecent->EnableDragColMove( false );
m_gridRecent->EnableDragColSize( false ); m_gridRecent->EnableDragColSize( false );
m_gridRecent->SetColLabelSize( 0 ); m_gridRecent->SetColLabelSize( 0 );
m_gridRecent->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridRecent->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows // Rows
m_gridRecent->SetRowSize( 0, 35 );
m_gridRecent->EnableDragRowSize( false ); m_gridRecent->EnableDragRowSize( false );
m_gridRecent->SetRowLabelSize( 0 ); m_gridRecent->SetRowLabelSize( 0 );
m_gridRecent->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridRecent->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
@ -521,7 +491,7 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
m_gridRecent->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridRecent->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
m_gridRecent->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) ); m_gridRecent->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), 70, 90, 90, false, wxEmptyString ) );
sbSizerRecent->Add( m_gridRecent, 0, wxALL, 5 ); sbSizerRecent->Add( m_gridRecent, 0, wxALL|wxEXPAND, 5 );
bSizerLeft->Add( sbSizerRecent, 0, wxALL|wxEXPAND, 5 ); bSizerLeft->Add( sbSizerRecent, 0, wxALL|wxEXPAND, 5 );
@ -543,25 +513,22 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
bSizerUnicode->Add( m_labelUnicode, 0, wxALIGN_CENTER, 5 ); bSizerUnicode->Add( m_labelUnicode, 0, wxALIGN_CENTER, 5 );
m_unicode = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50,-1 ), 0 ); m_unicode = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 50,-1 ), 0 );
m_unicode->SetMaxLength( 4 );
m_unicode->SetValidator( wxTextValidator( wxFILTER_INCLUDE_CHAR_LIST, &m_unicodeValid ) );
bSizerUnicode->Add( m_unicode, 0, wxALIGN_CENTER, 5 ); bSizerUnicode->Add( m_unicode, 0, wxALIGN_CENTER, 5 );
sbSizerPreview->Add( bSizerUnicode, 0, wxALIGN_CENTER|wxALL, 5 ); sbSizerPreview->Add( bSizerUnicode, 0, wxALIGN_CENTER|wxALL, 5 );
m_gridPreview = new wxGrid( sbSizerPreview->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_gridPreview = new wxGrid( sbSizerPreview->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSTATIC_BORDER );
// Grid // Grid
m_gridPreview->CreateGrid( 1, 1 ); m_gridPreview->CreateGrid( 1, 1 );
m_gridPreview->EnableEditing( false ); m_gridPreview->EnableEditing( false );
m_gridPreview->EnableGridLines( true ); m_gridPreview->EnableGridLines( false );
m_gridPreview->EnableDragGridSize( false ); m_gridPreview->EnableDragGridSize( false );
m_gridPreview->SetMargins( 0, 0 ); m_gridPreview->SetMargins( 0, 0 );
// Columns // Columns
m_gridPreview->SetColSize( 0, 210 ); m_gridPreview->SetColSize( 0, 200 );
m_gridPreview->EnableDragColMove( false ); m_gridPreview->EnableDragColMove( false );
m_gridPreview->EnableDragColSize( false ); m_gridPreview->EnableDragColSize( false );
m_gridPreview->SetColLabelSize( 0 ); m_gridPreview->SetColLabelSize( 0 );
@ -576,44 +543,37 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
// Label Appearance // Label Appearance
// Cell Defaults // Cell Defaults
m_gridPreview->SetDefaultCellFont( wxFont( 180, 70, 90, 90, false, wxT("00 ZRCola") ) ); m_gridPreview->SetDefaultCellFont( wxFont( 120, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridPreview->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridPreview->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
sbSizerPreview->Add( m_gridPreview, 0, wxALIGN_CENTER|wxALL, 5 ); m_gridPreview->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) );
sbSizerPreview->Add( m_gridPreview, 0, wxALL|wxEXPAND, 5 );
m_description = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_READONLY ); m_description = new wxTextCtrl( sbSizerPreview->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_CENTRE|wxTE_MULTILINE|wxTE_READONLY );
sbSizerPreview->Add( m_description, 1, wxALL|wxEXPAND, 5 ); sbSizerPreview->Add( m_description, 1, wxALL|wxEXPAND, 5 );
bSizerRight->Add( sbSizerPreview, 0, wxALL|wxEXPAND, 5 ); bSizerRight->Add( sbSizerPreview, 70, wxALL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizerRelated; wxStaticBoxSizer* sbSizerRelated;
sbSizerRelated = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&lated") ), wxVERTICAL ); sbSizerRelated = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Re&lated") ), wxVERTICAL );
m_gridRelated = new wxGrid( sbSizerRelated->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_gridRelated = new wxZRColaCharGrid( sbSizerRelated->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxSize( -1,-1 ), wxSTATIC_BORDER );
// Grid // Grid
m_gridRelated->CreateGrid( 3, 6 ); m_gridRelated->CreateGrid( 0, 0 );
m_gridRelated->EnableEditing( false ); m_gridRelated->EnableEditing( false );
m_gridRelated->EnableGridLines( true ); m_gridRelated->EnableGridLines( false );
m_gridRelated->EnableDragGridSize( false ); m_gridRelated->EnableDragGridSize( false );
m_gridRelated->SetMargins( 0, 0 ); m_gridRelated->SetMargins( 0, 0 );
// Columns // Columns
m_gridRelated->SetColSize( 0, 35 );
m_gridRelated->SetColSize( 1, 35 );
m_gridRelated->SetColSize( 2, 35 );
m_gridRelated->SetColSize( 3, 35 );
m_gridRelated->SetColSize( 4, 35 );
m_gridRelated->SetColSize( 5, 35 );
m_gridRelated->EnableDragColMove( false ); m_gridRelated->EnableDragColMove( false );
m_gridRelated->EnableDragColSize( false ); m_gridRelated->EnableDragColSize( false );
m_gridRelated->SetColLabelSize( 0 ); m_gridRelated->SetColLabelSize( 0 );
m_gridRelated->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridRelated->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows // Rows
m_gridRelated->SetRowSize( 0, 35 );
m_gridRelated->SetRowSize( 1, 35 );
m_gridRelated->SetRowSize( 2, 35 );
m_gridRelated->EnableDragRowSize( false ); m_gridRelated->EnableDragRowSize( false );
m_gridRelated->SetRowLabelSize( 0 ); m_gridRelated->SetRowLabelSize( 0 );
m_gridRelated->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_gridRelated->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
@ -622,11 +582,11 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
// Cell Defaults // Cell Defaults
m_gridRelated->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) ); m_gridRelated->SetDefaultCellFont( wxFont( 20, 70, 90, 90, false, wxT("00 ZRCola") ) );
m_gridRelated->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_gridRelated->SetDefaultCellAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
sbSizerRelated->Add( m_gridRelated, 0, wxALIGN_CENTER|wxALL, 5 ); sbSizerRelated->Add( m_gridRelated, 1, wxALL|wxEXPAND, 5 );
bSizerRight->Add( sbSizerRelated, 1, wxALL|wxEXPAND, 5 ); bSizerRight->Add( sbSizerRelated, 30, wxALL|wxEXPAND, 5 );
bSizerColumns->Add( bSizerRight, 0, wxEXPAND, 5 ); bSizerColumns->Add( bSizerRight, 0, wxEXPAND, 5 );
@ -650,22 +610,41 @@ wxZRColaCharSelectBase::wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id,
this->SetSizer( bSizerContent ); this->SetSizer( bSizerContent );
this->Layout(); this->Layout();
bSizerContent->Fit( this ); bSizerContent->Fit( this );
m_timerSearch.SetOwner( this, wxID_TIMER_SEARCH );
// Connect Events // Connect Events
this->Connect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaCharSelectBase::OnIdle ) );
m_search->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this ); m_search->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this );
m_search->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchEnter ), NULL, this );
m_categories->Connect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( wxZRColaCharSelectBase::OnCategoriesToggle ), NULL, this );
m_gridResults->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnResultCellDClick ), NULL, this );
m_gridResults->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this ); m_gridResults->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this );
m_gridResults->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnResultsKeyDown ), NULL, this );
m_gridRecent->Connect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentCellDClick ), NULL, this );
m_gridRecent->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this ); m_gridRecent->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this );
m_gridRecent->Connect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnRecentKeyDown ), NULL, this );
m_unicode->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this ); m_unicode->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this );
m_gridRelated->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this ); m_gridRelated->Connect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this );
m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaCharSelectBase::OnOKButtonClick ), NULL, this );
this->Connect( wxID_TIMER_SEARCH, wxEVT_TIMER, wxTimerEventHandler( wxZRColaCharSelectBase::OnSearchTimer ) );
} }
wxZRColaCharSelectBase::~wxZRColaCharSelectBase() wxZRColaCharSelectBase::~wxZRColaCharSelectBase()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_IDLE, wxIdleEventHandler( wxZRColaCharSelectBase::OnIdle ) );
m_search->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this ); m_search->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchText ), NULL, this );
m_search->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( wxZRColaCharSelectBase::OnSearchEnter ), NULL, this );
m_categories->Disconnect( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, wxCommandEventHandler( wxZRColaCharSelectBase::OnCategoriesToggle ), NULL, this );
m_gridResults->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnResultCellDClick ), NULL, this );
m_gridResults->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this ); m_gridResults->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnResultSelectCell ), NULL, this );
m_gridResults->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnResultsKeyDown ), NULL, this );
m_gridRecent->Disconnect( wxEVT_GRID_CELL_LEFT_DCLICK, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentCellDClick ), NULL, this );
m_gridRecent->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this ); m_gridRecent->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRecentSelectCell ), NULL, this );
m_gridRecent->Disconnect( wxEVT_KEY_DOWN, wxKeyEventHandler( wxZRColaCharSelectBase::OnRecentKeyDown ), NULL, this );
m_unicode->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this ); m_unicode->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( wxZRColaCharSelectBase::OnUnicodeText ), NULL, this );
m_gridRelated->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this ); m_gridRelated->Disconnect( wxEVT_GRID_SELECT_CELL, wxGridEventHandler( wxZRColaCharSelectBase::OnRelatedSelectCell ), NULL, this );
m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( wxZRColaCharSelectBase::OnOKButtonClick ), NULL, this );
this->Disconnect( wxID_TIMER_SEARCH, wxEVT_TIMER, wxTimerEventHandler( wxZRColaCharSelectBase::OnSearchTimer ) );
} }

View File

@ -35,11 +35,11 @@ class wxZRColaComposerPanel;
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/panel.h> #include <wx/panel.h>
#include <wx/splitter.h> #include <wx/splitter.h>
#include <wx/timer.h>
#include <wx/grid.h> #include <wx/grid.h>
#include <wx/srchctrl.h> #include <wx/srchctrl.h>
#include <wx/checklst.h> #include <wx/checklst.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/valtext.h>
#include <wx/button.h> #include <wx/button.h>
#include <wx/dialog.h> #include <wx/dialog.h>
@ -56,7 +56,7 @@ class wxZRColaFrameBase : public wxFrame
enum enum
{ {
wxID_AUTOSTART = 1000, wxID_AUTOSTART = 1000,
wxID_INSERT_CHARACTER, wxID_CHARACTER_SELECTOR,
wxID_SEND_COMPOSED, wxID_SEND_COMPOSED,
wxID_SEND_DECOMPOSED, wxID_SEND_DECOMPOSED,
wxID_SEND_ABORT, wxID_SEND_ABORT,
@ -77,6 +77,7 @@ class wxZRColaFrameBase : public wxFrame
wxAuiToolBarItem* m_toolEditCopy; wxAuiToolBarItem* m_toolEditCopy;
wxAuiToolBarItem* m_toolEditPaste; wxAuiToolBarItem* m_toolEditPaste;
wxAuiToolBar* m_toolbarCompose; wxAuiToolBar* m_toolbarCompose;
wxAuiToolBarItem* m_toolCharSelect;
wxAuiToolBarItem* m_toolSendComposed; wxAuiToolBarItem* m_toolSendComposed;
wxAuiToolBarItem* m_toolSendDecomposed; wxAuiToolBarItem* m_toolSendDecomposed;
wxChoice* m_toolDecompLanguage; wxChoice* m_toolDecompLanguage;
@ -107,6 +108,11 @@ class wxZRColaComposerPanelBase : public wxPanel
private: private:
protected: protected:
enum
{
wxID_TIMER_SAVE = 1000
};
wxSplitterWindow* m_splitterDecomposed; wxSplitterWindow* m_splitterDecomposed;
wxPanel* m_panelDecomposedEdit; wxPanel* m_panelDecomposedEdit;
wxPanel* m_panelDecomposedHex; wxPanel* m_panelDecomposedHex;
@ -115,6 +121,7 @@ class wxZRColaComposerPanelBase : public wxPanel
wxPanel* m_panelComposedEdit; wxPanel* m_panelComposedEdit;
wxPanel* m_panelComposedHex; wxPanel* m_panelComposedHex;
wxTextCtrl* m_composedHex; wxTextCtrl* m_composedHex;
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 OnDecomposedPaint( wxPaintEvent& event ) { event.Skip(); }
@ -123,6 +130,7 @@ class wxZRColaComposerPanelBase : public wxPanel
virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnComposedPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); } virtual void OnComposedText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); } virtual void OnComposedHexPaint( wxPaintEvent& event ) { event.Skip(); }
virtual void OnSaveTimer( wxTimerEvent& event ) { event.Skip(); }
public: public:
@ -178,29 +186,43 @@ class wxZRColaCharSelectBase : public wxDialog
private: private:
protected: protected:
enum
{
wxID_TIMER_SEARCH = 1000
};
wxSearchCtrl* m_search; wxSearchCtrl* m_search;
wxCheckListBox* m_categories; wxCheckListBox* m_categories;
wxGrid* m_gridResults; wxZRColaCharGrid* m_gridResults;
wxGrid* m_gridRecent; wxZRColaCharGrid* m_gridRecent;
wxStaticText* m_labelUnicode; wxStaticText* m_labelUnicode;
wxTextCtrl* m_unicode; wxTextCtrl* m_unicode;
wxGrid* m_gridPreview; wxGrid* m_gridPreview;
wxTextCtrl* m_description; wxTextCtrl* m_description;
wxGrid* m_gridRelated; wxZRColaCharGrid* m_gridRelated;
wxStdDialogButtonSizer* m_sdbSizerButtons; wxStdDialogButtonSizer* m_sdbSizerButtons;
wxButton* m_sdbSizerButtonsOK; wxButton* m_sdbSizerButtonsOK;
wxButton* m_sdbSizerButtonsCancel; wxButton* m_sdbSizerButtonsCancel;
wxTimer m_timerSearch;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnIdle( wxIdleEvent& event ) { event.Skip(); }
virtual void OnSearchText( wxCommandEvent& event ) { event.Skip(); } virtual void OnSearchText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSearchEnter( wxCommandEvent& event ) { event.Skip(); }
virtual void OnCategoriesToggle( wxCommandEvent& event ) { event.Skip(); }
virtual void OnResultCellDClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnResultSelectCell( wxGridEvent& event ) { event.Skip(); } virtual void OnResultSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnResultsKeyDown( wxKeyEvent& event ) { event.Skip(); }
virtual void OnRecentCellDClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnRecentSelectCell( wxGridEvent& event ) { event.Skip(); } virtual void OnRecentSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnRecentKeyDown( wxKeyEvent& event ) { event.Skip(); }
virtual void OnUnicodeText( wxCommandEvent& event ) { event.Skip(); } virtual void OnUnicodeText( wxCommandEvent& event ) { event.Skip(); }
virtual void OnRelatedSelectCell( wxGridEvent& event ) { event.Skip(); } virtual void OnRelatedSelectCell( wxGridEvent& event ) { event.Skip(); }
virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnSearchTimer( wxTimerEvent& event ) { event.Skip(); }
public: public:
wxString m_unicodeValid;
wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Character Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("ZRColaCharSelect") ); wxZRColaCharSelectBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Character Selector"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE, const wxString& name = wxT("ZRColaCharSelect") );
~wxZRColaCharSelectBase(); ~wxZRColaCharSelectBase();

View File

@ -20,6 +20,94 @@
#include "stdafx.h" #include "stdafx.h"
bool ZRCola::DBSource::character_desc_idx::add_keywords(const wchar_t *str, wchar_t chr, size_t sub)
{
wxASSERT_MSG(str, wxT("string is NULL"));
while (*str) {
// Skip white space.
for (;;) {
if (*str == 0)
return true;
else if (!iswspace(*str))
break;
else
str++;
}
// Get term.
std::wstring term;
if (*str == L'"') {
const wchar_t *str_end = ++str;
for (;;) {
if (*str_end == 0) {
term.assign(str, str_end);
break;
} else if (*str_end == L'"') {
term.assign(str, str_end);
str_end++;
break;
} else
str_end++;
}
str = str_end;
} else {
const wchar_t *str_end = str + 1;
for (; *str_end && !iswspace(*str_end); str_end++);
term.assign(str, str_end);
str = str_end;
}
if (!term.empty()) {
std::transform(term.begin(), term.end(), term.begin(), std::towlower);
if (sub) {
std::wstring::size_type j_end = term.size();
if (j_end >= sub) {
// Insert all keyword substrings "sub" or more characters long.
for (std::wstring::size_type i = 0, i_end = j_end - sub; i < i_end; ++i) {
for (std::wstring::size_type j = i + sub; j < j_end; ++j)
add_keyword(term.substr(i, j - i), chr);
}
}
} else {
// Insert exact keyword only.
add_keyword(term, chr);
}
}
}
return true;
}
void ZRCola::DBSource::character_desc_idx::save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const
{
idx .clear();
idx.keys .clear();
idx.values.clear();
// Pre-allocate memory.
std::vector<wchar_t>::size_type size_keys = 0;
std::vector<wchar_t>::size_type size_values = 0;
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
size_keys += i->first.size();
size_values += i->second.size();
}
idx .reserve(size() );
idx.keys .reserve(size_keys );
idx.values.reserve(size_values);
// Convert the index.
for (const_iterator i = cbegin(), i_end = cend(); i != i_end; ++i) {
ZRCola::mappair_t<unsigned __int32> p = { idx.keys.size(), idx.values.size() };
idx.push_back(p);
idx.keys.insert(idx.keys.end(), i->first.cbegin(), i->first.cend());
idx.values.insert(idx.values.end(), i->second.cbegin(), i->second.cend());
}
}
ZRCola::DBSource::DBSource() ZRCola::DBSource::DBSource()
{ {
} }
@ -348,14 +436,14 @@ bool ZRCola::DBSource::GetChrCat(const ATL::CComPtr<ADOField>& f, chrcatid_t& cc
_ftprintf(stderr, wxT("%s: error ZCC0111: Syntax error in \"%.*ls\" field (\"%.*ls\"). Character category ID must contain ASCII characters only.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v)); _ftprintf(stderr, wxT("%s: error ZCC0111: Syntax error in \"%.*ls\" field (\"%.*ls\"). Character category ID must contain ASCII characters only.\n"), m_filename.c_str(), fieldname.Length(), (BSTR)fieldname, n, V_BSTR(&v));
return false; return false;
} }
cc[i] = (char)c; cc.data[i] = (char)c;
} else } else
cc[i] = 0; cc.data[i] = 0;
} else } else
break; break;
} }
} else } else
memset(cc, 0, sizeof(cc)); memset(cc.data, 0, sizeof(cc));
return true; return true;
} }

View File

@ -24,6 +24,7 @@
#include <atlbase.h> #include <atlbase.h>
#include <adoint.h> #include <adoint.h>
#include <map>
#include <string> #include <string>
#include <vector> #include <vector>
@ -112,6 +113,61 @@ namespace ZRCola {
}; };
///
/// Character description index key comparator
///
struct character_desc_idx_less : public std::binary_function<std::wstring, std::wstring, bool>
{
inline bool operator()(const std::wstring& _Left, const std::wstring& _Right) const
{
size_t
_Left_len = _Left .size(),
_Right_len = _Right.size();
int r = _wcsncoll(_Left.c_str(), _Right.c_str(), std::min<size_t>(_Left_len, _Right_len));
if (r != 0 ) return r < 0;
else if (_Left_len < _Right_len) return true;
return false;
}
};
///
/// Character description index
///
class character_desc_idx : public std::map<std::wstring, std::vector<wchar_t>, character_desc_idx_less>
{
public:
bool add_keywords(const wchar_t *str, wchar_t chr, size_t sub = 0);
void save(ZRCola::textindex<wchar_t, wchar_t, unsigned __int32> &idx) const;
protected:
inline void add_keyword(const std::wstring &term, wchar_t chr)
{
iterator idx = find(term);
if (idx == end()) {
// New keyword.
insert(std::make_pair(term, std::vector<wchar_t>(1, chr)));
} else {
// Append to existing keyword.
std::vector<wchar_t> &val = idx->second;
for (std::vector<wchar_t>::iterator i = val.begin(), i_end = val.end(); ; ++i) {
if (i == i_end) {
// End-of-values reached. Append character.
val.push_back(chr);
break;
} else if (*i == chr) {
// Character already among the values.
break;
}
}
}
}
};
/// ///
/// Character category /// Character category
/// ///
@ -176,6 +232,19 @@ namespace ZRCola {
} }
///
/// Splits string to individual keywords
///
/// \param[in ] str String
/// \param[out] keywords Array of keywords
///
/// \returns
/// - true when successful
/// - false otherwise
///
static bool GetKeywords(const wchar_t *str, std::vector< std::wstring > &keywords);
/// ///
/// Gets boolean from ZRCola.zrc database /// Gets boolean from ZRCola.zrc database
/// ///

View File

@ -20,383 +20,6 @@
#include "stdafx.h" #include "stdafx.h"
///
/// Writes translation database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Translation database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::translation_db &db)
{
assert(db.idxComp.size() == db.idxDecomp.size());
unsigned __int32 count;
// Write index count.
ZRCola::translation_db::indexComp::size_type trans_count = db.idxComp.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (trans_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)trans_count;
stream.write((const char*)&count, sizeof(count));
// Write composition index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxComp.data(), sizeof(unsigned __int32)*count);
// Write decomposition index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxDecomp.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes key sequence database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Key sequence database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::keyseq_db &db)
{
assert(db.idxChr.size() == db.idxKey.size());
unsigned __int32 count;
// Write index count.
ZRCola::keyseq_db::indexChr::size_type ks_count = db.idxChr.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (ks_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)ks_count;
stream.write((const char*)&count, sizeof(count));
// Write character index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
// Write key index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxKey.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes language database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::language_db &db)
{
unsigned __int32 count;
// Write index count.
ZRCola::language_db::indexLang::size_type lang_count = db.idxLng.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (lang_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)lang_count;
stream.write((const char*)&count, sizeof(count));
// Write language index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxLng.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes language character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::langchar_db &db)
{
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
assert(db.idxChr.size() == db.idxLng.size());
#endif
unsigned __int32 count;
// Write index count.
ZRCola::langchar_db::indexChar::size_type lc_count = db.idxChr.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (lc_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)lc_count;
stream.write((const char*)&count, sizeof(count));
// Write character index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
// Write language index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxLng.data(), sizeof(unsigned __int32)*count);
#endif
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes character group database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character group database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrgrp_db &db)
{
unsigned __int32 count;
// Write index count.
ZRCola::keyseq_db::indexChr::size_type ks_count = db.idxRnk.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (ks_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)ks_count;
stream.write((const char*)&count, sizeof(count));
// Write rank index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxRnk.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::character_db &db)
{
unsigned __int32 count;
// Write index count.
ZRCola::keyseq_db::indexChr::size_type ks_count = db.idxChr.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (ks_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)ks_count;
stream.write((const char*)&count, sizeof(count));
// Write character index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes character category database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character category database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrcat_db &db)
{
unsigned __int32 count;
// Write index count.
ZRCola::keyseq_db::indexChr::size_type ks_count = db.idxChrCat.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (ks_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)ks_count;
stream.write((const char*)&count, sizeof(count));
// Write character category index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxChrCat.data(), sizeof(unsigned __int32)*count);
// Write rank index.
if (stream.fail()) return stream;
stream.write((const char*)db.idxRnk.data(), sizeof(unsigned __int32)*count);
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
/// ///
/// Main function /// Main function
/// ///
@ -768,6 +391,7 @@ int _tmain(int argc, _TCHAR *argv[])
if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition) if (count < 0xffffffff) { // 4G check (-1 is reserved for error condition)
ZRCola::DBSource::character chr; ZRCola::DBSource::character chr;
ZRCola::character_db db; ZRCola::character_db db;
ZRCola::DBSource::character_desc_idx idxChrDsc, idxChrDscSub;
// Preallocate memory. // Preallocate memory.
db.idxChr.reserve(count); db.idxChr.reserve(count);
@ -781,7 +405,7 @@ int _tmain(int argc, _TCHAR *argv[])
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
db.data.push_back((unsigned __int16)chr.chr); db.data.push_back((unsigned __int16)chr.chr);
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++) for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)chr.cat)[i]); db.data.push_back(((const unsigned __int16*)chr.cat.data)[i]);
std::wstring::size_type n_desc = chr.desc.length(); std::wstring::size_type n_desc = chr.desc.length();
wxASSERT_MSG(n_desc <= 0xffff, wxT("character description too long")); wxASSERT_MSG(n_desc <= 0xffff, wxT("character description too long"));
db.data.push_back((unsigned __int16)n_desc); db.data.push_back((unsigned __int16)n_desc);
@ -793,6 +417,12 @@ int _tmain(int argc, _TCHAR *argv[])
for (std::wstring::size_type i = 0; i < n_rel; i++) for (std::wstring::size_type i = 0; i < n_rel; i++)
db.data.push_back(chr.rel[i]); db.data.push_back(chr.rel[i]);
db.idxChr.push_back(idx); db.idxChr.push_back(idx);
// Add description (and keywords) to index.
idxChrDsc .add_keywords(chr.desc .c_str(), chr.chr, 0);
idxChrDsc .add_keywords(chr.keywords.c_str(), chr.chr, 0);
idxChrDscSub.add_keywords(chr.desc .c_str(), chr.chr, 3);
idxChrDscSub.add_keywords(chr.keywords.c_str(), chr.chr, 3);
} else } else
has_errors = true; has_errors = true;
@ -802,6 +432,10 @@ int _tmain(int argc, _TCHAR *argv[])
// Sort indices. // Sort indices.
db.idxChr.sort(); db.idxChr.sort();
// Save text indices.
idxChrDsc .save(db.idxDsc );
idxChrDscSub.save(db.idxDscSub);
// Write characters to file. // Write characters to file.
dst << ZRCola::character_rec(db); dst << ZRCola::character_rec(db);
} else { } else {
@ -835,7 +469,7 @@ int _tmain(int argc, _TCHAR *argv[])
// Add character category to index and data. // Add character category to index and data.
unsigned __int32 idx = db.data.size(); unsigned __int32 idx = db.data.size();
for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++) for (std::wstring::size_type i = 0; i < sizeof(ZRCola::chrcatid_t)/sizeof(unsigned __int16); i++)
db.data.push_back(((const unsigned __int16*)cc.id)[i]); db.data.push_back(((const unsigned __int16*)cc.id.data)[i]);
wxASSERT_MSG((int)0xffff8000 <= cc.rank && cc.rank <= (int)0x00007fff, wxT("character category rank out of bounds")); wxASSERT_MSG((int)0xffff8000 <= cc.rank && cc.rank <= (int)0x00007fff, wxT("character category rank out of bounds"));
db.data.push_back((unsigned __int16)cc.rank); db.data.push_back((unsigned __int16)cc.rank);
std::wstring::size_type n_name = cc.name.length(); std::wstring::size_type n_name = cc.name.length();

View File

@ -48,6 +48,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <algorithm>
#include <codecvt> #include <codecvt>
#include <cwctype>
#include <fstream> #include <fstream>
#include <set> #include <set>

View File

@ -19,6 +19,7 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\src\character.cpp" />
<ClCompile Include="..\src\language.cpp" /> <ClCompile Include="..\src\language.cpp" />
<ClCompile Include="..\src\mapping.cpp" /> <ClCompile Include="..\src\mapping.cpp" />
<ClCompile Include="..\src\normalize.cpp" /> <ClCompile Include="..\src\normalize.cpp" />

View File

@ -30,6 +30,9 @@
<ClCompile Include="..\src\language.cpp"> <ClCompile Include="..\src\language.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\character.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\src\stdafx.h"> <ClInclude Include="..\src\stdafx.h">

View File

@ -23,6 +23,8 @@
#include <stdex/idrec.h> #include <stdex/idrec.h>
#include <istream> #include <istream>
#include <map>
#include <ostream>
#include <vector> #include <vector>
#include <string> #include <string>
@ -37,7 +39,55 @@ namespace ZRCola {
/// Character category ID type /// Character category ID type
/// Two letter abbreviation, non-terminated /// Two letter abbreviation, non-terminated
/// ///
typedef char chrcatid_t[2]; struct chrcatid_t {
char data[2];
inline chrcatid_t& operator=(const chrcatid_t &src)
{
data[0] = src.data[0];
data[1] = src.data[1];
return *this;
}
};
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a < \p b
/// - false otherwise
///
inline bool operator<(const chrcatid_t& a, const chrcatid_t& b)
{
if (a.data[0] < b.data[0]) return true;
else if (a.data[0] > b.data[0]) return false;
else if (a.data[1] < b.data[1]) return true;
else return false;
}
///
/// Compares two character category IDs
///
/// \param[in] a First character category ID
/// \param[in] b Second character category ID
///
/// \returns
/// - true when \p a > \p b
/// - false otherwise
///
inline bool operator>(const chrcatid_t& a, const chrcatid_t& b)
{
if (a.data[0] > b.data[0]) return true;
else if (a.data[0] < b.data[0]) return false;
else if (a.data[1] > b.data[1]) return true;
else return false;
}
/// ///
/// Character Database /// Character Database
@ -91,6 +141,8 @@ namespace ZRCola {
} }
} idxChr; ///< Character index } idxChr; ///< Character index
textindex<wchar_t, wchar_t, unsigned __int32> idxDsc; ///< Description index
textindex<wchar_t, wchar_t, unsigned __int32> idxDscSub; ///< Description index (sub-terms)
std::vector<unsigned __int16> data; ///< Character data std::vector<unsigned __int16> data; ///< Character data
public: public:
@ -98,6 +150,8 @@ namespace ZRCola {
/// Constructs the database /// Constructs the database
/// ///
inline character_db() : idxChr(data) {} inline character_db() : idxChr(data) {}
void search_by_desc(_In_z_ const wchar_t *str, _Inout_ std::map<wchar_t, unsigned long> &hits, _Inout_ std::map<wchar_t, unsigned long> &hits_sub) const;
}; };
@ -148,10 +202,9 @@ namespace ZRCola {
/// ///
virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const virtual int compare(_In_ const chrcat &a, _In_ const chrcat &b) const
{ {
int r = memcmp(a.id, b.id, sizeof(chrcatid_t)); if (a.id < b.id) return -1;
if (r != 0) return r; else if (a.id < b.id) return 1;
else return 0;
return 0;
} }
} idxChrCat; ///< Character category index } idxChrCat; ///< Character category index
@ -240,24 +293,111 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::chrcat_db, ZRCola::recordi
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::character_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::character_db &db)
{ {
unsigned __int32 count; // Read character index.
stream >> db.idxChr;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read character index. // Read description index.
db.idxChr.resize(count); stream >> db.idxDsc;
stream.read((char*)db.idxChr.data(), sizeof(unsigned __int32)*count); if (!stream.good()) return stream;
// Read sub-term description index.
stream >> db.idxDscSub;
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
///
/// Writes character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::character_db &db)
{
// Write character index.
if (stream.fail()) return stream;
stream << db.idxChr;
// Write description index.
if (!stream.good()) return stream;
stream << db.idxDsc;
// Write sub-term description index.
if (!stream.good()) return stream;
stream << db.idxDscSub;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
///
/// Writes character category database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character category database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrcat_db &db)
{
// Write character category index.
if (stream.fail()) return stream;
stream << db.idxChrCat;
// Write rank index.
if (stream.fail()) return stream;
stream << db.idxRnk;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream; return stream;
} }
@ -273,29 +413,25 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::charac
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrcat_db &db)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read character category index. // Read character category index.
db.idxChrCat.resize(count); stream >> db.idxChrCat;
stream.read((char*)db.idxChrCat.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read rank index. // Read rank index.
db.idxRnk.resize(count); stream >> db.idxRnk;
stream.read((char*)db.idxRnk.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream; return stream;
} }

View File

@ -19,6 +19,9 @@
#pragma once #pragma once
#include <istream>
#include <ostream>
#include <utility>
#include <vector> #include <vector>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <Windows.h>
@ -60,6 +63,20 @@ namespace ZRCola {
typedef unsigned __int32 recordsize_t; typedef unsigned __int32 recordsize_t;
///
/// Key-value index pair for mappings
///
#pragma pack(push)
#pragma pack(2)
template <class T>
struct mappair_t
{
T idx_key; ///< Index of key
T idx_val; ///< Index of value
};
#pragma pack(pop)
/// ///
/// Language ID type /// Language ID type
/// Three letter abbreviation, zero terminated /// Three letter abbreviation, zero terminated
@ -240,6 +257,75 @@ namespace ZRCola {
}; };
///
/// Memory text index
///
template <class T_key, class T_val, class T_idx = unsigned __int32>
class textindex : public std::vector< mappair_t<T_idx> >
{
public:
typedef std::vector< mappair_t<T_idx> > base_t;
std::vector<T_key> keys; ///< Key data
std::vector<T_val> values; ///< Index values
public:
///
/// Constructs the index
///
textindex() {}
///
/// Finds data for given key
///
/// \param[in ] key Pointer to key
/// \param[in ] key_len Count of \p key elements
/// \param[out] val Pointer to receive pointer to key's values
/// \param[out] val_len Pointer to receive count of \p val elements
///
/// \returns
/// - \c true if found
/// - \c false otherwise
///
bool find(_In_count_(key_len) const T_key *key, _In_ size_t key_len, _Out_ const T_val **val, _Out_ size_t *val_len) const
{
for (size_type start = 0, end = size(); start < end; ) {
size_type m = (start + end) / 2;
int r = compare(key, key_len, m);
if (r < 0) end = m;
else if (r > 0) start = m + 1;
else {
// Get values at position m.
size_t start = base_t::at(m ).idx_val;
*val_len = (m < size() ? base_t::at(m + 1).idx_val : values.size()) - start;
*val = &values.at(start);
return true;
}
}
return false;
}
protected:
inline int compare(_In_count_(key_len) const T_key *key, _In_ size_t key_len, size_type pos) const
{
// Get key at position pos.
size_t
start = base_t::at(pos ).idx_key,
key2_len = (pos < size() ? base_t::at(pos + 1).idx_key : keys.size()) - start;
std::vector<T_key>::const_pointer key2 = &keys.at(start);
// Compare keys.
int r = memcmp(key, key2, sizeof(T_key)*std::min<size_t>(key_len, key2_len));
if (r != 0 ) return r;
else if (key_len < key2_len) return -1;
else if (key_len > key2_len) return 1;
return 0;
}
};
/// ///
/// Source-destination index transformation mapping /// Source-destination index transformation mapping
/// ///
@ -292,4 +378,184 @@ namespace ZRCola {
}; };
}; };
///
/// Writes index to a stream
///
/// \param[in] stream Output stream
/// \param[in] idx Index
///
/// \returns The stream \p stream
///
template <class T, class T_idx, class T_data>
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::index<T, T_idx, T_data> &idx)
{
// Write index count.
ZRCola::index<T, T_idx, T_data>::size_type idx_count = idx.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)idx_count;
stream.write((const char*)&count, sizeof(count));
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(T_idx)*count);
return stream;
}
///
/// Reads index from a stream
///
/// \param[in] stream Input stream
/// \param[out] idx Index
///
/// \returns The stream \p stream
///
template <class T, class T_idx, class T_data>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::index<T, T_idx, T_data> &idx)
{
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read index data.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(T_idx)*count);
} else
idx.clear();
return stream;
}
///
/// Writes text index to a stream
///
/// \param[in] stream Output stream
/// \param[in] idx Text index
///
/// \returns The stream \p stream
///
template <class T_key, class T_val, class T_idx>
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::textindex<T_key, T_val, T_idx> &idx)
{
unsigned __int32 count;
// Write index count.
ZRCola::textindex<T_key, T_val, T_idx>::size_type idx_count = idx.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)idx_count;
stream.write((const char*)&count, sizeof(count));
// Write index data.
if (stream.fail()) return stream;
stream.write((const char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
// Write key count.
std::vector<T_key>::size_type key_count = idx.keys.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)key_count;
stream.write((const char*)&count, sizeof(count));
// Write key data.
if (stream.fail()) return stream;
stream.write((const char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
// Write value count.
std::vector<T_val>::size_type value_count = idx.values.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (idx_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
count = (unsigned __int32)value_count;
stream.write((const char*)&count, sizeof(count));
// Write value data.
if (stream.fail()) return stream;
stream.write((const char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
return stream;
}
///
/// Reads text index from a stream
///
/// \param[in] stream Input stream
/// \param[out] idx Text index
///
/// \returns The stream \p stream
///
template <class T_key, class T_val, class T_idx>
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::textindex<T_key, T_val, T_idx> &idx)
{
unsigned __int32 count;
// Read text index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read text index.
idx.resize(count);
stream.read((char*)idx.data(), sizeof(ZRCola::textindex<T_key, T_val, T_idx>::value_type)*count);
if (!stream.good()) return stream;
} else
idx.clear();
// Read keys count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read keys.
idx.keys.resize(count);
stream.read((char*)idx.keys.data(), sizeof(std::vector<T_key>::value_type)*count);
if (!stream.good()) return stream;
} else
idx.keys.clear();
// Read value count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
if (count) {
// Read values.
idx.values.resize(count);
stream.read((char*)idx.values.data(), sizeof(std::vector<T_val>::value_type)*count);
} else
idx.values.clear();
return stream;
}
#pragma warning(pop) #pragma warning(pop)

View File

@ -23,6 +23,7 @@
#include <stdex/idrec.h> #include <stdex/idrec.h>
#include <istream> #include <istream>
#include <ostream>
#include <vector> #include <vector>
#include <string> #include <string>
@ -258,6 +259,47 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::langchar_db, ZRCola::recor
const ZRCola::recordid_t stdex::idrec::record<ZRCola::language_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"LNG"; const ZRCola::recordid_t stdex::idrec::record<ZRCola::language_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"LNG";
///
/// Writes language character database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language character database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::langchar_db &db)
{
// Write character index.
if (stream.fail()) return stream;
stream << db.idxChr;
#ifdef ZRCOLA_LANGCHAR_LANG_IDX
// Write language index.
if (stream.fail()) return stream;
stream << db.idxLng;
#endif
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
/// ///
/// Reads language character database from a stream /// Reads language character database from a stream
/// ///
@ -268,31 +310,62 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::language_db, ZRCola::recor
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langchar_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langchar_db &db)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read character index. // Read character index.
db.idxChr.resize(count); stream >> db.idxChr;
stream.read((char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
#ifdef ZRCOLA_LANGCHAR_LANG_IDX #ifdef ZRCOLA_LANGCHAR_LANG_IDX
// Read language index. // Read language index.
db.idxLng.resize(count); stream >> db.idxLng;
stream.read((char*)db.idxLng.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
#endif #endif
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream;
}
///
/// Writes language database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Language database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::language_db &db)
{
// Write language index.
if (stream.fail()) return stream;
stream << db.idxLng;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream; return stream;
} }
@ -308,24 +381,21 @@ inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::langch
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::language_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::language_db &db)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read language index. // Read language index.
db.idxLng.resize(count); stream >> db.idxLng;
stream.read((char*)db.idxLng.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream; return stream;
} }

View File

@ -24,6 +24,7 @@
#include <stdex/idrec.h> #include <stdex/idrec.h>
#include <istream> #include <istream>
#include <ostream>
#include <vector> #include <vector>
#include <string> #include <string>
@ -247,6 +248,45 @@ namespace ZRCola {
const ZRCola::recordid_t stdex::idrec::record<ZRCola::translation_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"TRN"; const ZRCola::recordid_t stdex::idrec::record<ZRCola::translation_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"TRN";
///
/// Writes translation database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Translation database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::translation_db &db)
{
// Write composition index.
if (stream.fail()) return stream;
stream << db.idxComp;
// Write decomposition index.
if (stream.fail()) return stream;
stream << db.idxDecomp;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
/// ///
/// Reads translation database from a stream /// Reads translation database from a stream
/// ///
@ -257,29 +297,25 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::translation_db, ZRCola::re
/// ///
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)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read composition index. // Read composition index.
db.idxComp.resize(count); stream >> db.idxComp;
stream.read((char*)db.idxComp.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read decomposition index. // Read decomposition index.
db.idxDecomp.resize(count); stream >> db.idxDecomp;
stream.read((char*)db.idxDecomp.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream; return stream;
} }

View File

@ -0,0 +1,97 @@
/*
Copyright 2015-2016 Amebis
This file is part of ZRCola.
ZRCola is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ZRCola is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ZRCola. If not, see <http://www.gnu.org/licenses/>.
*/
#include "stdafx.h"
void ZRCola::character_db::search_by_desc(_In_z_ const wchar_t *str, _Inout_ std::map<wchar_t, unsigned long> &hits, _Inout_ std::map<wchar_t, unsigned long> &hits_sub) const
{
assert(str);
while (*str) {
// Skip white space.
for (;;) {
if (*str == 0)
return;
else if (!iswspace(*str))
break;
else
str++;
}
// Get term.
std::wstring term;
if (*str == L'"') {
const wchar_t *str_end = ++str;
for (;;) {
if (*str_end == 0) {
term.assign(str, str_end);
break;
} else if (*str_end == L'"') {
term.assign(str, str_end);
str_end++;
break;
} else
str_end++;
}
str = str_end;
} else {
const wchar_t *str_end = str + 1;
for (; *str_end && !iswspace(*str_end); str_end++);
term.assign(str, str_end);
str = str_end;
}
if (!term.empty()) {
// Find the term.
std::transform(term.begin(), term.end(), term.begin(), std::towlower);
const wchar_t *data;
size_t len;
if (idxDsc.find(term.c_str(), term.size(), &data, &len)) {
// The term was found.
for (size_t i = 0; i < len; i++) {
std::map<wchar_t, unsigned long>::iterator idx = hits.find(data[i]);
if (idx == hits.end()) {
// New character.
hits.insert(std::make_pair(data[i], 1));
} else {
// Increment existing character.
idx->second++;
}
}
}
if (idxDscSub.find(term.c_str(), term.size(), &data, &len)) {
// The term was found in the sub-term index.
for (size_t i = 0; i < len; i++) {
std::map<wchar_t, unsigned long>::iterator idx = hits_sub.find(data[i]);
if (idx == hits_sub.end()) {
// New character.
hits_sub.insert(std::make_pair(data[i], 1));
} else {
// Increment existing character.
idx->second++;
}
}
}
}
}
}

View File

@ -27,3 +27,6 @@
#include "../include/zrcola/translate.h" #include "../include/zrcola/translate.h"
#include <assert.h> #include <assert.h>
#include <algorithm>
#include <cwctype>

View File

@ -24,6 +24,7 @@
#include <stdex/idrec.h> #include <stdex/idrec.h>
#include <istream> #include <istream>
#include <ostream>
#include <vector> #include <vector>
#pragma warning(push) #pragma warning(push)
@ -126,6 +127,41 @@ namespace ZRCola {
const ZRCola::recordid_t stdex::idrec::record<ZRCola::chrgrp_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"CGR"; const ZRCola::recordid_t stdex::idrec::record<ZRCola::chrgrp_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"CGR";
///
/// Writes character group database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Character group database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::chrgrp_db &db)
{
// Write rank index.
if (stream.fail()) return stream;
stream << db.idxRnk;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
/// ///
/// Reads character group database from a stream /// Reads character group database from a stream
/// ///
@ -136,24 +172,21 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::chrgrp_db, ZRCola::recordi
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::chrgrp_db &db)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read rank index. // Read rank index.
db.idxRnk.resize(count); stream >> db.idxRnk;
stream.read((char*)db.idxRnk.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream; return stream;
} }

View File

@ -27,6 +27,7 @@
#include <wx/string.h> #include <wx/string.h>
#include <istream> #include <istream>
#include <ostream>
#include <vector> #include <vector>
#pragma warning(push) #pragma warning(push)
@ -244,6 +245,45 @@ namespace ZRCola {
const ZRCola::recordid_t stdex::idrec::record<ZRCola::keyseq_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"KEY"; const ZRCola::recordid_t stdex::idrec::record<ZRCola::keyseq_db, ZRCola::recordid_t, ZRCola::recordsize_t, ZRCOLA_RECORD_ALIGN>::id = *(ZRCola::recordid_t*)"KEY";
///
/// Writes key sequence database to a stream
///
/// \param[in] stream Output stream
/// \param[in] db Key sequence database
///
/// \returns The stream \p stream
///
inline std::ostream& operator <<(_In_ std::ostream& stream, _In_ const ZRCola::keyseq_db &db)
{
// Write character index.
if (stream.fail()) return stream;
stream << db.idxChr;
// Write key index.
if (stream.fail()) return stream;
stream << db.idxKey;
// Write data count.
std::vector<unsigned __int16>::size_type data_count = db.data.size();
#if defined(_WIN64) || defined(__x86_64__) || defined(__ppc64__)
// 4G check
if (data_count > 0xffffffff) {
stream.setstate(std::ios_base::failbit);
return stream;
}
#endif
if (stream.fail()) return stream;
unsigned __int32 count = (unsigned __int32)data_count;
stream.write((const char*)&count, sizeof(count));
// Write data.
if (stream.fail()) return stream;
stream.write((const char*)db.data.data(), sizeof(unsigned __int16)*count);
return stream;
}
/// ///
/// Reads key sequence database from a stream /// Reads key sequence database from a stream
/// ///
@ -254,29 +294,25 @@ const ZRCola::recordid_t stdex::idrec::record<ZRCola::keyseq_db, ZRCola::recordi
/// ///
inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::keyseq_db &db) inline std::istream& operator >>(_In_ std::istream& stream, _Out_ ZRCola::keyseq_db &db)
{ {
unsigned __int32 count;
// Read index count.
stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream;
// Read character index. // Read character index.
db.idxChr.resize(count); stream >> db.idxChr;
stream.read((char*)db.idxChr.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read key index. // Read key index.
db.idxKey.resize(count); stream >> db.idxKey;
stream.read((char*)db.idxKey.data(), sizeof(unsigned __int32)*count);
if (!stream.good()) return stream; if (!stream.good()) return stream;
// Read data count. // Read data count.
unsigned __int32 count;
stream.read((char*)&count, sizeof(count)); stream.read((char*)&count, sizeof(count));
if (!stream.good()) return stream; if (!stream.good()) return stream;
if (count) {
// Read data. // Read data.
db.data.resize(count); db.data.resize(count);
stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count); stream.read((char*)db.data.data(), sizeof(unsigned __int16)*count);
} else
db.data.clear();
return stream; return stream;
} }

Binary file not shown.