Class: XRC2Ruby::ObjectTypes::TOOL

Inherits:
Object
  • Object
show all
Defined in:
lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb

Overview

Not a real wxRuby class; individual tools are created by calls to add_tool and friends.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(toolbar, an_id) ⇒ TOOL

Returns a new instance of TOOL.



27
28
29
30
31
32
33
34
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 27

def initialize(toolbar, an_id)
  @toolbar  = toolbar
    @var_name = an_id.downcase
  if an_id.sub!(/^wx/, "Wx::")
    @stock_id = an_id
  end
  @toolbar.add_tool(self)
end

Instance Attribute Details

#bitmapObject

Returns the value of attribute bitmap.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def bitmap
  @bitmap
end

#bitmap2Object

Returns the value of attribute bitmap2.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def bitmap2
  @bitmap2
end

#helpObject

Returns the value of attribute help.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def help
  @help
end

#labelObject

Returns the value of attribute label.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def label
  @label
end

#longhelpObject

Returns the value of attribute longhelp.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def longhelp
  @longhelp
end

#radioObject

Returns the value of attribute radio.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def radio
  @radio
end

#toggleObject

Returns the value of attribute toggle.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def toggle
  @toggle
end

#toolbarObject (readonly)

Returns the value of attribute toolbar.



22
23
24
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 22

def toolbar
  @toolbar
end

#tooltipObject

Returns the value of attribute tooltip.



23
24
25
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 23

def tooltip
  @tooltip
end

#var_nameObject (readonly)

Returns the value of attribute var_name.



22
23
24
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 22

def var_name
  @var_name
end

Instance Method Details

#outputObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/wx_sugar/xrc/xrc2ruby_types/toolbar.rb', line 36

def output
  @label ||= ''
  @help ||= ''
  @longhelp  ||= ''

  # Normal bitmap
  if bitmap
    bmp1 = "Wx::Bitmap.new(#{self.bitmap.inspect}, Wx::BITMAP_TYPE_PNG)"
  else
    bmp1 = "Wx::NULL_BITMAP"
  end

  # Disabled bitmap
  if bitmap2
    bmp2 = "Wx::Bitmap.new(#{self.bitmap2.inspect}, Wx::BITMAP_TYPE_PNG)"
  else
    bmp2 = "Wx::NULL_BITMAP"
  end

  # What type of tool?
  if radio
    tooltype = "Wx::ITEM_RADIO"
  elsif toggle
    tooltype = "Wx::ITEM_CHECK"
  else
    tooltype = "Wx::ITEM_NORMAL"
  end
  if @stock_id
    the_id = @stock_id
  else
    the_id = "Wx::ID_ANY"
  end
  # This is the most general form of add_tool 
  "#{var_name} = #{toolbar.var_name}.add_tool(#{the_id},
                                              #{label.inspect},
                                              #{bmp1},
                                              #{bmp2},
                                              #{tooltype},
                                              #{help.inspect},
                                              #{longhelp.inspect})\n"

end