diff options
author | Peng Wu <alexepico@gmail.com> | 2014-04-17 17:24:03 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2014-04-17 17:24:03 +0800 |
commit | b6e80e9831529cc4f7bcca45dafff8d807fd6423 (patch) | |
tree | 672de71decb4050d9e32b8060e25fc8277e743fb | |
parent | 18311e8b50a5c0d63d47014f7d2352aa0a688009 (diff) | |
download | ibus-libzhuyin-b6e80e9831529cc4f7bcca45dafff8d807fd6423.tar.gz ibus-libzhuyin-b6e80e9831529cc4f7bcca45dafff8d807fd6423.tar.xz ibus-libzhuyin-b6e80e9831529cc4f7bcca45dafff8d807fd6423.zip |
write class PhoneticEditor in progress
-rw-r--r-- | src/ZYZEnhancedEditor.cc | 12 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.cc | 102 | ||||
-rw-r--r-- | src/ZYZPhoneticEditor.h | 5 |
3 files changed, 118 insertions, 1 deletions
diff --git a/src/ZYZEnhancedEditor.cc b/src/ZYZEnhancedEditor.cc index 63d6117..524c6a0 100644 --- a/src/ZYZEnhancedEditor.cc +++ b/src/ZYZEnhancedEditor.cc @@ -98,4 +98,16 @@ EnhancedEditor::processKeyEvent (guint keyval, guint keycode, guint modifiers) } } +void +EnhancedEditor::update (void) +{ + Editor::update (); +} + +void +EnhancedEditor::reset (void) +{ + Editor::reset (); +} + }; diff --git a/src/ZYZPhoneticEditor.cc b/src/ZYZPhoneticEditor.cc index 1356e7f..2a80263 100644 --- a/src/ZYZPhoneticEditor.cc +++ b/src/ZYZPhoneticEditor.cc @@ -173,4 +173,106 @@ PhoneticEditor::processCandidateKey (guint keyval, guint keycode, return TRUE; } +gboolean +PhoneticEditor::processKeyEvent (guint keyval, guint keycode, + guint modifiers) +{ + return FALSE; +} + +void +PhoneticEditor::updateLookupTableFast (void) +{ + Editor::updateLookupTableFast (m_lookup_table, TRUE); +} + +void +PhoneticEditor::updateLookupTable (void) +{ + m_lookup_table.clear (); + + fillLookupTableByPage (); + if (m_lookup_table.size ()) { + Editor::updateLookupTable (m_lookup_table, TRUE); + } else { + hideLookupTable (); + } +} + +gboolean +PhoneticEditor::fillLookupTableByPage (void) +{ + assert (FALSE); +} + +void +PhoneticEditor::pageUp (void) +{ + if (G_LIKELY (m_lookup_table.pageUp ())) { + updateLookupTableFast (); + updatePreeditText (); + updateAuxiliaryText (); + } +} + +void +PhoneticEditor::pageDown (void) +{ + if (G_LIKELY ((m_lookup_table.pageDown ()) || + (fillLookupTableByPage () && m_lookup_table.pageDown ()))) { + updateLookupTableFast (); + updatePreeditText (); + updateAuxiliaryText (); + } +} + +void +PhoneticEditor::cursorUp (void) +{ + if (G_LIKELY (m_lookup_table.cursorUp ())) { + updateLookupTableFast (); + updatePreeditText (); + updateAuxiliaryText (); + } +} + +void +PhoneticEditor::cursorDown (void) +{ + if (G_LIKELY ((m_lookup_table.cursorPos () == m_lookup_table.size() - 1) && + (fillLookupTableByPage () == FALSE))) { + return; + } + + if (G_LIKELY (m_lookup_table.cursorDown ())) { + updateLookupTableFast (); + updatePreeditText (); + updateAuxiliaryText (); + } +} + +void +PhoneticEditor::candidateClicked (guint index, guint button, + guint state) +{ + selectCandidateInPage (index); +} + +void +PhoneticEditor::reset (void) +{ + m_lookup_table.clear (); + m_buffer = ""; + + zhuyin_reset (m_instance); + + zhuyin_instance_vec::iterator iter; + for (; iter != m_instances.end (); ++iter) { + zhuyin_free_instance (*iter); + } + m_instances.clear (); + + EnhancedEditor::reset (); +} + }; diff --git a/src/ZYZPhoneticEditor.h b/src/ZYZPhoneticEditor.h index e33121f..b8f9db7 100644 --- a/src/ZYZPhoneticEditor.h +++ b/src/ZYZPhoneticEditor.h @@ -39,6 +39,9 @@ class PhoneticEditor : public EnhancedEditor { friend class SymbolSection; friend class PhoneticSection; +protected: + typedef std::vector<zhuyin_instance_t *> zhuyin_instance_vec; + public: PhoneticEditor (ZhuyinProperties & props, Config & config); virtual ~PhoneticEditor (void); @@ -98,7 +101,7 @@ protected: SymbolSectionPtr m_symbol_sections[STATE_LAST]; PhoneticSectionPtr m_phonetic_section; - std::vector<zhuyin_instance_t *> m_instances; + zhuyin_instance_vec m_instances; }; }; |