[wxruby-users] set the background to a bitmap
Alex Fenton
alex at pressure.to
Tue Jan 13 13:10:38 EST 2009
John Griffiths wrote:
> any ideas whether you can set the background of a dialog to use an
> image?
Use evt_erase_background, which is meant for this:
http://wxruby.rubyforge.org/doc/eraseevent.html
The example below just fills with colour, but you could replace the call
to gradient_fill_linear with one to DC#draw_bitmap or whatever other
drawing/painting code yoou wanted. Please, just don't do anything as
eyesore as this ...
alex
__
require 'wx'
class BackgroundDialog < Wx::Dialog
def initialize(parent)
super(parent, :title => "dialog with background")
Wx::TextCtrl.new(self, :value => 'foo', :pos => [ 50, 50 ])
evt_erase_background :on_erase_background
end
def on_erase_background(evt)
# Use the event's DC object to draw whatever background you want
evt.dc.gradient_fill_linear( client_rect,
Wx::RED, Wx::BLACK, Wx::NORTH )
end
end
Wx::App.run do
frame = Wx::Frame.new(nil, :title => 'frame')
frame.show
BackgroundDialog.new(frame).show
end
More information about the wxruby-users
mailing list