163 "add_contact.png", "Create a new contact")], |
166 "add_contact.png", "Create a new contact")], |
164 "ST" : [], |
167 "ST" : [], |
165 "IL" : [] |
168 "IL" : [] |
166 } |
169 } |
167 |
170 |
168 def GenerateBitmap(icon1_name, icon2_name = None): |
|
169 if icon2_name is None: |
|
170 return wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
171 else: |
|
172 icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
173 icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) |
|
174 width = icon1.GetWidth() + icon2.GetWidth() - 1 |
|
175 height = max(icon1.GetHeight(), icon2.GetHeight()) |
|
176 tmp_bitmap = wx.EmptyBitmap(width, height) |
|
177 dc = wx.MemoryDC() |
|
178 dc.SelectObject(tmp_bitmap) |
|
179 dc.Clear() |
|
180 dc.DrawBitmap(icon1, 0, 0) |
|
181 dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) |
|
182 return tmp_bitmap |
|
183 |
|
184 def AppendMenu(parent, help, id, kind, text): |
171 def AppendMenu(parent, help, id, kind, text): |
185 if wx.VERSION >= (2, 6, 0): |
172 if wx.VERSION >= (2, 6, 0): |
186 parent.Append(help=help, id=id, kind=kind, text=text) |
173 parent.Append(help=help, id=id, kind=kind, text=text) |
187 else: |
174 else: |
188 parent.Append(helpString=help, id=id, kind=kind, item=text) |
175 parent.Append(helpString=help, id=id, kind=kind, item=text) |
367 self._init_utils() |
354 self._init_utils() |
368 self.SetClientSize(wx.Size(1000, 600)) |
355 self.SetClientSize(wx.Size(1000, 600)) |
369 self.SetMenuBar(self.MenuBar) |
356 self.SetMenuBar(self.MenuBar) |
370 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
357 self.Bind(wx.EVT_CLOSE, self.OnCloseFrame) |
371 |
358 |
372 if wx.VERSION >= (2, 8, 0): |
359 if USE_AUI: |
373 self.AUIManager = wx.aui.AuiManager(self) |
360 self.AUIManager = wx.aui.AuiManager(self) |
374 self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
361 self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
375 self.Panes = {} |
362 self.Panes = {} |
376 |
363 |
377 if wx.VERSION < (2, 8, 0): |
364 self.TreeNoteBook = wx.aui.AuiNotebook(self) |
|
365 self.AUIManager.AddPane(self.TreeNoteBook, wx.aui.AuiPaneInfo().Caption("Project").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False)) |
|
366 |
|
367 else: |
378 self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER, |
368 self.MainSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORMAINSPLITTER, |
379 name='MainSplitter', parent=self, point=wx.Point(0, 0), |
369 name='MainSplitter', parent=self, point=wx.Point(0, 0), |
380 size=wx.Size(0, 0), style=wx.SP_3D) |
370 size=wx.Size(0, 0), style=wx.SP_3D) |
381 self.MainSplitter.SetNeedUpdating(True) |
371 self.MainSplitter.SetNeedUpdating(True) |
382 self.MainSplitter.SetMinimumPaneSize(1) |
372 self.MainSplitter.SetMinimumPaneSize(1) |
383 |
373 |
384 self.TreeNoteBook = wx.Notebook(id=ID_PLCOPENEDITORTREENOTEBOOK, |
374 self.TreeNoteBook = wx.Notebook(id=ID_PLCOPENEDITORTREENOTEBOOK, |
385 name='TreeNoteBook', parent=self.MainSplitter, pos=wx.Point(0, |
375 name='TreeNoteBook', parent=self.MainSplitter, pos=wx.Point(0, |
386 0), size=wx.Size(0, 0), style=0) |
376 0), size=wx.Size(0, 0), style=0) |
387 else: |
377 |
388 self.TreeNoteBook = wx.aui.AuiNotebook(self) |
|
389 self.AUIManager.AddPane(self.TreeNoteBook, wx.aui.AuiPaneInfo().Caption("Project").Left().Layer(1).BestSize(wx.Size(200, 500)).CloseButton(False)) |
|
390 |
|
391 typestreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
378 typestreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
392 if not self.Debug: |
379 if not self.Debug: |
393 typestreestyle |= wx.TR_EDIT_LABELS |
380 typestreestyle |= wx.TR_EDIT_LABELS |
394 self.TypesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORTYPESTREE, |
381 self.TypesTree = wx.TreeCtrl(id=ID_PLCOPENEDITORTYPESTREE, |
395 name='TypesTree', parent=self.TreeNoteBook, |
382 name='TypesTree', parent=self.TreeNoteBook, |
430 id=ID_PLCOPENEDITORINSTANCESTREE) |
417 id=ID_PLCOPENEDITORINSTANCESTREE) |
431 |
418 |
432 self.TreeNoteBook.AddPage(self.InstancesTree, "Instances") |
419 self.TreeNoteBook.AddPage(self.InstancesTree, "Instances") |
433 self.TreeNoteBook.AddPage(self.TypesTree, "Types") |
420 self.TreeNoteBook.AddPage(self.TypesTree, "Types") |
434 |
421 |
435 if wx.VERSION < (2, 8, 0): |
422 if USE_AUI: |
|
423 self.TabsOpened = wx.aui.AuiNotebook(self) |
|
424 self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
|
425 self.OnPouSelectedChanged) |
|
426 self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane()) |
|
427 else: |
436 self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED, |
428 self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED, |
437 name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0, |
429 name='TabsOpened', parent=self.MainSplitter, pos=wx.Point(0, |
438 0), size=wx.Size(0, 0), style=0) |
430 0), size=wx.Size(0, 0), style=0) |
439 if wx.VERSION >= (2, 6, 0): |
431 if wx.VERSION >= (2, 6, 0): |
440 self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
432 self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
442 else: |
434 else: |
443 wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED, |
435 wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED, |
444 self.OnPouSelectedChanged) |
436 self.OnPouSelectedChanged) |
445 |
437 |
446 self.MainSplitter.SplitVertically(self.TreeNoteBook, self.TabsOpened, 200) |
438 self.MainSplitter.SplitVertically(self.TreeNoteBook, self.TabsOpened, 200) |
447 else: |
|
448 self.TabsOpened = wx.aui.AuiNotebook(self) |
|
449 self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
|
450 self.OnPouSelectedChanged) |
|
451 self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane()) |
|
452 else: |
439 else: |
453 self.TreeNoteBook.AddPage(self.TypesTree, "Types") |
440 self.TreeNoteBook.AddPage(self.TypesTree, "Types") |
454 self.TreeNoteBook.AddPage(self.InstancesTree, "Instances") |
441 self.TreeNoteBook.AddPage(self.InstancesTree, "Instances") |
455 |
442 |
456 if wx.VERSION < (2, 8, 0): |
443 if USE_AUI: |
457 self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, |
|
458 ID_PLCOPENEDITORTOOLBAR, 'ToolBar') |
|
459 self.ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
460 self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
|
461 wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
|
462 self.ToolBar.Realize() |
|
463 else: |
|
464 ToolBar = wx.ToolBar(self, ID_PLCOPENEDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize, |
444 ToolBar = wx.ToolBar(self, ID_PLCOPENEDITORTOOLBAR, wx.DefaultPosition, wx.DefaultSize, |
465 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
445 wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
466 ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
446 ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
467 ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
447 ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
468 wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
448 wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
470 self.Panes["ToolBar"] = ToolBar |
450 self.Panes["ToolBar"] = ToolBar |
471 self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo(). |
451 self.AUIManager.AddPane(ToolBar, wx.aui.AuiPaneInfo(). |
472 Name("ToolBar").Caption("Toolbar"). |
452 Name("ToolBar").Caption("Toolbar"). |
473 ToolbarPane().Top(). |
453 ToolbarPane().Top(). |
474 LeftDockable(False).RightDockable(False)) |
454 LeftDockable(False).RightDockable(False)) |
|
455 else: |
|
456 self.ToolBar = self.CreateToolBar(wx.TB_HORIZONTAL|wx.TB_FLAT|wx.NO_BORDER, |
|
457 ID_PLCOPENEDITORTOOLBAR, 'ToolBar') |
|
458 self.ToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
|
459 self.ToolBar.AddRadioTool(ID_PLCOPENEDITORTOOLBARSELECTION, |
|
460 wx.Bitmap(os.path.join(CWD, 'Images', 'select.png')), wx.NullBitmap, "Select an object") |
|
461 self.ToolBar.Realize() |
475 |
462 |
476 self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
463 self.Bind(wx.EVT_TOOL, self.OnSelectionTool, |
477 id=ID_PLCOPENEDITORTOOLBARSELECTION) |
464 id=ID_PLCOPENEDITORTOOLBARSELECTION) |
478 |
465 |
479 if wx.VERSION < (2, 8, 0): |
466 if USE_AUI: |
|
467 self.VariablePanelIndexer = VariablePanelIndexer(self, self, self.Controler) |
|
468 self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption("Variables").Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False)) |
|
469 |
|
470 self.TabsOpened = wx.aui.AuiNotebook(self) |
|
471 self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
|
472 self.OnPouSelectedChanged) |
|
473 self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane().MinSize(wx.Size(0, 0))) |
|
474 |
|
475 self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL, |
|
476 name='LibraryPanel', parent=self, pos=wx.Point(0, |
|
477 0), size=wx.Size(0, 0), style=0) |
|
478 self.AUIManager.AddPane(self.LibraryPanel, wx.aui.AuiPaneInfo().Caption("Library").Right().Layer(0).BestSize(wx.Size(250, 400)).CloseButton(False)) |
|
479 else: |
480 self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER, |
480 self.SecondSplitter = wx.SplitterWindow(id=ID_PLCOPENEDITORSECONDSPLITTER, |
481 name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0), |
481 name='SecondSplitter', parent=self.MainSplitter, point=wx.Point(0, 0), |
482 size=wx.Size(0, 0), style=wx.SP_3D) |
482 size=wx.Size(0, 0), style=wx.SP_3D) |
483 self.SecondSplitter.SetMinimumPaneSize(1) |
483 self.SecondSplitter.SetMinimumPaneSize(1) |
484 |
484 |
492 self.ThirdSplitter.SetMinimumPaneSize(1) |
492 self.ThirdSplitter.SetMinimumPaneSize(1) |
493 |
493 |
494 self.SecondSplitter.SplitHorizontally(self.ThirdSplitter, self.VariablePanelIndexer, -200) |
494 self.SecondSplitter.SplitHorizontally(self.ThirdSplitter, self.VariablePanelIndexer, -200) |
495 |
495 |
496 self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED, |
496 self.TabsOpened = wx.Notebook(id=ID_PLCOPENEDITORTABSOPENED, |
497 name='TabsOpened', parent=self.SecondSplitter, pos=wx.Point(0, |
497 name='TabsOpened', parent=self.ThirdSplitter, pos=wx.Point(0, |
498 0), size=wx.Size(0, 0), style=0) |
498 0), size=wx.Size(0, 0), style=0) |
|
499 self.TabsImageList = wx.ImageList(16, 31) |
|
500 self.TabsOpened.SetImageList(self.TabsImageList) |
|
501 self.TabsImageListIndexes = {} |
499 if wx.VERSION >= (2, 6, 0): |
502 if wx.VERSION >= (2, 6, 0): |
500 self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
503 self.TabsOpened.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, |
501 self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED) |
504 self.OnPouSelectedChanged, id=ID_PLCOPENEDITORTABSOPENED) |
502 else: |
505 else: |
503 wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED, |
506 wx.EVT_NOTEBOOK_PAGE_CHANGED(self.TabsOpened, ID_PLCOPENEDITORTABSOPENED, |
506 self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL, |
509 self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL, |
507 name='LibraryPanel', parent=self.ThirdSplitter, pos=wx.Point(0, |
510 name='LibraryPanel', parent=self.ThirdSplitter, pos=wx.Point(0, |
508 0), size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
511 0), size=wx.Size(0, 0), style=wx.SUNKEN_BORDER) |
509 |
512 |
510 self.ThirdSplitter.SplitVertically(self.TabsOpened, self.LibraryPanel, -250) |
513 self.ThirdSplitter.SplitVertically(self.TabsOpened, self.LibraryPanel, -250) |
511 else: |
514 |
512 self.VariablePanelIndexer = VariablePanelIndexer(self, self, self.Controler) |
|
513 self.AUIManager.AddPane(self.VariablePanelIndexer, wx.aui.AuiPaneInfo().Caption("Variables").Bottom().Layer(0).BestSize(wx.Size(800, 200)).CloseButton(False)) |
|
514 |
|
515 self.TabsOpened = wx.aui.AuiNotebook(self) |
|
516 self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
|
517 self.OnPouSelectedChanged) |
|
518 self.AUIManager.AddPane(self.TabsOpened, wx.aui.AuiPaneInfo().CentrePane()) |
|
519 |
|
520 self.LibraryPanel = wx.Panel(id=ID_PLCOPENEDITORLIBRARYPANEL, |
|
521 name='LibraryPanel', parent=self, pos=wx.Point(0, |
|
522 0), size=wx.Size(0, 0), style=0) |
|
523 self.AUIManager.AddPane(self.LibraryPanel, wx.aui.AuiPaneInfo().Caption("Library").Right().Layer(0).BestSize(wx.Size(250, 400)).CloseButton(False)) |
|
524 |
|
525 if wx.Platform == '__WXMSW__': |
515 if wx.Platform == '__WXMSW__': |
526 librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
516 librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER |
527 else: |
517 else: |
528 librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER |
518 librarytreestyle = wx.TR_HAS_BUTTONS|wx.TR_HIDE_ROOT|wx.TR_SINGLE|wx.SUNKEN_BORDER |
529 self.LibraryTree = wx.TreeCtrl(id=ID_PLCOPENEDITORLIBRARYTREE, |
519 self.LibraryTree = wx.TreeCtrl(id=ID_PLCOPENEDITORLIBRARYTREE, |
540 pos=wx.Point(0, 0), size=wx.Size(0, 60), |
530 pos=wx.Point(0, 0), size=wx.Size(0, 60), |
541 style=wx.TE_READONLY|wx.TE_MULTILINE) |
531 style=wx.TE_READONLY|wx.TE_MULTILINE) |
542 |
532 |
543 self._init_sizers() |
533 self._init_sizers() |
544 |
534 |
545 if wx.VERSION >= (2, 8, 0): |
535 if USE_AUI: |
546 self.AUIManager.Update() |
536 self.AUIManager.Update() |
547 |
537 |
548 def __init__(self, parent, controler = None, fileOpen = None, debug = False): |
538 def __init__(self, parent, controler = None, fileOpen = None, debug = False): |
549 self.ModeSolo = controler == None |
539 self.ModeSolo = controler == None |
550 self.Debug = debug |
540 self.Debug = debug |
702 |
692 |
703 #------------------------------------------------------------------------------- |
693 #------------------------------------------------------------------------------- |
704 # Notebook Unified Functions |
694 # Notebook Unified Functions |
705 #------------------------------------------------------------------------------- |
695 #------------------------------------------------------------------------------- |
706 |
696 |
|
697 def GenerateBitmap(self, icon1_name, icon2_name = None): |
|
698 if not USE_AUI: |
|
699 index = self.TabsImageListIndexes.get((icon1_name, icon2_name), None) |
|
700 if index is not None: |
|
701 return index |
|
702 if icon2_name is None: |
|
703 tmp_bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
704 else: |
|
705 icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name)) |
|
706 icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name)) |
|
707 width = icon1.GetWidth() + icon2.GetWidth() - 1 |
|
708 height = max(icon1.GetHeight(), icon2.GetHeight()) |
|
709 tmp_bitmap = wx.EmptyBitmap(width, height) |
|
710 dc = wx.MemoryDC() |
|
711 dc.SelectObject(tmp_bitmap) |
|
712 dc.Clear() |
|
713 dc.DrawBitmap(icon1, 0, 0) |
|
714 dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0) |
|
715 if USE_AUI: |
|
716 return tmp_bitmap |
|
717 else: |
|
718 index = self.TabsImageList.Add(tmp_bitmap) |
|
719 self.TabsImageListIndexes[(icon1_name, icon2_name)] = index |
|
720 return index |
|
721 |
707 def DeleteAllPages(self): |
722 def DeleteAllPages(self): |
708 if wx.VERSION >= (2, 8, 0): |
723 if USE_AUI: |
709 for idx in xrange(self.TabsOpened.GetPageCount()): |
724 for idx in xrange(self.TabsOpened.GetPageCount()): |
710 self.TabsOpened.DeletePage(0) |
725 self.TabsOpened.DeletePage(0) |
711 else: |
726 else: |
712 self.TabsOpened.DeleteAllPages() |
727 self.TabsOpened.DeleteAllPages() |
713 |
728 |
714 def SetPageBitmap(self, idx, bitmap): |
729 def SetPageBitmap(self, idx, bitmap): |
715 if wx.VERSION >= (2, 8, 0): |
730 if USE_AUI: |
716 return self.TabsOpened.SetPageBitmap(idx, bitmap) |
731 return self.TabsOpened.SetPageBitmap(idx, bitmap) |
717 else: |
732 else: |
718 return self.TabsOpened.SetPageImage(idx, bitmap) |
733 return self.TabsOpened.SetPageImage(idx, bitmap) |
719 |
734 |
720 |
735 |
1190 window = self.TabsOpened.GetPage(idx) |
1205 window = self.TabsOpened.GetPage(idx) |
1191 words = window.GetTagName().split("::") |
1206 words = window.GetTagName().split("::") |
1192 if words[0] == "P": |
1207 if words[0] == "P": |
1193 pou_type = self.Controler.GetEditedElementType(window.GetTagName(), self.Debug)[1].upper() |
1208 pou_type = self.Controler.GetEditedElementType(window.GetTagName(), self.Debug)[1].upper() |
1194 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1209 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1195 self.SetPageBitmap(idx, GenerateBitmap(pou_type, pou_body_type)) |
1210 self.SetPageBitmap(idx, self.GenerateBitmap(pou_type, pou_body_type)) |
1196 elif words[0] == "T": |
1211 elif words[0] == "T": |
1197 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1212 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1198 self.SetPageBitmap(idx, GenerateBitmap("TRANSITION", pou_body_type)) |
1213 self.SetPageBitmap(idx, self.GenerateBitmap("TRANSITION", pou_body_type)) |
1199 elif words[0] == "A": |
1214 elif words[0] == "A": |
1200 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1215 pou_body_type = self.Controler.GetEditedElementBodyType(window.GetTagName(), self.Debug) |
1201 self.SetPageBitmap(idx, GenerateBitmap("ACTION", pou_body_type)) |
1216 self.SetPageBitmap(idx, self.GenerateBitmap("ACTION", pou_body_type)) |
1202 elif words[0] == "C": |
1217 elif words[0] == "C": |
1203 self.SetPageBitmap(idx, GenerateBitmap("CONFIGURATION")) |
1218 self.SetPageBitmap(idx, self.GenerateBitmap("CONFIGURATION")) |
1204 elif words[0] == "R": |
1219 elif words[0] == "R": |
1205 self.SetPageBitmap(idx, GenerateBitmap("RESOURCE")) |
1220 self.SetPageBitmap(idx, self.GenerateBitmap("RESOURCE")) |
1206 elif words[0] == "D": |
1221 elif words[0] == "D": |
1207 self.SetPageBitmap(idx, GenerateBitmap("DATATYPE")) |
1222 self.SetPageBitmap(idx, self.GenerateBitmap("DATATYPE")) |
1208 if self.Debug: |
1223 if self.Debug: |
1209 self.TabsOpened.SetPageText(idx, window.GetInstancePath()) |
1224 self.TabsOpened.SetPageText(idx, window.GetInstancePath()) |
1210 else: |
1225 else: |
1211 self.TabsOpened.SetPageText(idx, "-".join(words[1:])) |
1226 self.TabsOpened.SetPageText(idx, "-".join(words[1:])) |
1212 |
1227 |
1905 if wx.VERSION >= (2, 6, 0): |
1920 if wx.VERSION >= (2, 6, 0): |
1906 self.Unbind(wx.EVT_MENU, id=item) |
1921 self.Unbind(wx.EVT_MENU, id=item) |
1907 else: |
1922 else: |
1908 self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED) |
1923 self.Disconnect(id=item, eventType=wx.wxEVT_COMMAND_MENU_SELECTED) |
1909 |
1924 |
1910 if wx.VERSION < (2, 8, 0): |
1925 if USE_AUI: |
|
1926 ToolBar = self.Panes["ToolBar"] |
|
1927 else: |
1911 ToolBar = self.ToolBar |
1928 ToolBar = self.ToolBar |
1912 else: |
|
1913 ToolBar = self.Panes["ToolBar"] |
|
1914 if ToolBar: |
1929 if ToolBar: |
1915 ToolBar.DeleteTool(item) |
1930 ToolBar.DeleteTool(item) |
1916 ToolBar.Realize() |
1931 ToolBar.Realize() |
1917 if wx.VERSION >= (2, 8, 0): |
1932 if USE_AUI: |
1918 self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
1933 self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
1919 self.AUIManager.Update() |
1934 self.AUIManager.Update() |
1920 |
1935 |
1921 def RefreshToolBar(self): |
1936 def RefreshToolBar(self): |
1922 if not self.Debug: |
1937 if not self.Debug: |
1927 language = None |
1942 language = None |
1928 if language is not None and language != self.CurrentLanguage: |
1943 if language is not None and language != self.CurrentLanguage: |
1929 self.ResetToolBar() |
1944 self.ResetToolBar() |
1930 self.CurrentLanguage = language |
1945 self.CurrentLanguage = language |
1931 self.CurrentToolBar = [] |
1946 self.CurrentToolBar = [] |
1932 if wx.VERSION < (2, 8, 0): |
1947 if USE_AUI: |
|
1948 ToolBar = self.Panes["ToolBar"] |
|
1949 else: |
1933 ToolBar = self.ToolBar |
1950 ToolBar = self.ToolBar |
1934 else: |
|
1935 ToolBar = self.Panes["ToolBar"] |
|
1936 if ToolBar: |
1951 if ToolBar: |
1937 for radio, modes, id, method, picture, help in ToolBarItems[language]: |
1952 for radio, modes, id, method, picture, help in ToolBarItems[language]: |
1938 if modes & self.DrawingMode: |
1953 if modes & self.DrawingMode: |
1939 if radio or self.DrawingMode == FREEDRAWING_MODE: |
1954 if radio or self.DrawingMode == FREEDRAWING_MODE: |
1940 ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help) |
1955 ToolBar.AddRadioTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), wx.NullBitmap, help) |
1941 else: |
1956 else: |
1942 ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help) |
1957 ToolBar.AddSimpleTool(id, wx.Bitmap(os.path.join(CWD, "Images", picture)), help) |
1943 self.Bind(wx.EVT_TOOL, getattr(self, method), id=id) |
1958 self.Bind(wx.EVT_TOOL, getattr(self, method), id=id) |
1944 self.CurrentToolBar.append(id) |
1959 self.CurrentToolBar.append(id) |
1945 ToolBar.Realize() |
1960 ToolBar.Realize() |
1946 if wx.VERSION >= (2, 8, 0): |
1961 if USE_AUI: |
1947 self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
1962 self.AUIManager.GetPane("ToolBar").BestSize(ToolBar.GetBestSize()) |
1948 self.AUIManager.Update() |
1963 self.AUIManager.Update() |
1949 elif not language: |
1964 elif not language: |
1950 self.ResetToolBar() |
1965 self.ResetToolBar() |
1951 self.CurrentLanguage = language |
1966 self.CurrentLanguage = language |
1959 def ResetCurrentMode(self): |
1974 def ResetCurrentMode(self): |
1960 selected = self.TabsOpened.GetSelection() |
1975 selected = self.TabsOpened.GetSelection() |
1961 if selected != -1: |
1976 if selected != -1: |
1962 window = self.TabsOpened.GetPage(selected) |
1977 window = self.TabsOpened.GetPage(selected) |
1963 window.SetMode(MODE_SELECTION) |
1978 window.SetMode(MODE_SELECTION) |
1964 if wx.VERSION < (2, 8, 0): |
1979 if USE_AUI: |
|
1980 ToolBar = self.Panes["ToolBar"] |
|
1981 else: |
1965 ToolBar = self.ToolBar |
1982 ToolBar = self.ToolBar |
1966 else: |
|
1967 ToolBar = self.Panes["ToolBar"] |
|
1968 if ToolBar: |
1983 if ToolBar: |
1969 ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True) |
1984 ToolBar.ToggleTool(ID_PLCOPENEDITORTOOLBARSELECTION, True) |
1970 |
1985 |
1971 def ResetToolToggle(self, id): |
1986 def ResetToolToggle(self, id): |
1972 if wx.VERSION < (2, 8, 0): |
1987 if USE_AUI: |
|
1988 tool = self.Panes["ToolBar"].FindById(id) |
|
1989 else: |
1973 tool = self.ToolBar.FindById(id) |
1990 tool = self.ToolBar.FindById(id) |
1974 else: |
|
1975 tool = self.Panes["ToolBar"].FindById(id) |
|
1976 tool.SetToggle(False) |
1991 tool.SetToggle(False) |
1977 |
1992 |
1978 def OnSelectionTool(self, event): |
1993 def OnSelectionTool(self, event): |
1979 selected = self.TabsOpened.GetSelection() |
1994 selected = self.TabsOpened.GetSelection() |
1980 if selected != -1: |
1995 if selected != -1: |