Class: Swing::MenuBar

Inherits:
Object
  • Object
show all
Includes:
AttrSetter
Defined in:
lib/swing/old/menu_bar.rb

Instance Method Summary collapse

Methods included from AttrSetter

dim_proc, included, #set_attributes

Constructor Details

#initialize(opts = {}) ⇒ MenuBar

Returns a new instance of MenuBar.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/swing/old/menu_bar.rb', line 10

def initialize opts = {}
  set_attributes(opts) { super() }

  if opts[:structure]
    [opts[:structure]].flatten.each do |element|
      case element
        when Hash # Hash defines menu structure
          element.each do |menu_name, menu_structure|
            menu = Menu.new menu_name.to_s, :parent => self
            menu_structure.each do |item_name, item_action|
              MenuItem.new item_name.to_s, :parent => menu, &item_action
            end
          end
        else
          self.add element
      end
    end
  end
end