Sha256: 928c0903fbec5de87756329bbc8d62330fd41f02fdf66c16cb50f4ffea914d95

Contents?: true

Size: 1.98 KB

Versions: 42

Compression:

Stored size: 1.98 KB

Contents

#!/usr/bin/env ruby
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
begin
  require 'rubygems' 
rescue LoadError
end
require 'wx'


require 'wx'


class TestPanel < Wx::Panel
  def initialize(parent, log)
    super(parent, :style => Wx::NO_FULL_REPAINT_ON_RESIZE)
    @log = log
    
    bmp_file = File.join( File.dirname(__FILE__), 'icons', 'test2.bmp')
    bmp = Wx::Bitmap.new(bmp_file, Wx::BITMAP_TYPE_BMP)
    bmp.mask= Wx::Mask.new(bmp, Wx::BLUE)

    b = Wx::BitmapButton.new( self, 
                              :bitmap => bmp, 
                              :pos    => [ 20, 20 ], 
                              :size   => [ bmp.width + 10,bmp.height + 10] )
    evt_button b, :on_click
    b.tool_tip = 'This is a bitmap button.'
    
    b = Wx::BitmapButton.new( self,
                              :bitmap => bmp, 
                              :pos    => [ 20, 120 ], 
                              :size   => [ bmp.width + 10,bmp.height + 10],
                              :style  => Wx::NO_BORDER)
    evt_button b, :on_click
    b.tool_tip = "This is a Bitmap button with\nWx::NO_BORDER style."

    bmp_file = File.join( File.dirname(__FILE__), 'icons', 'smiles.bmp')
    bmp = Wx::Bitmap.new(bmp_file, Wx::BITMAP_TYPE_BMP)
    b.bitmap_selected = bmp
  end
  
  def on_click(event)
    @log.write_text("Click! %d" % event.id)
  end
end

module Demo

  def Demo.run(frame, nb, log)
    win = TestPanel.new(nb, log)
    return win
  end
  
  def Demo.overview
    return "A BitmapButton control displays a bitmap. It can have a separate bitmap for each button state: normal, selected, disabled.\n\nThe bitmaps to be displayed should have a small number of colours, such as 16, to avoid palette problems.\n\nA bitmap can be derived from most image formats using the Wx::Image class."
  end

end

if __FILE__ == $0
  run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
  load run_solo_lib
  run File.basename($0)
end

Version data entries

42 entries across 42 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 samples/bigdemo/wxBitmapButton.rbw
wxruby-ruby19-2.0.1-x86-mingw32 samples/bigdemo/wxBitmapButton.rbw
wxruby-ruby19-2.0.1-x86-linux samples/bigdemo/wxBitmapButton.rbw
wxruby-ruby19-2.0.1-x86-darwin-9 samples/bigdemo/wxBitmapButton.rbw
wxruby-2.0.1-x86-mswin32-60 samples/bigdemo/wxBitmapButton.rbw
wxruby-2.0.1-x86-mingw32 samples/bigdemo/wxBitmapButton.rbw
wxruby-2.0.1-x86-linux samples/bigdemo/wxBitmapButton.rbw
wxruby-2.0.1-universal-darwin-9 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.7-i386-mswin32 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.10-universal-darwin-9 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.10-x86-linux samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.10-x86_64-linux samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.10-x86-mswin32-60 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.10-x86-mingw32 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.6-universal-darwin-9 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.6-x86-linux samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.6-x86-mswin32-60 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.6-x86-mingw32 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.7-universal-darwin-9 samples/bigdemo/wxBitmapButton.rbw
wxruby-1.9.7-x86-mswin32-60 samples/bigdemo/wxBitmapButton.rbw