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, context_underline = nil) ⇒ Object
- #get_menu_context(_menubar, _context, _underline = nil) ⇒ 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.
989 990 991 992 993 994 995 996 997 998 999 |
# File 'lib/a-core.rb', line 989 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
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'lib/a-core.rb', line 1078 def build = [ ['File', 0], ['Open', proc{Arcadia.process_event(OpenBufferEvent.new(self,'file'=>Arcadia.open_file_dialog))}, 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', proc{Arcadia.process_event(CutTextEvent.new(self))}, 2], ['Copy', proc{Arcadia.process_event(CopyTextEvent.new(self))}, 0], ['Paste', proc{Arcadia.process_event(PasteTextEvent.new(self))}, 0], ['Prettify Current', proc{Arcadia.process_event(PrettifyTextEvent.new(self))}, 0]] = [['Search', 0], ['Find/Replace ...', proc{Arcadia.process_event(SearchBufferEvent.new(self))}, 2], ['Find in files...', proc{Arcadia.process_event(SearchInFilesEvent.new(self))}, 2], ['Ack in files...', proc{Arcadia.process_event(AckInFilesEvent.new(self))}, 2], ['Go to line ...', proc{Arcadia.process_event(GoToLineBufferEvent.new(self))}, 2]] = [['View', 0],['Show/Hide Toolbar', proc{$arcadia.}, 2], ['Close current tab', proc{Arcadia.process_event(CloseCurrentTabEvent.new(self))}, 0], ] = [['Tools', 0], ['Keys-test', $arcadia['action.test.keys'], 2], ['Edit prefs', proc{Arcadia.process_event(OpenBufferEvent.new(self,'file'=>$arcadia.local_file_config))}, 0], ['Load from edited prefs', proc{$arcadia.load_local_config}, 0] ] = [['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 && @last_post != ch.menu # 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 # @last_post=nil # }) # } #}) end |
#get_menu(_menubar, _context, context_path, context_underline = nil) ⇒ Object
1055 1056 1057 1058 1059 1060 1061 1062 1063 |
# File 'lib/a-core.rb', line 1055 def (, _context, context_path, context_underline=nil) = (, _context, context_underline) folders = context_path.split('/') sub = folders.each{|folder| sub = (sub, folder) } sub end |
#get_menu_context(_menubar, _context, _underline = nil) ⇒ Object
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
# File 'lib/a-core.rb', line 1001 def (, _context, _underline=nil) = [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,_underline],[]])[1].delete(0) end end |
#get_sub_menu(menu_context, folder = nil) ⇒ Object
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 |
# File 'lib/a-core.rb', line 1019 def (, folder=nil) if folder s_i = -1 i_end = .index('end') if i_end 0.upto(i_end){|j| type = .(j) if type != 'separator' l = .entrycget(j,'label') if l == folder && type == 'cascade' s_i = j break end end } end end if s_i > -1 #&& menu_context.menutype(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
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 |
# File 'lib/a-core.rb', line 1066 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'], _args['context_underline']) super(_sender, _args) end |