90 |
90 |
91 def Bpath(*args): |
91 def Bpath(*args): |
92 return os.path.join(beremiz_dir, *args) |
92 return os.path.join(beremiz_dir, *args) |
93 |
93 |
94 def AppendMenu(parent, help, id, kind, text): |
94 def AppendMenu(parent, help, id, kind, text): |
95 return parent.Append(help=help, id=id, kind=kind, text=text) |
95 return parent.Append(wx.MenuItem(helpString=help, id=id, kind=kind, text=text)) |
96 |
96 |
97 MAX_RECENT_PROJECTS = 9 |
97 MAX_RECENT_PROJECTS = 9 |
98 |
98 |
99 |
99 |
100 if wx.Platform == '__WXMSW__': |
100 if wx.Platform == '__WXMSW__': |
177 self.StackLock.acquire() |
177 self.StackLock.acquire() |
178 for s, style in self.stack: |
178 for s, style in self.stack: |
179 if style is None: |
179 if style is None: |
180 style = self.black_white |
180 style = self.black_white |
181 if style != self.black_white: |
181 if style != self.black_white: |
182 self.output.StartStyling(self.output.GetLength(), 0xff) |
182 self.output.StartStyling(self.output.GetLength()) |
183 |
183 |
184 # Temporary deactivate read only mode on StyledTextCtrl for |
184 # Temporary deactivate read only mode on StyledTextCtrl for |
185 # adding text. It seems that text modifications, even |
185 # adding text. It seems that text modifications, even |
186 # programmatically, are disabled in StyledTextCtrl when read |
186 # programmatically, are disabled in StyledTextCtrl when read |
187 # only is active |
187 # only is active |
247 def _init_coll_FileMenu_Items(self, parent): |
247 def _init_coll_FileMenu_Items(self, parent): |
248 AppendMenu(parent, help='', id=wx.ID_NEW, |
248 AppendMenu(parent, help='', id=wx.ID_NEW, |
249 kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
249 kind=wx.ITEM_NORMAL, text=_(u'New') + '\tCTRL+N') |
250 AppendMenu(parent, help='', id=wx.ID_OPEN, |
250 AppendMenu(parent, help='', id=wx.ID_OPEN, |
251 kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
251 kind=wx.ITEM_NORMAL, text=_(u'Open') + '\tCTRL+O') |
252 parent.AppendMenu(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
252 parent.Append(ID_FILEMENURECENTPROJECTS, _("&Recent Projects"), self.RecentProjectsMenu) |
253 parent.AppendSeparator() |
253 parent.AppendSeparator() |
254 AppendMenu(parent, help='', id=wx.ID_SAVE, |
254 AppendMenu(parent, help='', id=wx.ID_SAVE, |
255 kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
255 kind=wx.ITEM_NORMAL, text=_(u'Save') + '\tCTRL+S') |
256 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
256 AppendMenu(parent, help='', id=wx.ID_SAVEAS, |
257 kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
257 kind=wx.ITEM_NORMAL, text=_(u'Save as') + '\tCTRL+SHIFT+S') |
289 |
289 |
290 def _RecursiveAddMenuItems(self, menu, items): |
290 def _RecursiveAddMenuItems(self, menu, items): |
291 for name, text, helpstr, children in items: |
291 for name, text, helpstr, children in items: |
292 if len(children) > 0: |
292 if len(children) > 0: |
293 new_menu = wx.Menu(title='') |
293 new_menu = wx.Menu(title='') |
294 menu.AppendMenu(wx.ID_ANY, text, new_menu) |
294 menu.AppendSubMenu(new_menu, text) |
295 self._RecursiveAddMenuItems(new_menu, children) |
295 self._RecursiveAddMenuItems(new_menu, children) |
296 else: |
296 else: |
297 item = menu.Append(wx.ID_ANY, text, helpstr) |
297 item = menu.Append(wx.MenuItem(text=text, helpString=helpstr)) |
298 self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name), item) |
298 self.Bind(wx.EVT_MENU, self.GetAddConfNodeFunction(name), item) |
299 |
299 |
300 def _init_coll_AddMenu_Items(self, parent): |
300 def _init_coll_AddMenu_Items(self, parent): |
301 IDEFrame._init_coll_AddMenu_Items(self, parent, False) |
301 IDEFrame._init_coll_AddMenu_Items(self, parent, False) |
302 self._RecursiveAddMenuItems(parent, GetAddMenuItems()) |
302 self._RecursiveAddMenuItems(parent, GetAddMenuItems()) |
309 wx.OK | wx.ICON_INFORMATION) |
309 wx.OK | wx.ICON_INFORMATION) |
310 |
310 |
311 item = parent.Append(wx.ID_ANY, _(u'Community support'), '') |
311 item = parent.Append(wx.ID_ANY, _(u'Community support'), '') |
312 self.Bind(wx.EVT_MENU, handler, item) |
312 self.Bind(wx.EVT_MENU, handler, item) |
313 |
313 |
314 parent.Append(help='', id=wx.ID_ABOUT, |
314 parent.Append(wx.MenuItem(helpString='', id=wx.ID_ABOUT, |
315 kind=wx.ITEM_NORMAL, text=_(u'About')) |
315 kind=wx.ITEM_NORMAL, text=_(u'About'))) |
316 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
316 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
317 |
317 |
318 def _init_coll_ConnectionStatusBar_Fields(self, parent): |
318 def _init_coll_ConnectionStatusBar_Fields(self, parent): |
319 parent.SetFieldsCount(3) |
319 parent.SetFieldsCount(3) |
320 |
320 |
321 parent.SetStatusText(number=0, text='') |
321 parent.SetStatusText(i=0, text='') |
322 parent.SetStatusText(number=1, text='') |
322 parent.SetStatusText(i=1, text='') |
323 parent.SetStatusText(number=2, text='') |
323 parent.SetStatusText(i=2, text='') |
324 |
324 |
325 parent.SetStatusWidths([-1, 300, 200]) |
325 parent.SetStatusWidths([-1, 300, 200]) |
326 |
326 |
327 def _init_ctrls(self, prnt): |
327 def _init_ctrls(self, prnt): |
328 IDEFrame._init_ctrls(self, prnt) |
328 IDEFrame._init_ctrls(self, prnt) |
395 ToolbarPane().Top().Position(1). |
395 ToolbarPane().Top().Position(1). |
396 LeftDockable(False).RightDockable(False)) |
396 LeftDockable(False).RightDockable(False)) |
397 |
397 |
398 self.AUIManager.Update() |
398 self.AUIManager.Update() |
399 |
399 |
400 self.ConnectionStatusBar = esb.EnhancedStatusBar(self, style=wx.ST_SIZEGRIP) |
400 self.ConnectionStatusBar = esb.EnhancedStatusBar(self, style=wx.STB_SIZEGRIP) |
401 self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar) |
401 self._init_coll_ConnectionStatusBar_Fields(self.ConnectionStatusBar) |
402 self.ProgressStatusBar = wx.Gauge(self.ConnectionStatusBar, -1, range=100) |
402 self.ProgressStatusBar = wx.Gauge(self.ConnectionStatusBar, -1, range=100) |
403 self.ConnectionStatusBar.AddWidget(self.ProgressStatusBar, esb.ESB_EXACT_FIT, esb.ESB_EXACT_FIT, 2) |
403 self.ConnectionStatusBar.AddWidget(self.ProgressStatusBar, esb.ESB_EXACT_FIT, esb.ESB_EXACT_FIT, 2) |
404 self.ProgressStatusBar.Hide() |
404 self.ProgressStatusBar.Hide() |
405 self.SetStatusBar(self.ConnectionStatusBar) |
405 self.SetStatusBar(self.ConnectionStatusBar) |
697 except Exception: |
697 except Exception: |
698 recent_projects = [] |
698 recent_projects = [] |
699 |
699 |
700 while self.RecentProjectsMenu.GetMenuItemCount() > 0: |
700 while self.RecentProjectsMenu.GetMenuItemCount() > 0: |
701 item = self.RecentProjectsMenu.FindItemByPosition(0) |
701 item = self.RecentProjectsMenu.FindItemByPosition(0) |
702 self.RecentProjectsMenu.RemoveItem(item) |
702 self.RecentProjectsMenu.Remove(item) |
703 |
703 |
704 self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0) |
704 self.FileMenu.Enable(ID_FILEMENURECENTPROJECTS, len(recent_projects) > 0) |
705 for idx, projectpath in enumerate(recent_projects): |
705 for idx, projectpath in enumerate(recent_projects): |
706 text = u'&%d: %s' % (idx + 1, projectpath) |
706 text = u'&%d: %s' % (idx + 1, projectpath) |
707 |
707 |
744 |
744 |
745 if self.CTR is not None: |
745 if self.CTR is not None: |
746 |
746 |
747 for confnode_method in self.CTR.StatusMethods: |
747 for confnode_method in self.CTR.StatusMethods: |
748 if "method" in confnode_method and confnode_method.get("shown", True): |
748 if "method" in confnode_method and confnode_method.get("shown", True): |
749 tool = StatusToolBar.AddSimpleTool( |
749 tool = StatusToolBar.AddTool( |
750 wx.ID_ANY, GetBitmap(confnode_method.get("bitmap", "Unknown")), |
750 wx.ID_ANY, confnode_method["tooltip"], |
751 confnode_method["tooltip"]) |
751 GetBitmap(confnode_method.get("bitmap", "Unknown"))) |
752 self.Bind(wx.EVT_MENU, self.GetMenuCallBackFunction(confnode_method["method"]), tool) |
752 self.Bind(wx.EVT_MENU, self.GetMenuCallBackFunction(confnode_method["method"]), tool) |
753 |
753 |
754 StatusToolBar.Realize() |
754 StatusToolBar.Realize() |
755 self.AUIManager.GetPane("StatusToolBar").BestSize(StatusToolBar.GetBestSize()).Show() |
755 self.AUIManager.GetPane("StatusToolBar").BestSize(StatusToolBar.GetBestSize()).Show() |
756 else: |
756 else: |
796 if item.IsSeparator(): |
796 if item.IsSeparator(): |
797 self.EditMenu.RemoveItem(item) |
797 self.EditMenu.RemoveItem(item) |
798 else: |
798 else: |
799 self.EditMenu.Delete(item.GetId()) |
799 self.EditMenu.Delete(item.GetId()) |
800 self.LastPanelSelected = None |
800 self.LastPanelSelected = None |
801 self.MenuBar.UpdateMenus() |
801 self.MenuBar.Refresh() |
802 |
802 |
803 def RefreshAll(self): |
803 def RefreshAll(self): |
804 self.RefreshStatusToolBar() |
804 self.RefreshStatusToolBar() |
805 |
805 |
806 def GetMenuCallBackFunction(self, method): |
806 def GetMenuCallBackFunction(self, method): |