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 Method Summary collapse
- #build ⇒ Object
- #get_menu(_menubar, _context, context_path) ⇒ Object
- #get_menu_context(_menubar, _context) ⇒ Object
- #get_sub_menu(menu_context, folder = nil) ⇒ Object
-
#initialize(menu) ⇒ ArcadiaMainMenu
constructor
A new instance of ArcadiaMainMenu.
- #new_item(_sender, _args = nil) ⇒ Object
Methods inherited from ArcadiaUserControl
Constructor Details
#initialize(menu) ⇒ ArcadiaMainMenu
Returns a new instance of ArcadiaMainMenu.
704 705 706 707 708 709 710 711 712 713 714 |
# File 'lib/a-core.rb', line 704 def initialize() # create main menu @menu = build @menu.configure(Arcadia.style('menu')) # menu.foreground('black') # menu.activeforeground('#6679f1') # menu.relief('flat') # menu.borderwidth(0) # menu.font(Arcadia.conf('main.mainmenu.font')) end |
Instance Method Details
#build ⇒ Object
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
# File 'lib/a-core.rb', line 790 def build = [ ['File', 0], ['Open', proc{Arcadia.process_event(OpenBufferEvent.new(self,'file'=>Tk.getOpenFile))}, 0], ['New', $arcadia['main.action.new_file'], 0], #['Save', proc{EditorContract.instance.save_file_raised(self)},0], ['Save', proc{Arcadia.process_event(SaveBufferEvent.new(self))},0], ['Save as ...', proc{Arcadia.process_event(SaveAsBufferEvent.new(self))},0], '---', ['Quit', $arcadia['action.on_exit'], 0]] = [['Edit', 0], ['Cut', $arcadia['main.action.edit_cut'], 2], ['Copy', $arcadia['main.action.edit_copy'], 0], ['Paste', $arcadia['main.action.edit_paste'], 0]] = [['Search', 0], ['Find ...', proc{Arcadia.process_event(SearchBufferEvent.new(self))}, 2], ['Find in files...', proc{Arcadia.process_event(SearchInFilesEvent.new(self))}, 2], ['Go to line ...', proc{Arcadia.process_event(GoToLineBufferEvent.new(self))}, 2]] = [['View', 0],['Show/Hide Toolbar', proc{$arcadia.}, 2]] = [['Tools', 0], ['Keys-test', $arcadia['action.test.keys'], 2] ] = [['Help', 0], ['About', $arcadia['action.show_about'], 2],] @menu.() @menu.() @menu.() @menu.() @menu.() @menu.() #@menu.bind_append("1", proc{ # chs = TkWinfo.children(@menu) # hh = 25 # @last_post = nil # chs.each{|ch| # ch.bind_append("Enter", proc{|x,y,rx,ry| # @last_post.unpost if @last_post # ch.menu.post(x-rx,y-ry+hh) # @last_post=ch.menu}, "%X %Y %x %y") # ch.bind_append("Leave", proc{ # @last_post.unpost if @last_post # }) # } #}) end |
#get_menu(_menubar, _context, context_path) ⇒ Object
767 768 769 770 771 772 773 774 775 |
# File 'lib/a-core.rb', line 767 def (, _context, context_path) = (, _context) folders = context_path.split('/') sub = folders.each{|folder| sub = (sub, folder) } sub end |
#get_menu_context(_menubar, _context) ⇒ Object
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 |
# File 'lib/a-core.rb', line 716 def (, _context) = [0..-1] # cerchiamo il context m_i = -1 .each_with_index{|mb, i| _t = mb[0].cget('text') if _t==_context m_i = i break end } if m_i > -1 [m_i][1] else .([[_context],[]])[1].delete(0) end end |
#get_sub_menu(menu_context, folder = nil) ⇒ Object
734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
# File 'lib/a-core.rb', line 734 def (, folder=nil) if folder s_i = -1 i_end = .index('end') if i_end 0.upto(i_end){|j| l = .entrycget(j,'label') if l == folder s_i = j break end } end end if s_i > -1 && .(s_i) == 'cascade' sub = .entrycget(s_i, 'menu') else sub = TkMenu.new( :parent=>@pop_up, :tearoff=>0 ) sub.configure(Arcadia.style('menu')) #update_style(sub) .insert('end', :cascade, :label=>folder, :menu=>sub, :hidemargin => false ) end sub end |
#new_item(_sender, _args = nil) ⇒ Object
778 779 780 781 782 783 784 785 786 787 |
# File 'lib/a-core.rb', line 778 def new_item(_sender, _args= nil) return if _args.nil? if _args['context_caption'] conte = _args['context_caption'] else conte = _args['context'] end _args['menu']=(@menu, conte, _args['context_path']) super(_sender, _args) end |