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
This commit is contained in:
Vadim Zeitlin
2006-09-10 02:00:24 +00:00
parent 9d639ffa59
commit aea95b1c3a
19 changed files with 75 additions and 70 deletions

View File

@@ -83,10 +83,8 @@ protected:
// puts the object in an invalid, uninitialized state // puts the object in an invalid, uninitialized state
void Init(); void Init();
virtual void InitWith(unsigned char red, virtual void
unsigned char green, InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
unsigned char blue,
unsigned char alpha);
private: private:
WX_NSColor m_cocoaNSColor; WX_NSColor m_cocoaNSColor;

View File

@@ -21,8 +21,8 @@
// Set() is a virtual function and thus cannot be called by wxColourBase // Set() is a virtual function and thus cannot be called by wxColourBase
// constructors // constructors
#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
wxColour( unsigned char red, unsigned char green, unsigned char blue, \ wxColour( ChannelType red, ChannelType green, ChannelType blue, \
unsigned char alpha = wxALPHA_OPAQUE ) \ ChannelType alpha = wxALPHA_OPAQUE ) \
{ Set(red, green, blue, alpha); } \ { Set(red, green, blue, alpha); } \
wxColour( unsigned long colRGB ) { Set(colRGB); } \ wxColour( unsigned long colRGB ) { Set(colRGB); } \
wxColour(const wxString &colourName) { Set(colourName); } \ wxColour(const wxString &colourName) { Set(colourName); } \
@@ -47,19 +47,10 @@ const unsigned char wxALPHA_OPAQUE = 0xff;
class WXDLLEXPORT wxColourBase : public wxGDIObject 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: public:
// type of a single colour component
typedef unsigned char ChannelType;
wxColourBase() {} wxColourBase() {}
virtual ~wxColourBase() {} virtual ~wxColourBase() {}
@@ -67,23 +58,26 @@ public:
// Set() functions // Set() functions
// --------------- // ---------------
void Set(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = wxALPHA_OPAQUE) void Set(ChannelType red,
{ InitWith(red,green,blue, alpha); } ChannelType green,
ChannelType blue,
ChannelType alpha = wxALPHA_OPAQUE)
{ InitRGBA(red,green,blue, alpha); }
// implemented in colourcmn.cpp // implemented in colourcmn.cpp
bool Set(const wxChar *str) bool Set(const wxChar *str)
{ return FromString(str); } { return FromString(str); }
bool Set(const wxString &str) bool Set(const wxString &str)
{ return Set((const wxChar *)str); } { return FromString(str); }
void Set(unsigned long colRGB) void Set(unsigned long colRGB)
{ {
// we don't need to know sizeof(long) here because we assume that the three // 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 // least significant bytes contain the R, G and B values
Set((unsigned char)colRGB, Set((ChannelType)colRGB,
(unsigned char)(colRGB >> 8), (ChannelType)(colRGB >> 8),
(unsigned char)(colRGB >> 16)); (ChannelType)(colRGB >> 16));
} }
@@ -93,10 +87,10 @@ public:
virtual bool Ok() const = 0; virtual bool Ok() const = 0;
virtual unsigned char Red() const = 0; virtual ChannelType Red() const = 0;
virtual unsigned char Green() const = 0; virtual ChannelType Green() const = 0;
virtual unsigned char Blue() const = 0; virtual ChannelType Blue() const = 0;
virtual unsigned char Alpha() const virtual ChannelType Alpha() const
{ return wxALPHA_OPAQUE ; } { return wxALPHA_OPAQUE ; }
// implemented in colourcmn.cpp // implemented in colourcmn.cpp
@@ -111,35 +105,40 @@ public:
wxDEPRECATED( static wxColour CreateByName(const wxString& name) ); wxDEPRECATED( static wxColour CreateByName(const wxString& name) );
wxDEPRECATED( void InitFromName(const wxString& col) ); wxDEPRECATED( void InitFromName(const wxString& col) );
#endif #endif
protected:
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
virtual bool FromString(const wxChar *s);
}; };
#if defined(__WXPALMOS__) #if defined(__WXPALMOS__)
#include "wx/generic/colour.h" #include "wx/generic/colour.h"
#elif defined(__WXMSW__) #elif defined(__WXMSW__)
#include "wx/msw/colour.h" #include "wx/msw/colour.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/colour.h" #include "wx/motif/colour.h"
#elif defined(__WXGTK20__) #elif defined(__WXGTK20__)
#include "wx/gtk/colour.h" #include "wx/gtk/colour.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk1/colour.h" #include "wx/gtk1/colour.h"
#elif defined(__WXMGL__) #elif defined(__WXMGL__)
#include "wx/generic/colour.h" #include "wx/generic/colour.h"
#elif defined(__WXDFB__) #elif defined(__WXDFB__)
#include "wx/generic/colour.h" #include "wx/generic/colour.h"
#elif defined(__WXX11__) #elif defined(__WXX11__)
#include "wx/x11/colour.h" #include "wx/x11/colour.h"
#elif defined(__WXMAC__) #elif defined(__WXMAC__)
#include "wx/mac/colour.h" #include "wx/mac/colour.h"
#elif defined(__WXCOCOA__) #elif defined(__WXCOCOA__)
#include "wx/cocoa/colour.h" #include "wx/cocoa/colour.h"
#elif defined(__WXPM__) #elif defined(__WXPM__)
#include "wx/os2/colour.h" #include "wx/os2/colour.h"
#endif #endif
#define wxColor wxColour #define wxColor wxColour
#endif #endif // _WX_COLOUR_H_BASE_
// _WX_COLOUR_H_BASE_

