From 6d0ef23bee93aa9aaab66886740c5127cbab34f1 Mon Sep 17 00:00:00 2001 From: Andrea Gavana Date: Mon, 3 Dec 2012 21:16:07 +0000 Subject: [PATCH] `AquaButton`: apply patch from Werner to allow the definition of a disabled colour. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@73117 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wx/lib/agw/__init__.py | 2 +- wx/lib/agw/aquabutton.py | 67 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/wx/lib/agw/__init__.py b/wx/lib/agw/__init__.py index f6873369..daf2b4c5 100644 --- a/wx/lib/agw/__init__.py +++ b/wx/lib/agw/__init__.py @@ -120,7 +120,7 @@ andrea.gavana@maerskoil.com AGW version: 0.9.7 -Last updated: 31 October 2012, 21.00 GMT +Last updated: 03 December 2012, 21.00 GMT """ diff --git a/wx/lib/agw/aquabutton.py b/wx/lib/agw/aquabutton.py index 88d2a96a..0d7402bd 100644 --- a/wx/lib/agw/aquabutton.py +++ b/wx/lib/agw/aquabutton.py @@ -2,7 +2,7 @@ # AQUABUTTON wxPython IMPLEMENTATION # # Andrea Gavana, @ 07 October 2008 -# Latest Revision: 24 Nov 2011, 22.00 GMT +# Latest Revision: 03 Dec 2012, 21.00 GMT # # # TODO List @@ -100,7 +100,7 @@ License And Version :class:`AquaButton` control is distributed under the wxPython license. -Latest Revision: Andrea Gavana @ 22 Nov 2011, 22.00 GMT +Latest Revision: Andrea Gavana @ 03 Dec 2012, 21.00 GMT Version 0.4 @@ -216,11 +216,15 @@ class AquaButton(wx.PyControl): self._hoverColour = self.LightColour(self._backColour, 30) self._disableColour = self.LightColour(self._backColour, 70) self._textColour = wx.BLACK + self._shadowColour = wx.Colour("grey") + self._rectColour = self.GetParent().GetBackgroundColour() else: self._backColour = wx.SystemSettings.GetColour(wx.SYS_COLOUR_ACTIVECAPTION) self._hoverColour = self.LightColour(self._backColour, 30) self._disableColour = self.LightColour(self._backColour, 70) self._textColour = wx.WHITE + self._shadowColour = wx.Colour("grey") + self._rectColour = self.GetParent().GetBackgroundColour() def SetBitmapLabel(self, bitmap): @@ -273,7 +277,7 @@ class AquaButton(wx.PyControl): xpos, ypos, width, height = self.GetClientRect() - dc.SetBackground(wx.Brush(self.GetParent().GetBackgroundColour())) + dc.SetBackground(wx.Brush(self._rectColour)) dc.Clear() gc.SetBrush(wx.WHITE_BRUSH) @@ -302,7 +306,7 @@ class AquaButton(wx.PyControl): path2 = self.GetPath(gc, rc2, 10) br2 = gc.CreateRadialGradientBrush(rc2.x, rc2.y, rc2.x+rc2.width, rc2.y+rc2.height, - rc2.width, wx.NamedColour("grey"), wx.WHITE) + rc2.width, self._shadowColour, wx.WHITE) # Create top water colour to give "aqua" effect rc3 = wx.Rect(*rc1) @@ -734,11 +738,66 @@ class AquaButton(wx.PyControl): return self._disableColour + + def SetShadowColour(self, colour): + """ + Sets the button shadow colour. + + :param `colour`: a valid :class:`Colour` object. + + .. versionadded:: 0.9.7 + """ + + self._shadowColour = colour + self.Invalidate() + + + def GetShadowColour(self): + """ + Returns the button shadow colour. + + :return: An instance of :class:`Colour`. + + .. versionadded:: 0.9.7 + """ + + return self._shadowColour + + + def SetRectColour(self, colour): + """ + Sets the button rectangular background colour. + + :param `colour`: a valid :class:`Colour` object. + + .. versionadded:: 0.9.7 + """ + + self._rectColour = colour + self.Invalidate() + + + def GetRectColour(self): + """ + Returns the button rectangular background colour. + + :return: An instance of :class:`Colour`. + + .. versionadded:: 0.9.7 + """ + + return self._rectColour + + SetBackgroundColor = SetBackgroundColour SetHoverColor = SetHoverColour GetHoverColor = GetHoverColour SetDisabledColor = SetDisabledColour GetDisabledColor = GetDisabledColour + SetShadowColor = SetShadowColour + GetShadowColor = SetShadowColour + SetRectColor = SetRectColour + GetRectColor = SetRectColour def SetForegroundColour(self, colour):