27 'other': 'new century schoolbook', |
27 'other': 'new century schoolbook', |
28 'size' : 18, |
28 'size' : 18, |
29 } |
29 } |
30 |
30 |
31 SCROLLBAR_UNIT = 10 |
31 SCROLLBAR_UNIT = 10 |
32 WINDOW_COLOUR = wx.Colour(240, 240, 240) |
|
33 |
32 |
34 CWD = os.path.split(os.path.realpath(__file__))[0] |
33 CWD = os.path.split(os.path.realpath(__file__))[0] |
35 |
34 |
36 def Bpath(*args): |
35 def Bpath(*args): |
37 return os.path.join(CWD,*args) |
36 return os.path.join(CWD,*args) |
38 |
|
39 # Some helpers to tweak GenBitmapTextButtons |
|
40 # TODO: declare customized classes instead. |
|
41 gen_mini_GetBackgroundBrush = lambda obj:lambda dc: wx.Brush(obj.GetParent().GetBackgroundColour(), wx.SOLID) |
|
42 gen_textbutton_GetLabelSize = lambda obj:lambda:(wx.lib.buttons.GenButton._GetLabelSize(obj)[:-1] + (False,)) |
|
43 |
|
44 def make_genbitmaptogglebutton_flat(button): |
|
45 button.GetBackgroundBrush = gen_mini_GetBackgroundBrush(button) |
|
46 button.labelDelta = 0 |
|
47 button.SetBezelWidth(0) |
|
48 button.SetUseFocusIndicator(False) |
|
49 |
37 |
50 # Patch wx.lib.imageutils so that gray is supported on alpha images |
38 # Patch wx.lib.imageutils so that gray is supported on alpha images |
51 import wx.lib.imageutils |
39 import wx.lib.imageutils |
52 from wx.lib.imageutils import grayOut as old_grayOut |
40 from wx.lib.imageutils import grayOut as old_grayOut |
53 def grayOut(anImage): |
41 def grayOut(anImage): |
114 pos_y += bh + 2 |
102 pos_y += bh + 2 |
115 |
103 |
116 dc.DrawText(label, pos_x, pos_y) # draw the text |
104 dc.DrawText(label, pos_x, pos_y) # draw the text |
117 |
105 |
118 |
106 |
119 class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap): |
107 class GenStaticBitmap(wx.StaticBitmap): |
120 """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
108 """ Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32, |
121 and accept image name as __init__ parameter, fail silently if file do not exist""" |
109 and accept image name as __init__ parameter, fail silently if file do not exist""" |
122 def __init__(self, parent, ID, bitmapname, |
110 def __init__(self, parent, ID, bitmapname, |
123 pos = wx.DefaultPosition, size = wx.DefaultSize, |
111 pos = wx.DefaultPosition, size = wx.DefaultSize, |
124 style = 0, |
112 style = 0, |
125 name = "genstatbmp"): |
113 name = "genstatbmp"): |
126 |
114 |
127 wx.lib.statbmp.GenStaticBitmap.__init__(self, parent, ID, |
115 bitmap = GetBitmap(bitmapname) |
128 GetBitmap(bitmapname), |
116 if bitmap is None: |
|
117 bitmap = wx.EmptyBitmap(0, 0) |
|
118 |
|
119 wx.StaticBitmap.__init__(self, parent, ID, |
|
120 bitmap, |
129 pos, size, |
121 pos, size, |
130 style, |
122 style, |
131 name) |
123 name) |
132 |
|
133 def OnPaint(self, event): |
|
134 dc = wx.PaintDC(self) |
|
135 colour = self.GetParent().GetBackgroundColour() |
|
136 dc.SetPen(wx.Pen(colour)) |
|
137 dc.SetBrush(wx.Brush(colour )) |
|
138 dc.DrawRectangle(0, 0, *dc.GetSizeTuple()) |
|
139 if self._bitmap: |
|
140 dc.DrawBitmap(self._bitmap, 0, 0, True) |
|
141 |
124 |
142 class ConfTreeNodeEditor(EditorPanel): |
125 class ConfTreeNodeEditor(EditorPanel): |
143 |
126 |
144 SHOW_BASE_PARAMS = True |
127 SHOW_BASE_PARAMS = True |
145 SHOW_PARAMS = True |
128 SHOW_PARAMS = True |
151 tabs_num += 1 |
134 tabs_num += 1 |
152 |
135 |
153 if tabs_num > 1 or self.SHOW_BASE_PARAMS: |
136 if tabs_num > 1 or self.SHOW_BASE_PARAMS: |
154 self.Editor = wx.Panel(parent, |
137 self.Editor = wx.Panel(parent, |
155 style=wx.SUNKEN_BORDER|wx.SP_3D) |
138 style=wx.SUNKEN_BORDER|wx.SP_3D) |
156 self.Editor.SetBackgroundColour(WINDOW_COLOUR) |
|
157 |
139 |
158 self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
140 self.MainSizer = wx.BoxSizer(wx.VERTICAL) |
159 |
141 |
160 if self.SHOW_BASE_PARAMS: |
142 if self.SHOW_BASE_PARAMS: |
161 baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL) |
143 baseparamseditor_sizer = wx.BoxSizer(wx.HORIZONTAL) |
184 self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), |
166 self.IECCDownButton.Bind(wx.EVT_BUTTON, self.GetItemChannelChangedFunction(-1), |
185 self.IECCDownButton) |
167 self.IECCDownButton) |
186 updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT) |
168 updownsizer.AddWindow(self.IECCDownButton, flag=wx.ALIGN_LEFT) |
187 |
169 |
188 self.ConfNodeName = wx.TextCtrl(self.Editor, |
170 self.ConfNodeName = wx.TextCtrl(self.Editor, |
189 size=wx.Size(150, 25), style=wx.NO_BORDER) |
171 size=wx.Size(150, 25)) |
190 self.ConfNodeName.SetFont( |
172 self.ConfNodeName.SetFont( |
191 wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, |
173 wx.Font(faces["size"] * 0.75, wx.DEFAULT, wx.NORMAL, |
192 wx.BOLD, faceName = faces["helv"])) |
174 wx.BOLD, faceName = faces["helv"])) |
193 self.ConfNodeName.Bind(wx.EVT_TEXT, |
175 self.ConfNodeName.Bind(wx.EVT_TEXT, |
194 self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), |
176 self.GetTextCtrlCallBackFunction(self.ConfNodeName, "BaseParams.Name", True), |
226 panel_style = wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL |
208 panel_style = wx.TAB_TRAVERSAL|wx.HSCROLL|wx.VSCROLL |
227 if self.ConfNodeNoteBook is None and parent != self.Editor: |
209 if self.ConfNodeNoteBook is None and parent != self.Editor: |
228 panel_style |= wx.SUNKEN_BORDER |
210 panel_style |= wx.SUNKEN_BORDER |
229 self.ParamsEditor = wx.ScrolledWindow(parent, |
211 self.ParamsEditor = wx.ScrolledWindow(parent, |
230 style=panel_style) |
212 style=panel_style) |
231 self.ParamsEditor.SetBackgroundColour(WINDOW_COLOUR) |
|
232 self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnWindowResize) |
213 self.ParamsEditor.Bind(wx.EVT_SIZE, self.OnWindowResize) |
233 self.ParamsEditor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) |
214 self.ParamsEditor.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheel) |
234 |
215 |
235 # Variable allowing disabling of ParamsEditor scroll when Popup shown |
216 # Variable allowing disabling of ParamsEditor scroll when Popup shown |
236 self.ScrollingEnabled = True |
217 self.ScrollingEnabled = True |