Back to index

im-sdk  12.3.91
IMProtocolStruct.h
Go to the documentation of this file.
00001 /*
00002 Copyright 1990-2001 Sun Microsystems, Inc. All Rights Reserved.
00003 
00004 Permission is hereby granted, free of charge, to any person obtaining a
00005 copy of this software and associated documentation files (the
00006 "Software"), to deal in the Software without restriction, including
00007 without limitation the rights to use, copy, modify, merge, publish,
00008 distribute, sublicense, and/or sell copies of the Software, and to
00009 permit persons to whom the Software is furnished to do so, subject to
00010 the following conditions: The above copyright notice and this
00011 permission notice shall be included in all copies or substantial
00012 portions of the Software.
00013 
00014 
00015 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
00019 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00020 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
00021 THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
00022 ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
00023 
00024 
00025 Except as contained in this notice, the names of The Open Group and/or
00026 Sun Microsystems, Inc. shall not be used in advertising or otherwise to
00027 promote the sale, use or other dealings in this Software without prior
00028 written authorization from The Open Group and/or Sun Microsystems,
00029 Inc., as applicable.
00030 
00031 
00032 X Window System is a trademark of The Open Group
00033 
00034 OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
00035 logo, LBX, X Window System, and Xinerama are trademarks of the Open
00036 Group. All other trademarks and registered trademarks mentioned herein
00037 are the property of their respective owners. No right, title or
00038 interest in or to any trademark, service mark, logo or trade name of
00039 Sun Microsystems, Inc. or its licensors is granted.
00040 
00041 */
00042 #ifndef _improtocolstruct_hh
00043 #define _improtocolstruct_hh
00044 
00045 #ifdef HAVE_CONFIG_H
00046 #include <config.h>
00047 #endif
00048 
00049 #include "syscfg.h"
00050 
00051 #ifndef Bool
00052 typedef enum {
00053   True=1, False=0
00054 } Bool;
00055 #endif
00056 
00057 #define IMID int
00058 
00059 typedef unsigned short UTFCHAR;
00060 
00061 #define NoSymbol        0L
00062 #define BufferOverflow         -1
00063 #define LookupNone             1
00064 #define LookupChars            2
00065 #define LookupKeySym           3
00066 #define LookupBoth             4
00067 
00068 typedef enum {
00069   IM_DECORATION_FEEDBACK = 0,      /* IMNormal, IMReverse, IMUnderline */
00070   IM_FOREGROUND_RGB_FEEDBACK = 1,
00071   IM_BACKGROUND_RGB_FEEDBACK = 2,
00072   IM_UNDERLINE_RGB_FEEDBACK = 3
00073 } IMFeedbackType;
00074 
00075 typedef enum {
00076   IM_ANNOTATION_INPUT_STRING = 1,
00077   IM_ANNOTATION_READING = 2,
00078   IM_ANNOTATION_SPEECH = 3,
00079   IM_ANNOTATION_CLAUSE = 4,
00080 
00081   IM_ANNOTATION_FEEDBACK = 0x10,
00082   IM_ANNOTATION_CURRENT = 0x12,
00083   IM_ANNOTATION_CANDIDATES = 0x11,
00084   IM_ANNOTATION_SELECTED_CANDIDATES = 0x12
00085 } IMAnnotationType;
00086 
00087 typedef struct _IMAnnotationValue {
00088   int start_pos;
00089   int end_pos;
00090   int len;
00091   void *value;
00092 } IMAnnotationValue;
00093 
00094 #define IM_FEEDBACK_COUNT(feedbacks) feedbacks->count_feedbacks
00095 #define IM_FEEDBACK_TYPE(feedback) feedback->type
00096 #define IM_FEEDBACK_VALUE(feedback) feedback->value
00097 
00098 #define IM_RGB_COLOR(RED,GREEN,BLUE)      (int)((RED<<16) + (GREEN<<8) + BLUE)
00099 #define IM_RGB_COLOR_RED(COLOR)           (int)(COLOR>>16)
00100 #define IM_RGB_COLOR_GREEN(COLOR)  (int)((COLOR>>8)&0x00ff)
00101 #define IM_RGB_COLOR_BLUE(COLOR)   (int)(COLOR&0x0000ff)
00102 
00103 typedef struct _IMFeedback {
00104   IMFeedbackType type;
00105   int   value;                     /* depends on id-type */
00106 } IMFeedback;
00107 
00108 typedef struct _IMFeedbackList {
00109   unsigned int count_feedbacks;
00110   IMFeedback  *feedbacks;
00111 } IMFeedbackList;
00112 
00113 typedef struct _IMAnnotation {
00114   int type;  /* IMAnnotationType */
00115   int num_values;
00116   IMAnnotationValue   *values;
00117 } IMAnnotation;
00118 
00119 typedef enum {
00120   UTF16_CODESET = 0,
00121   JAEUC_CODESET = 1,
00122   JAPCK_CODESET = 2,
00123   ZHEUC_CODESET = 3,
00124   ZHGBK_CODESET = 4,
00125   TWEUC_CODESET = 5,
00126   TWBIG5_CODESET = 6,
00127   KOEUC_CODESET = 7,
00128   UTF8_CODESET = 8,
00129   UTF32_CODESET = 9
00130 } IMEncoding;
00131 
00132 /* 
00133  * Define the structure used to exchange text
00134 */
00135 typedef struct _IMText {
00136   IMEncoding    encoding;
00137   unsigned int         char_length;
00138   union {
00139     UTFCHAR     *utf_chars; /* UTF16 */
00140     char        *native_chars;/* non-UTF16  */
00141   } text;
00142   IMFeedbackList  *feedback;
00143   unsigned int    count_annotations;
00144   IMAnnotation         *annotations;
00145 } IMText;
00146 
00147 /* Operation related Data structures */
00148 typedef struct _IMOperation {
00149     unsigned int id;        /* operation id */
00150     int length;                 /* length of value */
00151     void *value;                /* contents, contents in ccdef case */
00152 } IMOperation, *IMOperationList;
00153 
00154 /*
00155  * Event Type
00156  */
00157 
00158 typedef enum {
00159     IM_EventKeyList = 1,
00160     IM_EventString = 2,
00161     IM_EventText = 3,
00162     IM_EventAux = 4,        /* duplicated to IM_EventAuxSet - 
00163                                left for compatibility */
00164     IM_EventAuxSet = 4,
00165     IM_EventAuxGet = 5,
00166     IM_EventX = 100
00167 } IM_Event_Type;
00168 
00169 /*
00170  * a key event for IMKeyListEvent
00171  */
00172 
00173 typedef struct _IMKeyEventStruct {
00174    int keyCode;
00175    int keyChar;
00176    int modifier;
00177    int time_stamp;
00178 } IMKeyEventStruct, *IMKeyList;
00179 
00180 /*
00181  * keylist event
00182  */
00183 typedef struct _IMKeyListEvent {
00184     int type;
00185     int n_operation;
00186     IMOperationList operation_list;
00187 
00188     int n_key;
00189     IMKeyList keylist;
00190 } IMKeyListEvent;
00191 
00192 /*
00193  * Data structures for Preedit
00194 */
00195 
00196 #define IMNormal               0
00197 #define IMReverse              1
00198 #define IMUnderline            2
00199 
00200 typedef struct _IMPreeditDrawCallbackStruct {
00201   int caret;          /* Cursor offset within pre-edit string */
00202   int chg_first;      /* Starting change position */
00203   int chg_length;     /* Length of the change in character count */
00204   IMText *text;
00205 } IMPreeditDrawCallbackStruct;
00206 
00207 typedef enum {
00208   IMForwardChar, IMBackwardChar,
00209   IMForwardWord, IMBackwardWord,
00210   IMCaretUp, IMCaretDown,
00211   IMNextLine, IMPreviousLine,
00212   IMLineStart, IMLineEnd,
00213   IMAbsolutePosition,
00214   IMDontChange
00215 } IMCaretDirection;
00216 
00217 typedef enum {
00218   IMIsInvisible,     /* Disable caret feedback */
00219   IMIsPrimary,       /* UI defined caret feedback */
00220   IMIsSecondary      /* UI defined caret feedback */
00221 } IMCaretStyle;
00222 
00223 typedef struct _IMPreeditCaretCallbackStruct {
00224   int position;               /* Caret offset within pre-edit string */
00225   IMCaretDirection direction; /* Caret moves direction */
00226   IMCaretStyle style;         /* Feedback of the caret */
00227 } IMPreeditCaretCallbackStruct;
00228 
00229 struct IMPreeditStruct {
00230   union {
00231     int return_value;
00232     IMPreeditDrawCallbackStruct draw;
00233     IMPreeditCaretCallbackStruct caret;
00234   } todo;
00235 };
00236 
00237 /*
00238  * Data structures for Status 
00239 */ 
00240 typedef struct _IMStatusDrawCallbackStruct {
00241   IMText *text;
00242 } IMStatusDrawCallbackStruct;
00243 
00244 struct IMStatusStruct {
00245   union {
00246     IMStatusDrawCallbackStruct draw;      /* StatusDraw */
00247   } todo;
00248 };
00249 
00250 /*
00251  * Data structures for Lookup
00252 */
00253 
00254 #define IM_LUC_LABEL_NONE               0
00255 #define IM_LUC_LABEL_NUMERIC            1
00256 #define IM_LUC_LABEL_ALPHABETIC         2
00257 #define IM_LUC_LABEL_ALPHA_UPPER        3
00258 
00259 typedef enum {
00260   HasNotBeenNegotiated = 0,
00261   IMIsMaster = 1,
00262   CBIsMaster  = 2
00263 } WhoIsMaster;
00264  
00265 typedef enum {
00266   DrawUpHorizontally = 0,
00267   DrawUpVertically = 1
00268 } DrawUpDirection;
00269  
00270 typedef enum {
00271   IMOwnsLabel = 0 ,
00272   CBOwnsLabel = 1
00273 } WhoOwnsLabel;
00274 
00275 typedef struct _LayoutInfo {
00276   int choice_per_window;  /* Number of choices can be display
00277                         * in the region
00278                         */
00279   int nrows;
00280   int ncolumns;
00281   DrawUpDirection drawUpDirection ;
00282   WhoOwnsLabel whoOwnsLabel;      /* For callback to tell XIM
00283                                * whether it wants to control
00284                                * what label should be for the choices.
00285                                */
00286   int luc_is_rootwindow;
00287   int label_type;
00288   int root_width;
00289   int root_lines;
00290   int e_width_per_can;
00291   int max_width_per_car;
00292 } LayoutInfo;
00293 
00294 typedef struct _IMLookupStartCallbackStruct {
00295     IMKeyListEvent *event;
00296     WhoIsMaster whoIsMaster;    /* For callback to tell whether is
00297                                  * going to be a master */
00298     LayoutInfo *IMPreference;
00299     LayoutInfo *CBPreference;
00300 }   IMLookupStartCallbackStruct;
00301 
00302 typedef struct _IMChoiceObject {
00303   IMText *label;
00304   IMText *value;
00305 } IMChoiceObject;
00306 
00307 typedef struct _IMLookupDrawCallbackStruct {
00308   IMChoiceObject *choices;       /* the lookup choices */
00309   int n_choices;      /* Total number of lookup choices */
00310   int max_len;        /* Max number of characters per
00311                      * choice item
00312                      */
00313   int index_of_first_candidate ;
00314   int index_of_last_candidate ;
00315   int index_of_current_candidate ;
00316   IMText *title;
00317 } IMLookupDrawCallbackStruct;
00318 
00319 typedef enum {
00320   LookupIndex=0,
00321   LookupPage=1
00322 } IMLookupProcessOperationType;
00323 
00324 typedef enum {
00325   LookupNextPage=1,
00326   LookupPrevPage=2,
00327   LookupFirstPage=3,
00328   LookupLastPage=4
00329 } IMLookupProcessPageOperationType;
00330 
00331 typedef struct _IMLookupProcessCallbackStruct {
00332   IMLookupProcessOperationType type;
00333                                 /* Index(#0) index_of_choice_selected */
00334                                 /* Page(#1)  page_operation_id */
00335   union {
00336     int index_of_choice_selected;/* Set by callback for the
00337                               * selected choice.
00338                               * IM_UNKNOW_KEYSYM and
00339                               * IM_UNDETERMINED are
00340                               * also possible value.
00341                               */
00342     IMLookupProcessPageOperationType page_operation_id;
00343   } value;
00344 } IMLookupProcessCallbackStruct;
00345 
00346 /*
00347  * Values for IMLookupProcessCallbackStruct.index_of_choice_selected
00348  */
00349 #define         IM_UNKNOWN_KEYSYM       0x77777777
00350 #define         IM_UNDETERMINED 0x77777776
00351 #define         IM_UNKNOWN_CONTROL      0x77777775
00352 
00353 
00354 struct IMLookupStruct {
00355   union {
00356     IMLookupStartCallbackStruct start;    /* LookupStart */
00357     IMLookupDrawCallbackStruct draw;      /* LookupDraw */
00358     IMLookupProcessCallbackStruct process;       /* LookupProcess */
00359   } todo;
00360 };
00361 
00362 /*
00363  * Data structures for Auxiliary 
00364 */
00365 typedef struct _IMAuxBasicCallbackStruct {
00366   char *aux_name;
00367   int  aux_index;    /* do not use in 2.0 */
00368 } IMAuxBasicCallbackStruct, IMAuxStartCallbackStruct, IMAuxDoneCallbackStruct;
00369 
00370 typedef struct _IMAuxDrawCallbackStruct {
00371   char *aux_name;
00372   int  aux_index;    /* do not use in 2.0 */
00373   int  count_integer_values;
00374   int  *integer_values;
00375   int  count_string_values;
00376   IMText *string_values;
00377 } IMAuxDrawCallbackStruct;
00378 
00379 struct IMAuxStruct {
00380   union {
00381     IMAuxStartCallbackStruct start; /* AuxStart */
00382     IMAuxDrawCallbackStruct draw;   /* AuxDraw  */
00383     IMAuxDoneCallbackStruct done;   /* AuxDone  */
00384   } todo;
00385 };
00386 
00387 /*
00388  * Object Downloading
00389  */
00390 
00391 typedef enum {
00392     IM_GUI_OBJECT = 0,
00393     IM_LWE_OBJECT = 1,
00394     IM_SYNTAX_RULE_OBJECT = 2,
00395     IM_MANAGER_RULE_OBJECT = 3,
00396     IM_PRELOADING_LWE_OBJECT = 4
00397 }   IMObjectCategory;
00398 
00399 typedef enum {
00400     IM_DOWNLOADINGOBJECT_JARGUI_TYPE = 0x1031,
00401     IM_DOWNLOADINGOBJECT_JARLWE_TYPE = 0x1032,
00402     IM_DOWNLOADINGOBJECT_CCDEF_TYPE = 0x1030,
00403     IM_DOWNLOADINGOBJECT_EIMIL_TYPE = 0x1030,
00404 
00405     IM_DOWNLOADINGOBJECT_BINGUI_TYPE = 0x1033,
00406     IM_DOWNLOADINGOBJECT_BINLWE_TYPE = 0x1034,
00407 
00408     IM_DOWNLOADINGOBJECT_SGUI_TYPE = 0x1035,
00409     IM_DOWNLOADINGOBJECT_SLWE_TYPE = 0x1036
00410 }   IMObjectType;
00411 
00412 typedef struct _IMObjectDescriptorStruct {
00413     char *leid;                 /* id for LE, `sampleja' */
00414     IMObjectType type;
00415     unsigned int id;        /* assigined dynamically by LELookup */
00416     unsigned int size;             /* object size */
00417 
00418     char **class_names;            /* only for JARFILE_OBJECT */
00419     unsigned int count_names;      /* count of class names */
00420                             /* only for CCDEF */
00421     UTFCHAR *name;                 /* HRN */
00422     int name_length;        /* HRN len in UTF16-char unit */
00423     char *domain;               /* reversed domain */
00424     char *path;                    /* path for object */
00425     char *scope;            /* usability id or `generic' */
00426 
00427                             /* only for CCDEF */
00428     char *signature;        /* Object signature */
00429     char *basepath;         /* base path for include tag */
00430     char *encoding;         /* encoding of CCDEF */
00431 } IMObjectDescriptorStruct;
00432 
00433 /*
00434  * string event
00435  */
00436 typedef struct _IMStringEvent {
00437     int type;
00438     int n_operation;
00439     IMOperationList operation_list;
00440     UTFCHAR *string;
00441 } IMStringEvent;
00442 
00443 /*
00444  * text event
00445  */
00446 typedef struct _IMTextEvent {
00447     int type;
00448     int n_operation;
00449     IMOperationList operation_list;
00450     IMText *text;
00451 } IMTextEvent;
00452 
00453 /*
00454  * event for Auxiliary
00455  */
00456 typedef struct _IMAuxEvent {
00457     int type;
00458     IMAuxDrawCallbackStruct *aux;
00459 } IMAuxEvent;
00460 
00461 typedef struct _IMAuxGetEvent {
00462     int type;
00463     IMAuxDrawCallbackStruct *fromaux;     /* AUX -> LE */
00464     IMAuxDrawCallbackStruct *toaux;       /* LE -> AUX */
00465 } IMAuxGetEvent;
00466 
00467 /*
00468  * event for X, only for XSunIM's if_FilterEvent()
00469  */
00470 typedef struct _IMXEvent {
00471     int type;
00472     void *xevent;
00473 } IMXEvent;
00474 
00475 /*
00476  * IMInputEvent
00477  */
00478 typedef union IMInputEvent_ {
00479     int type;
00480     IMKeyListEvent keylist;
00481     IMTextEvent text;
00482     IMStringEvent string;
00483     IMAuxEvent aux;
00484     IMAuxGetEvent auxget;
00485     IMXEvent xevent;
00486 } IMInputEvent;
00487 
00488 /*
00489  * IC & IM ATTRIBID
00490  */
00491 
00492 enum IM_ATTRIBID {
00493   INPUTMETHOD_LIST = 0x1001,
00494   OBJECT_DESCRIPTER_LIST = 0x1010,
00495   CLIENT_DESCRIPTER = 0x1011,
00496   CCDEF = 0x1030,
00497   GUI_OBJECT = 0x1031,
00498   LWE_OBJECT = 0x1032
00499 };
00500 
00501 enum IC_ATTRIBID {
00502   IC_INPUT_LANGUAGE = 1,
00503   IC_CHARACTER_SUBSETS = 2,
00504   IC_INPUT_METHOD = 3,
00505   IC_PREFERED_OBJECT = 4,
00506   IC_SUPPORTED_CLASSES = 5
00507 };
00508 
00509 
00510 /*
00511  * Data structures for sync up.
00512 */
00513 
00514 typedef struct IMTransaction {
00515   CARD32BIT opid;
00516   CARD32BIT trid;
00517 } IMTransaction;
00518 
00519 #define IM_TRANSACTION_NOP_ID 0
00520 #define IM_DIFFERENTIAL_FLAG_NILP(dflag) ((dflag) & 0x1)
00521 
00522 typedef struct IMDifferential {
00523     CARD32BIT symid;
00524     int nil;
00525     int number;
00526     int bool_val;
00527     CARD32BIT ch;
00528     IMInputEvent ev;
00529     int chg_first;
00530     int chg_len;
00531     IMText text;
00532 } IMDifferential;
00533 
00534 #define SYMBOLID_TYPE(symid) (((symid) >> 16) & 0xFF)
00535 
00536 enum IM_SYMBOL_TYPE {
00537   IM_SYMBOL_ATTRIBID = 0,
00538 
00539   IM_SYMBOL_VARIABLE_NUMBER = 1,
00540   IM_SYMBOL_VARIABLE_BOOL = 2,
00541   IM_SYMBOL_VARIABLE_CHAR = 3,
00542   IM_SYMBOL_VARIABLE_MTEXT = 4,
00543   IM_SYMBOL_VARIABLE_EVENT = 5,
00544 
00545   IM_SYMBOL_PROPERTY_MASK = 0x10,
00546   IM_SYMBOL_PROPERTY_NUMBER = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_NUMBER,
00547   IM_SYMBOL_PROPERTY_BOOL = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_BOOL,
00548   IM_SYMBOL_PROPERTY_CHAR = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_CHAR,
00549   IM_SYMBOL_PROPERTY_MTEXT = IM_SYMBOL_PROPERTY_MASK | IM_SYMBOL_VARIABLE_MTEXT,
00550 
00551   IM_SYMBOL_OPERATION = 0x20
00552 };
00553 
00554 typedef struct IMProp {
00555   int type;
00556   int count;
00557   union vals {
00558     IMText *mtexts;
00559     int *numbers;
00560     int *bools;
00561     CARD32BIT *chars;
00562   } vals;
00563 } IMProp;
00564 
00565 typedef struct IMSymbol {
00566   char *symname;
00567   CARD32BIT symid;
00568 } IMSymbol;
00569 
00570 #endif