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 from __future__ import division |
28 import types |
29 import types |
29 |
30 |
30 import wx |
31 import wx |
31 |
32 |
32 from editors.EditorPanel import EditorPanel |
33 from editors.EditorPanel import EditorPanel |
98 label = self.GetLabel() |
99 label = self.GetLabel() |
99 tw, th = dc.GetTextExtent(label) # size of text |
100 tw, th = dc.GetTextExtent(label) # size of text |
100 if not self.up: |
101 if not self.up: |
101 dw = dy = self.labelDelta |
102 dw = dy = self.labelDelta |
102 |
103 |
103 pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre |
104 pos_x = (width - bw) // 2 + dw # adjust for bitmap and text to centre |
104 pos_y = (height-bh-th)/2+dy |
105 pos_y = (height - bh - th) // 2 + dy |
105 if bmp is not None: |
106 if bmp is not None: |
106 dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available |
107 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 |
108 pos_x = (width-tw)//2+dw # adjust for bitmap and text to centre |
108 pos_y += bh + 2 |
109 pos_y += bh + 2 |
109 |
110 |
110 dc.DrawText(label, pos_x, pos_y) # draw the text |
111 dc.DrawText(label, pos_x, pos_y) # draw the text |
111 |
112 |
112 |
113 |
303 |
304 |
304 self.ParamsEditorSizer.Layout() |
305 self.ParamsEditorSizer.Layout() |
305 self.Thaw() |
306 self.Thaw() |
306 |
307 |
307 def GenerateMethodButtonSizer(self): |
308 def GenerateMethodButtonSizer(self): |
308 normal_bt_font = wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"]) |
309 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) |
310 mouseover_bt_font = wx.Font(faces["size"] // 3, wx.DEFAULT, wx.NORMAL, wx.NORMAL, faceName=faces["helv"], underline=True) |
310 |
311 |
311 msizer = wx.BoxSizer(wx.HORIZONTAL) |
312 msizer = wx.BoxSizer(wx.HORIZONTAL) |
312 |
313 |
313 for confnode_method in self.Controler.ConfNodeMethods: |
314 for confnode_method in self.Controler.ConfNodeMethods: |
314 if "method" in confnode_method and confnode_method.get("shown", True): |
315 if "method" in confnode_method and confnode_method.get("shown", True): |
613 def RefreshScrollbars(self): |
614 def RefreshScrollbars(self): |
614 self.ParamsEditor.GetBestSize() |
615 self.ParamsEditor.GetBestSize() |
615 xstart, ystart = self.ParamsEditor.GetViewStart() |
616 xstart, ystart = self.ParamsEditor.GetViewStart() |
616 window_size = self.ParamsEditor.GetClientSize() |
617 window_size = self.ParamsEditor.GetClientSize() |
617 maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
618 maxx, maxy = self.ParamsEditorSizer.GetMinSize() |
618 posx = max(0, min(xstart, (maxx - window_size[0]) / SCROLLBAR_UNIT)) |
619 posx = max(0, min(xstart, (maxx - window_size[0]) // SCROLLBAR_UNIT)) |
619 posy = max(0, min(ystart, (maxy - window_size[1]) / SCROLLBAR_UNIT)) |
620 posy = max(0, min(ystart, (maxy - window_size[1]) // SCROLLBAR_UNIT)) |
620 self.ParamsEditor.Scroll(posx, posy) |
621 self.ParamsEditor.Scroll(posx, posy) |
621 self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
622 self.ParamsEditor.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
622 maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, |
623 maxx // SCROLLBAR_UNIT, |
|
624 maxy // SCROLLBAR_UNIT, |
623 posx, posy) |
625 posx, posy) |
624 |
626 |
625 def OnParamsEditorResize(self, event): |
627 def OnParamsEditorResize(self, event): |
626 self.RefreshScrollbars() |
628 self.RefreshScrollbars() |
627 event.Skip() |
629 event.Skip() |