author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Wed, 27 Apr 2016 18:42:30 +0300 | |
changeset 1505 | 5ecb16be9a3c |
parent 1451 | 94e620cbd9de |
child 1511 | 91538d0c242c |
permissions | -rw-r--r-- |
738 | 1 |
|
2 |
import os |
|
3 |
import types |
|
4 |
||
5 |
import wx |
|
6 |
||
814 | 7 |
from EditorPanel import EditorPanel |
8 |
||
9 |
from IDEFrame import TITLE, FILEMENU, PROJECTTREE, PAGETITLES |
|
10 |
||
11 |
from controls import TextCtrlAutoComplete |
|
12 |
from dialogs import BrowseValuesLibraryDialog |
|
13 |
from util.BitmapLibrary import GetBitmap |
|
738 | 14 |
|
15 |
if wx.Platform == '__WXMSW__': |
|
16 |
faces = { 'times': 'Times New Roman', |
|
17 |
'mono' : 'Courier New', |
|
18 |
'helv' : 'Arial', |
|
19 |
'other': 'Comic Sans MS', |
|
20 |
'size' : 16, |
|
21 |
} |
|
22 |
else: |
|
23 |
faces = { 'times': 'Times', |
|
24 |
'mono' : 'Courier', |
|
25 |
'helv' : 'Helvetica', |
|
26 |
'other': 'new century schoolbook', |
|
27 |
'size' : 18, |
|
28 |
} |
|
29 |
||
30 |
SCROLLBAR_UNIT = 10 |
|
31 |
||
32 |
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton): |
|
33 |
def _GetLabelSize(self): |
|
34 |
""" used internally """ |
|
35 |
w, h = self.GetTextExtent(self.GetLabel()) |
|
36 |
if not self.bmpLabel: |
|
37 |
return w, h, False # if there isn't a bitmap use the size of the text |
|
38 |
||
39 |
w_bmp = self.bmpLabel.GetWidth()+2 |
|
40 |
h_bmp = self.bmpLabel.GetHeight()+2 |
|
41 |
height = h + h_bmp |
|
42 |
if w_bmp > w: |
|
43 |
width = w_bmp |
|
44 |
else: |
|
45 |
width = w |
|
46 |
return width, height, False |
|
47 |
||
48 |
def DrawLabel(self, dc, width, height, dw=0, dy=0): |
|
49 |
bmp = self.bmpLabel |
|
50 |
if bmp != None: # if the bitmap is used |
|
51 |
if self.bmpDisabled and not self.IsEnabled(): |
|
52 |
bmp = self.bmpDisabled |
|
53 |
if self.bmpFocus and self.hasFocus: |
|
54 |
bmp = self.bmpFocus |
|
55 |
if self.bmpSelected and not self.up: |
|
56 |
bmp = self.bmpSelected |
|
57 |
bw,bh = bmp.GetWidth(), bmp.GetHeight() |
|
58 |
if not self.up: |
|
59 |
dw = dy = self.labelDelta |
|
60 |
hasMask = bmp.GetMask() != None |
|
61 |
else: |
|
62 |
bw = bh = 0 # no bitmap -> size is zero |
|
63 |
||
64 |
dc.SetFont(self.GetFont()) |
|
65 |
if self.IsEnabled(): |
|
66 |
dc.SetTextForeground(self.GetForegroundColour()) |
|
67 |
else: |
|
68 |
dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) |
|
69 |
||
70 |
label = self.GetLabel() |
|
71 |
tw, th = dc.GetTextExtent(label) # size of text |
|
72 |
if not self.up: |
|
73 |
dw = dy = self.labelDelta |
|
74 |
||
75 |
pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
|
76 |
pos_y = (height-bh-th)/2+dy |
|
77 |
if bmp !=None: |
|
78 |
dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
|
79 |
pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre |
|
80 |
pos_y += bh + 2 |
|
81 |
||
82 |
dc.DrawText(label, pos_x, pos_y) # draw the text |
|
83 |
||
84 |
||
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
85 |
class GenStaticBitmap(wx.StaticBitmap): |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
86 |
""" Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
738 | 87 |
and accept image name as __init__ parameter, fail silently if file do not exist""" |
88 |
def __init__(self, parent, ID, bitmapname, |
|
89 |
pos = wx.DefaultPosition, size = wx.DefaultSize, |
|
90 |
style = 0, |
|
91 |
name = "genstatbmp"): |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
92 |
|
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
93 |
bitmap = GetBitmap(bitmapname) |
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
94 |
if bitmap is None: |
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
95 |
bitmap = wx.EmptyBitmap(0, 0) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
96 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
97 |
wx.StaticBitmap.__init__(self, parent, ID, |
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
98 |
bitmap, |
738 | 99 |
pos, size, |
100 |
style, |
|
101 |
name) |
|
102 |
||
103 |
class ConfTreeNodeEditor(EditorPanel): |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
104 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
105 |
SHOW_BASE_PARAMS = True |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
106 |
SHOW_PARAMS = True |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
107 |
CONFNODEEDITOR_TABS = [] |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
108 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
109 |
def _init_Editor(self, parent): |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
110 |
tabs_num = len(self.CONFNODEEDITOR_TABS) |
1055 | 111 |
if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0: |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
112 |
tabs_num += 1 |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
113 |
|
1055 | 114 |
if tabs_num > 1 or self.SHOW_BASE_PARAMS: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
115 |
self.Editor = wx.Panel(parent, |
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
116 |
style=wx.SUNKEN_BORDER|wx.SP_3D) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
117 |
|
1055 | 118 |
self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
119 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
120 |
if self.SHOW_BASE_PARAMS: |
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
121 |
baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
122 |
self.MainSizer.AddSizer(baseparamseditor_sizer, border=5, |
1055 | 123 |
flag=wx.GROW|wx.ALL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
124 |
|
1055 | 125 |
self.FullIECChannel = wx.StaticText(self.Editor, -1) |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
126 |
self.FullIECChannel.SetFont( |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
127 |
wx.Font(faces["size"], wx.DEFAULT, wx.NORMAL, |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
128 |
wx.BOLD, faceName = faces["helv"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
129 |
baseparamseditor_sizer.AddWindow(self.FullIECChannel, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
130 |
flag=wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
131 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
132 |
updownsizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
133 |
baseparamseditor_sizer.AddSizer(updownsizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
134 |
flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
135 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
136 |
self.IECCUpButton = wx.lib.buttons.GenBitmapTextButton(self.Editor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
137 |
bitmap=GetBitmap('IECCDown'), size=wx.Size(16, 16), style=wx.NO_BORDER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
138 |
self.IECCUpButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(1), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
139 |
self.IECCUpButton) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
140 |
updownsizer.AddWindow(self.IECCUpButton, flag=wx.ALIGN_LEFT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
141 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
142 |
self.IECCDownButton = wx.lib.buttons.GenBitmapButton(self.Editor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
143 |
bitmap=GetBitmap('IECCUp'), size=wx.Size(16, 16), style=wx.NO_BORDER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
144 |
self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
145 |
self.IECCDownButton) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
146 |
updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
147 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
148 |
self.ConfNodeName = wx.TextCtrl(self.Editor, |
1162
a2b4d366bc66
Fixed ConfTreeNodeEditor background colour
Laurent Bessard
parents:
1111
diff
changeset
|
149 |
size=wx.Size(150, 25)) |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
150 |
self.ConfNodeName.SetFont( |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
151 |
wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, |
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
152 |
wx.BOLD, faceName = faces["helv"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
153 |
self.ConfNodeName.Bind(wx.EVT_TEXT, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
154 |
self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
155 |
self.ConfNodeName) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
156 |
baseparamseditor_sizer.AddWindow(self.ConfNodeName, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
157 |
flag=wx.LEFT|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
158 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
159 |
buttons_sizer = self.GenerateMethodButtonSizer() |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
160 |
baseparamseditor_sizer.AddSizer(buttons_sizer, flag=wx.ALIGN_CENTER) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
161 |
|
1055 | 162 |
if tabs_num > 1: |
163 |
self.ConfNodeNoteBook = wx.Notebook(self.Editor) |
|
164 |
parent = self.ConfNodeNoteBook |
|
165 |
self.MainSizer.AddWindow(self.ConfNodeNoteBook, 1, flag=wx.GROW) |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
166 |
else: |
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
167 |
parent = self.Editor |
1055 | 168 |
self.ConfNodeNoteBook = None |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
169 |
|
1055 | 170 |
self.Editor.SetSizer(self.MainSizer) |
171 |
else: |
|
172 |
self.ConfNodeNoteBook = None |
|
173 |
self.Editor = None |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
174 |
|
1055 | 175 |
for title, create_func_name in self.CONFNODEEDITOR_TABS: |
176 |
editor = getattr(self, create_func_name)(parent) |
|
177 |
if self.ConfNodeNoteBook is not None: |
|
178 |
self.ConfNodeNoteBook.AddPage(editor, title) |
|
179 |
elif self.SHOW_BASE_PARAMS: |
|
180 |
self.MainSizer.AddWindow(editor, 1, flag=wx.GROW) |
|
181 |
else: |
|
182 |
self.Editor = editor |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
183 |
|
1055 | 184 |
if self.SHOW_PARAMS and len(self.Controler.GetParamsAttributes()) > 0: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
185 |
|
1055 | 186 |
panel_style = wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL |
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
187 |
if self.ConfNodeNoteBook is None and parent != self.Editor: |
1055 | 188 |
panel_style |= wx.SUNKEN_BORDER |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
189 |
self.ParamsEditor = wx.ScrolledWindow(parent, |
1055 | 190 |
style=panel_style) |
1180 | 191 |
self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnParamsEditorResize) |
192 |
self.ParamsEditor.Bind(wx.EVT_SCROLLWIN, self.OnParamsEditorScroll) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
193 |
|
1055 | 194 |
self.ParamsEditorSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=1, vgap=5) |
195 |
self.ParamsEditorSizer.AddGrowableCol(0) |
|
196 |
self.ParamsEditorSizer.AddGrowableRow(0) |
|
197 |
self.ParamsEditor.SetSizer(self.ParamsEditorSizer) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
198 |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
199 |
self.ConfNodeParamsSizer = wx.BoxSizer(wx.VERTICAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
200 |
self.ParamsEditorSizer.AddSizer(self.ConfNodeParamsSizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
201 |
flag=wx.LEFT|wx.RIGHT|wx.BOTTOM) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
202 |
|
775
172be32a2482
Adding support for hiding node base params controls if needed
laurent
parents:
767
diff
changeset
|
203 |
self.RefreshConfNodeParamsSizer() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
204 |
|
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
205 |
if self.ConfNodeNoteBook is not None: |
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
206 |
self.ConfNodeNoteBook.AddPage(self.ParamsEditor, _("Config")) |
1055 | 207 |
elif self.SHOW_BASE_PARAMS: |
208 |
self.MainSizer.AddWindow(self.ParamsEditor, 1, flag=wx.GROW) |
|
920
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
209 |
else: |
1499a4d225db
Replaced SplitterWindow in ConfTreeNodeEditor by Notebook
Laurent Bessard
parents:
846
diff
changeset
|
210 |
self.Editor = self.ParamsEditor |
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
211 |
else: |
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
212 |
self.ParamsEditor = None |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
213 |
|
743 | 214 |
def __init__(self, parent, controler, window, tagname=""): |
738 | 215 |
EditorPanel.__init__(self, parent, tagname, window, controler) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
216 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
217 |
icon_name = self.Controler.GetIconName() |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
218 |
if icon_name is not None: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
219 |
self.SetIcon(GetBitmap(icon_name)) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
220 |
else: |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
221 |
self.SetIcon(GetBitmap("Extension")) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
222 |
|
738 | 223 |
def __del__(self): |
224 |
self.Controler.OnCloseEditor(self) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
225 |
|
738 | 226 |
def GetTagName(self): |
227 |
return self.Controler.CTNFullName() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
228 |
|
738 | 229 |
def GetTitle(self): |
230 |
fullname = self.Controler.CTNFullName() |
|
231 |
if self.Controler.CTNTestModified(): |
|
232 |
return "~%s~" % fullname |
|
233 |
return fullname |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
234 |
|
738 | 235 |
def HasNoModel(self): |
236 |
return False |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
237 |
|
743 | 238 |
def GetBufferState(self): |
239 |
return False, False |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
240 |
|
743 | 241 |
def Undo(self): |
242 |
pass |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
243 |
|
743 | 244 |
def Redo(self): |
245 |
pass |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
246 |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
247 |
def RefreshView(self): |
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
248 |
EditorPanel.RefreshView(self) |
1055 | 249 |
if self.SHOW_BASE_PARAMS: |
250 |
self.ConfNodeName.ChangeValue(self.Controler.MandatoryParams[1].getName()) |
|
251 |
self.RefreshIECChannelControlsState() |
|
762
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
252 |
if self.ParamsEditor is not None: |
aaacc83aa86b
Modifying canfestival plugin to following the new Beremiz confnode paradigm
laurent
parents:
751
diff
changeset
|
253 |
self.RefreshConfNodeParamsSizer() |
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
254 |
self.RefreshScrollbars() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
255 |
|
738 | 256 |
def RefreshIECChannelControlsState(self): |
257 |
self.FullIECChannel.SetLabel(self.Controler.GetFullIEC_Channel()) |
|
258 |
self.IECCDownButton.Enable(self.Controler.BaseParams.getIEC_Channel() > 0) |
|
1059
50246061d5c6
Fixed new ConfTreeNodeEditor layout on Windows
Laurent Bessard
parents:
1055
diff
changeset
|
259 |
self.MainSizer.Layout() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
260 |
|
738 | 261 |
def RefreshConfNodeParamsSizer(self): |
262 |
self.Freeze() |
|
263 |
self.ConfNodeParamsSizer.Clear(True) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
264 |
|
738 | 265 |
confnode_infos = self.Controler.GetParamsAttributes() |
266 |
if len(confnode_infos) > 0: |
|
267 |
self.GenerateSizerElements(self.ConfNodeParamsSizer, confnode_infos, None, False) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
268 |
|
738 | 269 |
self.ParamsEditorSizer.Layout() |
270 |
self.Thaw() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
271 |
|
738 | 272 |
def GenerateMethodButtonSizer(self): |
273 |
normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]) |
|
274 |
mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, underline=True, faceName = faces["helv"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
275 |
|
738 | 276 |
msizer = wx.BoxSizer(wx.HORIZONTAL) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
277 |
|
738 | 278 |
for confnode_method in self.Controler.ConfNodeMethods: |
279 |
if "method" in confnode_method and confnode_method.get("shown",True): |
|
1055 | 280 |
button = GenBitmapTextButton(self.Editor, |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
281 |
bitmap=GetBitmap(confnode_method.get("bitmap", "Unknown")), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
282 |
label=confnode_method["name"], style=wx.NO_BORDER) |
738 | 283 |
button.SetFont(normal_bt_font) |
284 |
button.SetToolTipString(confnode_method["tooltip"]) |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
285 |
if confnode_method.get("push", False): |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
286 |
button.Bind(wx.EVT_LEFT_DOWN, self.GetButtonCallBackFunction(confnode_method["method"], True)) |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
287 |
else: |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
288 |
button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(confnode_method["method"]), button) |
738 | 289 |
# a fancy underline on mouseover |
290 |
def setFontStyle(b, s): |
|
291 |
def fn(event): |
|
292 |
b.SetFont(s) |
|
293 |
b.Refresh() |
|
294 |
event.Skip() |
|
295 |
return fn |
|
296 |
button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, mouseover_bt_font)) |
|
297 |
button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, normal_bt_font)) |
|
298 |
#hack to force size to mini |
|
299 |
if not confnode_method.get("enabled",True): |
|
300 |
button.Disable() |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
301 |
msizer.AddWindow(button, flag=wx.ALIGN_CENTER) |
738 | 302 |
return msizer |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
303 |
|
738 | 304 |
def GenerateSizerElements(self, sizer, elements, path, clean = True): |
305 |
if clean: |
|
306 |
sizer.Clear(True) |
|
307 |
first = True |
|
308 |
for element_infos in elements: |
|
309 |
if path: |
|
310 |
element_path = "%s.%s"%(path, element_infos["name"]) |
|
311 |
else: |
|
312 |
element_path = element_infos["name"] |
|
313 |
if element_infos["type"] == "element": |
|
1282
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
314 |
name = element_infos["name"] |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
315 |
value = element_infos["value"] |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
316 |
label = _(name) |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
317 |
if value is not None: |
f427352f9727
Added support for left panel add menu with multiple levels
laurent
parents:
1281
diff
changeset
|
318 |
label += " - %s" % _(value) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
319 |
staticbox = wx.StaticBox(self.ParamsEditor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
320 |
label=_(label), size=wx.Size(10, 0)) |
738 | 321 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
322 |
if first: |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
323 |
sizer.AddSizer(staticboxsizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
324 |
flag=wx.GROW|wx.TOP|wx.BOTTOM) |
738 | 325 |
else: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
326 |
sizer.AddSizer(staticboxsizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
327 |
flag=wx.GROW|wx.BOTTOM) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
328 |
self.GenerateSizerElements(staticboxsizer, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
329 |
element_infos["children"], |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
330 |
element_path) |
738 | 331 |
else: |
332 |
boxsizer = wx.FlexGridSizer(cols=3, rows=1) |
|
333 |
boxsizer.AddGrowableCol(1) |
|
334 |
if first: |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
335 |
sizer.AddSizer(boxsizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
336 |
flag=wx.GROW|wx.ALL) |
738 | 337 |
else: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
338 |
sizer.AddSizer(boxsizer, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
339 |
flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
340 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
341 |
staticbitmap = GenStaticBitmap(ID=-1, bitmapname=element_infos["name"], |
738 | 342 |
name="%s_bitmap"%element_infos["name"], parent=self.ParamsEditor, |
343 |
pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
344 |
boxsizer.AddWindow(staticbitmap, border=5, flag=wx.RIGHT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
345 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
346 |
statictext = wx.StaticText(self.ParamsEditor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
347 |
label="%s:"%_(element_infos["name"])) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
348 |
boxsizer.AddWindow(statictext, border=5, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
349 |
flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
350 |
|
738 | 351 |
if isinstance(element_infos["type"], types.ListType): |
352 |
if isinstance(element_infos["value"], types.TupleType): |
|
353 |
browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
354 |
boxsizer.AddSizer(browse_boxsizer) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
355 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
356 |
textctrl = wx.TextCtrl(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
357 |
size=wx.Size(275, -1), style=wx.TE_READONLY) |
738 | 358 |
if element_infos["value"] is not None: |
359 |
textctrl.SetValue(element_infos["value"][0]) |
|
360 |
value_infos = element_infos["value"][1] |
|
361 |
else: |
|
362 |
value_infos = None |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
363 |
browse_boxsizer.AddWindow(textctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
364 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
365 |
button = wx.Button(self.ParamsEditor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
366 |
label="...", size=wx.Size(25, 25)) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
367 |
browse_boxsizer.AddWindow(button) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
368 |
button.Bind(wx.EVT_BUTTON, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
369 |
self.GetBrowseCallBackFunction(element_infos["name"], textctrl, element_infos["type"], |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
370 |
value_infos, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
371 |
button) |
738 | 372 |
else: |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
373 |
combobox = wx.ComboBox(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
374 |
size=wx.Size(300, -1), style=wx.CB_READONLY) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
375 |
boxsizer.AddWindow(combobox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
376 |
|
738 | 377 |
if element_infos["use"] == "optional": |
378 |
combobox.Append("") |
|
379 |
if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
|
380 |
for choice, xsdclass in element_infos["type"]: |
|
381 |
combobox.Append(choice) |
|
382 |
name = element_infos["name"] |
|
383 |
value = element_infos["value"] |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
384 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
385 |
staticbox = wx.StaticBox(self.ParamsEditor, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
386 |
label="%s - %s"%(_(name), _(value)), size=wx.Size(10, 0)) |
738 | 387 |
staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
388 |
sizer.AddSizer(staticboxsizer, border=5, flag=wx.GROW|wx.BOTTOM) |
738 | 389 |
self.GenerateSizerElements(staticboxsizer, element_infos["children"], element_path) |
390 |
callback = self.GetChoiceContentCallBackFunction(combobox, staticboxsizer, element_path) |
|
391 |
else: |
|
392 |
for choice in element_infos["type"]: |
|
393 |
combobox.Append(choice) |
|
394 |
callback = self.GetChoiceCallBackFunction(combobox, element_path) |
|
395 |
if element_infos["value"] is None: |
|
396 |
combobox.SetStringSelection("") |
|
397 |
else: |
|
398 |
combobox.SetStringSelection(element_infos["value"]) |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
399 |
combobox.Bind(wx.EVT_COMBOBOX, callback, combobox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
400 |
|
738 | 401 |
elif isinstance(element_infos["type"], types.DictType): |
402 |
scmin = -(2**31) |
|
403 |
scmax = 2**31-1 |
|
404 |
if "min" in element_infos["type"]: |
|
405 |
scmin = element_infos["type"]["min"] |
|
406 |
if "max" in element_infos["type"]: |
|
407 |
scmax = element_infos["type"]["max"] |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
408 |
spinctrl = wx.SpinCtrl(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
409 |
size=wx.Size(300, -1), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
410 |
spinctrl.SetRange(scmin, scmax) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
411 |
boxsizer.AddWindow(spinctrl) |
738 | 412 |
if element_infos["value"] is not None: |
413 |
spinctrl.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
414 |
spinctrl.Bind(wx.EVT_SPINCTRL, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
415 |
self.GetTextCtrlCallBackFunction(spinctrl, element_path), |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
416 |
spinctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
417 |
|
738 | 418 |
else: |
419 |
if element_infos["type"] == "boolean": |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
420 |
checkbox = wx.CheckBox(self.ParamsEditor, size=wx.Size(17, 25)) |
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
421 |
boxsizer.AddWindow(checkbox) |
738 | 422 |
if element_infos["value"] is not None: |
423 |
checkbox.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
424 |
checkbox.Bind(wx.EVT_CHECKBOX, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
425 |
self.GetCheckBoxCallBackFunction(checkbox, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
426 |
checkbox) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
427 |
|
738 | 428 |
elif element_infos["type"] in ["unsignedLong", "long","integer"]: |
429 |
if element_infos["type"].startswith("unsigned"): |
|
430 |
scmin = 0 |
|
431 |
else: |
|
432 |
scmin = -(2**31) |
|
433 |
scmax = 2**31-1 |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
434 |
spinctrl = wx.SpinCtrl(self.ParamsEditor, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
435 |
size=wx.Size(300, -1), style=wx.SP_ARROW_KEYS|wx.ALIGN_RIGHT) |
738 | 436 |
spinctrl.SetRange(scmin, scmax) |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
437 |
boxsizer.AddWindow(spinctrl) |
738 | 438 |
if element_infos["value"] is not None: |
439 |
spinctrl.SetValue(element_infos["value"]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
440 |
spinctrl.Bind(wx.EVT_SPINCTRL, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
441 |
self.GetTextCtrlCallBackFunction(spinctrl, element_path), |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
442 |
spinctrl) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
443 |
|
738 | 444 |
else: |
445 |
choices = self.ParentWindow.GetConfigEntry(element_path, [""]) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
446 |
textctrl = TextCtrlAutoComplete(name=element_infos["name"], |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
447 |
parent=self.ParamsEditor, |
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
448 |
choices=choices, |
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
449 |
element_path=element_path, |
846
26836e421e19
Fix ConfTreeNodeEditor parameters controls size on Windows
laurent
parents:
844
diff
changeset
|
450 |
size=wx.Size(300, -1)) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
451 |
|
781
cdc6393705ce
Adding support using plcopeneditor bitmap library for icon request
laurent
parents:
775
diff
changeset
|
452 |
boxsizer.AddWindow(textctrl) |
738 | 453 |
if element_infos["value"] is not None: |
454 |
textctrl.ChangeValue(str(element_infos["value"])) |
|
1180 | 455 |
callback = self.GetTextCtrlCallBackFunction(textctrl, element_path) |
456 |
textctrl.Bind(wx.EVT_TEXT_ENTER, callback) |
|
457 |
textctrl.Bind(wx.EVT_KILL_FOCUS, callback) |
|
738 | 458 |
first = False |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
459 |
|
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
460 |
|
738 | 461 |
def GetItemChannelChangedFunction(self, dir): |
462 |
def OnConfNodeTreeItemChannelChanged(event): |
|
463 |
confnode_IECChannel = self.Controler.BaseParams.getIEC_Channel() |
|
464 |
res = self.SetConfNodeParamsAttribute("BaseParams.IEC_Channel", confnode_IECChannel + dir) |
|
465 |
wx.CallAfter(self.RefreshIECChannelControlsState) |
|
466 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE) |
|
467 |
event.Skip() |
|
468 |
return OnConfNodeTreeItemChannelChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
469 |
|
738 | 470 |
def SetConfNodeParamsAttribute(self, *args, **kwargs): |
471 |
res, StructChanged = self.Controler.SetParamsAttribute(*args, **kwargs) |
|
1111
ee1a8c961f11
Fixed bug when changing IEC_Channel of node without params
Laurent Bessard
parents:
1105
diff
changeset
|
472 |
if StructChanged and self.ParamsEditor is not None: |
738 | 473 |
wx.CallAfter(self.RefreshConfNodeParamsSizer) |
474 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU) |
|
475 |
return res |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
476 |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
477 |
def GetButtonCallBackFunction(self, method, push=False): |
738 | 478 |
""" Generate the callbackfunc for a given confnode method""" |
479 |
def OnButtonClick(event): |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
480 |
# Disable button to prevent re-entrant call |
738 | 481 |
event.GetEventObject().Disable() |
482 |
# Call |
|
483 |
getattr(self.Controler,method)() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
484 |
# Re-enable button |
738 | 485 |
event.GetEventObject().Enable() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
486 |
|
767
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
487 |
if not push: |
36e823a90d94
Adding support for push buttons (EVT_LEFT_DOWN is bind instead of EVT_BUTTON)
laurent
parents:
762
diff
changeset
|
488 |
event.Skip() |
738 | 489 |
return OnButtonClick |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
490 |
|
738 | 491 |
def GetChoiceCallBackFunction(self, choicectrl, path): |
492 |
def OnChoiceChanged(event): |
|
493 |
res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) |
|
1315
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1282
diff
changeset
|
494 |
if res is None: |
ff14a66bbd12
Fixed Beremiz for working with new xmlclass support using lxml
Laurent Bessard
parents:
1282
diff
changeset
|
495 |
res = "" |
738 | 496 |
choicectrl.SetStringSelection(res) |
497 |
event.Skip() |
|
498 |
return OnChoiceChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
499 |
|
738 | 500 |
def GetChoiceContentCallBackFunction(self, choicectrl, staticboxsizer, path): |
501 |
def OnChoiceContentChanged(event): |
|
502 |
res = self.SetConfNodeParamsAttribute(path, choicectrl.GetStringSelection()) |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
503 |
wx.CallAfter(self.RefreshConfNodeParamsSizer) |
738 | 504 |
event.Skip() |
505 |
return OnChoiceContentChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
506 |
|
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
507 |
def GetTextCtrlCallBackFunction(self, textctrl, path, refresh=False): |
738 | 508 |
def OnTextCtrlChanged(event): |
509 |
res = self.SetConfNodeParamsAttribute(path, textctrl.GetValue()) |
|
510 |
if res != textctrl.GetValue(): |
|
844
ec9e6ef49878
Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents:
840
diff
changeset
|
511 |
if isinstance(textctrl, wx.SpinCtrl): |
ec9e6ef49878
Fixing bug when spinctrl new value is changed by ConfTreeNode
laurent
parents:
840
diff
changeset
|
512 |
textctrl.SetValue(res) |
1179
3e7bd88fcff7
Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents:
1162
diff
changeset
|
513 |
elif res is not None: |
3e7bd88fcff7
Fixed inconsistency in value display when setting integer value for float parameter
Laurent Bessard
parents:
1162
diff
changeset
|
514 |
textctrl.ChangeValue(str(res)) |
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
515 |
if refresh: |
738 | 516 |
wx.CallAfter(self.ParentWindow._Refresh, TITLE, FILEMENU, PROJECTTREE, PAGETITLES) |
517 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, self.GetTagName()) |
|
518 |
event.Skip() |
|
519 |
return OnTextCtrlChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
520 |
|
738 | 521 |
def GetCheckBoxCallBackFunction(self, chkbx, path): |
522 |
def OnCheckBoxChanged(event): |
|
523 |
res = self.SetConfNodeParamsAttribute(path, chkbx.IsChecked()) |
|
524 |
chkbx.SetValue(res) |
|
525 |
event.Skip() |
|
526 |
return OnCheckBoxChanged |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
527 |
|
738 | 528 |
def GetBrowseCallBackFunction(self, name, textctrl, library, value_infos, path): |
529 |
infos = [value_infos] |
|
530 |
def OnBrowseButton(event): |
|
531 |
dialog = BrowseValuesLibraryDialog(self, name, library, infos[0]) |
|
532 |
if dialog.ShowModal() == wx.ID_OK: |
|
533 |
value, value_infos = self.SetConfNodeParamsAttribute(path, dialog.GetValueInfos()) |
|
534 |
textctrl.ChangeValue(value) |
|
535 |
infos[0] = value_infos |
|
536 |
dialog.Destroy() |
|
537 |
event.Skip() |
|
538 |
return OnBrowseButton |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
539 |
|
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
540 |
def RefreshScrollbars(self): |
746
2e09777a40d3
Fix refresh of ConfTreeNodeEditors content when values change
laurent
parents:
744
diff
changeset
|
541 |
self.ParamsEditor.GetBestSize() |
738 | 542 |
xstart, ystart = self.ParamsEditor.GetViewStart() |
543 |
window_size = self.ParamsEditor.GetClientSize() |
|
544 |
maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
|
545 |
posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
|
546 |
posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
|
547 |
self.ParamsEditor.Scroll(posx, posy) |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
548 |
self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
738 | 549 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, posx, posy) |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
550 |
|
1180 | 551 |
def OnParamsEditorResize(self, event): |
840
980863738cf6
Fix scroll bug in ConfNode params panel when changing tab selection on Windows
Laurent Bessard
parents:
814
diff
changeset
|
552 |
self.RefreshScrollbars() |
738 | 553 |
event.Skip() |
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
554 |
|
1180 | 555 |
def OnParamsEditorScroll(self, event): |
556 |
control = self.ParamsEditor.FindFocus() |
|
557 |
if isinstance(control, TextCtrlAutoComplete): |
|
558 |
control.DismissListBox() |
|
559 |
self.Refresh() |
|
560 |
event.Skip() |
|
1451
94e620cbd9de
Added Ronan Bignaux (genesis) patch to use wxversion. Fixed side effects with sys.path. Other cosmetic fixes about path included.
Edouard Tisserant
parents:
1315
diff
changeset
|
561 |