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