299e42511b35ef946f3a96a31aa33962027df193
[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     bool                 m_lookup_table_always_on;
93     
94   public:
95     SunPyInstance(SunPyFactory *factory,
96                   CHotkeyProfile *hotkey_profile,
97                   const String& encoding, int id);
98     virtual ~SunPyInstance();
99     /**
100      * - mode switch key
101      * - toggle full width punctuation mode
102      * - toggle full width letter mode
103      * - chinese/english switch
104      * - caret left/right/home/end
105      * - candidate table cursor_up/cursor_down/page_up/page_down/number_select
106      * - backspace/delete
107      * - space/enter
108      */
109     virtual bool process_key_event (const KeyEvent& key);
110     virtual void move_preedit_caret (unsigned int pos);
111     virtual void select_candidate (unsigned int item);
112     virtual void update_lookup_table_page_size (unsigned int page_size);
113     virtual void lookup_table_page_up ();
114     virtual void lookup_table_page_down ();
115     virtual void reset ();
116     virtual void focus_in ();
117     virtual void focus_out ();
118     virtual void flush ();
119     /**
120      * update the configuration of the input method
121      */
122     virtual void trigger_property (const String &property);
123     /**
124      * decide whether to display candidate window according to layout
125      */
126     virtual void set_layout (unsigned int layout);
127
128 public:
129     /**
130      * expose this inherited protected method
131      * so that CScimWinHandler can call it
132      */
133     using IMEngineInstanceBase::commit_string;
134     
135     void refresh_status_property(bool cn);
136     void refresh_fullsymbol_property(bool full);
137     void refresh_fullpunc_property(bool full);
138     void redraw_preedit_string(const IPreeditString* ppd);
139     void redraw_lookup_table(const ICandidateList* pcl);
140
141 private:
142     void create_session(CHotkeyProfile*);
143     void destroy_session();
144     
145     void init_lookup_table_labels ();
146     void reload_config (const ConfigPointer &config);
147     void refresh_all_properties ();
148     void initialize_all_properties();
149     
150     AttributeList build_preedit_attribs(const IPreeditString* ppd);
151
152     void lookup_page_up();
153     void lookup_page_down();
154 };
155
156 // emacs: -*- c++-mode -*-
157 #endif//SUNPINYIN_IMENGINE_H