X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/78385733e74adc246df560b6c27c96dd3fbe1a96..b4414c1f3778c54fb0ddfd2eea63f940bbee6d0f:/utils/wxPython/lib/buttons.py diff --git a/utils/wxPython/lib/buttons.py b/utils/wxPython/lib/buttons.py index 6c90aceda6..7d63710314 100644 --- a/utils/wxPython/lib/buttons.py +++ b/utils/wxPython/lib/buttons.py @@ -52,13 +52,14 @@ class wxGenButtonEvent(wxPyCommandEvent): #---------------------------------------------------------------------- -class wxGenButton(wxWindow): +class wxGenButton(wxControl): def __init__(self, parent, ID, label, pos = wxDefaultPosition, size = wxDefaultSize, style = 0, validator = wxDefaultValidator, name = "genbutton"): - wxWindow.__init__(self, parent, ID, pos, size, style, name) - self.SetValidator(validator) + if style == 0: + style = wxNO_BORDER + wxControl.__init__(self, parent, ID, pos, size, style, validator, name) self.up = true self.bezelWidth = 2 @@ -141,7 +142,8 @@ class wxGenButton(wxWindow): highlightClr = wxSystemSettings_GetSystemColour(wxSYS_COLOUR_BTNHIGHLIGHT) self.shadowPen = wxPen(shadowClr, 1, wxSOLID) self.highlightPen = wxPen(highlightClr, 1, wxSOLID) - self.focusIndPen = wxPen(textClr, 1, wxUSER_DASH) + ##self.focusIndPen = wxPen(textClr, 1, wxUSER_DASH) + self.focusIndPen = wxPen(textClr, 1, wxDOT) def SetBackgroundColour(self, colour): @@ -208,7 +210,7 @@ class wxGenButton(wxWindow): bw = self.bezelWidth dc.SetLogicalFunction(wxINVERT) self.focusIndPen.SetColour(self.GetForegroundColour()) - self.focusIndPen.SetDashes([1,2,1,2]) # This isn't quite working the way I expected... + ##self.focusIndPen.SetDashes([1,2,1,2]) # This isn't quite working the way I expected... dc.SetPen(self.focusIndPen) dc.SetBrush(wxTRANSPARENT_BRUSH) dc.DrawRectangle(bw+2,bw+2, w-bw*2-4, h-bw*2-4) @@ -230,6 +232,7 @@ class wxGenButton(wxWindow): if self.hasFocus and self.useFocusInd: self.DrawFocusIndicator(dc, width, height) + def OnEraseBackground(self, event): pass @@ -291,6 +294,7 @@ class wxGenButton(wxWindow): self.Refresh() event.Skip() + def OnKeyUp(self, event): if self.hasFocus and event.KeyCode() == ord(" "): self.up = true @@ -359,7 +363,8 @@ class wxGenBitmapButton(wxGenButton): bw,bh = bmp.GetWidth(), bmp.GetHeight() if not self.up: dw = dy = 1 - dc.DrawBitmap(bmp, (width-bw)/2+dw, (height-bh)/2+dy, true) + hasMask = bmp.GetMask() != None + dc.DrawBitmap(bmp, (width-bw)/2+dw, (height-bh)/2+dy, hasMask) @@ -376,6 +381,7 @@ class __ToggleMixin: def OnLeftDown(self, event): if not self.IsEnabled(): return + self.saveUp = self.up self.up = not self.up self.CaptureMouse() self.SetFocus() @@ -384,7 +390,8 @@ class __ToggleMixin: def OnLeftUp(self, event): if not self.IsEnabled(): return - self.Notify() + if self.up != self.saveUp: + self.Notify() self.ReleaseMouse() self.Refresh()