1 /** @file scim_hangul_imengine.h
5 * Smart Common Input Method
7 * Copyright (C) 2004-2006 Choe Hwanjin
8 * Copyright (c) 2004-2006 James Su <suzhe@tsinghua.org.cn>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24 * $Id: scim_hangul_imengine.h,v 1.17 2007/05/27 13:08:07 hwanjin Exp $
27 #if !defined (__SCIM_HANGUL_IMENGINE_H)
28 #define __SCIM_HANGUL_IMENGINE_H
43 OUTPUT_MODE_SYLLABLE = 0,
44 OUTPUT_MODE_JAMO = 1 << 1,
45 OUTPUT_MODE_JAMO_EXT = 1 << 2
48 class HangulFactory : public IMEngineFactoryBase
53 ConfigPointer m_config;
55 String m_keyboard_layout;
57 bool m_always_use_jamo;
59 bool m_show_candidate_comment;
60 bool m_lookup_table_vertical;
61 bool m_use_ascii_mode;
62 bool m_commit_by_word;
65 KeyEventList m_hangul_keys;
66 KeyEventList m_hanja_keys;
67 KeyEventList m_hanja_mode_keys;
69 Connection m_reload_signal_connection;
71 HanjaTable* m_hanja_table;
72 HanjaTable* m_symbol_table;
74 friend class HangulInstance;
77 HangulFactory (const ConfigPointer &config);
79 virtual ~HangulFactory ();
81 virtual WideString get_name () const;
82 virtual WideString get_authors () const;
83 virtual WideString get_credits () const;
84 virtual WideString get_help () const;
85 virtual String get_uuid () const;
86 virtual String get_icon_file () const;
88 virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1);
91 void reload_config (const ConfigPointer &config);
94 class HangulInstance : public IMEngineInstanceBase
96 HangulFactory *m_factory;
98 CommonLookupTable m_lookup_table;
99 std::vector<String> m_candidate_comments;
100 WideString m_preedit;
101 WideString m_surrounding_text;
105 HangulInputContext *m_hic;
111 HangulInstance (HangulFactory *factory,
112 const String &encoding,
115 virtual ~HangulInstance ();
117 virtual bool process_key_event (const KeyEvent& key);
118 virtual void move_preedit_caret (unsigned int pos);
119 virtual void select_candidate (unsigned int item);
120 virtual void update_lookup_table_page_size (unsigned int page_size);
121 virtual void lookup_table_page_up ();
122 virtual void lookup_table_page_down ();
123 virtual void reset ();
124 virtual void flush ();
125 virtual void focus_in ();
126 virtual void focus_out ();
127 virtual void trigger_property (const String &property);
130 bool is_backspace_key (const KeyEvent &key) const {
131 return (key.code == SCIM_KEY_BackSpace);
134 bool is_hangul_key (const KeyEvent &key) const {
135 return match_key_event (m_factory->m_hangul_keys, key);
138 bool is_hanja_key (const KeyEvent &key) const {
139 return match_key_event (m_factory->m_hanja_keys, key);
142 bool is_hanja_mode_key (const KeyEvent &key) const {
143 return match_key_event (m_factory->m_hanja_mode_keys, key);
147 WideString get_preedit_string () {
148 WideString wstr = m_preedit;
149 const ucschar *str = hangul_ic_get_preedit_string(m_hic);
151 wstr.push_back (*str++);
155 WideString get_commit_string () {
157 const ucschar *str = hangul_ic_get_commit_string(m_hic);
158 while (*str != L'\0')
159 wstr.push_back (*str++);
163 void hangul_update_preedit_string ();
165 bool use_ascii_mode() {
166 return m_factory->m_use_ascii_mode;
169 bool is_hangul_mode() {
170 return m_hangul_mode;
173 bool is_hanja_mode() {
174 return m_factory->m_hanja_mode;
177 void toggle_hangul_mode();
178 void toggle_hanja_mode();
179 void change_keyboard_layout(const String &layout);
181 /* property handling */
182 void register_all_properties();
185 void hangul_update_aux_string ();
187 /* candidate functions */
188 String get_candidate_string();
189 void update_candidates ();
190 void delete_candidates ();
193 bool candidate_key_event (const KeyEvent &key);
195 /* match key event */
196 bool match_key_event (const KeyEventList &keys, const KeyEvent &key) const;
201 vi:ts=4:nowrap:ai:expandtab