added wxColourBase::Init() and use DEFINE_STD_WXCOLOUR_CONSTRUCTORS() in all ports now (patch 1851600)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2007-12-22 15:03:58 +00:00
parent c8d380be4d
commit 9ef6890f0b
12 changed files with 25 additions and 83 deletions

View File

@@ -24,25 +24,11 @@ class WXDLLEXPORT wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// default
wxColour() { Init(); }
// the other standard ones: notice that we can't use
// DEFINE_STD_WXCOLOUR_CONSTRUCTORS here because we need to call Init() to
// initialize m_cocoaNSColor and the macro doesn't do it
wxColour( ChannelType red, ChannelType green, ChannelType blue,
ChannelType alpha = wxALPHA_OPAQUE )
{ Init(); Set(red, green, blue, alpha); }
wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
wxColour(const wxString& colourName) { Init(); Set(colourName); }
wxColour(const char *colourName) { Init(); Set(colourName); }
wxColour(const wchar_t *colourName) { Init(); Set(colourName); }
// initialization using existing NSColor // initialization using existing NSColor
wxColour( WX_NSColor aColor ); wxColour( WX_NSColor aColor );
// copy ctors and assignment operators // copy ctors and assignment operators
wxColour( const wxColour& col ); wxColour( const wxColour& col );
wxColour& operator = ( const wxColour& col ); wxColour& operator = ( const wxColour& col );

View File

@@ -18,18 +18,21 @@
class WXDLLIMPEXP_FWD_CORE wxColour; class WXDLLIMPEXP_FWD_CORE wxColour;
// the standard wxColour constructors; // A macro to define the standard wxColour constructors:
// this macro avoids to repeat these lines across all colour.h files, since //
// Set() is a virtual function and thus cannot be called by wxColourBase // It avoids the need to repeat these lines across all colour.h files, since
// constructors // Set() is a virtual function and thus cannot be called by wxColourBase ctors
#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
wxColour( ChannelType red, ChannelType green, ChannelType blue, \ wxColour() { Init(); } \
ChannelType alpha = wxALPHA_OPAQUE ) \ wxColour(ChannelType red, \
{ Set(red, green, blue, alpha); } \ ChannelType green, \
wxColour( unsigned long colRGB ) { Set(colRGB); } \ ChannelType blue, \
wxColour(const wxString& colourName) { Set(colourName); } \ ChannelType alpha = wxALPHA_OPAQUE) \
wxColour(const char *colourName) { Set(colourName); } \ { Init(); Set(red, green, blue, alpha); } \
wxColour(const wchar_t *colourName) { Set(colourName); } wxColour(unsigned long colRGB) { Init(); Set(colRGB ); } \
wxColour(const wxString& colourName) { Init(); Set(colourName); } \
wxColour(const char *colourName) { Init(); Set(colourName); } \
wxColour(const wchar_t *colourName) { Init(); Set(colourName); }
// flags for wxColour -> wxString conversion (see wxColour::GetAsString) // flags for wxColour -> wxString conversion (see wxColour::GetAsString)
@@ -129,6 +132,10 @@ public:
#endif #endif
protected: protected:
// Some ports need Init() and while we don't, provide a stub so that the
// ports which don't need it are not forced to define it
void Init() { }
virtual void virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0; InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;

View File

@@ -20,9 +20,6 @@ class WXDLLEXPORT wxColour: public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour();
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// copy ctors and assignment operators // copy ctors and assignment operators

View File

@@ -19,9 +19,6 @@ class WXDLLIMPEXP_CORE wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour() {}
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
wxColour(const GdkColor& gdkColor); wxColour(const GdkColor& gdkColor);

View File

@@ -36,9 +36,6 @@ class WXDLLIMPEXP_CORE wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour() { }
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
virtual ~wxColour(); virtual ~wxColour();

View File

