Hi; On 26 March 2015 at 19:54, Lucas Levrel <llev...@yahoo.fr> wrote: > Le 26 mars 2015, Sergei Naumov a écrit : > >> Hmm. This is something I did not know I could do. But in this case I would >> have to redraw everything in the widget's drawing area which is my axes, >> tickmarks, labeles, etc... All right, I will try it this way because it is >> much simpler. > > > What I do in a similar situation is keeping a kind of carbon copy of the > bare drawing: > > - get two pixmaps from the drawing area : > bare_pixmap=gdk_pixmap_new(d_area->window,width,height,-1); > full_pixmap=gdk_pixmap_new(d_area->window,width,height,-1); > > - draw your "background" on bare_pixmap > > - when you have to redraw, just copy bare_pixmap to full_pixmap, add stuff > to full_pixmap, then display it: > > gdk_draw_drawable(full_pixmap,copy_gc,bare_pixmap,0,0,0,0,-1,-1); > (add stuff to full_pixmap) > gdk_draw_drawable(d_area->window, copy_gc, full_pixmap, x, y, x, y, width, > height); > > Where copy_gc has been defined this way: > GdkGC *copy_gc=d_area->style->fg_gc[GTK_WIDGET_STATE (d_area)];
This is really GTK+ 2.x only, and even then it's pretty much X11-only. Pixmaps are really Cairo surfaces, these days, and GCs are Cairo contexts. The widget state is part of the GtkStyleContext, and the gtk_render_* API substitute the background rendering. Even for GTK+ 2.x API you should not be using gdk_draw_* and GdkGC API at all, unless your code is supposed to work with GTK+ 2.6. Again: I cannot recommend porting away from that API (even in GTK 2.x code) strongly enough. Ciao, Emmanuele. -- https://www.bassi.io [@] ebassi [@gmail.com] _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list