Clear A Pixmap
Hi Everyone! I explain my thing... I have a pixmap, a drawing area. There are events that draw on it. But i have a button that must clear, erase all the painted on the drawing area. Any idea how to make it happen Thanxs 4 advancement peoople! ;-) -- View this message in context: http://www.nabble.com/Clear-A-Pixmap-tf3849301.html#a10903439 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Clear A Pixmap
On Thu, May 31, 2007 at 03:35:07PM -0700, nahuel9728 wrote: > I explain my thing... I have a pixmap, a drawing area. > There are events that draw on it. But i have a button that must clear, erase > all the painted on the drawing area. > Any idea how to make it happen Make the drawing area repaint (e.g. with gtk_widget_queue_draw()) and just do not draw anything there in the "expose-event" handler this time. Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Clear A Pixmap
Thaxs Yeti for the answer but Sorry I'm not able to do it. I explain a little bit what im doing and i would like to do: main(){ mem_map=gtk_drawing_area_new(); gtk_signal_connect (GTK_OBJECT (mem_map), "expose_event",(GtkSignalFunc) expose_event, NULL); gtk_signal_connect (GTK_OBJECT(mem_map),"configure_event",(GtkSignalFunc)configure_event, NULL); gtk_signal_connect (GTK_OBJECT (mem_map), "button_press_event",(GtkSignalFunc) button_press_event, NULL); /*A button to erase all the drawed and paint things*/ boton = gtk_button_new_with_label ("Clear and paint"); gtk_signal_connect_object (GTK_OBJECT (boton), "clicked",GTK_SIGNAL_FUNC (clear_and_paint),GTK_OBJECT (main_window)); show } void expose_event(){ gdk_draw_pixmap } void clear_and_pain(GtkWidget *widget, GdkEventExpose *event){ /*HERE I WANNA CLEAN ALL MY DRAWED AREA*/ gtk_widget_queue_draw_area(GTK_WIDGET(mem_map),0,0,910,440); /*This up should clean all the area??? */ /*And later draw things.*/ draw_brush(); } Any idea anyone??? Has done somthing similar David Nečas (Yeti)-2 wrote: > > On Thu, May 31, 2007 at 03:35:07PM -0700, nahuel9728 wrote: >> I explain my thing... I have a pixmap, a drawing area. >> There are events that draw on it. But i have a button that must clear, >> erase >> all the painted on the drawing area. >> Any idea how to make it happen > > Make the drawing area repaint (e.g. with gtk_widget_queue_draw()) > and just do not draw anything there in the "expose-event" > handler this time. > > Yeti > > -- > http://gwyddion.net/ > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > -- View this message in context: http://www.nabble.com/Clear-A-Pixmap-tf3849301.html#a10922708 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Clear A Pixmap
On Fri, Jun 01, 2007 at 05:38:54PM -0700, nahuel9728 wrote: > > Thaxs Yeti for the answer but Sorry I'm not able to do it. I explain a little > bit what im doing and i would like to do: > main(){ > mem_map=gtk_drawing_area_new(); > gtk_signal_connect (GTK_OBJECT (mem_map), "expose_event",(GtkSignalFunc) > expose_event, NULL); > gtk_signal_connect > (GTK_OBJECT(mem_map),"configure_event",(GtkSignalFunc)configure_event, > NULL); > gtk_signal_connect (GTK_OBJECT (mem_map), > "button_press_event",(GtkSignalFunc) button_press_event, NULL); > /*A button to erase all the drawed and paint things*/ > boton = gtk_button_new_with_label ("Clear and paint"); > gtk_signal_connect_object (GTK_OBJECT (boton), "clicked",GTK_SIGNAL_FUNC > (clear_and_paint),GTK_OBJECT (main_window)); > show > } > > void expose_event(){ > gdk_draw_pixmap > } > > void clear_and_pain(GtkWidget *widget, GdkEventExpose *event){ > /*HERE I WANNA CLEAN ALL MY DRAWED AREA*/ >gtk_widget_queue_draw_area(GTK_WIDGET(mem_map),0,0,910,440); > /*This up should clean all the area??? */ > > /*And later draw things.*/ > draw_brush(); > } > Any idea anyone??? Has done somthing similar Sorry, this is a mess, I have no idea what you are doing. However, you seem to started from the Gtk+ scribble example, so here's a patch to scribble-simple.c that adds a Clear button: === --- scribble-simple.c.orig 2007-05-02 18:27:36.0 +0200 +++ scribble-simple.c 2007-06-02 12:25:02.0 +0200 @@ -115,12 +115,21 @@ exit (0); } +static void +clear(GtkWidget *widget) +{ +gdk_draw_rectangle(pixmap, widget->style->white_gc, TRUE, + 0, 0, + widget->allocation.width, widget->allocation.height); +gtk_widget_queue_draw(widget); +} + int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *drawing_area; - GtkWidget *vbox; + GtkWidget *vbox, *hbox; GtkWidget *button; @@ -164,16 +173,19 @@ | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK); - /* .. And a quit button */ - button = gtk_button_new_with_label ("Quit"); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - - g_signal_connect_swapped (G_OBJECT (button), "clicked", - G_CALLBACK (gtk_widget_destroy), - G_OBJECT (window)); - gtk_widget_show (button); + hbox = gtk_hbox_new(TRUE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); + + button = gtk_button_new_with_label("Clear"); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + g_signal_connect_swapped(button, "clicked", G_CALLBACK(clear), drawing_area); + + button = gtk_button_new_with_label("Quit"); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + g_signal_connect_swapped(button, "clicked", + G_CALLBACK(gtk_widget_destroy), window); - gtk_widget_show (window); + gtk_widget_show_all(window); gtk_main (); === Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Clear A Pixmap
Yeti.. THANK U VERY MUCH!! Sorry for use the forum for this but... THANK YOU for YOUR HELP! You're the best David Nečas (Yeti)-2 wrote: > > On Fri, Jun 01, 2007 at 05:38:54PM -0700, nahuel9728 wrote: >> >> Thaxs Yeti for the answer but Sorry I'm not able to do it. I explain a >> little >> bit what im doing and i would like to do: >> main(){ >> mem_map=gtk_drawing_area_new(); >> gtk_signal_connect (GTK_OBJECT (mem_map), "expose_event",(GtkSignalFunc) >> expose_event, NULL); >> gtk_signal_connect >> (GTK_OBJECT(mem_map),"configure_event",(GtkSignalFunc)configure_event, >> NULL); >> gtk_signal_connect (GTK_OBJECT (mem_map), >> "button_press_event",(GtkSignalFunc) button_press_event, NULL); >> /*A button to erase all the drawed and paint things*/ >> boton = gtk_button_new_with_label ("Clear and paint"); >> gtk_signal_connect_object (GTK_OBJECT (boton), "clicked",GTK_SIGNAL_FUNC >> (clear_and_paint),GTK_OBJECT (main_window)); >> show >> } >> >> void expose_event(){ >> gdk_draw_pixmap >> } >> >> void clear_and_pain(GtkWidget *widget, GdkEventExpose *event){ >> /*HERE I WANNA CLEAN ALL MY DRAWED AREA*/ >>gtk_widget_queue_draw_area(GTK_WIDGET(mem_map),0,0,910,440); >> /*This up should clean all the area??? */ >> >> /*And later draw things.*/ >> draw_brush(); >> } >> Any idea anyone??? Has done somthing similar > > Sorry, this is a mess, I have no idea what you are doing. > > However, you seem to started from the Gtk+ scribble example, > so here's a patch to scribble-simple.c that adds a Clear > button: > > === > --- scribble-simple.c.orig2007-05-02 18:27:36.0 +0200 > +++ scribble-simple.c 2007-06-02 12:25:02.0 +0200 > @@ -115,12 +115,21 @@ >exit (0); > } > > +static void > +clear(GtkWidget *widget) > +{ > +gdk_draw_rectangle(pixmap, widget->style->white_gc, TRUE, > + 0, 0, > + widget->allocation.width, > widget->allocation.height); > +gtk_widget_queue_draw(widget); > +} > + > int main( int argc, >char *argv[] ) > { >GtkWidget *window; >GtkWidget *drawing_area; > - GtkWidget *vbox; > + GtkWidget *vbox, *hbox; > >GtkWidget *button; > > @@ -164,16 +173,19 @@ >| GDK_POINTER_MOTION_MASK >| GDK_POINTER_MOTION_HINT_MASK); > > - /* .. And a quit button */ > - button = gtk_button_new_with_label ("Quit"); > - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); > - > - g_signal_connect_swapped (G_OBJECT (button), "clicked", > - G_CALLBACK (gtk_widget_destroy), > - G_OBJECT (window)); > - gtk_widget_show (button); > + hbox = gtk_hbox_new(TRUE, 0); > + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); > + > + button = gtk_button_new_with_label("Clear"); > + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); > + g_signal_connect_swapped(button, "clicked", G_CALLBACK(clear), > drawing_area); > + > + button = gtk_button_new_with_label("Quit"); > + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); > + g_signal_connect_swapped(button, "clicked", > + G_CALLBACK(gtk_widget_destroy), window); > > - gtk_widget_show (window); > + gtk_widget_show_all(window); > >gtk_main (); > > === > > Yeti > > -- > http://gwyddion.net/ > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > -- View this message in context: http://www.nabble.com/Clear-A-Pixmap-tf3849301.html#a10928145 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list