Merge branch 'explicit-colour-ctors'
Unix builds / Ubuntu 18.04 wxGTK 3 compatible 3.0 (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK ASAN not compatible (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK UTF-8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxQt (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxX11 (push) Has been cancelled
Unix builds / Ubuntu 20.04 wxGTK 3 with clang (push) Has been cancelled
Unix builds / Ubuntu 22.04 wxGTK with wx containers (push) Has been cancelled
Unix builds / Ubuntu 24.04 wxGTK UBSAN (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxDFB (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 3 static with gcc 4.8 (push) Has been cancelled
Unix builds / Ubuntu 18.04 wxGTK 2 (push) Has been cancelled
CMake builds / Ubuntu 22.04 wxGTK 3 (push) Has been cancelled
CMake builds / MSW/MSVC wxMSW (push) Has been cancelled
CMake builds / MSW/Clang wxMSW (push) Has been cancelled
CMake builds / macOS latest wxOSX Ninja (push) Has been cancelled
CMake builds / macOS 14 wxOSX Xcode (push) Has been cancelled
CMake builds / macOS 14 wxIOS (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 5.15 (push) Has been cancelled
CMake builds / MSW/MSVC wxQt 6.8 (push) Has been cancelled
Mac builds / wxMac ARM ASAN not compatible (push) Has been cancelled
Mac builds / wxMac Universal C++14 (push) Has been cancelled
Mac builds / wxiOS Simulator on Silicon Mac (push) Has been cancelled
Mac builds / wxiOS (push) Has been cancelled
Mac builds / wxMac Intel C++17 (push) Has been cancelled
Mac Xcode builds / iOS Simulator static (push) Has been cancelled
Mac Xcode builds / macOS dynamic Release (push) Has been cancelled
Mac Xcode builds / iOS static Debug (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Debug x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 DLL Release x64 (push) Has been cancelled
MSW builds / wxMSW vs2022 Debug Win32 (push) Has been cancelled
MSW builds / wxMSW vs2022 Release arm64 (push) Has been cancelled
MSW cross-builds / wxMSW 64 bits not compatible (push) Has been cancelled
MSW cross-builds / wxMSW/Univ (push) Has been cancelled
MSW cross-builds / wxMSW 32 bits (push) Has been cancelled
Code Checks / Check Spelling (push) Has been cancelled
Code Checks / Check Whitespace (push) Has been cancelled
Code Checks / Check Mixed EOL (push) Has been cancelled
Code Checks / Check C++ Style (push) Has been cancelled
Code Checks / Check All Headers In allheaders.h (push) Has been cancelled
Update Documentation / Update Online Documentation (push) Has been cancelled

Improve wxColour ctors.

See #25943.
This commit is contained in:
Vadim Zeitlin
2025-11-01 17:41:30 +01:00
18 changed files with 163 additions and 198 deletions
+5
View File
@@ -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-??-??)
----------------------------
+37 -27
View File
@@ -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<unsigned long>(colRGB)) {}
wxColour(unsigned int colRGB) : wxColour(static_cast<unsigned long>(colRGB)) {}
wxColour(int colRGB) : wxColour(static_cast<unsigned long>(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_
+12 -19
View File
@@ -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_
+8 -9
View File
@@ -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_
+11 -17
View File
@@ -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_
+8 -12
View File
@@ -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
+11 -11
View File
@@ -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_
+6 -11
View File
@@ -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_
-2
View File
@@ -406,5 +406,3 @@ bool wxFromString(const wxString& str, wxColourBase *col)
return col->Set(str);
}
+3 -12
View File
@@ -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;
+14 -14
View File
@@ -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())
+2 -12
View File
@@ -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;
+3 -3
View File
@@ -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
+17 -17
View File
@@ -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<wxColourRefData*>(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<const wxColourRefData*>(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);
+3 -3
View File
@@ -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
+8 -14
View File
@@ -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 <QtGui/QColor>
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;
+1 -1
View File
@@ -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));
+14 -14
View File
@@ -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 );