1998-09-18 06:19:10 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-05 12:22:44 -04:00
|
|
|
// Name: wx/motif/colour.h
|
1998-09-18 06:19:10 -04:00
|
|
|
// Purpose: wxColour class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2005-10-05 12:22:44 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-09-18 06:19:10 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
|
|
#define _WX_COLOUR_H_
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
|
|
|
// Colour
|
2006-04-24 10:52:23 -04:00
|
|
|
class WXDLLEXPORT wxColour : public wxColourBase
|
1998-09-18 06:19:10 -04:00
|
|
|
{
|
2002-02-05 11:34:33 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
1998-09-18 06:19:10 -04:00
|
|
|
public:
|
2005-10-05 12:22:44 -04:00
|
|
|
// constructors
|
|
|
|
// ------------
|
|
|
|
|
1998-10-20 10:35:22 -04:00
|
|
|
// default
|
2006-04-24 10:52:23 -04:00
|
|
|
wxColour() { Init(); }
|
|
|
|
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
|
2003-12-11 05:10:40 -05:00
|
|
|
|
1998-10-20 10:35:22 -04:00
|
|
|
// copy ctors and assignment operators
|
2002-02-05 11:34:33 -05:00
|
|
|
wxColour( const wxColour& col );
|
|
|
|
wxColour& operator = ( const wxColour& col );
|
2003-12-11 05:10:40 -05:00
|
|
|
|
1998-10-20 10:35:22 -04:00
|
|
|
// dtor
|
2006-09-05 16:47:48 -04:00
|
|
|
virtual ~wxColour();
|
2003-12-11 05:10:40 -05:00
|
|
|
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// accessors
|
2006-10-08 17:56:55 -04:00
|
|
|
bool Ok() const { return IsOk(); }
|
|
|
|
bool IsOk() const {return m_isInit; }
|
2002-02-05 11:34:33 -05:00
|
|
|
unsigned char Red() const { return m_red; }
|
|
|
|
unsigned char Green() const { return m_green; }
|
|
|
|
unsigned char Blue() const { return m_blue; }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2006-10-05 15:34:25 -04:00
|
|
|
WXPixel GetPixel() const { return m_pixel; };
|
|
|
|
void SetPixel(WXPixel pixel) { m_pixel = pixel; m_isInit = true; };
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
inline bool operator == (const wxColour& colour) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
inline bool operator != (const wxColour& colour) const { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
|
2003-10-23 17:49:44 -04:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// Allocate a colour, or nearest colour, using the given display.
|
2003-12-11 05:10:40 -05:00
|
|
|
// If realloc is true, ignore the existing pixel, otherwise just return
|
2002-02-05 11:34:33 -05:00
|
|
|
// the existing one.
|
|
|
|
// Returns the allocated pixel.
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
// TODO: can this handle mono displays? If not, we should have an extra
|
|
|
|
// flag to specify whether this should be black or white by default.
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2006-10-05 15:34:25 -04:00
|
|
|
WXPixel AllocColour(WXDisplay* display, bool realloc = false);
|
2003-12-11 05:10:40 -05:00
|
|
|
|
|
|
|
protected:
|
|
|
|
// Helper function
|
|
|
|
void Init();
|
|
|
|
|
2006-09-09 22:00:24 -04:00
|
|
|
virtual void
|
|
|
|
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
2006-04-24 10:52:23 -04:00
|
|
|
|
1998-10-20 10:35:22 -04:00
|
|
|
private:
|
2002-02-05 11:34:33 -05:00
|
|
|
bool m_isInit;
|
|
|
|
unsigned char m_red;
|
|
|
|
unsigned char m_blue;
|
|
|
|
unsigned char m_green;
|
2003-12-11 05:10:40 -05:00
|
|
|
|
1998-10-20 10:35:22 -04:00
|
|
|
public:
|
2006-10-05 15:34:25 -04:00
|
|
|
WXPixel m_pixel;
|
1998-09-18 06:19:10 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2002-02-05 11:34:33 -05:00
|
|
|
// _WX_COLOUR_H_
|