Back to index

im-sdk  12.3.91
ime.h
Go to the documentation of this file.
00001 #ifndef _Ime_INFO_H_
00002 #define _Ime_INFO_H_
00003 
00004 #include "imkey.h"
00005 
00007 typedef enum {
00008     ENCODE_INVALID = -1,
00009     ENCODE_GB2312 = 0,
00010     ENCODE_GBK,
00011     ENCODE_GB18030,
00012     ENCODE_BIG5,
00013     ENCODE_BIG5HKSCS,
00014     ENCODE_EUCTW,
00015     ENCODE_EUCKR,
00016     ENCODE_EUCJP,
00017     ENCODE_EUCTH,
00018     ENCODE_UTF8,
00019     ENCODE_UTF16,
00020     ENCODE_UTF16BE,
00021     ENCODE_UTF16LE,
00022     ENCODE_UTF32,
00023     ENCODE_UCS4,
00024     ENCODE_UCS4LE,
00025     ENCODE_UCS4BE,
00026     ENCODES_NUM,
00027 } ImeEncoding;
00028 
00029 typedef struct {
00030     int keycode;        
00031     int keychar;        
00032     int modifier;       
00033     int time_stamp;     
00034 } ImeKeyRec;
00035 
00036 typedef ImeKeyRec* ImeKey;  
00037 
00038 typedef unsigned    ImHandle;
00039 
00040 typedef ImHandle    ImeInputContext;
00041 
00042 typedef enum {
00043     ImeFeedbackDecoration = 0,  
00044     ImeFeedbackForegroundRGB,   
00045     ImeFeedbackBackgroundRGB    
00046 } ImeFeedbackType;
00047 
00048 typedef enum {
00049     IME_SCOPE_SESSION = 0,
00050     IME_SCOPE_DESKTOP,
00051     IME_SCOPE_USER
00052 } ImeScopeType;
00053 
00058 typedef struct {
00059     ImeFeedbackType type;       
00060     int             value;      
00061     int             start;      
00062     int             length;     
00063 } ImeFeedbackRec;
00064 
00065 typedef ImeFeedbackRec* ImeFeedback;    
00066 
00068 typedef enum {
00069     IME_DECORATION_NORMAL       = 0,                                
00070     IME_DECORATION_REVERSE      = 1,                                
00071     IME_DECORATION_HIGHLIGHT    = (IME_DECORATION_REVERSE << 1),    
00072     IME_DECORATION_UNDERLINE    = (IME_DECORATION_HIGHLIGHT << 1),  
00073     IME_DECORATION_UNDERWAVE    = (IME_DECORATION_UNDERLINE << 1)   
00074 } ImeDecorationStyle;
00075 
00076 // values for type = ImeFeedbackForegroundRGB || ImeFeedbackBackgroundRGB
00077 #define IME_RGB_COLOR(red, green, blue)     ((int)((red<<16) + (green<<8) + blue))
00078 #define IME_RGB_COLOR_RED(color)            ((int)(color>>16))
00079 #define IME_RGB_COLOR_GREEN(color)          ((int)((color>>8)&0x00ff))
00080 #define IME_RGB_COLOR_BLUE(color)           ((int)(color&0x0000ff))
00081 
00090 typedef struct {
00091     unsigned char  *text;           
00092     unsigned int    count_feedbacks;
00093     ImeFeedbackRec *feedbacks;      
00094 } ImeTextRec;
00095 
00096 typedef ImeTextRec* ImeText;            
00097 
00099 typedef struct {
00100     int             caret;        
00101     ImeTextRec      preedit;      
00102     int             cl_start;     
00103 } ImePreeditRec;
00104 
00105 typedef ImePreeditRec* ImePreedit;      
00106 
00108 typedef enum {
00109     ImeCandidatesFirstPage    = 1,            
00110     ImeCandidatesLastPage     = 2             
00111 } ImeCandidatePageMask;
00112 
00113 typedef struct {
00114     unsigned char  *title;          
00115     int             count;          
00116     ImeText         candidates;     
00117     unsigned char  *numbers;        
00118     int             focus;          
00119     int                   page_state;     
00120     int             horizental;     
00121 } ImeCandidatesRec;
00122 
00123 typedef ImeCandidatesRec* ImeCandidates;  
00124 
00133 typedef enum {
00134     ImeProperty_String,     
00135     ImeProperty_Int,        
00136     ImeProperty_Float,      
00137     ImeProperty_Toggle,     
00138     ImeProperty_Selection,  
00139 } ImePropertyType;
00140 
00142 typedef struct {
00143     unsigned int min_length;    
00144     unsigned int max_length;    
00145 } ImeStringPropertyRangeRec;
00146 
00148 typedef struct {
00149     int min;    
00150     int max;    
00151 } ImeIntPropertyRange;
00152 
00154 typedef struct {
00155     float min;  
00156     float max;  
00157 } ImeFloatPropertyRangeRec;
00158 
00160 typedef union {
00161     ImeIntPropertyRange            int_range;         
00162     ImeStringPropertyRangeRec  len_range;         
00163     ImeFloatPropertyRangeRec   float_range;       
00164     char **                    multiString_range; 
00165 } ImePropertyRangeRec;
00166 
00168 typedef union {
00169     int              int_value;      
00170     float     float_value;    
00171     char*     string_value;   
00172 } ImePropertyValueRec;
00173 
00175 typedef struct  {
00176     int              id;      
00177     ImeEncoding             encode;  
00178     const char *     key;     
00179     const char *     name;    
00180     const char *     tip;     
00181     ImePropertyType  type;    
00182     ImePropertyRangeRec     range;   
00183     ImePropertyValueRec     value;   
00184 } ImePropertyRec;
00185 
00186 typedef ImePropertyRec* ImeProperty; 
00187 
00192 typedef struct {
00193     int           count;         
00194     ImeProperty   properties;    
00195 } ImePropertyListRec;
00196 
00197 typedef ImePropertyListRec* ImePropertyList; 
00198 
00200 typedef struct {
00201     int              version;            
00202     int              mt_safe;            
00203     ImeEncoding      encoding;           
00204     const char      *uuid;               
00205     const char      *name;               
00206     const char      *author;             
00207     const char      *hinting;            
00208     const char      *copyright;          
00209     const char      *icon_file;          
00210     const char      *support_locales;    
00211     ImePropertyList  pl;                 
00212     void            *specific_data;      
00213 } ImeInfoRec;
00214 
00215 typedef ImeInfoRec  *ImeInfo;       
00216 
00219 
00221 typedef enum {
00222     IME_EVENT_CUSTOM_DATA  = 0,    
00223     IME_EVENT_IMM_NOTIFY,          
00224     IME_EVENT_QUIT,                
00225     IME_EVENT_EXPOSE,              
00226     IME_EVENT_MOVE,                
00227     IME_EVENT_PREEDIT_DATA,        
00228     IME_EVENT_PREEDIT_CARET_MOVE,  
00229     IME_EVENT_CANDI_DATA,          
00230     IME_EVENT_PROPERTY,            
00231     IME_EVENT_CANDI_PAGE,          
00232     IME_EVENT_CANDI_FOCUS,         
00233     IME_EVENT_CANDI_SELECT,        
00234     IME_EVENT_NONE
00235 } ImeAuxEventType;
00236 
00238 typedef struct {
00239     int                  type;           
00240     ImHandle      peer;           
00241     ImeInputContext ic;             
00242     int                  param;          
00243 } ImeEventHeadRec;
00244 
00245 typedef ImeEventHeadRec* ImeEventHead;  
00246 
00247 typedef enum {
00248     IMM_TRIGGER_FULL_HALF_SIMBOL = 0,   
00249     IMM_TRIGGER_FULL_HALF_PUNC,         
00250     IMM_TRIGGER_LANGUAGE,               
00251     IMM_TRIGGER_CONFIG_REQUEST          
00252 } ImmTriggerType;
00253 
00260 typedef struct {
00261     int                  type;           
00262     ImHandle      peer;           
00263     ImeInputContext ic;             
00264     ImmTriggerType  trigger;        
00265     int             value;          
00266 } ImeEventImmNotifyRec;
00267 
00268 typedef ImeEventImmNotifyRec* ImeEventImmNotify;
00269 
00274 typedef ImeEventHeadRec     ImeQuitEventRec;
00275 typedef ImeQuitEventRec*    ImeQuitEvent;    
00276 
00278 typedef enum {
00279     IMUI_STATE_SHOW         = 1,                        
00280     IMUI_STATE_ENABLE       = (IMUI_STATE_SHOW <<1),    
00281     IMUI_STATE_CHECK        = (IMUI_STATE_ENABLE<<1)    
00282 } ImeUIStatusMask;
00283 
00285 typedef enum {
00286     ImeCandidatesPageFirst,        
00287     ImeCandidatesPagePrevious,     
00288     ImeCandidatesPageNext,         
00289     ImeCandidatesPageLast          
00290 } ImePageOperation;
00291 
00301 typedef ImeEventHeadRec     ImeExposeEventRec;
00302 typedef ImeExposeEventRec*  ImeExposeEvent;     
00303 
00304 typedef ImeEventHeadRec     ImeCandidateSelectEventRec;
00305 typedef ImeEventHeadRec     ImeCandidatePageEventRec;
00306 
00307 #define IME_MOVE_FREELY     (-65535)            ///< When used in ImeMoveEventRec, means UI determines the position/size
00308 
00317 typedef struct {
00318     int                  type;    
00319     ImHandle      peer;    
00320     ImeInputContext ic;      
00321     int                  param;   
00322     int                  left;    
00323     int             top;     
00324     int             width;   
00325     int             height;  
00326 } ImeMoveEventRec;
00327 
00328 typedef ImeMoveEventRec*    ImeMoveEvent;   
00329 
00338 typedef struct {
00339     int                  type;    
00340     ImHandle      peer;    
00341     ImeInputContext ic;      
00342     int                  param;   
00343     ImePreedit*     preedit; 
00344 } ImePreeditDataEventRec;
00345 
00346 typedef ImePreeditDataEventRec* ImePreeditDataEvent;    
00347 
00352 typedef ImeEventHeadRec              ImePreeditCaretMoveEventRec;
00353 typedef ImePreeditCaretMoveEventRec* ImePreeditCaretMoveEvent;   
00354 
00359 typedef struct  {
00360     int                  type;       
00361     ImHandle      peer;       
00362     ImeInputContext ic;         
00363     int                  param;      
00364     ImeCandidates   candidates; 
00365 } ImeCandidateDataEventRec;
00366 
00367 typedef ImeCandidateDataEventRec* ImeCandidateDataEvent;    
00368 
00370 typedef struct {
00371     int                      type;    
00372     ImHandle          peer;    
00373     ImeInputContext     ic;      
00374     int                      param;   
00375 } ImePropertyEventRec;
00376 
00377 typedef ImePropertyEventRec*    ImePropertyEvent;
00378 
00383 typedef struct  {
00384     int                      type;    
00385     ImHandle          peer;    
00386     ImeInputContext     ic;      
00387     int                      param;   
00388     int                      nInteger;
00389     int*              integers;
00390     int                      nBuf;    
00391     int*              buf_lens;
00392     unsigned char**     bufs;    
00393 } ImeDataEventRec;
00394 
00395 typedef ImeDataEventRec* ImeDataEvent;  
00396 
00397 typedef union {
00398     int                      type;                     
00399     ImeEventHeadRec          any_event;                
00400     ImeQuitEventRec          quit_event;               
00401     ImeCandidateSelectEventRec  candidate_select_event;   
00402     ImeCandidatePageEventRec    candidate_page_event;     
00403     ImeMoveEventRec         move_event;               
00404     ImeExposeEventRec               expose_event;             
00405     ImeEventImmNotifyRec        notify_event;             
00406     ImePreeditDataEventRec  preedit_data_event;       
00407     ImePreeditCaretMoveEventRec    preedit_caret_move_event; 
00408     ImeCandidateDataEventRec       candidate_data_event;     
00409     ImeDataEventRec         data_event;               
00410     ImePropertyEventRec         property_event;           
00411 } ImeEventRec;
00412 
00413 typedef ImeEventRec*            ImeEvent;       
00414 
00417 typedef enum {
00418     ImeBeepWarning, 
00419     ImeBeepError    
00420 } ImeBeepType;
00421 
00423 typedef enum {
00424     IME_FILTERED_KEY_UNUSED = 0,
00425     IME_FILTERED_KEY_ESCAPE,
00426     IME_FILTERED_KEY_ENTER,
00427     IME_FILTERED_KEY_SPACEBAR,
00428     IME_FILTERED_KEY_PAGEUP,
00429     IME_FILTERED_KEY_PAGEDOWN,
00430     IME_FILTERED_KEY_INSERT,
00431     IME_FILTERED_KEY_DELETE,
00432     IME_FILTERED_KEY_BACKSPACE,
00433     IME_FILTERED_KEY_HOME,
00434     IME_FILTERED_KEY_END,
00435     IME_FILTERED_KEY_LEFT,
00436     IME_FILTERED_KEY_RIGHT,
00437     IME_FILTERED_KEY_UP,
00438     IME_FILTERED_KEY_DOWN,
00439 } ImeKeyType;
00440 
00441 typedef enum {
00442     IMM_OK                  = 0,      
00443     IMM_FAIL                          
00444 } ImmResult;
00445 
00446 typedef struct {
00447     int        version;     
00448 
00449     ImeInfo    (*ImmGetImeInfo)(ImeInputContext ic);
00450 
00451     ImeEncoding(*ImmGetSessionEncoding)(ImeInputContext ic);
00452 
00453 
00454     ImmResult  (*ImmShowPreedit)(ImeInputContext ic);
00455 
00456     ImmResult  (*ImmHidePreedit)(ImeInputContext ic);
00457 
00458     ImmResult  (*ImmUpdatePreedit)(ImeInputContext ic, ImePreedit preedit_data);
00459 
00460     ImmResult  (*ImmMovePreeditCaret)(ImeInputContext ic, int idx);
00461 
00462     ImmResult  (*ImmShowCandidates)(ImeInputContext ic);
00463 
00464     ImmResult  (*ImmHideCandidates)(ImeInputContext ic);
00465 
00466     ImmResult  (*ImmUpdateCandidates)(ImeInputContext ic, ImeCandidates candi);
00467 
00468     ImmResult  (*ImmCommit)(ImeInputContext ic, unsigned char* commit_text);
00469 
00470 
00471     ImHandle   (*ImmStartUI)(ImeInputContext ic, const char* aux_name);
00472 
00473     ImmResult  (*ImmCloseUI)(ImeInputContext ic, ImHandle aux_handle);
00474 
00475     ImmResult  (*ImmSendUiMessage)(ImeEvent event);
00476 
00477 
00478     void*      (*ImmGetData)(ImeInputContext ic, int scope); // "scope" please ref ImeScopeType
00479 
00480     ImmResult  (*ImmSetData)(ImeInputContext ic, int scope, void* pdata);
00481 
00482 
00483     void*      (*ImmLoadUserProfile)(ImeInputContext ic, const char* category, int* psz);
00484 
00485     ImmResult  (*ImmFreeUserProfile)(void* buf);
00486 
00487     ImmResult  (*ImmSaveUserProfile)(ImeInputContext ic, const char* category, void* buf, int sz);
00488 
00489 
00490     ImmResult  (*ImmBeep)(ImeInputContext ic, ImeBeepType ime_beep_type);
00491 
00492     ImeKeyType (*ImmPrefilterKey)(ImeKey key);
00493 
00494     ImePropertyListRec* (*ImmGetPropertyList)(ImeInputContext ic);
00495 
00496 } ImmServicesRec;
00497 
00498 typedef ImmServicesRec*     ImmServices;            
00499 
00500 
00501 typedef enum {
00502     IME_OK                  = 0,        
00503     IME_FAIL,                           
00504     IME_UNUSED_KEY,                     
00505     IME_INVALID_KEY,                    
00506     IME_UNPROCESSED_EVENT,              
00507     IME_UNSUPPORT_VERSION,              
00508     IME_WRONG_ARGS,                     
00509     IME_FIRST_CUSTOM_ERROR   = 1000     
00510 } ImeResult;
00511 
00512 typedef struct {
00513     int        version;                 
00514 
00515     ImeResult  (*ImeInitialize)(ImeInfo ime_info);
00516     ImeResult  (*ImeDestroy)(ImeInfo ime_info);
00517 
00518     ImeResult  (*ImeProcessKeyEvent)(ImeInputContext ic, ImeKey ime_key);
00519     ImeResult  (*ImeProcessUIEvent)(ImeInputContext ic, ImeEvent event);
00520 
00521     ImeResult  (*ImeCreateSession)(ImeInputContext ic);
00522 
00523     ImeResult  (*ImeDestroySession)(ImeInputContext ic);
00524 
00525     ImeResult  (*ImeFocusIn)(ImeInputContext ic);
00526 
00527     ImeResult  (*ImeFocusOut)(ImeInputContext ic);
00528 
00529     ImeResult  (*ImeAttachUser)(ImeInputContext ic);
00530 
00531     ImeResult  (*ImeDetachUser)(ImeInputContext ic);
00532 
00533     ImeResult  (*ImeAttachDesktop)(ImeInputContext ic);
00534 
00535     ImeResult  (*ImeDetachDesktop)(ImeInputContext ic);
00536 
00537     const char*(*ImeGetErrorMessage)(int error_id);
00538 
00539 } ImeMethodsRec;
00540 
00541 typedef ImeMethodsRec*  ImeMethods;     
00542 
00543 #if defined(__CPLUSPLUS__) || defined(__cplusplus)
00544 extern "C"
00545 #endif
00546 ImeResult RegisterIME(ImmServices srvs, ImeInfo* ppinfo, ImeMethods* pmthds, int argc, char **argv);
00547 
00548 
00549 typedef struct {
00550     int        version;
00551     ImmResult  (*ImmSendImeMessage)(ImeEvent event);
00552     ImmResult  (*ImmCommit)(unsigned char* commit_text, ImeEncoding enc);
00553 } ImmServicesUiRec;
00554 
00555 typedef ImmServicesUiRec* ImmServicesUi;
00556 
00557 typedef struct {
00558     int        version;
00559     ImeResult  (*ImUiInitialize)(ImmServicesUi pservices);
00560     ImeResult  (*ImUiDestroy)();
00561     ImeResult  (*ImUiProcessEvent)(ImeEvent event);
00562 } ImUiMethodsRec;
00563 
00564 typedef ImUiMethodsRec*  ImUiMethods;
00565 
00566 #endif /* _Ime_INFO_H_ */