author | Edouard Tisserant |
Mon, 21 May 2012 16:40:57 +0200 | |
changeset 740 | cee825fbe9b3 |
parent 738 | 413946c04c87 |
child 762 | aaacc83aa86b |
permissions | -rw-r--r-- |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
1 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
2 |
import wx |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
3 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
4 |
from subindextable import EditingPanel |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
5 |
from nodeeditor import NodeEditorTemplate |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
6 |
from controls import EditorPanel |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
7 |
|
717 | 8 |
[ID_SLAVEEDITORCONFNODEMENUNODEINFOS, ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, |
9 |
ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, |
|
10 |
ID_SLAVEEDITORCONFNODEMENUADD, |
|
11 |
] = [wx.NewId() for _init_coll_ConfNodeMenu_Items in range(5)] |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
12 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
13 |
[ID_SLAVEEDITORADDMENUSDOSERVER, ID_SLAVEEDITORADDMENUSDOCLIENT, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
14 |
ID_SLAVEEDITORADDMENUPDOTRANSMIT, ID_SLAVEEDITORADDMENUPDORECEIVE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
15 |
ID_SLAVEEDITORADDMENUMAPVARIABLE, ID_SLAVEEDITORADDMENUUSERTYPE, |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
16 |
] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
17 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
18 |
class SlaveEditor(EditorPanel, NodeEditorTemplate): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
19 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
20 |
def _init_Editor(self, prnt): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
21 |
self.Editor = EditingPanel(prnt, self, self.Controler, self.Editable) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
22 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
23 |
def __init__(self, parent, controler, window, editable=True): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
24 |
self.Editable = editable |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
25 |
EditorPanel.__init__(self, parent, "", window, controler) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
26 |
NodeEditorTemplate.__init__(self, controler, window, False) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
27 |
|
738 | 28 |
img = wx.Bitmap(controler.GetIconPath(), wx.BITMAP_TYPE_PNG).ConvertToImage() |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
29 |
self.SetIcon(wx.BitmapFromImage(img.Rescale(16, 16))) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
30 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
31 |
def __del__(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
32 |
self.Controler.OnCloseEditor(self) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
33 |
|
717 | 34 |
def GetConfNodeMenuItems(self): |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
35 |
if self.Editable: |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
36 |
add_menu = [(wx.ITEM_NORMAL, (_('SDO Server'), ID_SLAVEEDITORADDMENUSDOSERVER, '', self.OnAddSDOServerMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
37 |
(wx.ITEM_NORMAL, (_('SDO Client'), ID_SLAVEEDITORADDMENUSDOCLIENT, '', self.OnAddSDOClientMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
38 |
(wx.ITEM_NORMAL, (_('PDO Transmit'), ID_SLAVEEDITORADDMENUPDOTRANSMIT, '', self.OnAddPDOTransmitMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
39 |
(wx.ITEM_NORMAL, (_('PDO Receive'), ID_SLAVEEDITORADDMENUPDORECEIVE, '', self.OnAddPDOReceiveMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
40 |
(wx.ITEM_NORMAL, (_('Map Variable'), ID_SLAVEEDITORADDMENUMAPVARIABLE, '', self.OnAddMapVariableMenu)), |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
41 |
(wx.ITEM_NORMAL, (_('User Type'), ID_SLAVEEDITORADDMENUUSERTYPE, '', self.OnAddUserTypeMenu))] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
42 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
43 |
profile = self.Controler.GetCurrentProfileName() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
44 |
if profile not in ("None", "DS-301"): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
45 |
other_profile_text = _("%s Profile") % profile |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
46 |
add_menu.append((wx.ITEM_SEPARATOR, None)) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
47 |
for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
48 |
add_menu.append((wx.ITEM_NORMAL, (text, wx.NewId(), '', self.GetProfileCallBack(text)))) |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
49 |
else: |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
50 |
other_profile_text = _('Other Profile') |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
51 |
|
717 | 52 |
return [(wx.ITEM_NORMAL, (_('Node infos'), ID_SLAVEEDITORCONFNODEMENUNODEINFOS, '', self.OnNodeInfosMenu)), |
53 |
(wx.ITEM_NORMAL, (_('DS-301 Profile'), ID_SLAVEEDITORCONFNODEMENUDS301PROFILE, '', self.OnCommunicationMenu)), |
|
54 |
(wx.ITEM_NORMAL, (_('DS-302 Profile'), ID_SLAVEEDITORCONFNODEMENUDS302PROFILE, '', self.OnOtherCommunicationMenu)), |
|
55 |
(wx.ITEM_NORMAL, (other_profile_text, ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, '', self.OnEditProfileMenu)), |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
56 |
(wx.ITEM_SEPARATOR, None), |
717 | 57 |
(add_menu, (_('Add'), ID_SLAVEEDITORCONFNODEMENUADD))] |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
58 |
return [] |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
59 |
|
717 | 60 |
def RefreshConfNodeMenu(self, confnode_menu): |
61 |
confnode_menu.Enable(ID_SLAVEEDITORCONFNODEMENUDSOTHERPROFILE, False) |
|
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
62 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
63 |
def GetTitle(self): |
718 | 64 |
fullname = self.Controler.CTNFullName() |
680
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
65 |
if not self.Controler.CurrentIsSaved(): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
66 |
return "~%s~" % fullname |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
67 |
return fullname |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
68 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
69 |
def RefreshView(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
70 |
self.Editor.RefreshIndexList() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
71 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
72 |
def RefreshCurrentIndexList(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
73 |
self.RefreshView() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
74 |
|
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
75 |
def RefreshBufferState(self): |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
76 |
self.ParentWindow.RefreshTitle() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
77 |
self.ParentWindow.RefreshFileMenu() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
78 |
self.ParentWindow.RefreshEditMenu() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
79 |
self.ParentWindow.RefreshPageTitles() |
61746934df41
Adding support for integrating CanFestival plugin panels in Beremiz main frame
smarteh-dev
parents:
diff
changeset
|
80 |