2003-03-22 02:56:04 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-05 16:22:44 +00:00
|
|
|
// Name: wx/cocoa/colour.h
|
2003-03-22 02:56:04 +00:00
|
|
|
// Purpose: wxColour class
|
2003-06-19 21:24:10 +00:00
|
|
|
// Author: David Elliott
|
2003-03-22 02:56:04 +00:00
|
|
|
// Modified by:
|
2003-06-19 21:24:10 +00:00
|
|
|
// Created: 2003/06/17
|
2003-03-22 02:56:04 +00:00
|
|
|
// RCS-ID: $Id$
|
2003-06-19 21:24:10 +00:00
|
|
|
// Copyright: (c) 2003 David Elliott
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
2003-03-22 02:56:04 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
#ifndef __WX_COCOA_COLOUR_H__
|
|
|
|
#define __WX_COCOA_COLOUR_H__
|
2003-03-22 02:56:04 +00:00
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
// ========================================================================
|
|
|
|
// wxColour
|
|
|
|
// ========================================================================
|
2006-04-24 14:52:23 +00:00
|
|
|
|
|
|
|
class WXDLLEXPORT wxColour : public wxColourBase
|
2003-03-22 02:56:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-10-05 16:22:44 +00:00
|
|
|
// constructors
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
// default
|
2004-01-22 12:16:04 +00:00
|
|
|
wxColour() { Init(); }
|
2006-10-09 23:44:00 +00:00
|
|
|
|
|
|
|
// the other standard ones: notice that we can't use
|
|
|
|
// DEFINE_STD_WXCOLOUR_CONSTRUCTORS here because we need to call Init() to
|
|
|
|
// initialize m_cocoaNSColor and the macro doesn't do it
|
|
|
|
wxColour( ChannelType red, ChannelType green, ChannelType blue,
|
|
|
|
ChannelType alpha = wxALPHA_OPAQUE )
|
|
|
|
{ Init(); Set(red, green, blue, alpha); }
|
|
|
|
wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
|
2007-05-30 10:29:12 +00:00
|
|
|
wxColour(const wxString& colourName) { Init(); Set(colourName); }
|
2007-07-05 22:20:40 +00:00
|
|
|
wxColour(const char *colourName) { Init(); Set(colourName); }
|
|
|
|
wxColour(const wchar_t *colourName) { Init(); Set(colourName); }
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2005-01-10 18:37:36 +00:00
|
|
|
// initialization using existing NSColor
|
|
|
|
wxColour( WX_NSColor aColor );
|
|
|
|
|
2003-03-22 02:56:04 +00:00
|
|
|
|
|
|
|
// copy ctors and assignment operators
|
2003-06-19 21:24:10 +00:00
|
|
|
wxColour( const wxColour& col );
|
|
|
|
wxColour& operator = ( const wxColour& col );
|
2003-03-22 02:56:04 +00:00
|
|
|
|
2004-01-22 12:16:04 +00:00
|
|
|
virtual ~wxColour();
|
2003-03-22 02:56:04 +00:00
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
// accessors
|
2007-12-15 17:54:20 +00:00
|
|
|
virtual bool IsOk() const { return m_cocoaNSColor; }
|
2004-01-22 12:16:04 +00:00
|
|
|
WX_NSColor GetNSColor() { return m_cocoaNSColor; }
|
2003-03-22 02:56:04 +00:00
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
unsigned char Red() const { return m_red; }
|
|
|
|
unsigned char Green() const { return m_green; }
|
|
|
|
unsigned char Blue() const { return m_blue; }
|
2006-08-28 09:53:33 +00:00
|
|
|
unsigned char Alpha() const { return m_alpha; }
|
2003-03-22 02:56:04 +00:00
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
// comparison
|
|
|
|
bool operator == (const wxColour& colour) const
|
|
|
|
{
|
2006-08-28 09:53:33 +00:00
|
|
|
return m_cocoaNSColor == colour.m_cocoaNSColor ||
|
|
|
|
(m_red == colour.m_red &&
|
|
|
|
m_green == colour.m_green &&
|
|
|
|
m_blue == colour.m_blue &&
|
|
|
|
m_alpha == colour.m_alpha);
|
2003-06-19 21:24:10 +00:00
|
|
|
}
|
|
|
|
bool operator != (const wxColour& colour) const
|
2006-08-28 09:53:33 +00:00
|
|
|
{ return !(*this == colour); }
|
2003-03-22 02:56:04 +00:00
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
// Set() functions
|
2005-01-10 18:37:36 +00:00
|
|
|
void Set( WX_NSColor aColor );
|
2006-08-28 09:53:33 +00:00
|
|
|
|
2006-07-05 13:10:46 +00:00
|
|
|
// reroute the inherited ones
|
2006-08-28 09:53:33 +00:00
|
|
|
void Set(unsigned char red,
|
|
|
|
unsigned char green,
|
|
|
|
unsigned char blue,
|
|
|
|
unsigned char alpha = wxALPHA_OPAQUE)
|
|
|
|
{ wxColourBase::Set(red, green, blue, alpha); }
|
|
|
|
|
2006-07-05 13:10:46 +00:00
|
|
|
bool Set(const wxString &str)
|
2006-08-28 09:53:33 +00:00
|
|
|
{ return wxColourBase::Set(str); }
|
|
|
|
|
2006-07-05 13:10:46 +00:00
|
|
|
void Set(unsigned long colRGB)
|
2006-08-28 09:53:33 +00:00
|
|
|
{ wxColourBase::Set(colRGB); }
|
|
|
|
|
2004-01-22 12:16:04 +00:00
|
|
|
protected:
|
|
|
|
// puts the object in an invalid, uninitialized state
|
|
|
|
void Init();
|
|
|
|
|
2006-09-10 02:00:24 +00:00
|
|
|
virtual void
|
|
|
|
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
2003-03-22 02:56:04 +00:00
|
|
|
|
|
|
|
private:
|
2003-06-19 21:24:10 +00:00
|
|
|
WX_NSColor m_cocoaNSColor;
|
|
|
|
unsigned char m_red;
|
|
|
|
unsigned char m_green;
|
|
|
|
unsigned char m_blue;
|
2006-08-28 09:53:33 +00:00
|
|
|
unsigned char m_alpha;
|
2004-01-22 12:16:04 +00:00
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
2003-03-22 02:56:04 +00:00
|
|
|
};
|
|
|
|
|
2003-06-19 21:24:10 +00:00
|
|
|
#endif // __WX_COCOA_COLOUR_H__
|