RE: Re: Re: Re: Re: Getting a Cairo context



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)];


--
Lucas Levrel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]