# HG changeset patch # User lbessard # Date 1237823312 -3600 # Node ID c2c6db53a04f0c47ac7fc3d16b146f40cf887e77 # Parent cf0809bc5675ce368000b508d132db912570c7af Fix bug with maximize on TabCtrl DoubleClick. Adding scrolled panel to VariablePanel control. diff -r cf0809bc5675 -r c2c6db53a04f PLCOpenEditor.py --- a/PLCOpenEditor.py Mon Mar 23 16:42:02 2009 +0100 +++ b/PLCOpenEditor.py Mon Mar 23 16:48:32 2009 +0100 @@ -1318,14 +1318,16 @@ else: self.TabsOpened.SetPageText(idx, "-".join(words[1:])) - def GetTabsOpenedDClickFunction(self, window): + def GetTabsOpenedDClickFunction(self, tabctrl): def OnTabsOpenedDClick(event): - pane = self.AUIManager.GetPane(self.TabsOpened) - if pane.IsMaximized(): - self.AUIManager.RestorePane(pane) - else: - self.AUIManager.MaximizePane(pane) - self.AUIManager.Update() + pos = event.GetPosition() + if tabctrl.TabHitTest(pos.x, pos.y, None): + pane = self.AUIManager.GetPane(self.TabsOpened) + if pane.IsMaximized(): + self.AUIManager.RestorePane(pane) + else: + self.AUIManager.MaximizePane(pane) + self.AUIManager.Update() event.Skip() return OnTabsOpenedDClick @@ -1692,7 +1694,9 @@ self.TabsOpened.AddPage(new_window, "") if wx.VERSION >= (2, 6, 0): children = self.TabsOpened.GetChildren() - children[len(children) - 1].Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(new_window)) + last_element = children[len(children) - 1] + if isinstance(last_element, wx.aui.AuiTabCtrl): + last_element.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(last_element)) self.VariablePanelIndexer.ChangeVariablePanel(tagname) openedidx = self.IsOpened(tagname) old_selected = self.TabsOpened.GetSelection() @@ -1916,6 +1920,11 @@ else: new_window.SetKeywords(ST_KEYWORDS) self.TabsOpened.AddPage(new_window, "") + if wx.VERSION >= (2, 6, 0): + children = self.TabsOpened.GetChildren() + last_element = children[len(children) - 1] + if isinstance(last_element, wx.aui.AuiTabCtrl): + last_element.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(last_element)) new_window.RefreshView() new_window.SetFocus() self.RefreshPageTitles() @@ -3989,12 +3998,12 @@ message.Destroy() [ID_VARIABLEEDITORPANEL, ID_VARIABLEEDITORPANELVARIABLESGRID, - ID_VARIABLEEDITORPANELRETURNTYPE, ID_VARIABLEEDITORPANELCLASSFILTER, - ID_VARIABLEEDITORPANELADDBUTTON, ID_VARIABLEEDITORPANELDELETEBUTTON, - ID_VARIABLEEDITORPANELUPBUTTON, ID_VARIABLEEDITORPANELDOWNBUTTON, - ID_VARIABLEEDITORPANELSTATICTEXT1, ID_VARIABLEEDITORPANELSTATICTEXT2, - ID_VARIABLEEDITORPANELSTATICTEXT3, -] = [wx.NewId() for _init_ctrls in range(11)] + ID_VARIABLEEDITORCONTROLPANEL, ID_VARIABLEEDITORPANELRETURNTYPE, + ID_VARIABLEEDITORPANELCLASSFILTER, ID_VARIABLEEDITORPANELADDBUTTON, + ID_VARIABLEEDITORPANELDELETEBUTTON, ID_VARIABLEEDITORPANELUPBUTTON, + ID_VARIABLEEDITORPANELDOWNBUTTON, ID_VARIABLEEDITORPANELSTATICTEXT1, + ID_VARIABLEEDITORPANELSTATICTEXT2, ID_VARIABLEEDITORPANELSTATICTEXT3, +] = [wx.NewId() for _init_ctrls in range(12)] class VariablePanel(wx.Panel): @@ -4007,7 +4016,7 @@ def _init_coll_MainSizer_Items(self, parent): parent.AddWindow(self.VariablesGrid, 0, border=0, flag=wx.GROW) - parent.AddSizer(self.ControlPanelSizer, 0, border=5, flag=wx.GROW|wx.ALL) + parent.AddWindow(self.ControlPanel, 0, border=5, flag=wx.GROW|wx.ALL) def _init_coll_MainSizer_Growables(self, parent): parent.AddGrowableCol(0) @@ -4056,29 +4065,12 @@ self._init_coll_ButtonPanelSizer_Growables(self.ButtonPanelSizer) self.SetSizer(self.MainSizer) + self.ControlPanel.SetSizer(self.ControlPanelSizer) def _init_ctrls(self, prnt): wx.Panel.__init__(self, id=ID_VARIABLEEDITORPANEL, name='VariableEditorPanel', parent=prnt, pos=wx.Point(0, 0), size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) - - self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, - label='Return Type:', name='staticText1', parent=self, - pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) - - self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE, - name='ReturnType', parent=self, pos=wx.Point(0, 0), - size=wx.Size(145, 24), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE) - - self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2, - label='Class Filter:', name='staticText2', parent=self, - pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) - - self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER, - name='ClassFilter', parent=self, pos=wx.Point(0, 0), - size=wx.Size(145, 24), style=wx.CB_READONLY) - self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER) self.VariablesGrid = wx.grid.Grid(id=ID_VARIABLEEDITORPANELVARIABLESGRID, name='VariablesGrid', parent=self, pos=wx.Point(0, 0), @@ -4101,23 +4093,46 @@ wx.grid.EVT_GRID_EDITOR_SHOWN(self.VariablesGrid, self.OnVariablesGridEditorShown) self.VariablesGrid.SetDropTarget(VariableDropTarget(self)) + self.ControlPanel = wx.ScrolledWindow(id=ID_VARIABLEEDITORCONTROLPANEL, + name='ControlPanel', parent=self, pos=wx.Point(0, 0), + size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) + self.ControlPanel.SetScrollRate(0, 10) + + self.staticText1 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT1, + label='Return Type:', name='staticText1', parent=self.ControlPanel, + pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) + + self.ReturnType = wx.ComboBox(id=ID_VARIABLEEDITORPANELRETURNTYPE, + name='ReturnType', parent=self.ControlPanel, pos=wx.Point(0, 0), + size=wx.Size(145, 24), style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnReturnTypeChanged, id=ID_VARIABLEEDITORPANELRETURNTYPE) + + self.staticText2 = wx.StaticText(id=ID_VARIABLEEDITORPANELSTATICTEXT2, + label='Class Filter:', name='staticText2', parent=self.ControlPanel, + pos=wx.Point(0, 0), size=wx.Size(95, 17), style=0) + + self.ClassFilter = wx.ComboBox(id=ID_VARIABLEEDITORPANELCLASSFILTER, + name='ClassFilter', parent=self.ControlPanel, pos=wx.Point(0, 0), + size=wx.Size(145, 24), style=wx.CB_READONLY) + self.Bind(wx.EVT_COMBOBOX, self.OnClassFilter, id=ID_VARIABLEEDITORPANELCLASSFILTER) + self.AddButton = wx.Button(id=ID_VARIABLEEDITORPANELADDBUTTON, label='Add', - name='AddButton', parent=self, pos=wx.Point(0, 0), + name='AddButton', parent=self.ControlPanel, pos=wx.Point(0, 0), size=wx.Size(72, 32), style=0) self.Bind(wx.EVT_BUTTON, self.OnAddButton, id=ID_VARIABLEEDITORPANELADDBUTTON) self.DeleteButton = wx.Button(id=ID_VARIABLEEDITORPANELDELETEBUTTON, label='Delete', - name='DeleteButton', parent=self, pos=wx.Point(0, 0), + name='DeleteButton', parent=self.ControlPanel, pos=wx.Point(0, 0), size=wx.Size(72, 32), style=0) self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_VARIABLEEDITORPANELDELETEBUTTON) self.UpButton = wx.Button(id=ID_VARIABLEEDITORPANELUPBUTTON, label='^', - name='UpButton', parent=self, pos=wx.Point(0, 0), + name='UpButton', parent=self.ControlPanel, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_VARIABLEEDITORPANELUPBUTTON) self.DownButton = wx.Button(id=ID_VARIABLEEDITORPANELDOWNBUTTON, label='v', - name='DownButton', parent=self, pos=wx.Point(0, 0), + name='DownButton', parent=self.ControlPanel, pos=wx.Point(0, 0), size=wx.Size(32, 32), style=0) self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_VARIABLEEDITORPANELDOWNBUTTON)