Back to index

im-sdk  12.3.91
composite_aux.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 
00004 #include <gdk/gdkx.h>
00005 #include <gtk/gtk.h>
00006 
00007 #ifdef HAVE_CONFIG_H
00008 #include "config.h"
00009 #endif
00010 
00011 #include "gtkiiimwin.h"
00012 
00013 extern GdkFilterReturn xaux_ext_event_handler(GdkXEvent * gdk_xevent,
00014                                               GdkEvent * event,
00015                                               gpointer user_data);
00016 
00017 void * composite_aux = NULL;
00018 static GtkWidget* mainwin = NULL;
00019 
00020 static void
00021 pc_aux_option_change(TIIimPCWin vpc, int op)
00022 {
00023     TPCStyleOption* pcstyle = (TPCStyleOption*)op;
00024     composite_aux_send_option_change(pcstyle);
00025 }
00026  
00027 static void
00028 pc_aux_candidate_selection(TIIimPCWin vpc, int idx)
00029 {
00030     composite_aux_send_candidate_selection(idx);
00031 }
00032 
00033 static void
00034 pc_aux_candidate_page_request(TIIimPCWin vpc, int pgop)
00035 {
00036     composite_aux_send_candidate_page(pgop);
00037 }
00038 
00039 static void
00040 pc_aux_move_notify(TIIimPCWin vpc, int op)
00041 {
00042     int cursor_x, cursor_y, cursor_w, cursor_h;
00043     getPCCursorPosition(vpc, &cursor_x, &cursor_y, &cursor_w, &cursor_h);
00044     composite_aux_send_move(cursor_x, cursor_y, cursor_w, cursor_h);
00045 }
00046 
00047 static const char* example_preedit = "<span color=\"darkblue\">在经过了yi duan shi jian de nu li zhi hou</span>";
00048 static int example_caret  = 37;
00049 static int example_candi_start = 4;
00050 static const char* example_candidates[] = {
00051     "<span color=\"darkgreen\">1.一段时间的努力之后</span>",
00052     "<span color=\"darkblue\">2.一段时间</span>",
00053     "3.一段",
00054     "4.一端",
00055     "5.异端",
00056     "6.臆断"
00057 };
00058 
00059 int main(int argc, char **argv)
00060 {
00061     int style_id = 0;
00062     gtk_init (&argc, &argv);
00063 
00064     add_pixmap_directory (LE_PIXMAPS_DIR);
00065     add_pixmap_directory ("./pixmaps");
00066 
00067     mainwin = gtk_window_new(GTK_WINDOW_POPUP);
00068     gtk_widget_realize(mainwin);
00069 
00070     if (argc > 1)
00071         style_id = atoi(argv[1]);
00072     composite_aux = createStockPreeditCandidatesWindows(style_id);
00073 
00074     
00075     registerStyleChangeCallback(composite_aux, pc_aux_option_change);
00076     registerSelectionCallback(composite_aux, pc_aux_candidate_selection);
00077     registerPageCallback(composite_aux, pc_aux_candidate_page_request);
00078     registerMoveCallback(composite_aux, pc_aux_move_notify);
00079 
00080     if (argc > 1) {
00081         updatePreedit(composite_aux, example_preedit, example_caret, example_candi_start, 0, 0);
00082         updateCandidates(composite_aux, 6, example_candidates, "Sun拼音", 0, 0, 100, NULL, NULL);
00083         movePreedit(composite_aux, 300, 280, 12, 22);
00084         showCandidates(composite_aux);
00085         showPreedit(composite_aux);
00086     }
00087 
00088 
00089     gdk_window_add_filter(mainwin->window, xaux_ext_event_handler, 0);
00090 
00091     if (xaux_ext_register_classes(mainwin->window) == False) return (False);
00092 
00093     gtk_main();
00094 
00095 //    printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++gtk_quiting....\n");
00096     gtk_widget_destroy(mainwin);
00097     freePreeditCandidatesWindows(composite_aux);
00098 
00099     return 0;
00100 }
00101