2003-03-21 21:56:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: colour.h
|
|
|
|
// Purpose: wxColour class
|
2003-06-19 17:24:10 -04:00
|
|
|
// Author: David Elliott
|
2003-03-21 21:56:04 -05:00
|
|
|
// Modified by:
|
2003-06-19 17:24:10 -04:00
|
|
|
// Created: 2003/06/17
|
2003-03-21 21:56:04 -05:00
|
|
|
// RCS-ID: $Id$
|
2003-06-19 17:24:10 -04:00
|
|
|
// Copyright: (c) 2003 David Elliott
|
2003-03-21 21:56:04 -05:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
#ifndef __WX_COCOA_COLOUR_H__
|
|
|
|
#define __WX_COCOA_COLOUR_H__
|
2003-03-21 21:56:04 -05:00
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
// ========================================================================
|
|
|
|
// wxColour
|
|
|
|
// ========================================================================
|
2003-03-21 21:56:04 -05:00
|
|
|
class WXDLLEXPORT wxColour: public wxObject
|
|
|
|
{
|
|
|
|
public:
|
2003-06-19 17:24:10 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// initialization
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
wxColour();
|
2003-03-21 21:56:04 -05:00
|
|
|
// from RGB
|
2003-06-19 17:24:10 -04:00
|
|
|
wxColour( unsigned char red, unsigned char green, unsigned char blue )
|
|
|
|
: m_cocoaNSColor(NULL)
|
|
|
|
{ Set(red,green,blue); }
|
|
|
|
wxColour( unsigned long colRGB )
|
|
|
|
: m_cocoaNSColor(NULL)
|
|
|
|
{ Set(colRGB); }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2003-03-21 21:56:04 -05:00
|
|
|
// implicit conversion from the colour name
|
2003-06-19 17:24:10 -04:00
|
|
|
wxColour( const wxString &colourName )
|
|
|
|
: m_cocoaNSColor(NULL)
|
|
|
|
{ InitFromName(colourName); }
|
|
|
|
wxColour( const char *colourName )
|
|
|
|
: m_cocoaNSColor(NULL)
|
|
|
|
{ InitFromName(wxString::FromAscii(colourName)); }
|
2003-03-21 21:56:04 -05:00
|
|
|
|
|
|
|
// copy ctors and assignment operators
|
2003-06-19 17:24:10 -04:00
|
|
|
wxColour( const wxColour& col );
|
|
|
|
wxColour& operator = ( const wxColour& col );
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
~wxColour();
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// Implementation
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// accessors
|
|
|
|
bool Ok() const { return m_cocoaNSColor; }
|
2003-07-03 13:59:52 -04:00
|
|
|
inline WX_NSColor GetNSColor() { return m_cocoaNSColor; }
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
unsigned char Red() const { return m_red; }
|
|
|
|
unsigned char Green() const { return m_green; }
|
|
|
|
unsigned char Blue() const { return m_blue; }
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
// comparison
|
|
|
|
bool operator == (const wxColour& colour) const
|
|
|
|
{
|
2003-12-11 05:10:40 -05:00
|
|
|
return (m_cocoaNSColor == colour.m_cocoaNSColor
|
|
|
|
&& m_red == colour.m_red
|
|
|
|
&& m_green == colour.m_green
|
|
|
|
&& m_blue == colour.m_blue);
|
2003-06-19 17:24:10 -04:00
|
|
|
}
|
|
|
|
bool operator != (const wxColour& colour) const
|
|
|
|
{ return !(*this == colour); }
|
2003-03-21 21:56:04 -05:00
|
|
|
|
|
|
|
// const WXCOLORREF& GetPixel() const { return m_pixel; };
|
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
// 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));
|
|
|
|
}
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
void InitFromName(const wxString& col);
|
2003-03-21 21:56:04 -05:00
|
|
|
|
|
|
|
private:
|
2003-06-19 17:24:10 -04:00
|
|
|
WX_NSColor m_cocoaNSColor;
|
|
|
|
unsigned char m_red;
|
|
|
|
unsigned char m_green;
|
|
|
|
unsigned char m_blue;
|
2003-03-21 21:56:04 -05:00
|
|
|
};
|
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
#endif // __WX_COCOA_COLOUR_H__
|