1999-01-01 16:05:26 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: colour.h
|
|
|
|
// Purpose: wxColour class
|
2003-02-28 21:54:04 +00:00
|
|
|
// Author: Stefan Csomor
|
1999-01-01 16:05:26 +00:00
|
|
|
// Modified by:
|
2003-02-28 21:54:04 +00:00
|
|
|
// Created: 1998-01-01
|
1999-01-01 16:05:26 +00:00
|
|
|
// RCS-ID: $Id$
|
2003-02-28 21:54:04 +00:00
|
|
|
// Copyright: (c) Stefan Csomor
|
1999-01-01 16:05:26 +00:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
|
|
#define _WX_COLOUR_H_
|
|
|
|
|
2002-08-31 11:29:13 +00:00
|
|
|
#if defined(__GNUG__) && !defined(__APPLE__)
|
1999-01-01 16:05:26 +00:00
|
|
|
#pragma interface "colour.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
|
|
|
// Colour
|
|
|
|
class WXDLLEXPORT wxColour: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctors
|
|
|
|
// default
|
|
|
|
wxColour();
|
|
|
|
// from RGB
|
|
|
|
wxColour( unsigned char red, unsigned char green, unsigned char blue );
|
2002-05-07 21:58:27 +00:00
|
|
|
wxColour( unsigned long colRGB )
|
|
|
|
: m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
|
|
|
|
{ Set(colRGB); }
|
2001-02-26 07:14:18 +00:00
|
|
|
|
1999-01-01 16:05:26 +00:00
|
|
|
// implicit conversion from the colour name
|
2002-05-07 21:58:27 +00:00
|
|
|
wxColour( const wxString &colourName )
|
|
|
|
: m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
|
|
|
|
{ InitFromName(colourName); }
|
2003-03-27 20:14:39 +00:00
|
|
|
wxColour( const wxChar *colourName )
|
2002-05-07 21:58:27 +00:00
|
|
|
: m_isInit(FALSE), m_red(0), m_blue(0), m_green(0)
|
|
|
|
{ InitFromName(colourName); }
|
1999-01-01 16:05:26 +00:00
|
|
|
|
|
|
|
// copy ctors and assignment operators
|
|
|
|
wxColour( const wxColour& col );
|
|
|
|
wxColour( const wxColour* col );
|
|
|
|
wxColour& operator = ( const wxColour& col );
|
|
|
|
|
|
|
|
// dtor
|
|
|
|
~wxColour();
|
|
|
|
|
|
|
|
// Set() functions
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
bool Ok() const {return m_isInit; }
|
|
|
|
|
|
|
|
// Let's remove this inelegant function
|
|
|
|
#if WXWIN_COMPATIBILITY
|
|
|
|
void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
unsigned char Red() const { return m_red; }
|
|
|
|
unsigned char Green() const { return m_green; }
|
|
|
|
unsigned char Blue() const { return m_blue; }
|
|
|
|
|
|
|
|
// comparison
|
1999-11-09 15:24:52 +00:00
|
|
|
bool operator == (const wxColour& colour) const
|
1999-01-01 16:05:26 +00:00
|
|
|
{
|
2002-02-14 09:02:54 +00:00
|
|
|
return (m_isInit == colour.m_isInit &&
|
|
|
|
m_red == colour.m_red &&
|
1999-01-01 16:05:26 +00:00
|
|
|
m_green == colour.m_green &&
|
|
|
|
m_blue == colour.m_blue);
|
|
|
|
}
|
2002-05-15 13:13:17 +00:00
|
|
|
bool operator != (const wxColour& colour) const { return !(*this == colour); }
|
1999-01-01 16:05:26 +00:00
|
|
|
|
|
|
|
void InitFromName(const wxString& col);
|
|
|
|
|
2001-12-19 21:26:25 +00:00
|
|
|
const WXCOLORREF& GetPixel() const { return m_pixel; };
|
1999-01-01 16:05:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_isInit;
|
|
|
|
unsigned char m_red;
|
|
|
|
unsigned char m_blue;
|
|
|
|
unsigned char m_green;
|
|
|
|
|
|
|
|
public:
|
1999-11-05 09:16:09 +00:00
|
|
|
WXCOLORREF m_pixel ;
|
2002-01-04 17:13:39 +00:00
|
|
|
void Set( const WXCOLORREF* color ) ;
|
1999-01-01 16:05:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// _WX_COLOUR_H_
|