2002-02-05 16:34:33 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: colour.h
|
|
|
|
// Purpose: wxColour class
|
2002-02-11 20:41:24 +00:00
|
|
|
// Author: Julian Smart, Robert Roebling
|
2002-02-05 16:34:33 +00:00
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
2002-02-11 20:41:24 +00:00
|
|
|
// Copyright: (c) Julian Smart, Robert Roebling
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
2002-02-05 16:34:33 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
|
|
#define _WX_COLOUR_H_
|
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2002-02-05 16:34:33 +00:00
|
|
|
#pragma interface "colour.h"
|
|
|
|
#endif
|
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
#include "wx/defs.h"
|
2002-02-05 16:34:33 +00:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
2002-02-11 20:41:24 +00:00
|
|
|
#include "wx/gdiobj.h"
|
|
|
|
#include "wx/palette.h"
|
2002-02-05 16:34:33 +00:00
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDC;
|
|
|
|
class wxPaintDC;
|
|
|
|
class wxBitmap;
|
|
|
|
class wxWindow;
|
|
|
|
|
|
|
|
class wxColour;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxColour
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2003-12-11 10:10:40 +00:00
|
|
|
class WXDLLEXPORT wxColour: public wxGDIObject
|
2002-02-05 16:34:33 +00:00
|
|
|
{
|
|
|
|
public:
|
2002-02-11 20:41:24 +00:00
|
|
|
wxColour() { }
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
// Construct from RGB
|
2002-02-05 16:34:33 +00:00
|
|
|
wxColour( unsigned char red, unsigned char green, unsigned char blue );
|
|
|
|
wxColour( unsigned long colRGB ) { Set(colRGB); }
|
2002-02-11 20:41:24 +00:00
|
|
|
|
|
|
|
// Implicit conversion from the colour name
|
2002-02-05 16:34:33 +00:00
|
|
|
wxColour( const wxString &colourName ) { InitFromName(colourName); }
|
2002-12-04 14:11:26 +00:00
|
|
|
wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
|
|
|
|
#if wxUSE_UNICODE
|
|
|
|
wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
|
|
|
|
#endif
|
2002-02-11 20:41:24 +00:00
|
|
|
|
2003-10-18 23:51:01 +00:00
|
|
|
// Get colour from name or wxNullColour
|
|
|
|
static wxColour CreateByName(const wxString& name);
|
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
wxColour( const wxColour& col ) { Ref(col); }
|
|
|
|
wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
|
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
~wxColour();
|
2002-02-11 20:41:24 +00:00
|
|
|
|
|
|
|
bool Ok() const { return m_refData != NULL; }
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
bool operator == ( const wxColour& col ) const;
|
|
|
|
bool operator != ( const wxColour& col ) const { return !(*this == col); }
|
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
void Set( unsigned char red, unsigned char green, unsigned char blue );
|
|
|
|
void Set( unsigned long colRGB )
|
|
|
|
{
|
2002-02-11 20:41:24 +00:00
|
|
|
// We don't need to know sizeof(long) here because we assume that the three
|
2002-02-05 16:34:33 +00:00
|
|
|
// least significant bytes contain the R, G and B values
|
|
|
|
Set((unsigned char)colRGB,
|
|
|
|
(unsigned char)(colRGB >> 8),
|
|
|
|
(unsigned char)(colRGB >> 16));
|
|
|
|
}
|
2002-02-11 20:41:24 +00:00
|
|
|
|
|
|
|
unsigned char Red() const;
|
|
|
|
unsigned char Green() const;
|
|
|
|
unsigned char Blue() const;
|
|
|
|
|
|
|
|
// Implementation part
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
void CalcPixel( WXColormap cmap );
|
|
|
|
unsigned long GetPixel() const;
|
|
|
|
WXColor *GetColor() const;
|
|
|
|
|
2003-12-11 10:10:40 +00:00
|
|
|
void InitFromName(const wxString& colourName);
|
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
protected:
|
|
|
|
// ref counting code
|
|
|
|
virtual wxObjectRefData *CreateRefData() const;
|
|
|
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
2003-12-11 10:10:40 +00:00
|
|
|
|
2002-02-11 20:41:24 +00:00
|
|
|
|
2002-02-05 16:34:33 +00:00
|
|
|
private:
|
2002-02-11 20:41:24 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
2002-02-05 16:34:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2002-02-11 20:41:24 +00:00
|
|
|
|
2002-02-12 12:59:14 +00:00
|
|
|
// _WX_COLOUR_H_
|
|
|
|
|