Hi all,
I've been playing with generic buttons because I'd like to have a mouse
hover effect on flat bitmap buttons.
The existing ThemedGenBitmapButton add a themed rect even with the
wx.BORDER_NONE option and I don't want this.
I've come up with this trick of calling
wx.RendererNative.Get().DrawItemSelectionRect(self, dc, rect, state)
Is there a similar function (or would it be difficult to add) that shows
the 3d hover rect on a button, like when the mouse hovers on a toolbar
button?
##wx.lib.button.py test to have really flat buttons with an hover indicator
class FlatGenButton(GenButton):
" Test for a flat bitmap button with mouse hover effect "
def InitOtherEvents(self):
self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouse)
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouse)
def OnMouse(self, evt):
self.Refresh()
evt.Skip()
def DrawBezel(self, dc, x1, y1, x2, y2):
rect = wx.Rect(x1, y1, x2, y2)
if self.up:
state = 0
else:
state = wx.CONTROL_PRESSED
if not self.IsEnabled():
state = wx.CONTROL_DISABLED
pt = self.ScreenToClient(wx.GetMousePosition())
if self.GetClientRect().Contains(pt):
state = wx.CONTROL_CURRENT
wx.RendererNative.Get().DrawItemSelectionRect(self, dc, rect, state)
class FlatGenBitmapButton(FlatGenButton, GenBitmapButton):
"""A themed generic bitmap button."""
pass