From aea95b1c3a8ae221cc3aade5ce49a3cf848fd56a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 10 Sep 2006 02:00:24 +0000 Subject: [PATCH] removed overloaded virtual InitWith() methods, keep just a single InitRGBA() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41123 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/colour.h | 6 +-- include/wx/colour.h | 73 +++++++++++++++++----------------- include/wx/generic/colour.h | 8 +--- include/wx/gtk/colour.h | 4 +- include/wx/gtk1/colour.h | 3 +- include/wx/mac/carbon/colour.h | 10 ++--- include/wx/motif/colour.h | 3 +- include/wx/msw/colour.h | 3 +- include/wx/os2/colour.h | 3 +- include/wx/x11/colour.h | 4 +- src/cocoa/colour.mm | 2 +- src/generic/colour.cpp | 4 +- src/gtk/colour.cpp | 3 +- src/gtk1/colour.cpp | 3 +- src/mac/carbon/colour.cpp | 2 +- src/motif/colour.cpp | 3 +- src/msw/colour.cpp | 3 +- src/os2/colour.cpp | 5 ++- src/x11/colour.cpp | 3 +- 19 files changed, 75 insertions(+), 70 deletions(-) diff --git a/include/wx/cocoa/colour.h b/include/wx/cocoa/colour.h index f0088f694c..cfdcd373f3 100644 --- a/include/wx/cocoa/colour.h +++ b/include/wx/cocoa/colour.h @@ -83,10 +83,8 @@ protected: // puts the object in an invalid, uninitialized state void Init(); - virtual void InitWith(unsigned char red, - unsigned char green, - unsigned char blue, - unsigned char alpha); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: WX_NSColor m_cocoaNSColor; diff --git a/include/wx/colour.h b/include/wx/colour.h index 78204d1843..7bba397dc2 100644 --- a/include/wx/colour.h +++ b/include/wx/colour.h @@ -21,8 +21,8 @@ // Set() is a virtual function and thus cannot be called by wxColourBase // constructors #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ - wxColour( unsigned char red, unsigned char green, unsigned char blue, \ - unsigned char alpha = wxALPHA_OPAQUE ) \ + wxColour( ChannelType red, ChannelType green, ChannelType blue, \ + ChannelType alpha = wxALPHA_OPAQUE ) \ { Set(red, green, blue, alpha); } \ wxColour( unsigned long colRGB ) { Set(colRGB); } \ wxColour(const wxString &colourName) { Set(colourName); } \ @@ -47,19 +47,10 @@ const unsigned char wxALPHA_OPAQUE = 0xff; class WXDLLEXPORT wxColourBase : public wxGDIObject { -protected: - - virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue) = 0; - - // this will be overridden in alpha supporting classes - virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue, unsigned char WXUNUSED(alpha)) - { - InitWith( red, green, blue ) ; - } - - virtual bool FromString(const wxChar *); - public: + // type of a single colour component + typedef unsigned char ChannelType; + wxColourBase() {} virtual ~wxColourBase() {} @@ -67,23 +58,26 @@ public: // Set() functions // --------------- - void Set(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = wxALPHA_OPAQUE) - { InitWith(red,green,blue, alpha); } + void Set(ChannelType red, + ChannelType green, + ChannelType blue, + ChannelType alpha = wxALPHA_OPAQUE) + { InitRGBA(red,green,blue, alpha); } // implemented in colourcmn.cpp bool Set(const wxChar *str) { return FromString(str); } bool Set(const wxString &str) - { return Set((const wxChar *)str); } + { return FromString(str); } void Set(unsigned long colRGB) { // we don't need to know sizeof(long) here because we assume that the three // least significant bytes contain the R, G and B values - Set((unsigned char)colRGB, - (unsigned char)(colRGB >> 8), - (unsigned char)(colRGB >> 16)); + Set((ChannelType)colRGB, + (ChannelType)(colRGB >> 8), + (ChannelType)(colRGB >> 16)); } @@ -93,10 +87,10 @@ public: virtual bool Ok() const = 0; - virtual unsigned char Red() const = 0; - virtual unsigned char Green() const = 0; - virtual unsigned char Blue() const = 0; - virtual unsigned char Alpha() const + virtual ChannelType Red() const = 0; + virtual ChannelType Green() const = 0; + virtual ChannelType Blue() const = 0; + virtual ChannelType Alpha() const { return wxALPHA_OPAQUE ; } // implemented in colourcmn.cpp @@ -111,35 +105,40 @@ public: wxDEPRECATED( static wxColour CreateByName(const wxString& name) ); wxDEPRECATED( void InitFromName(const wxString& col) ); #endif + +protected: + virtual void + InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0; + + virtual bool FromString(const wxChar *s); }; #if defined(__WXPALMOS__) -#include "wx/generic/colour.h" + #include "wx/generic/colour.h" #elif defined(__WXMSW__) -#include "wx/msw/colour.h" + #include "wx/msw/colour.h" #elif defined(__WXMOTIF__) -#include "wx/motif/colour.h" + #include "wx/motif/colour.h" #elif defined(__WXGTK20__) -#include "wx/gtk/colour.h" + #include "wx/gtk/colour.h" #elif defined(__WXGTK__) -#include "wx/gtk1/colour.h" + #include "wx/gtk1/colour.h" #elif defined(__WXMGL__) -#include "wx/generic/colour.h" + #include "wx/generic/colour.h" #elif defined(__WXDFB__) -#include "wx/generic/colour.h" + #include "wx/generic/colour.h" #elif defined(__WXX11__) -#include "wx/x11/colour.h" + #include "wx/x11/colour.h" #elif defined(__WXMAC__) -#include "wx/mac/colour.h" + #include "wx/mac/colour.h" #elif defined(__WXCOCOA__) -#include "wx/cocoa/colour.h" + #include "wx/cocoa/colour.h" #elif defined(__WXPM__) -#include "wx/os2/colour.h" + #include "wx/os2/colour.h" #endif #define wxColor wxColour -#endif - // _WX_COLOUR_H_BASE_ +#endif // _WX_COLOUR_H_BASE_ diff --git a/include/wx/generic/colour.h b/include/wx/generic/colour.h index 66aa3800d4..1f4f4ed5c1 100644 --- a/include/wx/generic/colour.h +++ b/include/wx/generic/colour.h @@ -57,12 +57,8 @@ protected: // Helper function void Init(); - virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue) - { - InitWith(red, green, blue, wxALPHA_OPAQUE); - } - - virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: bool m_isInit; diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index 8eaa38e963..f41c52410d 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -48,8 +48,10 @@ public: #endif protected: + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); + virtual bool FromString(const wxChar *str); - virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue ); private: DECLARE_DYNAMIC_CLASS(wxColour) diff --git a/include/wx/gtk1/colour.h b/include/wx/gtk1/colour.h index 4fc19fc767..cf91604445 100644 --- a/include/wx/gtk1/colour.h +++ b/include/wx/gtk1/colour.h @@ -65,7 +65,8 @@ protected: virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue ); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: DECLARE_DYNAMIC_CLASS(wxColour) diff --git a/include/wx/mac/carbon/colour.h b/include/wx/mac/carbon/colour.h index 219761c48f..54fb53afba 100644 --- a/include/wx/mac/carbon/colour.h +++ b/include/wx/mac/carbon/colour.h @@ -55,12 +55,8 @@ protected : // Helper function void Init(); - void InitWith( unsigned char red, unsigned char green, unsigned char blue ) - { - InitWith( red, green, blue , wxALPHA_OPAQUE ) ; - } - - void InitWith( unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha ); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: bool m_isInit; @@ -72,7 +68,7 @@ private: public: WXCOLORREF m_pixel ; void FromRGBColor( const WXCOLORREF* color ) ; - + private: DECLARE_DYNAMIC_CLASS(wxColour) diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index 8bdddeb06b..9d89cccac4 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -62,7 +62,8 @@ protected: // Helper function void Init(); - virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue ); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: bool m_isInit; diff --git a/include/wx/msw/colour.h b/include/wx/msw/colour.h index d3d2562382..1a14604305 100644 --- a/include/wx/msw/colour.h +++ b/include/wx/msw/colour.h @@ -63,7 +63,8 @@ protected: // Helper function void Init(); - virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: bool m_isInit; diff --git a/include/wx/os2/colour.h b/include/wx/os2/colour.h index f8d69fa6e2..611a2e2512 100644 --- a/include/wx/os2/colour.h +++ b/include/wx/os2/colour.h @@ -65,7 +65,8 @@ private: unsigned char m_cBlue; unsigned char m_cGreen; - virtual void InitWith( unsigned char cRed, unsigned char cGreen, unsigned char cBlue); + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); public: WXCOLORREF m_vPixel ; diff --git a/include/wx/x11/colour.h b/include/wx/x11/colour.h index 9d9824199d..17c4f534c0 100644 --- a/include/wx/x11/colour.h +++ b/include/wx/x11/colour.h @@ -64,8 +64,10 @@ protected: virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; + virtual void + InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); + virtual bool FromString(const wxChar *str); - virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue ); private: DECLARE_DYNAMIC_CLASS(wxColour) diff --git a/src/cocoa/colour.mm b/src/cocoa/colour.mm index 92c5ee515c..914408e291 100644 --- a/src/cocoa/colour.mm +++ b/src/cocoa/colour.mm @@ -63,7 +63,7 @@ wxColour::~wxColour () [m_cocoaNSColor release]; } -void wxColour::InitWith(unsigned char r, +void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) diff --git a/src/generic/colour.cpp b/src/generic/colour.cpp index e51a7e3938..6cda3d1e84 100644 --- a/src/generic/colour.cpp +++ b/src/generic/colour.cpp @@ -59,7 +59,9 @@ wxColour::~wxColour() { } -void wxColour::InitWith(unsigned char r, unsigned char g, unsigned char b, +void wxColour::InitRGBA(unsigned char r, + unsigned char g, + unsigned char b, unsigned char a) { m_red = r; diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index af91273257..e09ef66eff 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -112,7 +112,8 @@ bool wxColour::operator == ( const wxColour& col ) const refData->m_blue == that_refData->m_blue; } -void wxColour::InitWith( unsigned char red, unsigned char green, unsigned char blue ) +void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, + unsigned char WXUNUSED(alpha)) { UnRef(); diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp index 7adf4b1dc2..82712095cd 100644 --- a/src/gtk1/colour.cpp +++ b/src/gtk1/colour.cpp @@ -169,7 +169,8 @@ wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const return new wxColourRefData(*(wxColourRefData *)data); } -void wxColour::InitWith( unsigned char red, unsigned char green, unsigned char blue ) +void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, + unsigned char WXUNUSED(alpha)) { AllocExclusive(); diff --git a/src/mac/carbon/colour.cpp b/src/mac/carbon/colour.cpp index 9fa04b0464..9d1435aa82 100644 --- a/src/mac/carbon/colour.cpp +++ b/src/mac/carbon/colour.cpp @@ -44,7 +44,7 @@ wxColour::~wxColour () { } -void wxColour::InitWith (unsigned char r, unsigned char g, unsigned char b, unsigned char a) +void wxColour::InitRGBA (unsigned char r, unsigned char g, unsigned char b, unsigned char a) { m_red = r; m_green = g; diff --git a/src/motif/colour.cpp b/src/motif/colour.cpp index 63d34f901e..32c0d39b78 100644 --- a/src/motif/colour.cpp +++ b/src/motif/colour.cpp @@ -64,7 +64,8 @@ wxColour::~wxColour() { } -void wxColour::InitWith(unsigned char r, unsigned char g, unsigned char b) +void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, + unsigned char WXUNUSED(a)) { m_red = r; m_green = g; diff --git a/src/msw/colour.cpp b/src/msw/colour.cpp index ad1c5221f9..d79ebc9af7 100644 --- a/src/msw/colour.cpp +++ b/src/msw/colour.cpp @@ -77,7 +77,8 @@ wxColour::~wxColour() { } -void wxColour::InitWith(unsigned char r, unsigned char g, unsigned char b) +void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, + unsigned char WXUNUSED(a)) { m_red = r; m_green = g; diff --git a/src/os2/colour.cpp b/src/os2/colour.cpp index 205a2475bb..d1add0c9c3 100644 --- a/src/os2/colour.cpp +++ b/src/os2/colour.cpp @@ -57,9 +57,10 @@ wxColour::~wxColour() { } // end of wxColour::~wxColour -void wxColour::InitWith( unsigned char cRed, +void wxColour::InitRGBA( unsigned char cRed, unsigned char cGreen, - unsigned char cBlue ) + unsigned char cBlue, + unsigned char WXUNUSED(calpha) ) { m_cRed = cRed; m_cGreen = cGreen; diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp index 84a183959b..6000924c83 100644 --- a/src/x11/colour.cpp +++ b/src/x11/colour.cpp @@ -172,7 +172,8 @@ wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const return new wxColourRefData(*(wxColourRefData *)data); } -void wxColour::InitWith( unsigned char red, unsigned char green, unsigned char blue ) +void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, + unsigned char WXUNUSED(alpha)) { AllocExclusive(); -- 2.45.2