23 # along with this program; if not, write to the Free Software |
23 # along with this program; if not, write to the Free Software |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
24 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
25 |
25 |
26 |
26 |
27 from __future__ import absolute_import |
27 from __future__ import absolute_import |
28 import types |
28 from __future__ import division |
29 |
29 |
30 import wx |
30 import wx |
31 |
31 |
32 from editors.EditorPanel import EditorPanel |
32 from editors.EditorPanel import EditorPanel |
33 |
33 |
98 label = self.GetLabel() |
98 label = self.GetLabel() |
99 tw, th = dc.GetTextExtent(label) # size of text |
99 tw, th = dc.GetTextExtent(label) # size of text |
100 if not self.up: |
100 if not self.up: |
101 dw = dy = self.labelDelta |
101 dw = dy = self.labelDelta |
102 |
102 |
103 pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
103 pos_x = (width - bw) // 2 + dw # adjust for bitmap and text to centre |
104 pos_y = (height-bh-th)/2+dy |
104 pos_y = (height - bh - th) // 2 + dy |
105 if bmp is not None: |
105 if bmp is not None: |
106 dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
106 dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
107 pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre |
107 pos_x = (width-tw)//2+dw # adjust for bitmap and text to centre |
108 pos_y += bh + 2 |
108 pos_y += bh + 2 |
109 |
109 |
110 dc.DrawText(label, pos_x, pos_y) # draw the text |
110 dc.DrawText(label, pos_x, pos_y) # draw the text |
111 |
111 |
112 |
112 |
303 |
303 |
304 self.ParamsEditorSizer.Layout() |
304 self.ParamsEditorSizer.Layout() |
305 self.Thaw() |
305 self.Thaw() |
306 |
306 |
307 def GenerateMethodButtonSizer(self): |
307 def GenerateMethodButtonSizer(self): |
308 normal_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) |
308 normal_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) |
309 mouseover_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) |
309 mouseover_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) |
310 |
310 |
311 msizer = wx.BoxSizer(wx.HORIZONTAL) |
311 msizer = wx.BoxSizer(wx.HORIZONTAL) |
312 |
312 |
313 for confnode_method in self.Controler.ConfNodeMethods: |
313 for confnode_method in self.Controler.ConfNodeMethods: |
314 if "method" in confnode_method and confnode_method.get("shown", True): |
314 if "method" in confnode_method and confnode_method.get("shown", True): |
400 statictext = wx.StaticText(self.ParamsEditor, |
400 statictext = wx.StaticText(self.ParamsEditor, |
401 label="%s:" % _(element_infos["name"])) |
401 label="%s:" % _(element_infos["name"])) |
402 boxsizer.AddWindow(statictext, border=5, |
402 boxsizer.AddWindow(statictext, border=5, |
403 flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT) |
403 flag=wx.ALIGN_CENTER_VERTICAL | wx.RIGHT) |
404 |
404 |
405 if isinstance(element_infos["type"], types.ListType): |
405 if isinstance(element_infos["type"], list): |
406 if isinstance(element_infos["value"], types.TupleType): |
406 if isinstance(element_infos["value"], tuple): |
407 browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
407 browse_boxsizer = wx.BoxSizer(wx.HORIZONTAL) |
408 boxsizer.AddSizer(browse_boxsizer) |
408 boxsizer.AddSizer(browse_boxsizer) |
409 |
409 |
410 textctrl = wx.TextCtrl(self.ParamsEditor, |
410 textctrl = wx.TextCtrl(self.ParamsEditor, |
411 size=wx.Size(275, -1), style=wx.TE_READONLY) |
411 size=wx.Size(275, -1), style=wx.TE_READONLY) |
427 size=wx.Size(300, -1), style=wx.CB_READONLY) |
427 size=wx.Size(300, -1), style=wx.CB_READONLY) |
428 boxsizer.AddWindow(combobox) |
428 boxsizer.AddWindow(combobox) |
429 |
429 |
430 if element_infos["use"] == "optional": |
430 if element_infos["use"] == "optional": |
431 combobox.Append("") |
431 combobox.Append("") |
432 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
432 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], tuple): |
433 for choice, _xsdclass in element_infos["type"]: |
433 for choice, _xsdclass in element_infos["type"]: |
434 combobox.Append(choice) |
434 combobox.Append(choice) |
435 name = element_infos["name"] |
435 name = element_infos["name"] |
436 value = element_infos["value"] |
436 value = element_infos["value"] |
437 |
437 |
450 combobox.SetStringSelection("") |
450 combobox.SetStringSelection("") |
451 else: |
451 else: |
452 combobox.SetStringSelection(element_infos["value"]) |
452 combobox.SetStringSelection(element_infos["value"]) |
453 combobox.Bind(wx.EVT_COMBOBOX, callback, combobox) |
453 combobox.Bind(wx.EVT_COMBOBOX, callback, combobox) |
454 |
454 |
455 elif isinstance(element_infos["type"], types.DictType): |
455 elif isinstance(element_infos["type"], dict): |
456 scmin = -(2**31) |
456 scmin = -(2**31) |
457 scmax = 2**31-1 |
457 scmax = 2**31-1 |
458 if "min" in element_infos["type"]: |
458 if "min" in element_infos["type"]: |
459 scmin = element_infos["type"]["min"] |
459 scmin = element_infos["type"]["min"] |
460 if "max" in element_infos["type"]: |
460 if "max" in element_infos["type"]: |
613 def RefreshScrollbars(self): |
613 def RefreshScrollbars(self): |
614 self.ParamsEditor.GetBestSize() |
614 self.ParamsEditor.GetBestSize() |
615 xstart, ystart = self.ParamsEditor.GetViewStart() |
615 xstart, ystart = self.ParamsEditor.GetViewStart() |
616 window_size = self.ParamsEditor.GetClientSize() |
616 window_size = self.ParamsEditor.GetClientSize() |
617 maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
617 maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
618 posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
618 posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) |
619 posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
619 posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) |
620 self.ParamsEditor.Scroll(posx, posy) |
620 self.ParamsEditor.Scroll(posx, posy) |
621 self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
621 self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
622 maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, |
622 maxx // SCROLLBAR_UNIT, |
|
623 maxy // SCROLLBAR_UNIT, |
623 posx, posy) |
624 posx, posy) |
624 |
625 |
625 def OnParamsEditorResize(self, event): |
626 def OnParamsEditorResize(self, event): |
626 self.RefreshScrollbars() |
627 self.RefreshScrollbars() |
627 event.Skip() |
628 event.Skip() |