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.
1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 |
# File 'lib/a-core.rb', line 1678 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.
1645 1646 1647 |
# File 'lib/a-core.rb', line 1645 def @menubar end |
Class Method Details
.sub_menu(_menu, _title = nil) ⇒ Object
1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 |
# File 'lib/a-core.rb', line 1714 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
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 |
# File 'lib/a-core.rb', line 1695 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
1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 |
# File 'lib/a-core.rb', line 1739 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
1766 1767 1768 1769 1770 1771 1772 1773 |
# File 'lib/a-core.rb', line 1766 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
1761 1762 1763 1764 |
# File 'lib/a-core.rb', line 1761 def (, _context, context_path, context_underline=nil) = (, _context, context_underline) (, context_path, context_underline) end |
#new_item(_sender, _args = nil) ⇒ Object
1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 |
# File 'lib/a-core.rb', line 1775 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 |