1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2005-10-05 12:22:44 -04:00
|
|
|
// Name: wx/gtk/colour.h
|
1998-05-20 10:01:55 -04:00
|
|
|
// Purpose:
|
|
|
|
// Author: Robert Roebling
|
1998-10-26 05:56:58 -05:00
|
|
|
// Id: $Id$
|
1998-10-24 13:12:05 -04:00
|
|
|
// Copyright: (c) 1998 Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-20 10:01:55 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef __GTKCOLOURH__
|
|
|
|
#define __GTKCOLOURH__
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
|
|
|
#include "wx/gdiobj.h"
|
1998-07-11 05:53:58 -04:00
|
|
|
#include "wx/palette.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDC;
|
|
|
|
class WXDLLIMPEXP_CORE wxPaintDC;
|
|
|
|
class WXDLLIMPEXP_CORE wxBitmap;
|
|
|
|
class WXDLLIMPEXP_CORE wxWindow;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxColour;
|
1998-05-20 10:01:55 -04:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxColour
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2005-08-02 18:58:06 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxColour: public wxGDIObject
|
1998-05-20 10:01:55 -04:00
|
|
|
{
|
1998-10-20 10:35:22 -04:00
|
|
|
public:
|
2005-10-05 12:22:44 -04:00
|
|
|
// constructors
|
|
|
|
// ------------
|
|
|
|
|
|
|
|
// default
|
2002-02-04 13:01:21 -05:00
|
|
|
wxColour() { }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2005-10-05 12:22:44 -04:00
|
|
|
// from separate RGB
|
2002-02-04 13:01:21 -05:00
|
|
|
wxColour( unsigned char red, unsigned char green, unsigned char blue );
|
2005-10-05 12:22:44 -04:00
|
|
|
|
|
|
|
// from packed RGB
|
2002-02-04 13:01:21 -05:00
|
|
|
wxColour( unsigned long colRGB ) { Set(colRGB); }
|
|
|
|
|
|
|
|
// Implicit conversion from the colour name
|
|
|
|
wxColour( const wxString &colourName ) { InitFromName(colourName); }
|
2002-12-04 09:11:26 -05:00
|
|
|
wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
|
2002-08-05 14:04:08 -04:00
|
|
|
#if wxUSE_UNICODE
|
|
|
|
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
|
|
|
|
#endif
|
|
|
|
|
2002-02-04 13:01:21 -05:00
|
|
|
~wxColour();
|
|
|
|
|
|
|
|
bool Ok() const { return m_refData != NULL; }
|
2003-12-11 05:10:40 -05:00
|
|
|
|
2002-02-04 13:01:21 -05:00
|
|
|
bool operator == ( const wxColour& col ) const;
|
|
|
|
bool operator != ( const wxColour& col ) const { return !(*this == col); }
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned char Red() const;
|
|
|
|
unsigned char Green() const;
|
|
|
|
unsigned char Blue() const;
|
|
|
|
|
|
|
|
|
2003-10-17 13:39:28 -04:00
|
|
|
// Get colour from name or wxNullColour
|
|
|
|
static wxColour CreateByName(const wxString& name);
|
|
|
|
|
2002-02-04 13:01:21 -05:00
|
|
|
// Implementation part
|
|
|
|
void CalcPixel( GdkColormap *cmap );
|
|
|
|
int GetPixel() const;
|
|
|
|
GdkColor *GetColor() const;
|
1998-10-19 22:10:29 -04:00
|
|
|
|
2003-12-11 05:10:40 -05:00
|
|
|
void InitFromName(const wxString& colourName);
|
|
|
|
|
1998-10-19 10:18:56 -04:00
|
|
|
protected:
|
2002-02-04 13:01:21 -05:00
|
|
|
// ref counting code
|
|
|
|
virtual wxObjectRefData *CreateRefData() const;
|
|
|
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
2003-12-11 05:10:40 -05:00
|
|
|
|
1998-10-19 10:18:56 -04:00
|
|
|
|
|
|
|
private:
|
2002-02-04 13:01:21 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
1998-05-20 10:01:55 -04:00
|
|
|
};
|
1998-10-19 22:10:29 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif // __GTKCOLOURH__
|