Class: ArcadiaMainMenu
- Inherits:
-
ArcadiaUserControl
- Object
- ArcadiaUserControl
- ArcadiaMainMenu
- Defined in:
- lib/a-core.rb
Defined Under Namespace
Classes: UserItem
Constant Summary collapse
- SUF =
'user_menu'
Instance Attribute Summary collapse
-
#menubar ⇒ Object
readonly
Returns the value of attribute menubar.
Class Method Summary collapse
Instance Method Summary collapse
- #get_menu_context(_menubar, _context, _underline = nil) ⇒ Object
- #get_sub_menu(menu_context, folder = nil) ⇒ Object
-
#initialize(root) ⇒ ArcadiaMainMenu
constructor
A new instance of ArcadiaMainMenu.
- #make_menu(_menu, context_path, context_underline = nil) ⇒ Object
- #make_menu_in_menubar(_menubar, _context, context_path, context_underline = nil) ⇒ Object
- #new_item(_sender, _args = nil) ⇒ Object
Methods inherited from ArcadiaUserControl
Constructor Details
#initialize(root) ⇒ ArcadiaMainMenu
Returns a new instance of ArcadiaMainMenu.
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 |
# File 'lib/a-core.rb', line 1584 def initialize(root) # Creating Menubar @menubar = Arcadia.wf.(root) # @menubar = TkMenu.new(root) begin # if !OS.mac? # @menubar.configure(Arcadia.style('menu').delete_if {|key, value| key=='tearoff'}) # @menubar.extend(TkAutoPostMenu) # @menubar.event_posting_on # end root['menu'] = @menubar @menu_contexts = {} rescue RuntimeError => e Arcadia.runtime_error(e) end end |
Instance Attribute Details
#menubar ⇒ Object (readonly)
Returns the value of attribute menubar.
1551 1552 1553 |
# File 'lib/a-core.rb', line 1551 def @menubar end |
Class Method Details
.sub_menu(_menu, _title = nil) ⇒ Object
1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 |
# File 'lib/a-core.rb', line 1620 def ArcadiaMainMenu.(, _title=nil) s_i = -1 if _title i_end = .index('end') if i_end 0.upto(i_end){|j| type = .(j) if type != 'separator' l = .entrycget(j,'label') if l == _title && type == 'cascade' s_i = j break end end } end end if s_i > -1 sub = .entrycget(s_i, 'menu') else sub = nil end sub end |
Instance Method Details
#get_menu_context(_menubar, _context, _underline = nil) ⇒ Object
1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 |
# File 'lib/a-core.rb', line 1601 def (, _context, _underline=nil) m = @menu_contexts[_context] if !m.nil? m else = Arcadia.wf.() # topmenu = TkMenu.new(_menubar) # if !OS.mac? # topmenu.configure(Arcadia.style('menu')) # topmenu.extend(TkAutoPostMenu) # end opt = {:menu => , :label => _context} opt[:underline]=_underline if _underline .add(:cascade, opt) @menu_contexts[_context] = end end |
#get_sub_menu(menu_context, folder = nil) ⇒ Object
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 |
# File 'lib/a-core.rb', line 1645 def (, folder=nil) sub = ArcadiaMainMenu.(, folder) if sub.nil? sub = Arcadia.wf.(:tearoff=>0) # sub = TkMenu.new( # :tearoff=>0 # ) # if !OS.mac? # sub.configure(Arcadia.style('menu')) # sub.extend(TkAutoPostMenu) # end #update_style(sub) .insert('end', :cascade, :label=>folder, :menu=>sub, :hidemargin => false ) end sub end |
#make_menu(_menu, context_path, context_underline = nil) ⇒ Object
1672 1673 1674 1675 1676 1677 1678 1679 |
# File 'lib/a-core.rb', line 1672 def (, context_path, context_underline=nil) folders = context_path.split('/') sub = folders.each{|folder| sub = (sub, folder) } sub end |
#make_menu_in_menubar(_menubar, _context, context_path, context_underline = nil) ⇒ Object
1667 1668 1669 1670 |
# File 'lib/a-core.rb', line 1667 def (, _context, context_path, context_underline=nil) = (, _context, context_underline) (, context_path, context_underline) end |
#new_item(_sender, _args = nil) ⇒ Object
1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 |
# File 'lib/a-core.rb', line 1681 def new_item(_sender, _args= nil) return if _args.nil? if _args['context_caption'] conte = _args['context_caption'] else conte = _args['context'] end if _args['rif'] == 'main' _args['menu']=(@menubar, conte, _args['context_path'], _args['context_underline']) else if Arcadia.(_args['rif']) _args['menu']=(Arcadia.(_args['rif']), _args['context_path'], _args['context_underline']) else msg = Arcadia.text("main.e.adding_new_menu_item.msg", [_args['name'], _args['rif']]) Arcadia.dialog(self, 'type'=>'ok', 'title' => Arcadia.text("main.e.adding_new_menu_item.title",[self.class::SUF]), 'msg'=>msg, 'level'=>'error') _args['menu']=(@menubar, conte, _args['context_path'], _args['context_underline']) end end super(_sender, _args) end |