Tizen 2.1 base
[platform/core/uifw/ise-engine-sunpinyin.git] / wrapper / scim / src / sunpinyin_imengine.h
1 /*
2  * Copyright (c) 2007 Kov Chai <tchaikov@gmail.com>
3  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4  *
5  * The contents of this file are subject to the terms of either the GNU Lesser
6  * General Public License Version 2.1 only ("LGPL") or the Common Development and
7  * Distribution License ("CDDL")(collectively, the "License"). You may not use this
8  * file except in compliance with the License. You can obtain a copy of the CDDL at
9  * http://www.opensource.org/licenses/cddl1.php and a copy of the LGPLv2.1 at
10  * http://www.opensource.org/licenses/lgpl-license.php. See the License for the 
11  * specific language governing permissions and limitations under the License. When
12  * distributing the software, include this License Header Notice in each file and
13  * include the full text of the License in the License file as well as the
14  * following notice:
15  * 
16  * NOTICE PURSUANT TO SECTION 9 OF THE COMMON DEVELOPMENT AND DISTRIBUTION LICENSE
17  * (CDDL)
18  * For Covered Software in this distribution, this License shall be governed by the
19  * laws of the State of California (excluding conflict-of-law provisions).
20  * Any litigation relating to this License shall be subject to the jurisdiction of
21  * the Federal Courts of the Northern District of California and the state courts
22  * of the State of California, with venue lying in Santa Clara County, California.
23  * 
24  * Contributor(s):
25  * 
26  * If you wish your version of this file to be governed by only the CDDL or only
27  * the LGPL Version 2.1, indicate your decision by adding "[Contributor]" elects to
28  * include this software in this distribution under the [CDDL or LGPL Version 2.1]
29  * license." If you don't indicate a single choice of license, a recipient has the
30  * option to distribute your version of this file under either the CDDL or the LGPL
31  * Version 2.1, or to extend the choice of license to its licensees as provided
32  * above. However, if you add LGPL Version 2.1 code and therefore, elected the LGPL
33  * Version 2 license, then the option applies only if the new code is made subject
34  * to such option by the copyright holder. 
35  *
36  * Modifications by Samsung Electronics Co., Ltd.
37  *
38  * 1.Added always candidate show feature
39  * 2.Added auto commit feature for mobile user
40  */
41
42 #ifndef SUNPINYIN_IMENGINE_H
43 #define SUNPINYIN_IMENGINE_H
44
45 using namespace scim;
46
47 class CHotkeyProfile;
48
49 class SunPyFactory : public IMEngineFactoryBase
50 {
51     ConfigPointer       m_config;
52     bool                m_valid;
53     WideString          m_name;
54     Connection          m_reload_signal_connection;
55     CHotkeyProfile     *m_hotkey_profile;
56
57     friend class SunPyInstance;
58     
59 public:
60     SunPyFactory (const ConfigPointer &config);
61
62     virtual ~SunPyFactory ();
63
64     virtual WideString  get_name () const;
65     virtual WideString  get_authors () const;
66     virtual WideString  get_credits () const;
67     virtual WideString  get_help () const;
68     virtual String      get_uuid () const;
69     virtual String      get_icon_file () const;
70
71     virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1);
72     
73 public:
74     bool valid () const { return m_valid; }
75     void reload_config(const ConfigPointer& config);
76     
77 private:
78     bool init ();
79     bool load_user_config ();
80 };
81
82 class SunPyInstance : public IMEngineInstanceBase
83 {
84     SunPyFactory        *m_factory;
85     CIMIView            *m_pv;
86     CScimWinHandler     *m_wh;
87     CHotkeyProfile      *m_hotkey_profile;
88     SunLookupTable      *m_lookup_table;
89     CommonLookupTable   *m_common_lookup_table;
90     Connection           m_reload_signal_connection;
91     bool                 m_focused;
92     
93   public:
94     SunPyInstance(SunPyFactory *factory,
95                   CHotkeyProfile *hotkey_profile,
96                   const String& encoding, int id);
97     virtual ~SunPyInstance();
98     /**
99      * - mode switch key
100      * - toggle full width punctuation mode
101      * - toggle full width letter mode
102      * - chinese/english switch
103      * - caret left/right/home/end
104      * - candidate table cursor_up/cursor_down/page_up/page_down/number_select
105      * - backspace/delete
106      * - space/enter
107      */
108     virtual bool process_key_event (const KeyEvent& key);
109     virtual void move_preedit_caret (unsigned int pos);
110     virtual void select_candidate (unsigned int item);
111     virtual void update_lookup_table_page_size (unsigned int page_size);
112     virtual void lookup_table_page_up ();
113     virtual void lookup_table_page_down ();
114     virtual void reset ();
115     virtual void focus_in ();
116     virtual void focus_out ();
117     virtual void flush ();
118     /**
119      * update the configuration of the input method
120      */
121     virtual void trigger_property (const String &property);
122
123 public:
124     /**
125      * expose this inherited protected method
126      * so that CScimWinHandler can call it
127      */
128     using IMEngineInstanceBase::commit_string;
129     
130     void refresh_status_property(bool cn);
131     void refresh_fullsymbol_property(bool full);
132     void refresh_fullpunc_property(bool full);
133     void redraw_preedit_string(const IPreeditString* ppd);
134     void redraw_lookup_table(const ICandidateList* pcl);
135
136 private:
137     void create_session(CHotkeyProfile*);
138     void destroy_session();
139     
140     void init_lookup_table_labels ();
141     void reload_config (const ConfigPointer &config);
142     void refresh_all_properties ();
143     void initialize_all_properties();
144     
145     AttributeList build_preedit_attribs(const IPreeditString* ppd);
146
147     void lookup_page_up();
148     void lookup_page_down();
149 };
150
151 // emacs: -*- c++-mode -*-
152 #endif//SUNPINYIN_IMENGINE_H