2003-03-21 21:56:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-05 12:22:44 -04:00
|
|
|
// Name: wx/cocoa/colour.h
|
2003-03-21 21:56:04 -05:00
|
|
|
// 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
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
2003-03-21 21:56:04 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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:
|
2005-10-05 12:22:44 -04:00
|
|
|
// constructors
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
// default
|
2004-01-22 07:16:04 -05:00
|
|
|
wxColour() { Init(); }
|
|
|
|
|
2005-10-05 12:22:44 -04:00
|
|
|
// from separate 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); }
|
2005-10-05 12:22:44 -04:00
|
|
|
|
|
|
|
// from packed RGB
|
2003-06-19 17:24:10 -04:00
|
|
|
wxColour( unsigned long colRGB )
|
|
|
|
: m_cocoaNSColor(NULL)
|
|
|
|
{ Set(colRGB); }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2005-01-10 13:37:36 -05:00
|
|
|
// initialization using existing NSColor
|
|
|
|
wxColour( WX_NSColor aColor );
|
|
|
|
|
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 )
|
|
|
|
{ InitFromName(colourName); }
|
|
|
|
wxColour( const char *colourName )
|
|
|
|
{ InitFromName(wxString::FromAscii(colourName)); }
|
2004-10-07 13:45:04 -04:00
|
|
|
#if wxUSE_UNICODE
|
|
|
|
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
|
|
|
|
#endif
|
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
|
|
|
|
2004-01-22 07:16:04 -05:00
|
|
|
virtual ~wxColour();
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
// accessors
|
|
|
|
bool Ok() const { return m_cocoaNSColor; }
|
2004-01-22 07:16:04 -05:00
|
|
|
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
|
|
|
|
{
|
2005-01-10 13:37:36 -05:00
|
|
|
// TODO: Really compare the NSColor
|
2003-12-11 05:10:40 -05:00
|
|
|
return (m_cocoaNSColor == colour.m_cocoaNSColor
|
2005-01-10 13:37:36 -05:00
|
|
|
|| (m_red == colour.m_red
|
2003-12-11 05:10:40 -05:00
|
|
|
&& m_green == colour.m_green
|
2005-01-10 13:37:36 -05:00
|
|
|
&& 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
|
|
|
|
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));
|
|
|
|
}
|
2005-01-10 13:37:36 -05:00
|
|
|
void Set( WX_NSColor aColor );
|
2003-03-21 21:56:04 -05:00
|
|
|
|
2004-01-22 07:16:04 -05:00
|
|
|
protected:
|
|
|
|
// puts the object in an invalid, uninitialized state
|
|
|
|
void Init();
|
|
|
|
|
|
|
|
// create the object from name, leaves it uninitialized if it failed
|
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;
|
2004-01-22 07:16:04 -05:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
2003-03-21 21:56:04 -05:00
|
|
|
};
|
|
|
|
|
2003-06-19 17:24:10 -04:00
|
|
|
#endif // __WX_COCOA_COLOUR_H__
|