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