--- a/Beremiz.py Thu Aug 28 16:34:48 2008 +0200
+++ b/Beremiz.py Sat Aug 30 22:12:49 2008 +0200
@@ -126,7 +126,56 @@
class GenBitmapTextButton(wx.lib.buttons.GenBitmapTextButton):
- return wx.lib.buttons.GenBitmapTextButton._GetLabelSize(self)[:-1] + (False,)
+ """ used internally """ + w, h = self.GetTextExtent(self.GetLabel()) + return w, h, False # if there isn't a bitmap use the size of the text + w_bmp = self.bmpLabel.GetWidth()+2 + h_bmp = self.bmpLabel.GetHeight()+2 + return width, height, False + def DrawLabel(self, dc, width, height, dw=0, dy=0): + if bmp != None: # if the bitmap is used + if self.bmpDisabled and not self.IsEnabled(): + if self.bmpFocus and self.hasFocus: + if self.bmpSelected and not self.up: + bw,bh = bmp.GetWidth(), bmp.GetHeight() + dw = dy = self.labelDelta + hasMask = bmp.GetMask() != None + bw = bh = 0 # no bitmap -> size is zero + dc.SetFont(self.GetFont()) + dc.SetTextForeground(self.GetForegroundColour()) + dc.SetTextForeground(wx.SystemSettings.GetColour(wx.SYS_COLOUR_GRAYTEXT)) + label = self.GetLabel() + tw, th = dc.GetTextExtent(label) # size of text + dw = dy = self.labelDelta + pos_x = (width-bw)/2+dw # adjust for bitmap and text to centre + pos_y = (height-bh-th)/2+dy + dc.DrawBitmap(bmp, pos_x, pos_y, hasMask) # draw bitmap if available + pos_x = (width-tw)/2+dw # adjust for bitmap and text to centre + dc.DrawText(label, pos_x, pos_y) # draw the text class GenStaticBitmap(wx.lib.statbmp.GenStaticBitmap):
""" Customized GenStaticBitmap, fix transparency redraw bug on wx2.8/win32,
@@ -589,6 +638,8 @@
# addsizer.AddWindow(addbutton, 0, border=0, flag=0)
+ normal_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, 0, faceName = faces["helv"]) + mouseover_bt_font=wx.Font(faces["size"] / 3, wx.DEFAULT, wx.NORMAL, 0, underline=True, faceName = faces["helv"]) def GenerateMethodButtonSizer(self, plugin, parent, horizontal = True):
msizer = wx.FlexGridSizer(cols=len(plugin.PluginMethods))
@@ -597,15 +648,26 @@
for plugin_method in plugin.PluginMethods:
if "method" in plugin_method and plugin_method.get("shown",True):
+ label=plugin_method["name"] button = GenBitmapTextButton(id=id, parent=parent,
- bitmap=wx.Bitmap(Bpath( "%s.png"%plugin_method.get("bitmap", os.path.join("images", "Unknown")))), label=plugin_method["name"],
- name=plugin_method["name"], pos=wx.DefaultPosition, style=wx.NO_BORDER)
+ bitmap=wx.Bitmap(Bpath( "%s.png"%plugin_method.get("bitmap", os.path.join("images", "Unknown")))), label=label, + name=label, pos=wx.DefaultPosition, style=wx.NO_BORDER) + button.SetFont(self.normal_bt_font) button.SetToolTipString(plugin_method["tooltip"])
button.Bind(wx.EVT_BUTTON, self.GetButtonCallBackFunction(plugin, plugin_method["method"]), id=id)
+ # a fancy underline on mouseover + def setFontStyle(b, s): + button.Bind(wx.EVT_ENTER_WINDOW, setFontStyle(button, self.mouseover_bt_font)) + button.Bind(wx.EVT_LEAVE_WINDOW, setFontStyle(button, self.normal_bt_font)) #hack to force size to mini
if not plugin_method.get("enabled",True):
- msizer.AddWindow(button, 0, border=0, flag=0)
+ msizer.AddWindow(button, 0, border=0, flag=wx.ALIGN_CENTER) def RefreshPluginTree(self):