name = "genbutton"):
cstyle = style
if cstyle == 0:
- cstyle = wx.NO_BORDER
+ cstyle = wx.BORDER_NONE
wx.PyControl.__init__(self, parent, ID, pos, size, cstyle, validator, name)
self.up = True
self.hasFocus = False
- if style & wx.NO_BORDER:
+ self.style = style
+ if style & wx.BORDER_NONE:
self.bezelWidth = 0
self.useFocusInd = False
else:
self.Bind(wx.EVT_KILL_FOCUS, self.OnLoseFocus)
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
self.Bind(wx.EVT_KEY_UP, self.OnKeyUp)
- self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
self.Bind(wx.EVT_PAINT, self.OnPaint)
x1 = y1 = 0
x2 = width-1
y2 = height-1
+
dc = wx.BufferedPaintDC(self)
+ brush = None
+
if self.up:
- dc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
+ colBg = self.GetBackgroundColour()
+ brush = wx.Brush(colBg, wx.SOLID)
+ if self.style & wx.BORDER_NONE:
+ myAttr = self.GetDefaultAttributes()
+ parAttr = self.GetParent().GetDefaultAttributes()
+ myDef = colBg == myAttr.colBg
+ parDef = self.GetParent().GetBackgroundColour() == parAttr.colBg
+ if myDef and parDef:
+ if wx.Platform == "__WXMAC__":
+ brush.MacSetTheme(1) # 1 == kThemeBrushDialogBackgroundActive
+ elif wx.Platform == "__WXMSW__":
+ if self.DoEraseBackground(dc):
+ brush = None
+ elif myDef and not parDef:
+ colBg = self.GetParent().GetBackgroundColour()
+ brush = wx.Brush(colBg, wx.SOLID)
else:
- dc.SetBackground(wx.Brush(self.faceDnClr, wx.SOLID))
- dc.Clear()
+ brush = wx.Brush(self.faceDnClr, wx.SOLID)
+ if brush is not None:
+ dc.SetBackground(brush)
+ dc.Clear()
+
self.DrawBezel(dc, x1, y1, x2, y2)
self.DrawLabel(dc, width, height)
if self.hasFocus and self.useFocusInd:
self.DrawFocusIndicator(dc, width, height)
- def OnEraseBackground(self, event):
- pass
-
-
def OnLeftDown(self, event):
if not self.IsEnabled():
return
if not self.IsEnabled() or not self.HasCapture():
return
if self.HasCapture():
- if self.up != self.saveUp:
- self.Notify()
self.ReleaseMouse()
self.Refresh()
+ if self.up != self.saveUp:
+ self.Notify()
def OnKeyDown(self, event):
event.Skip()