~ubuntu-branches/ubuntu/quantal/sunpinyin/quantal

« back to all changes in this revision

Viewing changes to wrapper/scim/src/sunpinyin_imengine.h

  • Committer: Package Import Robot
  • Author(s): YunQiang Su
  • Date: 2012-04-11 03:06:40 UTC
  • mfrom: (1.1.4) (1.2.8 sid)
  • Revision ID: package-import@ubuntu.com-20120411030640-8mxepz5e6wffy87c
Tags: 2.0.3+git20120404-1
* Medium urgency for fixing RC bug.
* New upstream commit: fix FTBFS with gcc-4.7 (Closes: #667385).
* Add Multi-Arch: same to libsunpinyin3, -dev and -dbg.
* Add YunQiang Su to uploaders.

Show diffs side-by-side

added added

removed removed

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