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 via http://www.ruby-forum.com/.
Andreas Warberg wrote:> 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... >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
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, On Wed, Apr 23, 2008 at 5:34 AM, Alex Fenton <alex at pressure.to> wrote:> Andreas Warberg wrote: > > 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... > > > 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 > > _______________________________________________ > wxruby-users mailing list > wxruby-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/wxruby-users >-- Mario Steele http://www.trilake.net http://www.ruby-im.net http://rubyforge.org/projects/wxruby/ http://rubyforge.org/projects/wxride/ http://rubyforge.org/projects/vwmc/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/wxruby-users/attachments/20080423/473e4348/attachment.html
Andreas Warberg
2008-Apr-23 10:55 UTC
[wxruby-users] Black background using paint_buffered
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 :) -- Posted via http://www.ruby-forum.com/.