@@ -25,14 +25,9 @@ class WXDLLEXPORT wxColour: public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour() { }
wxColour( const wxColour& col );
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// dtor // default copy ctor and dtor are ok
virtual ~wxColour();
// accessors // accessors
virtual bool IsOk() const { return m_cgColour; } virtual bool IsOk() const { return m_cgColour; }
@@ -44,14 +39,14 @@ public:
// comparison // comparison
bool operator == (const wxColour& colour) const; bool operator == (const wxColour& colour) const;
bool operator != (const wxColour& colour) const { return !(*this == colour); } bool operator != (const wxColour& colour) const { return !(*this == colour); }
CGColorRef GetPixel() const { return m_cgColour; }; CGColorRef GetPixel() const { return m_cgColour; };
CGColorRef GetCGColor() const { return m_cgColour; }; CGColorRef GetCGColor() const { return m_cgColour; };
CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); }; CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); };
void GetRGBColor( RGBColor *col ) const; void GetRGBColor( RGBColor *col ) const;
// Mac-specific ctor and assignment operator from the native colour // Mac-specific ctor and assignment operator from the native colour
@@ -63,8 +58,6 @@ public:
wxColour& operator=(const wxColour& col); wxColour& operator=(const wxColour& col);
protected : protected :
virtual void virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a); InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a);
void InitRGBColor( const RGBColor& col ); void InitRGBColor( const RGBColor& col );

View File

@@ -22,9 +22,6 @@ class WXDLLEXPORT wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour() { Init(); }
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// copy ctors and assignment operators // copy ctors and assignment operators

View File

@@ -23,16 +23,8 @@ class WXDLLEXPORT wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour() { Init(); }
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// dtor
virtual ~wxColour();
// accessors // accessors
// --------- // ---------
@@ -53,11 +45,10 @@ public:
&& m_alpha == colour.m_alpha; && m_alpha == colour.m_alpha;
} }
bool operator != (const wxColour& colour) const { return !(*this == colour); } bool operator!=(const wxColour& colour) const { return !(*this == colour); }
WXCOLORREF GetPixel() const { return m_pixel; } WXCOLORREF GetPixel() const { return m_pixel; }
public: public:
WXCOLORREF m_pixel; WXCOLORREF m_pixel;
@@ -79,5 +70,4 @@ private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)
}; };
#endif #endif // _WX_COLOUR_H_
// _WX_COLOUR_H_

View File

@@ -20,9 +20,6 @@ class WXDLLEXPORT wxColour: public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
// default
wxColour();
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
// Copy ctors and assignment operators // Copy ctors and assignment operators

View File

@@ -38,8 +38,6 @@ class WXDLLEXPORT wxColour : public wxColourBase
public: public:
// constructors // constructors
// ------------ // ------------
wxColour() {}
DEFINE_STD_WXCOLOUR_CONSTRUCTORS DEFINE_STD_WXCOLOUR_CONSTRUCTORS
virtual ~wxColour(); virtual ~wxColour();

View File

@@ -26,15 +26,6 @@ wxColour::wxColour(const RGBColor& col)
InitRGBColor(col); InitRGBColor(col);
} }
wxColour::wxColour( const wxColour& col )
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_alpha = col.m_alpha;
m_cgColour = col.m_cgColour;
}
wxColour::wxColour(CGColorRef col) wxColour::wxColour(CGColorRef col)
{ {
InitCGColorRef(col); InitCGColorRef(col);
@@ -47,10 +38,6 @@ void wxColour::GetRGBColor( RGBColor *col ) const
col->green = (m_green << 8) + m_green; col->green = (m_green << 8) + m_green;
} }
wxColour::~wxColour ()
{
}
wxColour& wxColour::operator=(const RGBColor& col) wxColour& wxColour::operator=(const RGBColor& col)
{ {
InitRGBColor(col); InitRGBColor(col);

View File

@@ -74,10 +74,6 @@ void wxColour::Init()
m_green = 0; m_green = 0;
} }
wxColour::~wxColour()
{
}
void wxColour::InitRGBA(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)
{ {