Back to index

im-sdk  12.3.91
aux_manager_methods.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <gdk/gdk.h>
00003 #include <gtk/gtk.h>
00004 #include <gdk/gdkx.h>
00005 #include <X11/Xlib.h>
00006 #include <X11/Xmd.h>
00007 
00008 #include "aux_module.h"
00009 #include "xaux_common.h"
00010 #include "xaux_ext_common.h"
00011 
00012 /* Define Aux class */
00013 xaux_class_t *xc_ = 0;
00014 int im_ = 0;
00015 int ic_ = 0;
00016 
00017 #define XAUX_MANAGER_CLASS_NAME  "com.sun.iiim.cle.aux.manager.gtk2"
00018 #define ATOM_NUM_XAUX_MANAGER    32
00019 
00020 /* Define Aux class */
00021 xaux_class_t xaux_class = {
00022        XAUX_MANAGER_CLASS_NAME, 1,
00023        NULL,
00024        (Window)0, (Window)0, (Window)0,
00025        (Atom)0, (Atom)0, (Atom)0, (Atom)0,
00026        { (Atom)0 }, ATOM_NUM_XAUX_MANAGER, 0,
00027        { (Atom)0 }, ATOM_NUM_XAUX_MANAGER, 0,
00028        NULL,
00029 };
00030 
00031 /*  Auxiliary Window User Input Method Information  */
00032 extern GtkWidget *_toolbar_window;
00033 
00034 Display *gDisplay = NULL;
00035 Window  gWindow  = 0;
00036 
00037 void aux_manager_proc_le_notify(aux_ext_data_t *aux_ext_data);
00038 
00039 /*   
00040        Event Handler 
00041 */
00042 GdkFilterReturn xaux_ext_event_handler(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer user_data)
00043 {
00044        XEvent *xevent = (XEvent *) gdk_xevent;
00045 
00046        switch (xevent->type) {
00047               case ClientMessage:
00048                      xaux_ext_process_client_message((Display *)gDisplay,
00049                             (XClientMessageEvent *) xevent);
00050                      break;
00051               case SelectionClear:
00052                      break;
00053        }
00054        return GDK_FILTER_CONTINUE;
00055 }
00056 
00057 /*
00058        xaux_ext_init_classes(): Initialize the Atom of Auxiliary Window.
00059        It is in ../xaux_common/xaux_ext_common.c
00060 */
00061 int xaux_ext_register_classes(GdkWindow *window)
00062 {
00063        char *locale;
00064 
00065        gDisplay = (Display *)GDK_WINDOW_XDISPLAY(window);
00066        gWindow  = (Window)GDK_WINDOW_XWINDOW(window);
00067 
00068        /* Register aux class */
00069        if (xaux_ext_init_classes(gDisplay, (xaux_class_t *)&xaux_class, gWindow) == False)
00070               return(False);
00071 
00072        aux_manager_register_aux_modules(gDisplay, gWindow);
00073 
00074        return(True);
00075 }
00076 
00077 /* 
00078 Note:
00079      xaux_ext_Start(), xaux_ext_Draw(), xaux_ext_Done() 
00080      These three functions are all called by xaux_ext_process_client_message()
00081 
00082      xaux_ext_SetValue() will send auxiliary window information to language engine;
00083 */
00084 
00085 /* Method - Start */
00086 Bool xaux_ext_Start(xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00087 {
00088        AuxModule aux_module = NULL;
00089        char *class_name = NULL;
00090 
00091        char *locale = NULL;
00092        int  locale_id;
00093 
00094        DEBUG_printf("ext_Start: im:%d, ic:%d\n", aux_ext_data->im, aux_ext_data->ic);
00095        DEBUG_printf("ext_Start: integer_count: %d, strings_count: %d\n", aux_ext_data->integer_count, aux_ext_data->string_count);
00096        im_ = aux_ext_data->im;
00097        ic_ = aux_ext_data->ic;
00098        xc_ = xc;
00099 
00100        class_name = XGetAtomName(gDisplay, atom);
00101        if (class_name == NULL)
00102               return False;
00103 
00104        DEBUG_printf("class_name: %s\n", class_name);
00105        aux_module = (AuxModule)aux_manager_get_module_by_classname(class_name);
00106        DEBUG_printf("aux_module: %p\n", aux_module);
00107        if (aux_module == NULL || aux_module->methods == NULL)
00108               return False;
00109 
00110        aux_module->methods->aux_module_Start(aux_ext_data);
00111 
00112        return True;
00113 }
00114 
00115 /* Method - Draw */
00116 Bool xaux_ext_Draw(xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00117 {
00118        AuxModule aux_module = NULL;
00119        char *class_name = NULL;
00120 
00121        DEBUG_printf("ext_Draw == im:0x%x, ic:0x%x\n",aux_ext_data->im, aux_ext_data->ic);
00122        DEBUG_printf("ext_Draw: integer_count: %d, strings_count: %d\n", aux_ext_data->integer_count, aux_ext_data->string_count);
00123        im_ = aux_ext_data->im;
00124        ic_ = aux_ext_data->ic;
00125        xc_ = xc;
00126 
00127        class_name = XGetAtomName(gDisplay, atom);
00128        if (class_name == NULL)
00129               return False;
00130 
00131        DEBUG_printf("class_name: %s\n", class_name);
00132        aux_module = (AuxModule)aux_manager_get_module_by_classname(class_name);
00133        DEBUG_printf("aux_module: %p\n", aux_module);
00134        if (aux_module == NULL || aux_module->methods == NULL)
00135               return False;
00136 
00137        aux_module->methods->aux_module_Draw(aux_ext_data);
00138 
00139        return True;
00140 }
00141 
00142 /* Method - Done */
00143 Bool xaux_ext_Done(xaux_class_t *xc, aux_ext_data_t *aux_ext_data, Atom atom)
00144 {
00145        AuxModule aux_module = NULL;
00146        char *class_name = NULL;
00147 
00148        DEBUG_printf("ext_Done im:0x%x, ic_id:0x%x\n", aux_ext_data->im, aux_ext_data->ic);
00149        DEBUG_printf("ext_Done: integer_count: %d, strings_count: %d\n", aux_ext_data->integer_count, aux_ext_data->string_count);
00150 
00151        class_name = XGetAtomName(gDisplay, atom);
00152        if (class_name == NULL)
00153               return False;
00154 
00155        DEBUG_printf("class_name: %s\n", class_name);
00156        aux_module = (AuxModule)aux_manager_get_module_by_classname(class_name);
00157        DEBUG_printf("aux_module: %p\n", aux_module);
00158        if (aux_module == NULL || aux_module->methods == NULL)
00159               return False;
00160 
00161        aux_module->methods->aux_module_Done(aux_ext_data);
00162 
00163        return True;
00164 }
00165 
00166 NotifyIntegerListDataToLanguageEngine(Display *display, 
00167 int nIntegerCount, int *pIntegerList)
00168 {
00169        aux_ext_data_t aux_ext_data;
00170 
00171        DEBUG_printf("im_:%d, ic_:%d\n", im_, ic_);
00172 
00173 /*
00174        if (!im_ || !ic_ || !xc_)
00175               return;
00176 */
00177 
00178        aux_ext_data.im = im_;
00179        aux_ext_data.ic = ic_;
00180        aux_ext_data.integer_count = nIntegerCount;
00181        aux_ext_data.integer_list = pIntegerList;
00182        aux_ext_data.string_count = 0;
00183        aux_ext_data.string_list = NULL;
00184        aux_ext_data.string_ptr = NULL;
00185        aux_ext_data.point.x = 0;
00186        aux_ext_data.point.y = 0;
00187 
00188        DEBUG_printf("begin xaux_exe_setValue =============\n");
00189        xaux_ext_SetValue(display, xc_, &aux_ext_data);
00190        XFlush(display);
00191 }
00192 
00193 NotifyStringListDataToLanguageEngine(Display *display, 
00194 int nIntegerCount, int *pIntegerList,
00195 int nStringCount,  int *pStringLen,
00196 char **pStringList)
00197 {
00198        int i;
00199 
00200        aux_ext_data_t aux_ext_data;
00201        aux_ext_string_t *p;
00202 
00203        DEBUG_printf("im_:%d, ic_:%d\n", im_, ic_);
00204 
00205 /*
00206        if (!im_ || !ic_ || !xc_)
00207               return;
00208 */
00209 
00210        aux_ext_data.im = im_;
00211        aux_ext_data.ic = ic_;
00212        aux_ext_data.integer_count = nIntegerCount;
00213        aux_ext_data.integer_list = pIntegerList;
00214        aux_ext_data.point.x = 0;
00215        aux_ext_data.point.y = 0;
00216 
00217        aux_ext_data.string_count = nStringCount;
00218        aux_ext_data.string_ptr = NULL;
00219 
00220        if (nStringCount > 0) {
00221               aux_ext_data.string_list = (aux_ext_string_t *) calloc(nStringCount, sizeof(aux_ext_string_t));
00222               for (i = 0; i < nStringCount; i++) {
00223                      aux_ext_string_t *p = &aux_ext_data.string_list[i];
00224                      p->length = pStringLen[i];
00225                      p->ptr = (unsigned char *) (pStringList[i]);
00226               }
00227        }
00228 
00229        xaux_ext_SetValue(display, xc_, &aux_ext_data);
00230        XFlush(display);
00231 
00232        free(aux_ext_data.string_list);
00233 }