1998-09-18 10:19:10 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-05 16:22:44 +00:00
|
|
|
// Name: wx/motif/colour.h
|
1998-09-18 10:19:10 +00:00
|
|
|
// Purpose: wxColour class
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2005-10-05 16:22:44 +00:00
|
|
|
// Licence: wxWindows licence
|
1998-09-18 10:19:10 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
|
|
#define _WX_COLOUR_H_
|
|
|
|
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
|
|
|
|
// Colour
|
2006-04-24 14:52:23 +00:00
|
|
|
class WXDLLEXPORT wxColour : public wxColourBase
|
1998-09-18 10:19:10 +00:00
|
|
|
{
|
2002-02-05 16:34:33 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
1998-09-18 10:19:10 +00:00
|
|
|
public:
|
2005-10-05 16:22:44 +00:00
|
|
|
// constructors
|
|
|
|
// ------------
|
|
|
|
|
1998-10-20 14:35:22 +00:00
|
|
|
// default
|
2006-04-24 14:52:23 +00:00
|
|
|
wxColour() { Init(); }
|
|
|
|
DEFINE_STD_WXCOLOUR_CONSTRUCTORS
|
2003-12-11 10:10:40 +00:00
|
|
|
|
1998-10-20 14:35:22 +00:00
|
|
|
// copy ctors and assignment operators
|
2002-02-05 16:34:33 +00:00
|
|
|
wxColour( const wxColour& col );
|
|
|
|
wxColour& operator = ( const wxColour& col );
|
2003-12-11 10:10:40 +00:00
|
|
|
|
1998-10-20 14:35:22 +00:00
|
|
|
// dtor
|
2002-02-05 16:34:33 +00:00
|
|
|
~wxColour();
|
2003-12-11 10:10:40 +00:00
|
|
|
|
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
// accessors
|
|
|
|
bool Ok() const {return m_isInit; }
|
|
|
|
unsigned char Red() const { return m_red; }
|
|
|
|
unsigned char Green() const { return m_green; }
|
|
|
|
unsigned char Blue() const { return m_blue; }
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
int GetPixel() const { return m_pixel; };
|
2003-12-11 10:10:40 +00:00
|
|
|
void SetPixel(int pixel) { m_pixel = pixel; m_isInit = true; };
|
|
|
|
|
2002-02-05 16:34:33 +00: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 10:10:40 +00:00
|
|
|
|
2002-02-05 16:34:33 +00: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 21:49:44 +00:00
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
// Allocate a colour, or nearest colour, using the given display.
|
2003-12-11 10:10:40 +00:00
|
|
|
// If realloc is true, ignore the existing pixel, otherwise just return
|
2002-02-05 16:34:33 +00:00
|
|
|
// the existing one.
|
|
|
|
// Returns the allocated pixel.
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-05 16:34:33 +00: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 10:10:40 +00:00
|
|
|
|
|
|
|
int AllocColour(WXDisplay* display, bool realloc = false);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Helper function
|
|
|
|
void Init();
|
|
|
|
|
2006-04-24 14:52:23 +00:00
|
|
|
virtual void InitWith( unsigned char red, unsigned char green, unsigned char blue );
|
|
|
|
|
1998-10-20 14:35:22 +00:00
|
|
|
private:
|
2002-02-05 16:34:33 +00:00
|
|
|
bool m_isInit;
|
|
|
|
unsigned char m_red;
|
|
|
|
unsigned char m_blue;
|
|
|
|
unsigned char m_green;
|
2003-12-11 10:10:40 +00:00
|
|
|
|
1998-10-20 14:35:22 +00:00
|
|
|
public:
|
2002-02-05 16:34:33 +00:00
|
|
|
int m_pixel;
|
1998-09-18 10:19:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2002-02-05 16:34:33 +00:00
|
|
|
// _WX_COLOUR_H_
|