View File

@@ -57,12 +57,8 @@ protected:
// Helper function // Helper function
void Init(); 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);
InitWith(red, green, blue, wxALPHA_OPAQUE);
}
virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha);
private: private:
bool m_isInit; bool m_isInit;

View File

@@ -48,8 +48,10 @@ public:
#endif #endif
protected: protected:
virtual void
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
virtual bool FromString(const wxChar *str); virtual bool FromString(const wxChar *str);
virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue );
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -65,7 +65,8 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) 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: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -55,12 +55,8 @@ protected :
// Helper function // Helper function
void Init(); void Init();
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);
InitWith( red, green, blue , wxALPHA_OPAQUE ) ;
}
void InitWith( unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha );
private: private:
bool m_isInit; bool m_isInit;
@@ -72,7 +68,7 @@ private:
public: public:
WXCOLORREF m_pixel ; WXCOLORREF m_pixel ;
void FromRGBColor( const WXCOLORREF* color ) ; void FromRGBColor( const WXCOLORREF* color ) ;
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -62,7 +62,8 @@ protected:
// Helper function // Helper function
void Init(); 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: private:
bool m_isInit; bool m_isInit;

View File

@@ -63,7 +63,8 @@ protected:
// Helper function // Helper function
void Init(); 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: private:
bool m_isInit; bool m_isInit;

View File

@@ -65,7 +65,8 @@ private:
unsigned char m_cBlue; unsigned char m_cBlue;
unsigned char m_cGreen; 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: public:
WXCOLORREF m_vPixel ; WXCOLORREF m_vPixel ;

View File

@@ -64,8 +64,10 @@ protected:
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) 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 bool FromString(const wxChar *str);
virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue );
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -63,7 +63,7 @@ wxColour::~wxColour ()
[m_cocoaNSColor release]; [m_cocoaNSColor release];
} }
void wxColour::InitWith(unsigned char r, void wxColour::InitRGBA(unsigned char r,
unsigned char g, unsigned char g,
unsigned char b, unsigned char b,
unsigned char a) unsigned char a)

View File

@@ -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) unsigned char a)
{ {
m_red = r; m_red = r;

View File

@@ -112,7 +112,8 @@ bool wxColour::operator == ( const wxColour& col ) const
refData->m_blue == that_refData->m_blue; 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(); UnRef();

View File

@@ -169,7 +169,8 @@ wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const
return new wxColourRefData(*(wxColourRefData *)data); 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(); AllocExclusive();

View File

@@ -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_red = r;
m_green = g; m_green = g;

View File

@@ -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_red = r;
m_green = g; m_green = g;

View File

@@ -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_red = r;
m_green = g; m_green = g;

View File

@@ -57,9 +57,10 @@ wxColour::~wxColour()
{ {
} // end of wxColour::~wxColour } // end of wxColour::~wxColour
void wxColour::InitWith( unsigned char cRed, void wxColour::InitRGBA( unsigned char cRed,
unsigned char cGreen, unsigned char cGreen,
unsigned char cBlue ) unsigned char cBlue,
unsigned char WXUNUSED(calpha) )
{ {
m_cRed = cRed; m_cRed = cRed;
m_cGreen = cGreen; m_cGreen = cGreen;

View File

@@ -172,7 +172,8 @@ wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const
return new wxColourRefData(*(wxColourRefData *)data); 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(); AllocExclusive();