1 import wx |
1 import wx |
2 import wx.grid |
2 import wx.grid |
3 import wx.gizmos |
3 import wx.gizmos |
4 |
4 |
5 from controls import CustomGrid, CustomTable |
5 from controls import CustomGrid, CustomTable |
6 from ConfTreeNodeEditor import ConfTreeNodeEditor |
6 from ConfTreeNodeEditor import ConfTreeNodeEditor, SCROLLBAR_UNIT |
7 |
7 |
8 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3) |
8 [ETHERCAT_VENDOR, ETHERCAT_GROUP, ETHERCAT_DEVICE] = range(3) |
9 |
9 |
10 def AppendMenu(parent, help, id, kind, text): |
10 def AppendMenu(parent, help, id, kind, text): |
11 if wx.VERSION >= (2, 6, 0): |
11 if wx.VERSION >= (2, 6, 0): |
78 self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer) |
78 self._init_coll_SlaveInfosDetailsSizer_Items(self.SlaveInfosDetailsSizer) |
79 |
79 |
80 self.ConfNodeEditor.SetSizer(self.MainSizer) |
80 self.ConfNodeEditor.SetSizer(self.MainSizer) |
81 |
81 |
82 def _init_ConfNodeEditor(self, prnt): |
82 def _init_ConfNodeEditor(self, prnt): |
83 self.ConfNodeEditor = wx.Panel(id=-1, name='SlavePanel', parent=prnt, |
83 self.ConfNodeEditor = wx.ScrolledWindow(id=-1, name='SlavePanel', parent=prnt, |
84 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
84 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL|wx.SUNKEN_BORDER|wx.HSCROLL|wx.VSCROLL) |
|
85 self.ConfNodeEditor.Bind(wx.EVT_SIZE, self.OnConfNodeEditorResize) |
85 |
86 |
86 self.VendorLabel = wx.StaticText(id=ID_NODEEDITORVENDORLABEL, |
87 self.VendorLabel = wx.StaticText(id=ID_NODEEDITORVENDORLABEL, |
87 label=_('Vendor:'), name='VendorLabel', parent=self.ConfNodeEditor, |
88 label=_('Vendor:'), name='VendorLabel', parent=self.ConfNodeEditor, |
88 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
89 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
89 |
90 |
119 label=_('Sync managers:'), name='SyncManagersLabel', parent=self.ConfNodeEditor, |
120 label=_('Sync managers:'), name='SyncManagersLabel', parent=self.ConfNodeEditor, |
120 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
121 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
121 |
122 |
122 self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID, |
123 self.SyncManagersGrid = CustomGrid(id=ID_NODEEDITORSYNCMANAGERSGRID, |
123 name='SyncManagersGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
124 name='SyncManagersGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
124 size=wx.Size(0, 0), style=wx.VSCROLL) |
125 size=wx.Size(0, 200), style=wx.VSCROLL) |
125 |
126 |
126 self.VariablesLabel = wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL, |
127 self.VariablesLabel = wx.StaticText(id=ID_NODEEDITORVARIABLESLABEL, |
127 label=_('Variable entries:'), name='VariablesLabel', parent=self.ConfNodeEditor, |
128 label=_('Variable entries:'), name='VariablesLabel', parent=self.ConfNodeEditor, |
128 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
129 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
129 |
130 |
130 self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID, |
131 self.VariablesGrid = wx.gizmos.TreeListCtrl(id=ID_NODEEDITORVARIABLESGRID, |
131 name='VariablesGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
132 name='VariablesGrid', parent=self.ConfNodeEditor, pos=wx.Point(0, 0), |
132 size=wx.Size(0, 0), style=wx.TR_DEFAULT_STYLE | |
133 size=wx.Size(0, 400), style=wx.TR_DEFAULT_STYLE | |
133 wx.TR_ROW_LINES | |
134 wx.TR_ROW_LINES | |
134 wx.TR_COLUMN_LINES | |
135 wx.TR_COLUMN_LINES | |
135 wx.TR_HIDE_ROOT | |
136 wx.TR_HIDE_ROOT | |
136 wx.TR_FULL_ROW_HIGHLIGHT) |
137 wx.TR_FULL_ROW_HIGHLIGHT) |
137 self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick) |
138 self.VariablesGrid.GetMainWindow().Bind(wx.EVT_LEFT_DOWN, self.OnVariablesGridLeftClick) |
138 |
139 |
139 self._init_sizers() |
140 self._init_sizers() |
140 |
141 |
141 def __init__(self, parent, controler, window): |
142 def __init__(self, parent, controler, window): |
250 dragSource.SetData(data) |
251 dragSource.SetData(data) |
251 dragSource.DoDragDrop() |
252 dragSource.DoDragDrop() |
252 |
253 |
253 event.Skip() |
254 event.Skip() |
254 |
255 |
|
256 def OnConfNodeEditorResize(self, event): |
|
257 self.ConfNodeEditor.GetBestSize() |
|
258 xstart, ystart = self.ConfNodeEditor.GetViewStart() |
|
259 window_size = self.ConfNodeEditor.GetClientSize() |
|
260 maxx, maxy = self.ConfNodeEditor.GetMinSize() |
|
261 posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
|
262 posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
|
263 self.ConfNodeEditor.Scroll(posx, posy) |
|
264 self.ConfNodeEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
|
265 maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy) |
|
266 event.Skip() |
|
267 |
255 CIA402NodeEditor = NodeEditor |
268 CIA402NodeEditor = NodeEditor |