Back to index

im-sdk  12.3.91
IMProtocolStruct.h
Go to the documentation of this file.
00001 #ifndef _improtocolstruct_hh
00002 #define _improtocolstruct_hh
00003 
00004 #ifndef Bool
00005 typedef enum {
00006   True=1, False=0
00007 } Boolean;
00008 #define Bool Boolean
00009 #endif
00010 
00011 #define IMID int
00012 
00013 typedef unsigned short UTFCHAR;
00014 
00015 #define NoSymbol        0L
00016 #define BufferOverflow         -1
00017 #define LookupNone             1
00018 #define LookupChars            2
00019 #define LookupKeySym           3
00020 #define LookupBoth             4
00021 
00022 typedef enum {
00023   IM_DECORATION_FEEDBACK = 0,      /* IMNormal, IMReverse, IMUnderline */
00024   IM_FOREGROUND_RGB_FEEDBACK = 1,
00025   IM_BACKGROUND_RGB_FEEDBACK = 2,
00026   IM_UNDERLINE_RGB_FEEDBACK = 3
00027 } IMFeedbackType;
00028 
00029 typedef enum {
00030   IM_ANNOTATION_INPUT_STRING = 1,
00031   IM_ANNOTATION_READING = 2,
00032   IM_ANNOTATION_SPEECH = 3,
00033   IM_ANNOTATION_CLAUSE = 4
00034 } IMAnnotationType;
00035 
00036 typedef struct _IMAnnotationValue {
00037   int start_pos;
00038   int end_pos;
00039   int len;
00040   void *value;
00041 } IMAnnotationValue;
00042 
00043 #define IM_FEEDBACK_COUNT(feedbacks) feedbacks->count_feedbacks
00044 #define IM_FEEDBACK_TYPE(feedback) feedback->type
00045 #define IM_FEEDBACK_VALUE(feedback) feedback->value
00046 
00047 #define IM_RGB_COLOR(RED,GREEN,BLUE)      (int)((RED<<16) + (GREEN<<8) + BLUE)
00048 #define IM_RGB_COLOR_RED(COLOR)           (int)(COLOR>>16)
00049 #define IM_RGB_COLOR_GREEN(COLOR)  (int)((COLOR>>8)&0x00ff)
00050 #define IM_RGB_COLOR_BLUE(COLOR)   (int)(COLOR&0x0000ff)
00051 
00052 typedef struct _IMFeedback {
00053   IMFeedbackType type;
00054   int   value;                     /* depends on id-type */
00055 } IMFeedback;
00056 
00057 typedef struct _IMFeedbackList {
00058   unsigned int count_feedbacks;
00059   IMFeedback  *feedbacks;
00060 } IMFeedbackList;
00061 
00062 typedef struct _IMAnnotation {
00063   IMAnnotationType    type;
00064   IMAnnotationValue   value;
00065 } IMAnnotation;
00066 
00067 typedef enum {
00068   UTF16_CODESET = 0,
00069   JAEUC_CODESET = 1,
00070   JAPCK_CODESET = 2,
00071   ZHEUC_CODESET = 3,
00072   ZHGBK_CODESET = 4,
00073   TWEUC_CODESET = 5,
00074   TWBIG5_CODESET = 6,
00075   KOEUC_CODESET = 7,
00076   UTF8_CODESET = 8
00077 } IMEncoding;
00078 
00079 /* 
00080  * Define the structure used to exchange text
00081 */
00082 typedef struct _IMText {
00083   IMEncoding    encoding;
00084   unsigned int         char_length;
00085   union {
00086     UTFCHAR     *utf_chars; /* UTF16 */
00087     char        *native_chars;/* non-UTF16  */
00088   } text;
00089   IMFeedbackList  *feedback;
00090   unsigned int    count_annotations;
00091   IMAnnotation         *annotations;
00092 } IMText;
00093 
00094 /* Operation related Data structures */
00095 typedef struct _IMOperation {
00096     unsigned int id;        /* operation id */
00097     int length;                 /* length of value */
00098     void *value;                /* contents, contents in ccdef case */
00099 } IMOperation, *IMOperationList;
00100 
00101 /*
00102  * Event Type
00103  */
00104 
00105 typedef enum {
00106     IM_EventKeyList = 1,
00107     IM_EventString = 2,
00108     IM_EventText = 3,
00109     IM_EventAux = 4,
00110     IM_EventX = 100
00111 } IM_Event_Type;
00112 
00113 /*
00114  * a key event for IMKeyListEvent
00115  */
00116 
00117 typedef struct _IMKeyEventStruct {
00118    int keyCode;
00119    int keyChar;
00120    int modifier;
00121    int time_stamp;
00122 } IMKeyEventStruct, *IMKeyList;
00123 
00124 /*
00125  * keylist event
00126  */
00127 typedef struct _IMKeyListEvent {
00128     int type;
00129     int n_operation;
00130     IMOperationList operation_list;
00131 
00132     int n_key;
00133     IMKeyList keylist;
00134 } IMKeyListEvent;
00135 
00136 /*
00137  * Data structures for Preedit
00138 */
00139 
00140 #define IMNormal               0
00141 #define IMReverse              1
00142 #define IMUnderline            2
00143 
00144 typedef struct _IMPreeditDrawCallbackStruct {
00145   int caret;          /* Cursor offset within pre-edit string */
00146   int chg_first;      /* Starting change position */
00147   int chg_length;     /* Length of the change in character count */
00148   IMText *text;
00149 } IMPreeditDrawCallbackStruct;
00150 
00151 typedef enum {
00152   IMForwardChar, IMBackwardChar,
00153   IMForwardWord, IMBackwardWord,
00154   IMCaretUp, IMCaretDown,
00155   IMNextLine, IMPreviousLine,
00156   IMLineStart, IMLineEnd,
00157   IMAbsolutePosition,
00158   IMDontChange
00159 } IMCaretDirection;
00160 
00161 typedef enum {
00162   IMIsInvisible,     /* Disable caret feedback */
00163   IMIsPrimary,       /* UI defined caret feedback */
00164   IMIsSecondary      /* UI defined caret feedback */
00165 } IMCaretStyle;
00166 
00167 typedef struct _IMPreeditCaretCallbackStruct {
00168   int position;               /* Caret offset within pre-edit string */
00169   IMCaretDirection direction; /* Caret moves direction */
00170   IMCaretStyle style;         /* Feedback of the caret */
00171 } IMPreeditCaretCallbackStruct;
00172 
00173 struct IMPreeditStruct {
00174   union {
00175     int return_value;
00176     IMPreeditDrawCallbackStruct draw;
00177     IMPreeditCaretCallbackStruct caret;
00178   } todo;
00179 };
00180 
00181 /*
00182  * Data structures for Status 
00183 */ 
00184 typedef struct _IMStatusDrawCallbackStruct {
00185   IMText *text;
00186 } IMStatusDrawCallbackStruct;
00187 
00188 struct IMStatusStruct {
00189   union {
00190     IMStatusDrawCallbackStruct draw;      /* StatusDraw */
00191   } todo;
00192 };
00193 
00194 /*
00195  * Data structures for Lookup
00196 */
00197 
00198 #define IM_LUC_LABEL_NONE               0
00199 #define IM_LUC_LABEL_NUMERIC            1
00200 #define IM_LUC_LABEL_ALPHABETIC         2
00201 #define IM_LUC_LABEL_ALPHA_UPPER        3
00202 
00203 typedef enum {
00204   HasNotBeenNegotiated = 0,
00205   IMIsMaster = 1,
00206   CBIsMaster  = 2
00207 } WhoIsMaster;
00208  
00209 typedef enum {
00210   DrawUpHorizontally = 0,
00211   DrawUpVertically = 1
00212 } DrawUpDirection;
00213  
00214 typedef enum {
00215   IMOwnsLabel = 0 ,
00216   CBOwnsLabel = 1
00217 } WhoOwnsLabel;
00218 
00219 typedef struct _LayoutInfo {
00220   int choice_per_window;  /* Number of choices can be display
00221                         * in the region
00222                         */
00223   int nrows;
00224   int ncolumns;
00225   DrawUpDirection drawUpDirection ;
00226   WhoOwnsLabel whoOwnsLabel;      /* For callback to tell XIM
00227                                * whether it wants to control
00228                                * what label should be for the choices.
00229                                */
00230   int luc_is_rootwindow;
00231   int label_type;
00232   int root_width;
00233   int root_lines;
00234   int e_width_per_can;
00235   int max_width_per_car;
00236 } LayoutInfo;
00237 
00238 typedef struct _IMLookupStartCallbackStruct {
00239     IMKeyListEvent *event;
00240     WhoIsMaster whoIsMaster;    /* For callback to tell whether is
00241                                  * going to be a master */
00242     LayoutInfo *IMPreference;
00243     LayoutInfo *CBPreference;
00244 }   IMLookupStartCallbackStruct;
00245 
00246 typedef struct _IMChoiceObject {
00247   IMText *label;
00248   IMText *value;
00249 } IMChoiceObject;
00250 
00251 typedef struct _IMLookupDrawCallbackStruct {
00252   IMChoiceObject *choices;       /* the lookup choices */
00253   int n_choices;      /* Total number of lookup choices */
00254   int max_len;        /* Max number of characters per
00255                      * choice item
00256                      */
00257   int index_of_first_candidate ;
00258   int index_of_last_candidate ;
00259   int index_of_current_candidate ;
00260   IMText *title;
00261 } IMLookupDrawCallbackStruct;
00262 
00263 typedef enum {
00264   LookupIndex=0,
00265   LookupPage=1
00266 } IMLookupProcessOperationType;
00267 
00268 typedef enum {
00269   LookupNextPage=1,
00270   LookupPrevPage=2,
00271   LookupFirstPage=3,
00272   LookupLastPage=4
00273 } IMLookupProcessPageOperationType;
00274 
00275 typedef struct _IMLookupProcessCallbackStruct {
00276   IMLookupProcessOperationType type;
00277                                 /* Index(#0) index_of_choice_selected */
00278                                 /* Page(#1)  page_operation_id */
00279   union {
00280     int index_of_choice_selected;/* Set by callback for the
00281                               * selected choice.
00282                               * IM_UNKNOW_KEYSYM and
00283                               * IM_UNDETERMINED are
00284                               * also possible value.
00285                               */
00286     IMLookupProcessPageOperationType page_operation_id;
00287   } value;
00288 } IMLookupProcessCallbackStruct;
00289 
00290 /*
00291  * Values for IMLookupProcessCallbackStruct.index_of_choice_selected
00292  */
00293 #define         IM_UNKNOWN_KEYSYM       0x77777777
00294 #define         IM_UNDETERMINED 0x77777776
00295 #define         IM_UNKNOWN_CONTROL      0x77777775
00296 
00297 
00298 struct IMLookupStruct {
00299   union {
00300     IMLookupStartCallbackStruct start;    /* LookupStart */
00301     IMLookupDrawCallbackStruct draw;      /* LookupDraw */
00302     IMLookupProcessCallbackStruct process;       /* LookupProcess */
00303   } todo;
00304 };
00305 
00306 /*
00307  * Data structures for Auxiliary 
00308 */
00309 typedef struct _IMAuxBasicCallbackStruct {
00310   char *aux_name;
00311   int  aux_index;    /* do not use in 2.0 */
00312 } IMAuxBasicCallbackStruct, IMAuxStartCallbackStruct, IMAuxDoneCallbackStruct;
00313 
00314 typedef struct _IMAuxDrawCallbackStruct {
00315   char *aux_name;
00316   int  aux_index;    /* do not use in 2.0 */
00317   int  count_integer_values;
00318   int  *integer_values;
00319   int  count_string_values;
00320   IMText *string_values;
00321 } IMAuxDrawCallbackStruct;
00322 
00323 struct IMAuxStruct {
00324   union {
00325     IMAuxStartCallbackStruct start; /* AuxStart */
00326     IMAuxDrawCallbackStruct draw;   /* AuxDraw  */
00327     IMAuxDoneCallbackStruct done;   /* AuxDone  */
00328   } todo;
00329 };
00330 
00331 /*
00332  * Object Downloading
00333  */
00334 
00335 typedef enum {
00336     IM_GUI_OBJECT = 0,
00337     IM_LWE_OBJECT = 1,
00338     IM_SYNTAX_RULE_OBJECT = 2,
00339     IM_MANAGER_RULE_OBJECT = 3,
00340     IM_PRELOADING_LWE_OBJECT = 4
00341 }   IMObjectCategory;
00342 
00343 typedef enum {
00344     IM_DOWNLOADINGOBJECT_JARGUI_TYPE = 0x1031,
00345     IM_DOWNLOADINGOBJECT_JARLWE_TYPE = 0x1032,
00346     IM_DOWNLOADINGOBJECT_CCDEF_TYPE = 0x1030,
00347 
00348     IM_DOWNLOADINGOBJECT_BINGUI_TYPE = 0x1033,
00349     IM_DOWNLOADINGOBJECT_BINLWE_TYPE = 0x1034,
00350 
00351     IM_DOWNLOADINGOBJECT_SGUI_TYPE = 0x1035,
00352     IM_DOWNLOADINGOBJECT_SLWE_TYPE = 0x1036
00353 }   IMObjectType;
00354 
00355 typedef struct _IMObjectDescriptorStruct {
00356     char *leid;                 /* id for LE, `sampleja' */
00357     IMObjectType type;
00358     unsigned int id;        /* assigined dynamically by LELookup */
00359     unsigned int size;             /* object size */
00360 
00361     char **class_names;            /* only for JARFILE_OBJECT */
00362     unsigned int count_names;      /* count of class names */
00363                             /* only for CCDEF */
00364     UTFCHAR *name;                 /* HRN */
00365     int name_length;        /* HRN len in UTF16-char unit */
00366     char *domain;               /* reversed domain */
00367     char *path;                    /* path for object */
00368     char *scope;            /* usability id or `generic' */
00369 
00370                             /* only for CCDEF */
00371     char *signature;        /* Object signature */
00372     char *basepath;         /* base path for include tag */
00373     char *encoding;         /* encoding of CCDEF */
00374 } IMObjectDescriptorStruct;
00375 
00376 /*
00377  * string event
00378  */
00379 typedef struct _IMStringEvent {
00380     int type;
00381     int n_operation;
00382     IMOperationList operation_list;
00383     UTFCHAR *string;
00384 } IMStringEvent;
00385 
00386 /*
00387  * text event
00388  */
00389 typedef struct _IMTextEvent {
00390     int type;
00391     int n_operation;
00392     IMOperationList operation_list;
00393     IMText *text;
00394 } IMTextEvent;
00395 
00396 /*
00397  * event for Auxiliary
00398  */
00399 typedef struct _IMAuxEvent {
00400     int type;
00401     IMAuxDrawCallbackStruct *aux;
00402 } IMAuxEvent;
00403 
00404 /*
00405  * event for X, only for XSunIM's if_FilterEvent()
00406  */
00407 typedef struct _IMXEvent {
00408     int type;
00409     void *xevent;
00410 } IMXEvent;
00411 
00412 /*
00413  * IMInputEvent
00414  */
00415 typedef union IMInputEvent_ {
00416     int type;
00417     IMKeyListEvent keylist;
00418     IMTextEvent string;
00419     IMStringEvent text;
00420     IMAuxEvent aux;
00421     IMXEvent xevent;
00422 } IMInputEvent;
00423 
00424 #endif