diff --git a/docs/changes.txt b/docs/changes.txt index 50aa52088b..d37c3d1538 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -233,6 +233,11 @@ Changes in behaviour which may result in build errors corresponding Scintilla doesn't have any return value, so it was changed to return void, please update your code to not use its return value. +- Code unintentionally and mistakenly using wxColour ctor from bool that + previously compiled doesn't compile any longer, please fix it to use either + the ctor from RGB value or from string explicitly. + + 3.3.2: (released 2025-??-??) ---------------------------- diff --git a/include/wx/colour.h b/include/wx/colour.h index ff02fbd433..0be6fe1e4e 100644 --- a/include/wx/colour.h +++ b/include/wx/colour.h @@ -17,29 +17,6 @@ class WXDLLIMPEXP_FWD_CORE wxColour; -// 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 -#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING -#define wxWXCOLOUR_CTOR_FROM_CHAR \ - wxColour(const char *colourName) { Init(); Set(colourName); } -#else // wxNO_IMPLICIT_WXSTRING_ENCODING -#define wxWXCOLOUR_CTOR_FROM_CHAR -#endif -#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \ - 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); } \ - wxWXCOLOUR_CTOR_FROM_CHAR \ - wxColour(const wchar_t *colourName) { Init(); Set(colourName); } - - // flags for wxColour -> wxString conversion (see wxColour::GetAsString) enum { wxC2S_NAME = 1, // return colour name, when possible @@ -192,10 +169,6 @@ public: wxDECLARE_VARIANT_OBJECT_EXPORTED(wxColour, WXDLLIMPEXP_CORE); 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; @@ -244,4 +217,41 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxColourBase* col); #define wxColor wxColour +// Actual wxColour class, inheriting from the port-specific implementation +// class and defining all the overloaded constructors. +class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour : public wxColourImpl +{ +public: + wxColour() = default; + wxColour(ChannelType red, + ChannelType green, + ChannelType blue, + ChannelType alpha = wxALPHA_OPAQUE) + { Set(red, green, blue, alpha); } + wxColour(unsigned long colRGB) { Set(colRGB); } + wxColour(long colRGB) : wxColour(static_cast(colRGB)) {} + wxColour(unsigned int colRGB) : wxColour(static_cast(colRGB)) {} + wxColour(int colRGB) : wxColour(static_cast(colRGB)) {} + wxColour(const wxString& colourName) { Set(colourName); } + wxColour(const wchar_t *colourName) : wxColour(wxString(colourName)) {} +#ifndef wxNO_IMPLICIT_WXSTRING_ENCODING + wxColour(const char *colourName) : wxColour(wxString(colourName)) {} +#endif + wxColour(bool) = delete; + + // Also inherit port-specific constructors from the base class, if any. + using wxColourImpl::wxColourImpl; + + // And define copy constructor and assignment operator in this class too. + wxColour(const wxColour& col) : wxColourImpl(col) {} + wxColour& operator=(const wxColour& col) + { + wxColourImpl::operator=(col); + return *this; + } + +private: + wxDECLARE_DYNAMIC_CLASS(wxColour); +}; + #endif // _WX_COLOUR_H_BASE_ diff --git a/include/wx/generic/colour.h b/include/wx/generic/colour.h index bd7a10fdb0..d37ba4312d 100644 --- a/include/wx/generic/colour.h +++ b/include/wx/generic/colour.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/generic/colour.h -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Julian Smart // Created: 01/02/97 // Copyright: (c) Julian Smart @@ -13,20 +13,20 @@ #include "wx/object.h" // Colour -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour: public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl: public wxColourBase { public: // constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS + wxColourImpl() = default; // copy ctors and assignment operators - wxColour(const wxColour& col) + wxColourImpl(const wxColourImpl& col) { *this = col; } - wxColour& operator=(const wxColour& col); + wxColourImpl& operator=(const wxColourImpl& col); // accessors virtual bool IsOk() const { return m_isInit; } @@ -37,7 +37,7 @@ public: unsigned char Alpha() const { return m_alpha; } // comparison - bool operator==(const wxColour& colour) const + bool operator==(const wxColourImpl& colour) const { return (m_red == colour.m_red && m_green == colour.m_green && @@ -46,25 +46,18 @@ public: m_isInit == colour.m_isInit); } - bool operator!=(const wxColour& colour) const { return !(*this == colour); } + bool operator!=(const wxColourImpl& colour) const { return !(*this == colour); } protected: - - // Helper function - void Init(); - virtual void InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); private: - bool m_isInit; - unsigned char m_red; - unsigned char m_blue; - unsigned char m_green; - unsigned char m_alpha; - -private: - wxDECLARE_DYNAMIC_CLASS(wxColour); + bool m_isInit = false; + unsigned char m_red = 0; + unsigned char m_blue = 0; + unsigned char m_green = 0; + unsigned char m_alpha = wxALPHA_OPAQUE; }; #endif // _WX_GENERIC_COLOUR_H_ diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index b19b8bafc1..ea7b9b3dd8 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -17,19 +17,20 @@ typedef struct _GdkRGBA GdkRGBA; // wxColour //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour : public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl : public wxColourBase { public: - // constructors + wxColourImpl() = default; + + // port-specific constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS - wxColour(const GdkColor& gdkColor); + wxColourImpl(const GdkColor& gdkColor); #ifdef __WXGTK3__ - wxColour(const GdkRGBA& gdkRGBA); + wxColourImpl(const GdkRGBA& gdkRGBA); #endif - bool operator==(const wxColour& col) const; - bool operator!=(const wxColour& col) const { return !(*this == col); } + bool operator==(const wxColourImpl& col) const; + bool operator!=(const wxColourImpl& col) const { return !(*this == col); } unsigned char Red() const override; unsigned char Green() const override; @@ -48,8 +49,6 @@ public: protected: virtual void InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; - - wxDECLARE_DYNAMIC_CLASS(wxColour); }; #endif // _WX_GTK_COLOUR_H_ diff --git a/include/wx/msw/colour.h b/include/wx/msw/colour.h index 0ed4c60461..fa082b9cfe 100644 --- a/include/wx/msw/colour.h +++ b/include/wx/msw/colour.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/msw/colour.h -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Julian Smart // Created: 01/02/97 // Copyright: (c) Julian Smart @@ -16,12 +16,12 @@ // Colour // ---------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour : public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl : public wxColourBase { public: // constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS + wxColourImpl() = default; // accessors // --------- @@ -34,7 +34,7 @@ public: unsigned char Alpha() const override { return m_alpha ; } // comparison - bool operator==(const wxColour& colour) const + bool operator==(const wxColourImpl& colour) const { return m_isInit == colour.m_isInit && m_red == colour.m_red @@ -43,29 +43,23 @@ public: && m_alpha == colour.m_alpha; } - bool operator!=(const wxColour& colour) const { return !(*this == colour); } + bool operator!=(const wxColourImpl& colour) const { return !(*this == colour); } WXCOLORREF GetPixel() const { return m_pixel; } public: - WXCOLORREF m_pixel; + WXCOLORREF m_pixel = 0; protected: - // Helper function - void Init(); - virtual void InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) override; private: - bool m_isInit; - unsigned char m_red; - unsigned char m_blue; - unsigned char m_green; - unsigned char m_alpha; - -private: - wxDECLARE_DYNAMIC_CLASS(wxColour); + bool m_isInit = false; + unsigned char m_red = 0; + unsigned char m_blue = 0; + unsigned char m_green = 0; + unsigned char m_alpha = wxALPHA_TRANSPARENT; }; #endif // _WX_COLOUR_H_ diff --git a/include/wx/osx/core/colour.h b/include/wx/osx/core/colour.h index 221ea5a498..c338dcd21f 100644 --- a/include/wx/osx/core/colour.h +++ b/include/wx/osx/core/colour.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/osx/core/colour.h -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Stefan Csomor // Created: 1998-01-01 // Copyright: (c) Stefan Csomor @@ -18,12 +18,12 @@ struct RGBColor; // Colour -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour: public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl: public wxColourBase { public: // constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS + wxColourImpl() = default; // default copy ctor and dtor are ok @@ -36,14 +36,14 @@ public: virtual bool IsSolid() const override; // comparison - bool operator == (const wxColour& colour) const; - bool operator != (const wxColour& colour) const { return !(*this == colour); } + bool operator == (const wxColourImpl& colour) const; + bool operator != (const wxColourImpl& colour) const { return !(*this == colour); } // CoreGraphics CGColor // -------------------- // This ctor does take ownership of the color. - wxColour( CGColorRef col ); + wxColourImpl( CGColorRef col ); // don't take ownership of the returned value CGColorRef GetCGColor() const; @@ -54,12 +54,12 @@ public: #if wxOSX_USE_COCOA_OR_CARBON // Quickdraw RGBColor // ------------------ - wxColour(const RGBColor& col); + wxColourImpl(const RGBColor& col); void GetRGBColor( RGBColor *col ) const; #endif // This ctor does not take ownership of the color. - explicit wxColour(WXColor color); + explicit wxColourImpl(WXColor color); WXColor OSXGetWXColor() const; WXImage OSXGetWXPatternImage() const; @@ -87,10 +87,6 @@ public: virtual wxGDIRefData *CreateGDIRefData() const override; wxNODISCARD virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const override; - -private: - - wxDECLARE_DYNAMIC_CLASS(wxColour); }; class wxColourRefData : public wxGDIRefData diff --git a/include/wx/qt/colour.h b/include/wx/qt/colour.h index b59d94514e..1590804f22 100644 --- a/include/wx/qt/colour.h +++ b/include/wx/qt/colour.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/qt/colour.h -// Purpose: wxColour class implementation for wxQt +// Purpose: wxColourImpl class for wxQt // Author: Kolya Kosenko // Created: 2010-05-12 // Copyright: (c) 2010 Kolya Kosenko @@ -12,11 +12,11 @@ class QColor; -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour : public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl : public wxColourBase { public: - DEFINE_STD_WXCOLOUR_CONSTRUCTORS - wxColour(const QColor& color); + wxColourImpl() = default; + wxColourImpl(const QColor& color); virtual bool IsOk() const override { return m_valid; } @@ -25,22 +25,22 @@ public: ChannelType Blue() const override { return m_blue; } ChannelType Alpha() const override { return m_alpha; } - bool operator==(const wxColour& color) const; - bool operator!=(const wxColour& color) const; + bool operator==(const wxColourImpl& color) const; + bool operator!=(const wxColourImpl& color) const; int GetPixel() const; QColor GetQColor() const; protected: - void Init(); virtual void InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) override; private: - ChannelType m_red, m_green, m_blue, m_alpha; - bool m_valid; - - wxDECLARE_DYNAMIC_CLASS(wxColour); + ChannelType m_red = 0, + m_green = 0, + m_blue = 0, + m_alpha = wxALPHA_TRANSPARENT; + bool m_valid = false; }; #endif // _WX_QT_COLOUR_H_ diff --git a/include/wx/x11/colour.h b/include/wx/x11/colour.h index 467fe07769..d787b20ce5 100644 --- a/include/wx/x11/colour.h +++ b/include/wx/x11/colour.h @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: wx/x11/colour.h -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Julian Smart, Robert Roebling // Created: 17/09/98 // Copyright: (c) Julian Smart, Robert Roebling @@ -25,21 +25,19 @@ class WXDLLIMPEXP_FWD_CORE wxPaintDC; class WXDLLIMPEXP_FWD_CORE wxBitmap; class WXDLLIMPEXP_FWD_CORE wxWindow; -class WXDLLIMPEXP_FWD_CORE wxColour; - //----------------------------------------------------------------------------- -// wxColour +// wxColourImpl //----------------------------------------------------------------------------- -class WXDLLIMPEXP_CORE wxWARN_UNUSED wxColour : public wxColourBase +class WXDLLIMPEXP_CORE wxColourImpl : public wxColourBase { public: // constructors // ------------ - DEFINE_STD_WXCOLOUR_CONSTRUCTORS + wxColourImpl() = default; - bool operator==(const wxColour& col) const; - bool operator!=(const wxColour& col) const { return !(*this == col); } + bool operator==(const wxColourImpl& col) const; + bool operator!=(const wxColourImpl& col) const { return !(*this == col); } unsigned char Red() const; unsigned char Green() const; @@ -59,9 +57,6 @@ protected: InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a); virtual bool FromString(const wxString& str); - -private: - wxDECLARE_DYNAMIC_CLASS(wxColour); }; #endif // _WX_COLOUR_H_ diff --git a/src/common/colourcmn.cpp b/src/common/colourcmn.cpp index 91b7fea20d..a3625ab142 100644 --- a/src/common/colourcmn.cpp +++ b/src/common/colourcmn.cpp @@ -406,5 +406,3 @@ bool wxFromString(const wxString& str, wxColourBase *col) return col->Set(str); } - - diff --git a/src/generic/colour.cpp b/src/generic/colour.cpp index 103579901a..a8f8a2c02f 100644 --- a/src/generic/colour.cpp +++ b/src/generic/colour.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/generic/colour.cpp -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Julian Smart // Created: 01/02/97 // Copyright: (c) Julian Smart @@ -19,16 +19,7 @@ // Colour -void wxColour::Init() -{ - m_red = - m_blue = - m_green = 0; - m_alpha = wxALPHA_OPAQUE; - m_isInit = false; -} - -void wxColour::InitRGBA(unsigned char r, +void wxColourImpl::InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) @@ -40,7 +31,7 @@ void wxColour::InitRGBA(unsigned char r, m_isInit = true; } -wxColour& wxColour::operator=(const wxColour& col) +wxColourImpl& wxColourImpl::operator=(const wxColourImpl& col) { m_red = col.m_red; m_green = col.m_green; diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index 1dd1c5da61..70ae22524e 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -16,7 +16,7 @@ #include "wx/math.h" //----------------------------------------------------------------------------- -// wxColour +// wxColourImpl //----------------------------------------------------------------------------- class wxColourRefData : public wxGDIRefData @@ -123,23 +123,23 @@ void wxColourRefData::AllocColour( GdkColormap *cmap ) #define SHIFT 8 #ifdef __WXGTK3__ -wxColour::wxColour(const GdkRGBA& gdkRGBA) +wxColourImpl::wxColourImpl(const GdkRGBA& gdkRGBA) { m_refData = new wxColourRefData(gdkRGBA); } -wxColour::wxColour(const GdkColor& gdkColor) +wxColourImpl::wxColourImpl(const GdkColor& gdkColor) { m_refData = new wxColourRefData(gdkColor); } #else -wxColour::wxColour(const GdkColor& gdkColor) +wxColourImpl::wxColourImpl(const GdkColor& gdkColor) { m_refData = new wxColourRefData(gdkColor.red, gdkColor.green, gdkColor.blue); } #endif -bool wxColour::operator == ( const wxColour& col ) const +bool wxColourImpl::operator == ( const wxColourImpl& col ) const { if (m_refData == col.m_refData) return true; @@ -161,7 +161,7 @@ bool wxColour::operator == ( const wxColour& col ) const refData->m_alpha == that_refData->m_alpha; } -void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, +void wxColourImpl::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha) { UnRef(); @@ -177,7 +177,7 @@ void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char bl #endif } -unsigned char wxColour::Red() const +unsigned char wxColourImpl::Red() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -188,7 +188,7 @@ unsigned char wxColour::Red() const #endif } -unsigned char wxColour::Green() const +unsigned char wxColourImpl::Green() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -199,7 +199,7 @@ unsigned char wxColour::Green() const #endif } -unsigned char wxColour::Blue() const +unsigned char wxColourImpl::Blue() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -210,7 +210,7 @@ unsigned char wxColour::Blue() const #endif } -unsigned char wxColour::Alpha() const +unsigned char wxColourImpl::Alpha() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -218,14 +218,14 @@ unsigned char wxColour::Alpha() const } #ifndef __WXGTK3__ -void wxColour::CalcPixel( GdkColormap *cmap ) +void wxColourImpl::CalcPixel( GdkColormap *cmap ) { if (!IsOk()) return; M_COLDATA->AllocColour( cmap ); } -int wxColour::GetPixel() const +int wxColourImpl::GetPixel() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -233,7 +233,7 @@ int wxColour::GetPixel() const } #endif -const GdkColor *wxColour::GetColor() const +const GdkColor *wxColourImpl::GetColor() const { wxCHECK_MSG( IsOk(), nullptr, wxT("invalid colour") ); @@ -245,7 +245,7 @@ const GdkColor *wxColour::GetColor() const } #ifdef __WXGTK3__ -wxColour::operator const GdkRGBA*() const +wxColourImpl::operator const GdkRGBA*() const { const GdkRGBA* c = nullptr; if (IsOk()) diff --git a/src/msw/colour.cpp b/src/msw/colour.cpp index 0799d957b5..3c2af969bd 100644 --- a/src/msw/colour.cpp +++ b/src/msw/colour.cpp @@ -23,18 +23,8 @@ // Colour -void wxColour::Init() -{ - m_isInit = false; - m_pixel = 0; - m_alpha = - m_red = - m_blue = - m_green = 0; -} - -void wxColour::InitRGBA(unsigned char r, unsigned char g, unsigned char b, - unsigned char a) +void wxColourImpl::InitRGBA(unsigned char r, unsigned char g, unsigned char b, + unsigned char a) { m_red = r; m_green = g; diff --git a/src/osx/cocoa/colour.mm b/src/osx/cocoa/colour.mm index 3cf7fe746c..31515d146f 100644 --- a/src/osx/cocoa/colour.mm +++ b/src/osx/cocoa/colour.mm @@ -182,17 +182,17 @@ WX_NSImage wxNSColorRefData::GetWXPatternImage() const return nullptr; } -wxGDIRefData* wxColour::CreateGDIRefData() const +wxGDIRefData* wxColourImpl::CreateGDIRefData() const { return new wxNSColorRefData(0.0, 0.0, 0.0); } -wxColour::wxColour(WX_NSColor col) +wxColourImpl::wxColourImpl(WX_NSColor col) { m_refData = new wxNSColorRefData(col); } -wxColour::wxColour(CGColorRef col) +wxColourImpl::wxColourImpl(CGColorRef col) { m_refData = new wxNSColorRefData([[NSColor colorWithCGColor:col] retain]); // as per contract CGColorRef is not retained diff --git a/src/osx/core/colour.cpp b/src/osx/core/colour.cpp index de93e5f568..84cb305fd9 100644 --- a/src/osx/core/colour.cpp +++ b/src/osx/core/colour.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/osx/core/colour.cpp -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Stefan Csomor // Created: 1998-01-01 // Copyright: (c) Stefan Csomor @@ -156,7 +156,7 @@ WXImage wxCGColorRefData::GetWXPatternImage() const #define M_COLDATA static_cast(m_refData) #if wxOSX_USE_COCOA_OR_CARBON -wxColour::wxColour(const RGBColor& col) +wxColourImpl::wxColourImpl(const RGBColor& col) { InitRGBA((float)(col.red / 65535.0), (float)(col.green / 65535.0), (float)(col.blue / 65535.0), (float)1.0 ); @@ -164,7 +164,7 @@ wxColour::wxColour(const RGBColor& col) #endif #if !wxOSX_USE_COCOA_OR_IPHONE -wxColour::wxColour(CGColorRef col) +wxColourImpl::wxColourImpl(CGColorRef col) { wxASSERT_MSG(col != nullptr, "Invalid CoreGraphics Color"); @@ -172,35 +172,35 @@ wxColour::wxColour(CGColorRef col) } #endif -wxColour::ChannelType wxColour::Red() const +wxColourImpl::ChannelType wxColourImpl::Red() const { wxCHECK_MSG( IsOk(), 0, "invalid colour" ); return wxRound(M_COLDATA->Red() * 255.0); } -wxColour::ChannelType wxColour::Green() const +wxColourImpl::ChannelType wxColourImpl::Green() const { wxCHECK_MSG( IsOk(), 0, "invalid colour" ); return wxRound(M_COLDATA->Green() * 255.0); } -wxColour::ChannelType wxColour::Blue() const +wxColourImpl::ChannelType wxColourImpl::Blue() const { wxCHECK_MSG( IsOk(), 0, "invalid colour" ); return wxRound(M_COLDATA->Blue() * 255.0); } -wxColour::ChannelType wxColour::Alpha() const +wxColourImpl::ChannelType wxColourImpl::Alpha() const { wxCHECK_MSG( IsOk(), 0, "invalid colour" ); return wxRound(M_COLDATA->Alpha() * 255.0); } -bool wxColour::IsSolid() const +bool wxColourImpl::IsSolid() const { wxCHECK_MSG( IsOk(), false, "invalid colour" ); @@ -208,7 +208,7 @@ bool wxColour::IsSolid() const } #if wxOSX_USE_COCOA_OR_CARBON -void wxColour::GetRGBColor(RGBColor* col) const +void wxColourImpl::GetRGBColor(RGBColor* col) const { wxCHECK_RET( IsOk(), "invalid colour" ); @@ -218,28 +218,28 @@ void wxColour::GetRGBColor(RGBColor* col) const } #endif -CGColorRef wxColour::GetCGColor() const +CGColorRef wxColourImpl::GetCGColor() const { wxCHECK_MSG( IsOk(), nullptr, "invalid colour" ); return M_COLDATA->GetCGColor(); } -WXColor wxColour::OSXGetWXColor() const +WXColor wxColourImpl::OSXGetWXColor() const { wxCHECK_MSG( IsOk(), nullptr, "invalid colour" ); return M_COLDATA->GetWXColor(); } -WXImage wxColour::OSXGetWXPatternImage() const +WXImage wxColourImpl::OSXGetWXPatternImage() const { wxCHECK_MSG( IsOk(), nullptr, "invalid colour" ); return M_COLDATA->GetWXPatternImage(); } -bool wxColour::operator==(const wxColour& other) const +bool wxColourImpl::operator==(const wxColourImpl& other) const { if (m_refData == other.m_refData) return true; @@ -250,17 +250,17 @@ bool wxColour::operator==(const wxColour& other) const return CGColorEqualToColor(GetCGColor(), other.GetCGColor()); } -wxGDIRefData* wxColour::CloneGDIRefData(const wxGDIRefData* data) const +wxGDIRefData* wxColourImpl::CloneGDIRefData(const wxGDIRefData* data) const { return static_cast(data)->Clone(); } -void wxColour::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) +void wxColourImpl::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) { - InitRGBA((float)(r / 255.0), (float)(g / 255.0), (float)(b / 255.0), (float)(a / 255.0)); + InitRGBA(r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f); } -void wxColour::InitRGBA(float r, float g, float b, float a) +void wxColourImpl::InitRGBA(float r, float g, float b, float a) { UnRef(); m_refData = new wxCGColorRefData(r,g,b,a); diff --git a/src/osx/iphone/colour.mm b/src/osx/iphone/colour.mm index f866155188..b410a4b114 100644 --- a/src/osx/iphone/colour.mm +++ b/src/osx/iphone/colour.mm @@ -177,17 +177,17 @@ WXImage wxUIColorRefData::GetWXPatternImage() const return nullptr; } -wxGDIRefData* wxColour::CreateGDIRefData() const +wxGDIRefData* wxColourImpl::CreateGDIRefData() const { return new wxUIColorRefData(0.0, 0.0, 0.0, 1.0); } -wxColour::wxColour(WXColor col) +wxColourImpl::wxColourImpl(WXColor col) { m_refData = new wxUIColorRefData(col); } -wxColour::wxColour(CGColorRef col) +wxColourImpl::wxColourImpl(CGColorRef col) { m_refData = new wxUIColorRefData([[UIColor colorWithCGColor:col] retain]); // as per contract CGColorRef is not retained diff --git a/src/qt/colour.cpp b/src/qt/colour.cpp index cc4dc19968..612ba3eaec 100644 --- a/src/qt/colour.cpp +++ b/src/qt/colour.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/qt/colour.cpp -// Purpose: wxColour class implementation for wxQt +// Purpose: wxColourImpl class for wxQt // Author: Kolya Kosenko // Created: 2010-05-12 // Copyright: (c) 2010 Kolya Kosenko @@ -20,41 +20,35 @@ #include -wxColour::wxColour(const QColor& color) +wxColourImpl::wxColourImpl(const QColor& color) { InitRGBA(color.red(), color.green(), color.blue(), color.alpha()); } -bool wxColour::operator==(const wxColour& color) const +bool wxColourImpl::operator==(const wxColourImpl& color) const { return m_red == color.m_red && m_green == color.m_green && m_blue == color.m_blue && m_alpha == color.m_alpha; } -bool wxColour::operator!=(const wxColour& color) const +bool wxColourImpl::operator!=(const wxColourImpl& color) const { return !(*this == color); } -int wxColour::GetPixel() const +int wxColourImpl::GetPixel() const { - wxMISSING_IMPLEMENTATION( "wxColour::GetPixel" ); + wxMISSING_IMPLEMENTATION( "wxColourImpl::GetPixel" ); return 0; } -QColor wxColour::GetQColor() const +QColor wxColourImpl::GetQColor() const { if ( m_valid ) return QColor(m_red, m_green, m_blue, m_alpha); return QColor(); } -void wxColour::Init() -{ - m_red = m_green = m_blue = m_alpha = 0; - m_valid = false; -} - -void wxColour::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) +void wxColourImpl::InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) { m_red = r; m_green = g; m_blue = b; m_alpha = a; m_valid = true; diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index 512ed50eb7..4a2e663773 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -2214,7 +2214,7 @@ void wxWin32Renderer::DrawSliderThumb(wxDC& dc, "w ", " w", }; - dc.SetBrush(wxBrush(stipple_xpm)); + dc.SetBrush(wxBitmap(stipple_xpm)); dc.SetTextForeground(wxSCHEME_COLOUR(m_scheme, SHADOW_HIGHLIGHT)); dc.SetTextBackground(wxSCHEME_COLOUR(m_scheme, CONTROL)); diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp index 44e908ae80..600921e66a 100644 --- a/src/x11/colour.cpp +++ b/src/x11/colour.cpp @@ -1,6 +1,6 @@ ///////////////////////////////////////////////////////////////////////////// // Name: src/x11/colour.cpp -// Purpose: wxColour class +// Purpose: wxColourImpl class // Author: Julian Smart, Robert Roebling // Created: 17/09/98 // Copyright: (c) Julian Smart, Robert Roebling @@ -20,7 +20,7 @@ #include "wx/x11/private.h" //----------------------------------------------------------------------------- -// wxColour +// wxColourImpl //----------------------------------------------------------------------------- class wxColourRefData : public wxGDIRefData @@ -66,7 +66,7 @@ public: WXColormap m_colormap; bool m_hasPixel; - friend class wxColour; + friend class wxColourImpl; // reference counter for systems with <= 8-Bit display static unsigned short colMapAllocCounter[ 256 ]; @@ -140,7 +140,7 @@ void wxColourRefData::AllocColour( WXColormap cmap ) #define SHIFT (8*(sizeof(short int)-sizeof(char))) -bool wxColour::operator == ( const wxColour& col ) const +bool wxColourImpl::operator == ( const wxColourImpl& col ) const { if (m_refData == col.m_refData) return true; @@ -155,17 +155,17 @@ bool wxColour::operator == ( const wxColour& col ) const } -wxGDIRefData *wxColour::CreateGDIRefData() const +wxGDIRefData *wxColourImpl::CreateGDIRefData() const { return new wxColourRefData; } -wxGDIRefData *wxColour::CloneGDIRefData(const wxGDIRefData *data) const +wxGDIRefData *wxColourImpl::CloneGDIRefData(const wxGDIRefData *data) const { return new wxColourRefData(*(wxColourRefData *)data); } -void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, +void wxColourImpl::InitRGBA(unsigned char red, unsigned char green, unsigned char blue, unsigned char WXUNUSED(alpha)) { UnRef(); @@ -183,7 +183,7 @@ void wxColour::InitRGBA(unsigned char red, unsigned char green, unsigned char bl M_COLDATA->m_color.pixel = 0; } -unsigned char wxColour::Red() const +unsigned char wxColourImpl::Red() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -194,7 +194,7 @@ unsigned char wxColour::Red() const #endif } -unsigned char wxColour::Green() const +unsigned char wxColourImpl::Green() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -205,7 +205,7 @@ unsigned char wxColour::Green() const #endif } -unsigned char wxColour::Blue() const +unsigned char wxColourImpl::Blue() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); @@ -216,7 +216,7 @@ unsigned char wxColour::Blue() const #endif } -void wxColour::CalcPixel( WXColormap cmap ) +void wxColourImpl::CalcPixel( WXColormap cmap ) { wxCHECK_RET( IsOk(), wxT("invalid colour") ); @@ -225,21 +225,21 @@ void wxColour::CalcPixel( WXColormap cmap ) M_COLDATA->AllocColour( cmap ); } -unsigned long wxColour::GetPixel() const +unsigned long wxColourImpl::GetPixel() const { wxCHECK_MSG( IsOk(), 0, wxT("invalid colour") ); return M_COLDATA->m_color.pixel; } -WXColor *wxColour::GetColor() const +WXColor *wxColourImpl::GetColor() const { wxCHECK_MSG( IsOk(), nullptr, wxT("invalid colour") ); return (WXColor*) &M_COLDATA->m_color; } -bool wxColour::FromString(const wxString& name) +bool wxColourImpl::FromString(const wxString& name) { Display *dpy = wxGlobalDisplay(); WXColormap colormap = wxTheApp->GetMainColormap( dpy );