1 /** @file scim_fcitx_imengine.h
2  * definition of Fcitx related classes.
3  */
4 
5 /*
6  * Smart Common Input Method
7  *
8  * Copyright (c) 2002-2005 James Su <suzhe@tsinghua.org.cn>
9  *
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public
13  * License as published by the Free Software Foundation; either
14  * version 2 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public
22  * License along with this program; if not, write to the
23  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
24  * Boston, MA  02111-1307  USA
25  *
26  * $Id: scim_fcitx_imengine.h,v 1.2 2005/05/11 13:07:54 baohaojun Exp $
27  */
28 
29 #if !defined (__SCIM_FCITX_IMENGINE_H)
30 #define __SCIM_FCITX_IMENGINE_H
31 
32 #define Bool int
33 #define Status int
34 #define True 1
35 #define False 0
36 typedef unsigned char BYTE;
37 typedef char INT8;
38 typedef short INT16;
39 using namespace scim;
40 
41 #define DEFAULT_IMNAME "fcitx"
42 #define STRBUFLEN 64
43 
44 typedef enum _IME_STATE {
45     IS_CLOSED = 0,
46     IS_ENG,
47     IS_CHN
48 } IME_STATE;
49 
50 #ifdef SF_DEBUG
51 void FCIM_DEUBG();
52 #else
53 #define FCIM_DEUBG()
54 #endif
55 
56 class FcitxFactory : public IMEngineFactoryBase
57 {
58     WideString m_name;
59 
60     friend class FcitxInstance;
61 
62 public:
63     FcitxFactory ();
64     FcitxFactory (const WideString & name, const String & languages);
65     virtual ~FcitxFactory ();
66 
67     virtual WideString  get_name () const;
68     virtual WideString  get_authors () const;
69     virtual WideString  get_credits () const;
70     virtual WideString  get_help () const;
71     virtual String      get_uuid () const;
72     virtual String      get_icon_file () const;
73     virtual String      get_language () const;
74 
75     virtual IMEngineInstancePointer create_instance (const String& encoding, int id = -1);
76 
77 private:
78     int get_maxlen (const String &encoding);
79 };
80 
81 class FcitxInstance : public IMEngineInstanceBase
82 {
83 public:
84     static IConvert   m_gbiconv;
85 public:
86     Pointer <FcitxFactory> m_factory;
87 
88     CommonLookupTable m_lookup_table;
89     WideString        m_preedit_string;
90 
91     bool              m_unicode;
92     bool              m_forward;
93     bool              m_focused;
94     IME_STATE imeState;
95 
96     unsigned int      m_max_preedit_len;
97 
98     IConvert m_iconv;
99     Property              m_status_property;
100     Property              m_letter_property;
101     Property              m_punct_property;
102     Property              m_gbk_property;
103     Property              m_legend_property;
104     Property              m_lock_property;
105 
106 
107 public:
108     void send_string(char* str);
109     void DisplayInputWindow();
110     void ResetInputWindow();
111     void ChangeIMState();
112     FcitxInstance (FcitxFactory *factory,
113                      const String& encoding,
114                      int id = -1);
115     virtual ~FcitxInstance ();
116 
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 focus_in ();
125     virtual void focus_out ();
126     virtual void trigger_property (const String &property);
127     void refresh_status_property ();
128     void refresh_letter_property ();
129     void refresh_punct_property ();
130     void refresh_gbk_property ();
131     void refresh_legend_property ();
132     void refresh_lock_property ();
133 
134 
135 private:
136 
137     void initialize_properties ();
138 
139 };
140 
141 #endif
142 /*
143 vi:ts=4:nowrap:ai:expandtab
144 */
145