From: Vadim Zeitlin Date: Thu, 4 Oct 2012 23:23:18 +0000 (+0000) Subject: Add a more convenient wxColour::MakeDisabled() overload. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/893d540e536b46a7529923f82e8105acc1c536d8 Add a more convenient wxColour::MakeDisabled() overload. Allow creating a disabled version of the colour without having to manually break it into RGB components and then recreating it from them. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72618 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/colour.h b/include/wx/colour.h index eac59a6bd7..e421e19613 100644 --- a/include/wx/colour.h +++ b/include/wx/colour.h @@ -167,6 +167,7 @@ public: static void ChangeLightness(unsigned char* r, unsigned char* g, unsigned char* b, int ialpha); wxColour ChangeLightness(int ialpha) const; + wxColour& MakeDisabled(unsigned char brightness = 255); // old, deprecated // --------------- diff --git a/interface/wx/colour.h b/interface/wx/colour.h index bf051c3ff1..886b65adc6 100644 --- a/interface/wx/colour.h +++ b/interface/wx/colour.h @@ -235,7 +235,16 @@ public: @since 2.9.0 */ static void MakeDisabled(unsigned char* r, unsigned char* g, unsigned char* b, unsigned char brightness = 255); - + + /** + Make a disabled version of this colour. + + This method modifies the object in place and returns the object itself. + + @since 2.9.5 + */ + wxColour& MakeDisabled(unsigned char brightness = 255); + /** Create a grey colour from (in/out) rgb parameters using integer arithmetic. @since 2.9.0 diff --git a/src/common/colourcmn.cpp b/src/common/colourcmn.cpp index 013b17cee3..70e4a1d9ca 100644 --- a/src/common/colourcmn.cpp +++ b/src/common/colourcmn.cpp @@ -273,6 +273,16 @@ void wxColourBase::MakeDisabled(unsigned char* r, unsigned char* g, unsigned cha *b = AlphaBlend(*b, brightness, 0.4); } +wxColour& wxColourBase::MakeDisabled(unsigned char brightness) +{ + unsigned char r = Red(), + g = Green(), + b = Blue(); + MakeDisabled(&r, &g, &b, brightness); + Set(r, g, b, Alpha()); + return static_cast(*this); +} + // AlphaBlend is used by ChangeLightness and MakeDisabled // static