ArchiveOrangemail archive

General discussion of wxRuby


wxruby-users.rubyforge.org
(List home) (Recent threads) (250 other RubyForge lists)

Subscription Options

  • RSS or Atom: Read-only subscription using a browser or aggregator. This is the recommended way if you don't need to send messages to the list. You can learn more about feed syndication and clients here.
  • Conventional: All messages are delivered to your mail address, and you can reply. To subscribe, send an email to the list's subscribe address with "subscribe" in the subject line, or visit the list's homepage here.
  • Low traffic list: less than 3 messages per day
  • This list contains about 6,256 messages, beginning Aug 2003
  • 0 messages added yesterday
Report the Spam
This button sends a spam report to the moderator. Please use it sparingly. For other removal requests, read this.
Are you sure? yes no

set the background to a bitmap

Ad
John Griffiths 1231869326Tue, 13 Jan 2009 17:55:26 +0000 (UTC)
Hi,

any ideas whether you can set the background of a dialog to use an
image?
Alex Fenton 1231870238Tue, 13 Jan 2009 18:10:38 +0000 (UTC)
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.ht...

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
John Griffiths 1231881475Tue, 13 Jan 2009 21:17:55 +0000 (UTC)
Thanks again Alex, will give that a go tomorrow and see how things turn 
out.

Appreciate this
Eric Rubin 1231870526Tue, 13 Jan 2009 18:15:26 +0000 (UTC)
I have a WxRuby app running on Windows and I want to try to port it to the
new Ruby 1.9.1.  I see  wxruby-ruby19-1.9.8 gems for Darwin and Linux, but
not for Windows.  Is wxruby-ruby19-1.9.8 available for Windows yet?  If not,
when will it be available?  And how stable is it?

Thanks,
Eric Rubin
Alex Fenton 1231881092Tue, 13 Jan 2009 21:11:32 +0000 (UTC)
Eric Rubin wrote:
> I have a WxRuby app running on Windows and I want to try to port it to the
> new Ruby 1.9.1.  I see  wxruby-ruby19-1.9.8 gems for Darwin and Linux, but
> not for Windows.  Is wxruby-ruby19-1.9.8 available for Windows yet?  If not,
> when will it be available?We'll definitely have a ruby19 gem available for Windows for the 
upcoming 2.0 release (next week or so). Whether we offer both mingw and 
mswin32 for Ruby 1.9.1 is not yet finalised, but in practice they're 
interchangeable. There will certainly be mingw as that's the direction 
the OCI is going in (for good reasons, IMHO).

>  And how stable is it?

Very. wxRuby has supported ruby 1.9 for a year now, and I switched over 
mainline dev of my app to it a few months ago. There are also a lot of 
changes in SVN HEAD which make it considerably more stable generally 
than the current beta releaes, 1.9.9.

alex
John Griffiths 1232026604Thu, 15 Jan 2009 13:36:44 +0000 (UTC)
Thanks Alex, I got the dialog to use a background image eventually, did 
this with WxRuby 1.9.9 on Windows XP and it works (doesn't on OSX, but 
don't need it to).

  def initialize(title)
    ......
    evt_erase_background :on_erase_background
  end

  def on_erase_background(evt)
    b_splash_bmp = Wx::Bitmap.new('images/background.gif', 
BITMAP_TYPE_GIF)
    evt.dc.draw_bitmap(b_splash_bmp, 0, 0, false)
  end
Home | About | Privacy