1 /** @file scim_x11_ic.h 2 * definition of X11IC 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 Lesser 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 Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser 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_x11_ic.h,v 1.10 2005/06/26 16:35:12 suzhe Exp $ 27 */ 28 29 #if !defined (__SCIM_X11_IC_H) 30 #define __SCIM_X11_IC_H 31 32 #include "scim_stl_map.h" 33 34 using namespace scim; 35 36 struct X11PreeditAttributes 37 { 38 XRectangle area; /* area */ 39 XRectangle area_needed; /* area needed */ 40 XPoint spot_location; /* spot location */ 41 Colormap cmap; /* colormap */ 42 CARD32 foreground; /* foreground */ 43 CARD32 background; /* background */ 44 Pixmap bg_pixmap; /* background pixmap */ 45 String base_font; /* base font of fontset */ 46 CARD32 line_space; /* line spacing */ 47 Cursor cursor; /* cursor */ 48 }; 49 50 struct X11StatusAttributes 51 { 52 XRectangle area; /* area */ 53 XRectangle area_needed; /* area needed */ 54 Colormap cmap; /* colormap */ 55 CARD32 foreground; /* foreground */ 56 CARD32 background; /* background */ 57 Pixmap bg_pixmap; /* background pixmap */ 58 String base_font; /* base font of fontset */ 59 CARD32 line_space; /* line spacing */ 60 Cursor cursor; /* cursor */ 61 }; 62 63 struct X11IC 64 { 65 int siid; /* server instance id */ 66 CARD16 icid; /* ic id */ 67 CARD16 connect_id; /* connect id */ 68 INT32 input_style; /* input style */ 69 Window client_win; /* client window */ 70 Window focus_win; /* focus window */ 71 String encoding; /* connection encoding */ 72 String locale; /* connection locale */ 73 X11PreeditAttributes pre_attr; /* preedit attributes */ 74 X11StatusAttributes sts_attr; /* status attributes */ 75 76 bool shared_siid; 77 bool xims_on; 78 bool onspot_preedit_started; 79 int onspot_preedit_length; /* preedit length of onspot mode */ 80 int onspot_caret; /* caret position of onspot mode */ 81 82 X11IC *next; 83 }; 84 85 #define SCIM_X11_IC_INPUT_STYLE (1<<0) 86 #define SCIM_X11_IC_CLIENT_WINDOW (1<<1) 87 #define SCIM_X11_IC_FOCUS_WINDOW (1<<2) 88 #define SCIM_X11_IC_ENCODING (1<<3) 89 #define SCIM_X11_IC_PRE_AREA (1<<4) 90 #define SCIM_X11_IC_PRE_AREA_NEEDED (1<<5) 91 #define SCIM_X11_IC_PRE_SPOT_LOCATION (1<<6) 92 #define SCIM_X11_IC_PRE_COLORMAP (1<<7) 93 #define SCIM_X11_IC_PRE_FOREGROUND (1<<8) 94 #define SCIM_X11_IC_PRE_BACKGROUND (1<<9) 95 #define SCIM_X11_IC_PRE_BG_PIXMAP (1<<10) 96 #define SCIM_X11_IC_PRE_FONTSET (1<<11) 97 #define SCIM_X11_IC_PRE_LINE_SPACE (1<<12) 98 #define SCIM_X11_IC_PRE_CURSOR (1<<13) 99 #define SCIM_X11_IC_STS_AREA (1<<14) 100 #define SCIM_X11_IC_STS_AREA_NEEDED (1<<15) 101 #define SCIM_X11_IC_STS_COLORMAP (1<<16) 102 #define SCIM_X11_IC_STS_FOREGROUND (1<<17) 103 #define SCIM_X11_IC_STS_BACKGROUND (1<<18) 104 #define SCIM_X11_IC_STS_BG_PIXMAP (1<<19) 105 #define SCIM_X11_IC_STS_FONTSET (1<<20) 106 #define SCIM_X11_IC_STS_LINE_SPACE (1<<21) 107 #define SCIM_X11_IC_STS_CURSOR (1<<22) 108 #define SCIM_X11_IC_FILTER_EVENTS (1<<23) 109 110 class X11ICManager 111 { 112 #if SCIM_USE_STL_EXT_HASH_MAP 113 typedef __gnu_cxx::hash_map <int, String, __gnu_cxx::hash <int> > ConnectionLocaleMap; 114 #elif SCIM_USE_STL_HASH_MAP 115 typedef std::hash_map <int, String, std::hash <int> > ConnectionLocaleMap; 116 #else 117 typedef std::map <int, String> ConnectionLocaleMap; 118 #endif 119 120 X11IC *m_ic_list; 121 X11IC *m_free_list; 122 123 ConnectionLocaleMap m_connect_locales; 124 125 public: 126 X11ICManager (); 127 ~X11ICManager (); 128 129 private: 130 /** 131 * create an empty scimX11IC struct. 132 */ 133 X11IC * new_ic (); 134 135 /** 136 * store the attributes in call_data to rec. 137 * @return a bitsets indicates which attributes are set. 138 */ 139 uint32 store_ic_values (X11IC *rec, IMChangeICStruct *call_data); 140 141 /** 142 * delete a X11IC struct according to its icid. 143 */ 144 void delete_ic (CARD16 icid); 145 146 public: 147 void new_connection (IMOpenStruct *call_data); 148 void delete_connection (IMCloseStruct *call_data); 149 150 String get_connection_locale (CARD16 connect_id); 151 152 /** 153 * Create a new X11IC struct and set its attributes. 154 * @return a bitsets indicates which attributes are set. 155 */ 156 uint32 create_ic (IMChangeICStruct *call_data, int siid); 157 158 X11IC * find_ic (CARD16 icid); 159 X11IC * find_ic_by_siid (int siid); 160 161 void destroy_ic (IMDestroyICStruct *call_data); 162 163 /** 164 * load the attributes of ic into call_data 165 * @return a bitsets indicates which attributes are loaded. 166 */ 167 uint32 get_ic_values (IMChangeICStruct *call_data); 168 169 /** 170 * store the attributes in call_data to rec. 171 * @return a bitsets indicates which attributes are set. 172 */ 173 uint32 set_ic_values (IMChangeICStruct *call_data); 174 }; 175 176 #endif // _SCIM_X11_IC_H 177 178 /* 179 vi:ts=4:nowrap:ai:expandtab 180 */ 181