From 9ef6890f0bbda544c510be1bd81c990a480a3ef3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Dec 2007 15:03:58 +0000 Subject: [PATCH] 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 --- include/wx/cocoa/colour.h | 16 +--------------- include/wx/colour.h | 29 ++++++++++++++++++----------- include/wx/generic/colour.h | 3 --- include/wx/gtk/colour.h | 3 --- include/wx/gtk1/colour.h | 3 --- include/wx/mac/carbon/colour.h | 15 ++++----------- include/wx/motif/colour.h | 3 --- include/wx/msw/colour.h | 14 ++------------ include/wx/os2/colour.h | 3 --- include/wx/x11/colour.h | 2 -- src/mac/carbon/colour.cpp | 13 ------------- src/msw/colour.cpp | 4 ---- 12 files changed, 25 insertions(+), 83 deletions(-) diff --git a/include/wx/cocoa/colour.h b/include/wx/cocoa/colour.h index f0d7af4271..b2bc5796f1 100644 --- a/include/wx/cocoa/colour.h +++ b/include/wx/cocoa/colour.h @@ -24,25 +24,11 @@ class WXDLLEXPORT wxColour : public wxColourBase public: // 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); } + DEFINE_STD_WXCOLOUR_CONSTRUCTORS // initialization using existing NSColor wxColour( WX_NSColor aColor ); - // copy ctors and assignment operators wxColour( const wxColour& col ); wxColour& operator = ( const wxColour& col ); diff --git a/include/wx/colour.h b/include/wx/colour.h index 1adc13ee2e..b0296e860e 100644 --- a/include/wx/colour.h +++ b/include/wx/colour.h @@ -18,18 +18,21 @@ class WXDLLIMPEXP_FWD_CORE wxColour; -// 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 -// constructors +// A macro to define the standard wxColour constructors: +// +// It avoids the need to repeat these lines across all colour.h files, since +// Set() is a virtual function and thus cannot be called by wxColourBase ctors #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ - 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); } \ - wxColour(const char *colourName) { Set(colourName); } \ - wxColour(const wchar_t *colourName) { Set(colourName); } + wxColour() { Init(); } \ + 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); } // flags for wxColour -> wxString conversion (see wxColour::GetAsString) @@ -129,6 +132,10 @@ public: #endif 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 InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0; diff --git a/include/wx/generic/colour.h b/include/wx/generic/colour.h index c0d26dad03..24fefe2f6b 100644 --- a/include/wx/generic/colour.h +++ b/include/wx/generic/colour.h @@ -20,9 +20,6 @@ class WXDLLEXPORT wxColour: public wxColourBase public: // constructors // ------------ - - // default - wxColour(); DEFINE_STD_WXCOLOUR_CONSTRUCTORS // copy ctors and assignment operators diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index 07121726d6..410705fe65 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -19,9 +19,6 @@ class WXDLLIMPEXP_CORE wxColour : public wxColourBase public: // constructors // ------------ - - // default - wxColour() {} DEFINE_STD_WXCOLOUR_CONSTRUCTORS wxColour(const GdkColor& gdkColor); diff --git a/include/wx/gtk1/colour.h b/include/wx/gtk1/colour.h index 4d4950fbba..b1d06275d5 100644 --- a/include/wx/gtk1/colour.h +++ b/include/wx/gtk1/colour.h @@ -36,9 +36,6 @@ class WXDLLIMPEXP_CORE wxColour : public wxColourBase public: // constructors // ------------ - - // default - wxColour() { } DEFINE_STD_WXCOLOUR_CONSTRUCTORS virtual ~wxColour(); diff --git a/include/wx/mac/carbon/colour.h b/include/wx/mac/carbon/colour.h index 1036cd8507..22a3925e52 100644 --- a/include/wx/mac/carbon/colour.h +++ b/include/wx/mac/carbon/colour.h @@ -25,14 +25,9 @@ class WXDLLEXPORT wxColour: public wxColourBase public: // constructors // ------------ - - // default - wxColour() { } - wxColour( const wxColour& col ); DEFINE_STD_WXCOLOUR_CONSTRUCTORS - // dtor - virtual ~wxColour(); + // default copy ctor and dtor are ok // accessors virtual bool IsOk() const { return m_cgColour; } @@ -44,14 +39,14 @@ public: // comparison bool operator == (const wxColour& colour) const; - + bool operator != (const wxColour& colour) const { return !(*this == colour); } CGColorRef GetPixel() const { return m_cgColour; }; - + CGColorRef GetCGColor() const { return m_cgColour; }; CGColorRef CreateCGColor() const { return wxCFRetain( (CGColorRef)m_cgColour ); }; - + void GetRGBColor( RGBColor *col ) const; // Mac-specific ctor and assignment operator from the native colour @@ -63,8 +58,6 @@ public: wxColour& operator=(const wxColour& col); protected : - - virtual void InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a); void InitRGBColor( const RGBColor& col ); diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index a74c97321f..e7d12c14b2 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -22,9 +22,6 @@ class WXDLLEXPORT wxColour : public wxColourBase public: // constructors // ------------ - - // default - wxColour() { Init(); } DEFINE_STD_WXCOLOUR_CONSTRUCTORS // copy ctors and assignment operators diff --git a/include/wx/msw/colour.h b/include/wx/msw/colour.h index 1476009227..7f25bc88f4 100644 --- a/include/wx/msw/colour.h +++ b/include/wx/msw/colour.h @@ -23,16 +23,8 @@ class WXDLLEXPORT wxColour : public wxColourBase public: // constructors // ------------ - - // default - wxColour() { Init(); } DEFINE_STD_WXCOLOUR_CONSTRUCTORS - - // dtor - virtual ~wxColour(); - - // accessors // --------- @@ -53,11 +45,10 @@ public: && 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; } - public: WXCOLORREF m_pixel; @@ -79,5 +70,4 @@ private: DECLARE_DYNAMIC_CLASS(wxColour) }; -#endif - // _WX_COLOUR_H_ +#endif // _WX_COLOUR_H_ diff --git a/include/wx/os2/colour.h b/include/wx/os2/colour.h index 90e1fe0290..7b92b0db03 100644 --- a/include/wx/os2/colour.h +++ b/include/wx/os2/colour.h @@ -20,9 +20,6 @@ class WXDLLEXPORT wxColour: public wxColourBase public: // constructors // ------------ - - // default - wxColour(); DEFINE_STD_WXCOLOUR_CONSTRUCTORS // Copy ctors and assignment operators diff --git a/include/wx/x11/colour.h b/include/wx/x11/colour.h index 411665e88e..8fce06d6a0 100644 --- a/include/wx/x11/colour.h +++ b/include/wx/x11/colour.h @@ -38,8 +38,6 @@ class WXDLLEXPORT wxColour : public wxColourBase public: // constructors // ------------ - - wxColour() {} DEFINE_STD_WXCOLOUR_CONSTRUCTORS virtual ~wxColour(); diff --git a/src/mac/carbon/colour.cpp b/src/mac/carbon/colour.cpp index b2a7f5884e..4d91726650 100644 --- a/src/mac/carbon/colour.cpp +++ b/src/mac/carbon/colour.cpp @@ -26,15 +26,6 @@ wxColour::wxColour(const RGBColor& 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) { InitCGColorRef(col); @@ -47,10 +38,6 @@ void wxColour::GetRGBColor( RGBColor *col ) const col->green = (m_green << 8) + m_green; } -wxColour::~wxColour () -{ -} - wxColour& wxColour::operator=(const RGBColor& col) { InitRGBColor(col); diff --git a/src/msw/colour.cpp b/src/msw/colour.cpp index acd528ef63..9a9a13f98c 100644 --- a/src/msw/colour.cpp +++ b/src/msw/colour.cpp @@ -74,10 +74,6 @@ void wxColour::Init() m_green = 0; } -wxColour::~wxColour() -{ -} - void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) { -- 2.45.2