Back to index

im-sdk  12.3.91
candidate_aux.c
Go to the documentation of this file.
00001 #include <stdio.h>
00002 #include <glib.h>
00003 #include <gdk/gdk.h>
00004 #include <gtk/gtk.h>
00005 
00006 static GdkColor           _normal_bg;
00007 static GdkColor           _normal_text;
00008 static GdkColor           _active_bg;
00009 static GdkColor           _active_text;
00010  
00011 static GdkDisplay        *_current_display             = 0;
00012 static GdkScreen         *_current_screen              = 0;
00013 
00014 static GtkWidget         *_lookup_table_window         = 0;
00015 static GtkWidget         *_lookup_table_up_button      = 0;
00016 static GtkWidget         *_lookup_table_down_button    = 0;
00017 static GtkWidget         *_lookup_table_left_button    = 0;
00018 static GtkWidget         *_lookup_table_right_button   = 0;
00019 static GtkWidget         *_lookup_table_items[10]      = { 0 };
00020 
00021 int main(int argc, char **argv)
00022 {
00023     PangoFontDescription *font_desc = 0;
00024     GtkWidget *input_window_vbox;
00025     GtkWidget *_lookup_table_parent;
00026 
00027     int _lookup_table_vertical = 1;
00028     int i;
00029 
00030     gtk_init (&argc, &argv);
00031 
00032     // Read configurations.
00033     gdk_color_parse ("gray92",     &_normal_bg);
00034     gdk_color_parse ("black",      &_normal_text);
00035     gdk_color_parse ("light blue", &_active_bg);
00036     gdk_color_parse ("black",      &_active_text);
00037 
00038     _current_display = gdk_display_get_default ();
00039     _current_screen  = gdk_display_get_default_screen (_current_display);
00040   
00041     font_desc = pango_font_description_from_string ("default");                                                                                                     
00042     //Create lookup table window
00043     {
00044         GtkWidget *vbox;
00045         GtkWidget *hbox;
00046         GtkWidget *frame;
00047         GtkWidget *image;
00048         GtkWidget *separator;
00049         GtkRequisition size;
00050 
00051         _lookup_table_window = gtk_window_new (GTK_WINDOW_POPUP);
00052         gtk_widget_modify_bg (_lookup_table_window, GTK_STATE_NORMAL, &_normal_bg);
00053         gtk_window_set_policy (GTK_WINDOW (_lookup_table_window), TRUE, TRUE, FALSE);
00054         gtk_window_set_resizable (GTK_WINDOW (_lookup_table_window), FALSE);
00055         gtk_widget_add_events (_lookup_table_window,GDK_BUTTON_PRESS_MASK);
00056         gtk_widget_add_events (_lookup_table_window,GDK_BUTTON_RELEASE_MASK);
00057         gtk_widget_add_events (_lookup_table_window,GDK_POINTER_MOTION_MASK);
00058 /*
00059         g_signal_connect (G_OBJECT (_lookup_table_window), "button-press-event",
00060                           G_CALLBACK (ui_lookup_table_window_click_cb),
00061                           GINT_TO_POINTER (0));
00062         g_signal_connect (G_OBJECT (_lookup_table_window), "button-release-event",
00063                           G_CALLBACK (ui_lookup_table_window_click_cb),
00064                           GINT_TO_POINTER (1));
00065 */
00066         gtk_container_set_border_width (GTK_CONTAINER (_lookup_table_window), 0);
00067 
00068         frame = gtk_frame_new (0);
00069         gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_OUT);
00070         gtk_container_add (GTK_CONTAINER (_lookup_table_window), frame);
00071        _lookup_table_parent = frame;
00072 
00073         //Vertical lookup table
00074         if (_lookup_table_vertical) {
00075             vbox = gtk_vbox_new (FALSE, 0);
00076             gtk_container_add (GTK_CONTAINER (_lookup_table_parent), vbox);
00077 
00078             //New table items
00079             for (i=0; i<10; ++i) {
00080                 _lookup_table_items [i] = gtk_label_new ("Item         ");
00081                 if (font_desc)
00082                     gtk_widget_modify_font (_lookup_table_items [i], font_desc);
00083 
00084                 gtk_widget_modify_base (_lookup_table_items [i], GTK_STATE_NORMAL, &_normal_bg);
00085                 gtk_widget_modify_base (_lookup_table_items [i], GTK_STATE_ACTIVE, &_active_bg);
00086                 gtk_widget_modify_text (_lookup_table_items [i], GTK_STATE_NORMAL, &_normal_text);
00087                 gtk_widget_modify_text (_lookup_table_items [i], GTK_STATE_ACTIVE, &_active_text);
00088 /*
00089                 g_signal_connect (G_OBJECT (_lookup_table_items [i]), "button-press-event",
00090                                   G_CALLBACK (ui_lookup_table_vertical_click_cb),
00091                                   GINT_TO_POINTER (i));
00092 */
00093                 gtk_box_pack_start (GTK_BOX (vbox), _lookup_table_items [i], TRUE, TRUE, 0);
00094             }
00095 
00096             separator = gtk_hseparator_new ();
00097             gtk_box_pack_start (GTK_BOX (vbox), separator, FALSE, FALSE, 0);
00098 
00099             hbox = gtk_hbox_new (FALSE, 0);
00100             gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
00101 
00102             //New down button
00103             image = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_IN);
00104             _lookup_table_down_button = gtk_button_new ();
00105             gtk_container_add (GTK_CONTAINER (_lookup_table_down_button), image);
00106             gtk_box_pack_end (GTK_BOX (hbox), _lookup_table_down_button, FALSE, FALSE, 0);
00107 /*
00108             g_signal_connect (G_OBJECT (_lookup_table_down_button), "clicked",
00109                                 G_CALLBACK (ui_lookup_table_down_button_click_cb),
00110                                 image);
00111 */
00112 
00113             //New UP button
00114             image = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_IN);
00115             _lookup_table_up_button = gtk_button_new ();
00116             gtk_container_add (GTK_CONTAINER (_lookup_table_up_button), image);
00117             gtk_box_pack_end (GTK_BOX (hbox), _lookup_table_up_button, FALSE, FALSE, 0);
00118 /*
00119             g_signal_connect (G_OBJECT (_lookup_table_down_button), "clicked",
00120                                 G_CALLBACK (ui_lookup_table_down_button_click_cb),
00121                                 image);
00122 */
00123 
00124         } else {
00125             hbox = gtk_hbox_new (FALSE, 0);
00126             gtk_container_add (GTK_CONTAINER (_lookup_table_parent), hbox);
00127 
00128             _lookup_table_items [0] = gtk_label_new ("Item1 Item2 Item3 Item4 Item5 Item6   ");
00129             if (font_desc)
00130                 gtk_widget_modify_font (_lookup_table_items [0], font_desc);
00131             gtk_widget_modify_base (_lookup_table_items [0], GTK_STATE_NORMAL, &_normal_bg);
00132             gtk_widget_modify_base (_lookup_table_items [0], GTK_STATE_ACTIVE, &_active_bg);
00133             gtk_widget_modify_text (_lookup_table_items [0], GTK_STATE_NORMAL, &_normal_text);
00134             gtk_widget_modify_text (_lookup_table_items [0], GTK_STATE_ACTIVE, &_active_text);
00135 /*
00136             g_signal_connect (G_OBJECT (_lookup_table_items [0]), "move_cursor",
00137                             G_CALLBACK (ui_lookup_table_horizontal_click_cb),
00138                             0);
00139 */
00140             gtk_box_pack_start (GTK_BOX (hbox), _lookup_table_items [0], TRUE, TRUE, 0);
00141 
00142             separator = gtk_vseparator_new ();
00143             gtk_box_pack_start (GTK_BOX (hbox), separator, FALSE, FALSE, 0);
00144 
00145             //New left button
00146             image = gtk_arrow_new(GTK_ARROW_LEFT, GTK_SHADOW_IN);
00147             gtk_widget_size_request (image, &size);
00148             _lookup_table_up_button = gtk_button_new ();
00149             gtk_widget_set_size_request (_lookup_table_up_button, size.width + 4, size.height + 4);
00150             gtk_container_add (GTK_CONTAINER (_lookup_table_up_button), image);
00151 
00152             gtk_box_pack_start (GTK_BOX (hbox), _lookup_table_up_button, FALSE, FALSE, 0);
00153 /*
00154             g_signal_connect (G_OBJECT (_lookup_table_up_button), "clicked",
00155                                 G_CALLBACK (ui_lookup_table_up_button_click_cb),
00156                                 image);
00157 */
00158 
00159             //New right button
00160             image = gtk_arrow_new(GTK_ARROW_RIGHT, GTK_SHADOW_IN);
00161             gtk_widget_size_request (image, &size);
00162             _lookup_table_down_button = gtk_button_new ();
00163             gtk_widget_set_size_request (_lookup_table_down_button, size.width + 4, size.height + 4);
00164             gtk_container_add (GTK_CONTAINER (_lookup_table_down_button), image);
00165 
00166             gtk_box_pack_start (GTK_BOX (hbox), _lookup_table_down_button, FALSE, FALSE, 0);
00167 
00168 /*
00169             g_signal_connect (G_OBJECT (_lookup_table_down_button), "clicked",
00170                                 G_CALLBACK (ui_lookup_table_down_button_click_cb),
00171                                 image);
00172 */
00173         }
00174 
00175         gtk_button_set_relief (GTK_BUTTON (_lookup_table_up_button), GTK_RELIEF_NONE);
00176         gtk_widget_modify_bg (_lookup_table_up_button, GTK_STATE_ACTIVE, &_normal_bg);
00177         gtk_widget_modify_bg (_lookup_table_up_button, GTK_STATE_INSENSITIVE, &_normal_bg);
00178         gtk_widget_modify_bg (_lookup_table_up_button, GTK_STATE_PRELIGHT, &_normal_bg);
00179 
00180         gtk_button_set_relief (GTK_BUTTON (_lookup_table_down_button), GTK_RELIEF_NONE);
00181         gtk_widget_modify_bg (_lookup_table_down_button, GTK_STATE_ACTIVE, &_normal_bg);
00182         gtk_widget_modify_bg (_lookup_table_down_button, GTK_STATE_INSENSITIVE, &_normal_bg);
00183         gtk_widget_modify_bg (_lookup_table_down_button, GTK_STATE_PRELIGHT, &_normal_bg);
00184 
00185         gtk_window_move (GTK_WINDOW (_lookup_table_window), 200, 200);
00186 
00187         gtk_widget_show_all (_lookup_table_window);
00188     }
00189 
00190     gtk_main();
00191 
00192     return FALSE;
00193 }