179 ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", |
180 ID_PLCOPENEDITORTOOLBARBLOCK, "OnBlockTool", |
180 "add_block.png", _("Create a new block")), |
181 "add_block.png", _("Create a new block")), |
181 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
182 (True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
182 ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", |
183 ID_PLCOPENEDITORTOOLBARCONNECTION, "OnConnectionTool", |
183 "add_connection.png", _("Create a new connection"))], |
184 "add_connection.png", _("Create a new connection"))], |
184 "LD" : [((True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
185 "LD" : [(True, FREEDRAWING_MODE|DRIVENDRAWING_MODE, |
185 ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool", |
186 ID_PLCOPENEDITORTOOLBARMOTION, "OnMotionTool", |
186 "move.png", _("Move the view")), |
187 "move.png", _("Move the view")), |
187 True, FREEDRAWING_MODE, |
188 (True, FREEDRAWING_MODE, |
188 ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", |
189 ID_PLCOPENEDITORTOOLBARCOMMENT, "OnCommentTool", |
189 "add_comment.png", _("Create a new comment")), |
190 "add_comment.png", _("Create a new comment")), |
190 (True, FREEDRAWING_MODE, |
191 (True, FREEDRAWING_MODE, |
191 ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
192 ID_PLCOPENEDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
192 "add_powerrail.png", _("Create a new power rail")), |
193 "add_powerrail.png", _("Create a new power rail")), |
4190 def _init_ctrls(self, prnt): |
4191 def _init_ctrls(self, prnt): |
4191 wx.Panel.__init__(self, id=ID_DEBUGVARIABLEPANEL, |
4192 wx.Panel.__init__(self, id=ID_DEBUGVARIABLEPANEL, |
4192 name='DebugVariablePanel', parent=prnt, pos=wx.Point(0, 0), |
4193 name='DebugVariablePanel', parent=prnt, pos=wx.Point(0, 0), |
4193 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
4194 size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
4194 |
4195 |
4195 self.VariablesGrid = wx.grid.Grid(id=ID_DEBUGVARIABLEPANELVARIABLESGRID, |
4196 self.VariablesGrid = CustomGrid(id=ID_DEBUGVARIABLEPANELVARIABLESGRID, |
4196 name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
4197 name='VariablesGrid', parent=self, pos=wx.Point(0, 0), |
4197 size=wx.Size(0, 150), style=wx.VSCROLL) |
4198 size=wx.Size(0, 150), style=wx.VSCROLL) |
4198 self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
4199 self.VariablesGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False, |
4199 'Sans')) |
4200 'Sans')) |
4200 self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
4201 self.VariablesGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL, |
4201 False, 'Sans')) |
4202 False, 'Sans')) |
4202 self.VariablesGrid.SetSelectionBackground(wx.WHITE) |
4203 self.VariablesGrid.SetSelectionBackground(wx.WHITE) |
4203 self.VariablesGrid.SetSelectionForeground(wx.BLACK) |
4204 self.VariablesGrid.SetSelectionForeground(wx.BLACK) |
4204 self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
4205 self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
4205 if wx.VERSION >= (2, 6, 0): |
4206 if wx.VERSION >= (2, 6, 0): |
4206 self.VariablesGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnVariablesGridCellSelect) |
|
4207 self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnVariablesGridCellRightClick) |
4207 self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnVariablesGridCellRightClick) |
4208 else: |
4208 else: |
4209 wx.grid.EVT_GRID_SELECT_CELL(self.VariablesGrid, self.OnVariablesGridCellSelect) |
|
4210 wx.grid.EVT_GRID_CELL_RIGHT_CLICK(self.VariablesGrid, self.OnVariablesGridCellRightClick) |
4209 wx.grid.EVT_GRID_CELL_RIGHT_CLICK(self.VariablesGrid, self.OnVariablesGridCellRightClick) |
4211 |
4210 |
4212 self.UpButton = wx.Button(id=ID_DEBUGVARIABLEPANELUPBUTTON, label='^', |
4211 self.UpButton = wx.Button(id=ID_DEBUGVARIABLEPANELUPBUTTON, label='^', |
4213 name='UpButton', parent=self, pos=wx.Point(0, 0), |
4212 name='UpButton', parent=self, pos=wx.Point(0, 0), |
4214 size=wx.Size(32, 32), style=0) |
4213 size=wx.Size(32, 32), style=0) |
4215 self.Bind(wx.EVT_BUTTON, self.OnUpButton, id=ID_DEBUGVARIABLEPANELUPBUTTON) |
|
4216 |
4214 |
4217 self.DownButton = wx.Button(id=ID_DEBUGVARIABLEPANELDOWNBUTTON, label='v', |
4215 self.DownButton = wx.Button(id=ID_DEBUGVARIABLEPANELDOWNBUTTON, label='v', |
4218 name='DownButton', parent=self, pos=wx.Point(0, 0), |
4216 name='DownButton', parent=self, pos=wx.Point(0, 0), |
4219 size=wx.Size(32, 32), style=0) |
4217 size=wx.Size(32, 32), style=0) |
4220 self.Bind(wx.EVT_BUTTON, self.OnDownButton, id=ID_DEBUGVARIABLEPANELDOWNBUTTON) |
|
4221 |
4218 |
4222 self.DeleteButton = wx.Button(id=ID_DEBUGVARIABLEPANELDELETEBUTTON, label=_('Delete'), |
4219 self.DeleteButton = wx.Button(id=ID_DEBUGVARIABLEPANELDELETEBUTTON, label=_('Delete'), |
4223 name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
4220 name='DeleteButton', parent=self, pos=wx.Point(0, 0), |
4224 size=wx.DefaultSize, style=0) |
4221 size=wx.DefaultSize, style=0) |
4225 self.Bind(wx.EVT_BUTTON, self.OnDeleteButton, id=ID_DEBUGVARIABLEPANELDELETEBUTTON) |
|
4226 |
4222 |
4227 self._init_sizers() |
4223 self._init_sizers() |
4228 |
4224 |
4229 def __init__(self, parent, producer): |
4225 def __init__(self, parent, producer): |
4230 self._init_ctrls(parent) |
4226 self._init_ctrls(parent) |
4231 DebugViewer.__init__(self, producer, True) |
4227 DebugViewer.__init__(self, producer, True) |
4232 self.HasNewData = False |
4228 self.HasNewData = False |
4233 |
4229 |
4234 self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
4230 self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
4235 self.VariablesGrid.SetTable(self.Table) |
4231 self.VariablesGrid.SetTable(self.Table) |
|
4232 self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, |
|
4233 "Up": self.UpButton, |
|
4234 "Down": self.DownButton}) |
|
4235 |
|
4236 def _AddVariable(new_row): |
|
4237 return self.VariablesGrid.GetGridCursorRow() |
|
4238 setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
|
4239 |
|
4240 def _DeleteVariable(row): |
|
4241 item = self.Table.GetItem(row) |
|
4242 self.RemoveDataConsumer(item) |
|
4243 self.Table.RemoveItem(row) |
|
4244 self.RefreshGrid() |
|
4245 setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
|
4246 |
|
4247 def _MoveVariable(row, move): |
|
4248 new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1)) |
|
4249 if new_row != row: |
|
4250 self.Table.MoveItem(row, new_row) |
|
4251 self.RefreshGrid() |
|
4252 return new_row |
|
4253 setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
|
4254 |
4236 self.VariablesGrid.SetRowLabelSize(0) |
4255 self.VariablesGrid.SetRowLabelSize(0) |
4237 |
4256 |
4238 for col in range(self.Table.GetNumberCols()): |
4257 for col in range(self.Table.GetNumberCols()): |
4239 attr = wx.grid.GridCellAttr() |
4258 attr = wx.grid.GridCellAttr() |
4240 attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
4259 attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
4241 self.VariablesGrid.SetColAttr(col, attr) |
4260 self.VariablesGrid.SetColAttr(col, attr) |
4242 self.VariablesGrid.SetColSize(col, 100) |
4261 self.VariablesGrid.SetColSize(col, 100) |
4243 |
4262 |
4244 self.Table.ResetView(self.VariablesGrid) |
4263 self.Table.ResetView(self.VariablesGrid) |
4245 self.RefreshButtons() |
4264 self.VariablesGrid.RefreshButtons() |
4246 |
4265 |
4247 def RefreshNewData(self): |
4266 def RefreshNewData(self): |
4248 if self.HasNewData: |
4267 if self.HasNewData: |
4249 self.HasNewData = False |
4268 self.HasNewData = False |
4250 self.RefreshGrid() |
4269 self.RefreshGrid() |
4251 DebugViewer.RefreshNewData(self) |
4270 DebugViewer.RefreshNewData(self) |
4252 |
4271 |
4253 def RefreshGrid(self): |
4272 def RefreshGrid(self): |
4254 self.Freeze() |
4273 self.Freeze() |
4255 self.Table.ResetView(self.VariablesGrid) |
4274 self.Table.ResetView(self.VariablesGrid) |
|
4275 self.VariablesGrid.RefreshButtons() |
4256 self.Thaw() |
4276 self.Thaw() |
4257 |
4277 |
4258 def ResetGrid(self): |
4278 def ResetGrid(self): |
4259 self.DeleteDataConsumers() |
4279 self.DeleteDataConsumers() |
4260 self.Table.Empty() |
4280 self.Table.Empty() |
4261 self.Freeze() |
4281 self.Freeze() |
4262 self.Table.ResetView(self.VariablesGrid) |
4282 self.Table.ResetView(self.VariablesGrid) |
|
4283 self.VariablesGrid.RefreshButtons() |
4263 self.Thaw() |
4284 self.Thaw() |
4264 |
4285 |
4265 def GetForceVariableMenuFunction(self, iec_path, item): |
4286 def GetForceVariableMenuFunction(self, iec_path, item): |
4266 iec_type = self.GetDataType(iec_path) |
4287 iec_type = self.GetDataType(iec_path) |
4267 def ForceVariableFunction(event): |
4288 def ForceVariableFunction(event): |