Sha256: 6479267d0ef90faeba62807931ab034f35c0c4fafdc15d77a5edb41039eef075

Contents?: true

Size: 1.83 KB

Versions: 25

Compression:

Stored size: 1.83 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

require 'rubygems' rescue LoadError

require 'wx'

# Simple test application for keyword arguments to Sizer#add_item and
# ToolBar#add_item. Originally contributed by Chauk-Mean P

Wx::App.run do
  frame = Wx::Frame.new( nil, 
                         :title => 'ToolBar and Sizer API enhancements') do
    
    sizer = Wx::BoxSizer.new(Wx::VERTICAL)
    
    button1 = Wx::Button.new(self, :label => 'Button 1')
    button2 = Wx::Button.new(self, :label => 'Button 2')
    button3 = Wx::Button.new(self, :label => 'Button 3')

    # Sizer#add_item usage
    # use of positional arguments
    sizer.add_item(button1, -1, 1, Wx::EXPAND)
    # use of a spacer
    sizer.add_item([20, 15])
    # use of keyword arguments without index
    sizer.add_item(button3, :proportion => 1, :flag => Wx::EXPAND)
    # use of keyword arguments with index specified
    sizer.add_item(button2, :index => 1, :proportion => 1, :flag => Wx::EXPAND)
    self.sizer = sizer

    # ToolBar#add_item usage
    toolbar = create_tool_bar( Wx::TB_HORIZONTAL|Wx::TB_FLAT )
    # provide only a bitmap
    new_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_NEW) )
    # use of keyword arguments without pos
    save_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_FILE_SAVE), 
                                     :short_help => "Save")
    # use of keyword arguments with pos
    open_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_FILE_OPEN), 
                                     :position => 1, 
                                     :short_help => "Open")
    toolbar.realize
    
    # tool item event handling
    evt_tool new_item_id do
      Wx::message_box "New clicked"
    end
    
  end

  frame.show
end

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
wxruby64-2.0.1-x64-mingw32 samples/etc/toolbar_sizer_additem.rb
wxruby-ruby19-2.0.1-x86-mingw32 samples/etc/toolbar_sizer_additem.rb
wxruby-ruby19-2.0.1-x86-linux samples/etc/toolbar_sizer_additem.rb
wxruby-ruby19-2.0.1-x86-darwin-9 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.1-x86-mswin32-60 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.1-x86-mingw32 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.1-x86-linux samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.1-universal-darwin-9 samples/etc/toolbar_sizer_additem.rb
wxruby-1.9.10-universal-darwin-9 samples/etc/toolbar_sizer_additem.rb
wxruby-1.9.10-x86-linux samples/etc/toolbar_sizer_additem.rb
wxruby-1.9.10-x86_64-linux samples/etc/toolbar_sizer_additem.rb
wxruby-1.9.10-x86-mswin32-60 samples/etc/toolbar_sizer_additem.rb
wxruby-1.9.10-x86-mingw32 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.0-universal-darwin-9 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.0-x86-mingw32 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.0-x86-linux samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.0-x86-mswin32-60 samples/etc/toolbar_sizer_additem.rb
wxruby-2.0.0-x86_64-linux samples/etc/toolbar_sizer_additem.rb
wxruby-ruby19-1.9.10-x86-darwin-9 samples/etc/toolbar_sizer_additem.rb
wxruby-ruby19-1.9.10-x86-mingw32 samples/etc/toolbar_sizer_additem.rb