#define USE_NAMESPACE #include <iostream> #include <gtk++/gtkwindows.hpp> #include <gtk++/gtkdrawingareas.hpp> #include <gtk++/gdkwindows.hpp> bool Dessine (GtkWidget* ZoneDessin, GdkEventExpose *Ev, lgtkpp::gtk_drawing_area* This) { int i; lgtkpp::gdk_color Color; // La fenetre de dessin lgtkpp::gdk_window Window ((*(lgtkpp::gtk_widget*)This)->window); // On recupere la colormap de la zone de dessin lgtkpp::gdk_colormap Colormap = Window.GetColormap (); // On rend le fond de la fenetre blanc Color = "white"; Colormap.Alloc(Color); Window.SetBackground(Color); // On recupere le Gc par defaut lgtkpp::gdk_gc Gc = (Window.GetDrawable()); // On alloue la couleur bleue pour le dessin Color.SetRed(0).SetGreen(0).SetBlue(65535); Colormap.Alloc(Color); Gc.SetForeground(Color); Window.Clear(); // Ligne de la zone de dessin for (i=0; i < (*(lgtkpp::gtk_widget*)This)->allocation.width; i += 5) Window.Line(Gc, i, 0, (*(lgtkpp::gtk_widget*)This)->allocation.width - i,(*(lgtkpp::gtk_widget*)This)->allocation.height); for (i=0; i < (*(lgtkpp::gtk_widget*)This)->allocation.height; i += 5) Window.Line(Gc, 0, (*(lgtkpp::gtk_widget*)This)->allocation.height - i,(*(lgtkpp::gtk_widget*)This)->allocation.width, i); return true; } int main (int argc, char * argv[]) { // Initialisation des bibliotheques ::gtk_init(&argc, &argv); // Creation de la fenetre lgtkpp::gtk_window Fenetre; Fenetre.SetTitle ("Test Drawing Area"); Fenetre.SignalConnect ("delete_event",GtkSignalFunc(gtk_exit), NULL); Fenetre.SignalConnect ("destroy",GtkSignalFunc(gtk_exit), NULL); // Creation et attachement de la zone de dessin lgtkpp::gtk_drawing_area ZoneDessin; Fenetre += ZoneDessin; ZoneDessin.SignalConnect("expose_event",GtkSignalFunc(Dessine), &ZoneDessin); // Affichage et boucle principale Fenetre.ShowAll(); gtk_main(); return EXIT_SUCCESS; }