Back to index

gcompris  8.2.2
gtans_interface.c
Go to the documentation of this file.
00001 #include "gcompris/gcompris.h"
00002 
00003 #include "gtans_callbacks.h"
00004 #include "gtans_interface.h"
00005 #include "gtans_support.h"
00006 
00007 #define X_BASE_BIGAREA 340
00008 #define Y_BASE_BIGAREA 50
00009 #define WIDTH_BIGAREA 400
00010 
00011 #define X_BASE_SMALLAREA 50
00012 #define Y_BASE_SMALLAREA 50
00013 #define WIDTH_SMALLAREA 200
00014 
00015 void create_mainwindow (GnomeCanvasGroup *rootitem)
00016 {
00017   GtkWidget *wdrawareagrande;
00018   GtkWidget *wdrawareapetite;
00019 
00020 
00021   /* GCompris : suppression of all menus */
00022   g_assert(rootitem != NULL);
00023 
00024   wdrawareagrande = gtk_drawing_area_new ();
00025   gtk_widget_set_name (wdrawareagrande, "wdrawareagrande");
00026   //gtk_widget_set_size_request     (wdrawareagrande,
00027   //                               WIDTH_BIGAREA,
00028   //                    WIDTH_BIGAREA
00029   //                    );
00030 
00031   //gtk_container_add (GTK_CONTAINER (aspectframe1), wdrawareagrande);
00032 
00033   gtk_widget_set_events (wdrawareagrande, GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_STRUCTURE_MASK);
00034 
00035   /* Gcompris */
00036   gnome_canvas_item_new      ( rootitem,
00037                             gnome_canvas_widget_get_type(),
00038                             "widget", wdrawareagrande,
00039                             "x", (double) X_BASE_BIGAREA,
00040                             "y", (double) Y_BASE_BIGAREA,
00041                             "width", (double) WIDTH_BIGAREA,
00042                             "height", (double) WIDTH_BIGAREA,
00043                             NULL
00044                             );
00045 
00046   gtk_widget_show (wdrawareagrande);
00047 
00048   wdrawareapetite = gtk_drawing_area_new ();
00049   gtk_widget_set_name (wdrawareapetite, "wdrawareapetite");
00050 
00051   gtk_widget_set_events (wdrawareapetite, GDK_EXPOSURE_MASK | GDK_STRUCTURE_MASK);
00052 
00053   /* Gcompris */
00054   gnome_canvas_item_new      ( rootitem,
00055                             gnome_canvas_widget_get_type(),
00056                             "widget", wdrawareapetite,
00057                             "x", (double) X_BASE_SMALLAREA,
00058                             "y", (double) Y_BASE_SMALLAREA,
00059                             "width", (double) WIDTH_SMALLAREA,
00060                             "height", (double) WIDTH_SMALLAREA,
00061                             NULL
00062                             );
00063 
00064   gtk_widget_show (wdrawareapetite);
00065 
00066   gtk_signal_connect (GTK_OBJECT (wdrawareagrande), "expose_event",
00067                       GTK_SIGNAL_FUNC (on_wdrawareagrande_expose_event),
00068                       NULL);
00069   gtk_signal_connect (GTK_OBJECT (wdrawareagrande), "configure_event",
00070                       GTK_SIGNAL_FUNC (on_wdrawareagrande_configure_event),
00071                       NULL);
00072   gtk_signal_connect (GTK_OBJECT (wdrawareagrande), "button_press_event",
00073                       GTK_SIGNAL_FUNC (on_wdrawareagrande_button_press_event),
00074                       NULL);
00075   gtk_signal_connect (GTK_OBJECT (wdrawareagrande), "button_release_event",
00076                       GTK_SIGNAL_FUNC (on_wdrawareagrande_button_release_event),
00077                       NULL);
00078   gtk_signal_connect (GTK_OBJECT (wdrawareagrande), "motion_notify_event",
00079                       GTK_SIGNAL_FUNC (on_wdrawareagrande_motion_notify_event),
00080                       NULL);
00081   gtk_signal_connect (GTK_OBJECT (wdrawareapetite), "configure_event",
00082                       GTK_SIGNAL_FUNC (on_wdrawareapetite_configure_event),
00083                       NULL);
00084   gtk_signal_connect (GTK_OBJECT (wdrawareapetite), "expose_event",
00085                       GTK_SIGNAL_FUNC (on_wdrawareapetite_expose_event),
00086                       NULL);
00087 
00088 
00089   /* Gcompris */
00090   /* add here buttons */
00091 
00092   GdkPixbuf   *pixmap_l = NULL;
00093   GdkPixbuf   *pixmap_r = NULL;
00094   GdkPixbuf   *pixmap_show = NULL;
00095   GdkPixbuf   *pixmap_outline = NULL;
00096   GdkPixbuf   *pixmap_symetry = NULL;
00097   GnomeCanvasItem *previous_figure, *next_figure;
00098   GnomeCanvasItem *show_figure, *outline_figure, *symetry;
00099 
00100   pixmap_l = gc_skin_pixmap_load("button_backward.png");
00101 
00102   pixmap_r = gc_skin_pixmap_load("button_forward.png");
00103 
00104   previous_figure = gnome_canvas_item_new (rootitem,
00105                                       gnome_canvas_pixbuf_get_type (),
00106                                       "pixbuf", pixmap_l, 
00107                                       "x", (double) X_BASE_SMALLAREA,
00108                                       "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 10,
00109                                       NULL);
00110       
00111   next_figure = gnome_canvas_item_new (rootitem,
00112                                    gnome_canvas_pixbuf_get_type (),
00113                                    "pixbuf", pixmap_r, 
00114                                    "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA,
00115                                    "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 10,
00116                                    "anchor", GTK_ANCHOR_NE,
00117                                    NULL);
00118 
00119 
00120   gtk_signal_connect(GTK_OBJECT(previous_figure), "event",
00121                    (GtkSignalFunc) on_arrow_clicked,
00122                    (gpointer) FALSE);
00123       
00124   gtk_signal_connect(GTK_OBJECT(previous_figure), "event",
00125                    (GtkSignalFunc) gc_item_focus_event,
00126                    NULL);
00127       
00128   gtk_signal_connect(GTK_OBJECT(next_figure), "event",
00129                    (GtkSignalFunc) on_arrow_clicked,
00130                    (gpointer) TRUE);
00131   
00132   gtk_signal_connect(GTK_OBJECT(next_figure), "event",
00133                    (GtkSignalFunc) gc_item_focus_event,
00134                    NULL);
00135 
00136 
00137   pixmap_show = gc_pixmap_load("gtans/gtans_show.png");
00138 
00139   pixmap_outline = gc_pixmap_load("gtans/gtans_outline.png");
00140   
00141   show_figure = gnome_canvas_item_new (rootitem,
00142                                    gnome_canvas_pixbuf_get_type (),
00143                                    "pixbuf", pixmap_show, 
00144                                    "x", (double) X_BASE_SMALLAREA,
00145                                    "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 80,
00146                                    "anchor",  GTK_ANCHOR_W,
00147                                    NULL);
00148       
00149   outline_figure = gnome_canvas_item_new (rootitem,
00150                                    gnome_canvas_pixbuf_get_type (),
00151                                    "pixbuf", pixmap_outline, 
00152                                    "x", (double) X_BASE_SMALLAREA,
00153                                    "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 130,
00154                                    "anchor", GTK_ANCHOR_W,
00155                                    NULL);
00156       
00157   gtk_signal_connect(GTK_OBJECT(outline_figure), "event",
00158                    (GtkSignalFunc) on_outline_clicked,
00159                    NULL);
00160       
00161   gtk_signal_connect(GTK_OBJECT(show_figure), "event",
00162                    (GtkSignalFunc) on_show_clicked,
00163                    NULL);
00164       
00165   gtk_signal_connect(GTK_OBJECT(outline_figure), "event",
00166                    (GtkSignalFunc) gc_item_focus_event,
00167                    NULL);
00168       
00169   gtk_signal_connect(GTK_OBJECT(show_figure), "event",
00170                    (GtkSignalFunc) gc_item_focus_event,
00171                    NULL);
00172 
00173   pixmap_symetry = gc_skin_pixmap_load("draw/tool-flip.png");
00174 
00175       
00176   symetry = gnome_canvas_item_new (rootitem,
00177                                gnome_canvas_pixbuf_get_type (),
00178                                "pixbuf", pixmap_symetry, 
00179                                "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA - 50,
00180                                "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 180,
00181                                "anchor", GTK_ANCHOR_N,
00182                                NULL);
00183       
00184   gtk_signal_connect(GTK_OBJECT(symetry), "event",
00185                    (GtkSignalFunc) on_symetry_clicked,
00186                    NULL);
00187       
00188   gtk_signal_connect(GTK_OBJECT(symetry), "event",
00189                    (GtkSignalFunc) gc_item_focus_event,
00190                    NULL);
00191   
00192 
00193   /* rotation buttons */
00194   GdkPixbuf   *right_rot = NULL;
00195   GdkPixbuf   *left_rot = NULL;
00196   GdkPixbuf   *right_rot_big = NULL;
00197   GdkPixbuf   *left_rot_big = NULL;
00198   GnomeCanvasItem *l_rot_s, *r_rot_s, *l_rot_b,  *r_rot_b;
00199 
00200   right_rot       = gc_pixmap_load("gtans/gtans_rotate.png");
00201   left_rot        = gc_pixmap_load("gtans/gtans_rotate-left.png");
00202 
00203   r_rot_s = gnome_canvas_item_new (rootitem,
00204                                gnome_canvas_pixbuf_get_type (),
00205                                "pixbuf", right_rot, 
00206                                "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA,
00207                                "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
00208                                "anchor", GTK_ANCHOR_NE,
00209                                NULL);
00210       
00211 
00212   l_rot_s = gnome_canvas_item_new (rootitem,
00213                                gnome_canvas_pixbuf_get_type (),
00214                                "pixbuf", left_rot, 
00215                                "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
00216                                "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 60,
00217                                "anchor", GTK_ANCHOR_NW,
00218                                NULL);
00219       
00220 
00221   gdk_pixbuf_unref(right_rot);
00222   gdk_pixbuf_unref(left_rot);
00223 
00224   right_rot_big   = gc_pixmap_load("gtans/gtans_2x-rotate.png");
00225   left_rot_big    = gc_pixmap_load("gtans/gtans_2x-rotate-left.png");
00226 
00227   r_rot_b = gnome_canvas_item_new (rootitem,
00228                                gnome_canvas_pixbuf_get_type (),
00229                                "pixbuf", right_rot_big, 
00230                                "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA,
00231                                "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
00232                                "anchor", GTK_ANCHOR_NE,
00233                                NULL);
00234       
00235 
00236   l_rot_b = gnome_canvas_item_new (rootitem,
00237                                gnome_canvas_pixbuf_get_type (),
00238                                "pixbuf", left_rot_big, 
00239                                "x", (double) X_BASE_SMALLAREA + WIDTH_SMALLAREA - 100,
00240                                "y", (double) Y_BASE_SMALLAREA + WIDTH_SMALLAREA + 120,
00241                                "anchor", GTK_ANCHOR_NW,
00242                                NULL);
00243 
00244   gdk_pixbuf_unref(right_rot_big);
00245   gdk_pixbuf_unref(left_rot_big);
00246 
00247       
00248   gtk_signal_connect(GTK_OBJECT(r_rot_s), "event",
00249                    (GtkSignalFunc) on_rotation_clicked,
00250                    (gpointer) 0);
00251       
00252   gtk_signal_connect(GTK_OBJECT(r_rot_s), "event",
00253                    (GtkSignalFunc) gc_item_focus_event,
00254                    NULL);
00255       
00256   gtk_signal_connect(GTK_OBJECT(l_rot_s), "event",
00257                    (GtkSignalFunc) on_rotation_clicked,
00258                    (gpointer) 1);
00259       
00260   gtk_signal_connect(GTK_OBJECT(l_rot_s), "event",
00261                    (GtkSignalFunc) gc_item_focus_event,
00262                    NULL);
00263       
00264   gtk_signal_connect(GTK_OBJECT(r_rot_b), "event",
00265                    (GtkSignalFunc) on_rotation_clicked,
00266                    (gpointer) 2);
00267       
00268   gtk_signal_connect(GTK_OBJECT(r_rot_b), "event",
00269                    (GtkSignalFunc) gc_item_focus_event,
00270                    NULL);
00271       
00272   gtk_signal_connect(GTK_OBJECT(l_rot_b), "event",
00273                    (GtkSignalFunc) on_rotation_clicked,
00274                    (gpointer) 3);
00275       
00276   gtk_signal_connect(GTK_OBJECT(l_rot_b), "event",
00277                    (GtkSignalFunc) gc_item_focus_event,
00278                    NULL);
00279 
00280 }
00281 
00282