Ruby Forum wxRuby > Black background using paint_buffered

Posted by Andreas Warberg (awarberg)
on 23.04.2008 12:24
Hi,

To avoid flickering during screen updates in a Frame on Windows I
recently switched from

paint do | dc |
   #...
end

to

paint_buffered do | dc |
   #...
end

The background colour of the Frame is set to WHITE, which is respected
under paint, but is replaced by BLACK under paint_buffered.

The painting jobs seems fine, though all my black lines become invisible
:P

Is there something I can do to sort this out? Perhaps supply my own
buffer...

Thank you!

Regards, Andreas
Posted by Alex Fenton (Guest)
on 23.04.2008 12:39
(Received via mailing list)
Andreas Warberg wrote:
>    #...
>   
Yes, you can pass your own buffer as an optional argument to
paint_buffered. It should be a Wx::Bitmap of the appropriate height and
width.

I will see if the ruby code that does paint_buffered could make the
bitmap background match the window's.

a
Posted by Mario Steele (Guest)
on 23.04.2008 12:45
(Received via mailing list)
Dang you Alex,

You beat me to it. :P  Actually, another suggestion, would be to use
Wx::DC#draw_rectangle(), in which you set the Pen and Brush with the 
color
you want to use.

Simple Example (Not Tested):

<code>
pen = Wx::Pen.new(Wx::WHITE)
brush = Wx::Brush.new()
brush.colour(Wx::WHITE)

dc.set_pen(pen)
dc.set_brush(brush)
dc.draw_rectangle(0,0,self.width,self.height)

.... do your drawing here ....
</code>

L8ers,
Posted by Andreas Warberg (awarberg)
on 23.04.2008 12:55
Mario Steele wrote:
> pen = Wx::Pen.new(Wx::WHITE)
> brush = Wx::Brush.new()
> brush.colour(Wx::WHITE)
> 
> dc.set_pen(pen)
> dc.set_brush(brush)
> dc.draw_rectangle(0,0,self.width,self.height)
> 
> .... do your drawing here ....

Thanks for this workaround. I now have flicker free updates AND a white 
background :)

I'm looking forward to your update, Alex.

Thanks guys - I'm enjoying wxruby :)