Re: force redraw on another redraw (was: pixmaps and xpm-transparency)



Tobias Hintze wrote:
> 
> On Sun, Apr 22, 2001 at 02:35:19AM +0200, Tobias Hintze wrote:
> > On Wed, Apr 18, 2001 at 03:02:37PM +0100, John Cupitt wrote:
> > >
> > >
> > >         fixed = gtk_fixed_new();
> > >         gtk_box_pack_start( GTK_BOX( hb ), fixed, FALSE, FALSE, 2 );
> > >         gtk_widget_show( fixed );
> > >
> > >         px = gtk_pixmap_new( image, mask );
> > >         gtk_fixed_put( GTK_FIXED( fixed ), px, 10, 10 );
> > >         gtk_widget_show( px );
> > >
> > >         px = gtk_pixmap_new( image, mask );
> > >         gtk_fixed_put( GTK_FIXED( fixed ), px, 20, 20 );
> > >         gtk_widget_show( px );
> >
> > thanks. this one just works.
> 
> but as i just noticed - it brings a new problem:
> whenever the underlying "px" needs a repaint. it will be
> repainted AND it will draw OVER the overlying "px".
> 
> so i think i need some technique to force the overlying "px"
> to redraw every time the underlying one is being redrawn.
> 
> any hints?

Hi Tobias,

If you use gtk_pixmap_set() to change the lower pixmap, it 'just works'.
For example:

   fixed = gtk_fixed_new();
   gtk_box_pack_start( GTK_BOX( hb ), fixed, FALSE, FALSE, 2 );
   gtk_widget_show( fixed );

   px1 = gtk_pixmap_new( image, mask );
   gtk_fixed_put( GTK_FIXED( fixed ), px1, 10, 10 );
   gtk_widget_show( px1 );

   px2 = gtk_pixmap_new( image, mask );
   gtk_fixed_put( GTK_FIXED( fixed ), px2, 20, 20 );
   gtk_widget_show( px2 );

then, perhaps in a timer callback:

   gtk_pixmap_set( GTK_PIXMAP( px1 ), new_image, new_mask );

px1 will change underneath px2.

This isn't that great ... it flickers a little, since it's drawing px1,
then automatically redrawing px2. Plus, going through the gtk widget
mechanism isn't quite as quick as you can get it. But it's OK for simple
things.

HTH, John




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