Class: XRC2Ruby::ObjectTypes::MenuItem

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

Instance Attribute Summary collapse

Attributes inherited from Object

#centered, #name, #parent, #sub_class, #win_class

Instance Method Summary collapse

Methods inherited from Object

#inspect, next_id, #var_name

Constructor Details

#initialize(parent, klass, subclass, name) ⇒ MenuItem

Returns a new instance of MenuItem.



47
48
49
50
51
52
53
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 47

def initialize(parent, klass, subclass, name)
  super
  # stock id
  if name.sub!(/^wx/, "Wx::")
    @menu_id = name
  end
end

Instance Attribute Details

#checkableObject

Returns the value of attribute checkable.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def checkable
  @checkable
end

#checkedObject

Returns the value of attribute checked.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def checked
  @checked
end

#helpObject

Returns the value of attribute help.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def help
  @help
end

#labelObject

Returns the value of attribute label.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def label
  @label
end

#radioObject

Returns the value of attribute radio.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def radio
  @radio
end

Returns the value of attribute submenu.



45
46
47
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 45

def submenu
  @submenu
end

Instance Method Details

#outputObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/wx_sugar/xrc/xrc2ruby_types/menu.rb', line 55

def output
  @help ||= ''

  # What type of menu item?
  if radio
    item_type = "Wx::ITEM_RADIO"
  elsif checkable
    item_type = "Wx::ITEM_CHECK"
  else
    item_type = "Wx::ITEM_NORMAL"
  end

  # Using a stock id
  if @menu_id
    m_i = "#{var_name} = Wx::MenuItem.new(#{parent.var_name}, #{@menu_id})"
  else
    if XRC2Ruby.use_gettext
      the_label = "_(" + label.inspect + ")"
      the_help  = "_(" + help.inspect + ")"
    else
      the_label = label.inspect
      the_help  = help.inspect
    end
    the_submenu = submenu || "nil"
    m_i = "#{var_name} = Wx::MenuItem.new(#{parent.var_name}, Wx::ID_ANY,
               #{the_label}, #{the_help}, 
               #{item_type}, #{the_submenu})"
  end
  m_i + "\n" + "#{parent.var_name}.append_item(#{var_name})"
end