From 5f83a4540d1044f56b00147303786decd12a2dc2 Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Thu, 4 Feb 1999 19:03:55 +0000 Subject: [PATCH] Added wxColour::wxColour(unsigned long) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1596 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/colour.h | 11 +++++++++++ include/wx/gtk1/colour.h | 11 +++++++++++ include/wx/motif/colour.h | 2 ++ include/wx/msw/colour.h | 9 ++++++--- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/include/wx/gtk/colour.h b/include/wx/gtk/colour.h index ff686d2e06..9a6503eb41 100644 --- a/include/wx/gtk/colour.h +++ b/include/wx/gtk/colour.h @@ -44,6 +44,8 @@ public: wxColour(); // from RGB wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + // implicit conversion from the colour name wxColour( const wxString &colourName ) { InitFromName(colourName); } wxColour( const char *colourName ) { InitFromName(colourName); } @@ -61,6 +63,15 @@ public: // accessors void Set( unsigned char red, unsigned char green, unsigned char blue ); + void Set( unsigned long colRGB ) + { + // 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 + Set((unsigned char)colRGB, + (unsigned char)(colRGB >> 8), + (unsigned char)(colRGB >> 16)); + } + unsigned char Red() const; unsigned char Green() const; unsigned char Blue() const; diff --git a/include/wx/gtk1/colour.h b/include/wx/gtk1/colour.h index ff686d2e06..9a6503eb41 100644 --- a/include/wx/gtk1/colour.h +++ b/include/wx/gtk1/colour.h @@ -44,6 +44,8 @@ public: wxColour(); // from RGB wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + // implicit conversion from the colour name wxColour( const wxString &colourName ) { InitFromName(colourName); } wxColour( const char *colourName ) { InitFromName(colourName); } @@ -61,6 +63,15 @@ public: // accessors void Set( unsigned char red, unsigned char green, unsigned char blue ); + void Set( unsigned long colRGB ) + { + // 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 + Set((unsigned char)colRGB, + (unsigned char)(colRGB >> 8), + (unsigned char)(colRGB >> 16)); + } + unsigned char Red() const; unsigned char Green() const; unsigned char Blue() const; diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index 7059f61441..893cd7afa2 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -29,6 +29,8 @@ public: wxColour(); // from RGB wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + // implicit conversion from the colour name wxColour( const wxString &colourName ) { InitFromName(colourName); } wxColour( const char *colourName ) { InitFromName(colourName); } diff --git a/include/wx/msw/colour.h b/include/wx/msw/colour.h index 08f4e8ef17..52f15ed96f 100644 --- a/include/wx/msw/colour.h +++ b/include/wx/msw/colour.h @@ -25,13 +25,16 @@ public: wxColour(); // from RGB wxColour( unsigned char red, unsigned char green, unsigned char blue ); + wxColour( unsigned long colRGB ) { Set(colRGB); } + // implicit conversion from the colour name wxColour( const wxString &colourName ) { InitFromName(colourName); } wxColour( const char *colourName ) { InitFromName(colourName); } + // copy ctors and assignment operators wxColour( const wxColour& col ); -// wxColour( const wxColour* col ); + wxColour( const wxColour* col ); wxColour& operator = ( const wxColour& col ); // dtor @@ -63,8 +66,8 @@ public: // comparison bool operator == (const wxColour& colour) { - return (m_red == colour.m_red && - m_green == colour.m_green && + return (m_red == colour.m_red && + m_green == colour.m_green && m_blue == colour.m_blue); } bool operator != (const wxColour& colour) { return !(*this == colour); } -- 2.47.2