2002-02-05 11:34:33 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: colour.h
|
|
|
|
// Purpose: wxColour class
|
2002-02-11 15:41:24 -05:00
|
|
|
// Author: Julian Smart, Robert Roebling
|
2002-02-05 11:34:33 -05:00
|
|
|
// Modified by:
|
|
|
|
// Created: 17/09/98
|
|
|
|
// RCS-ID: $Id$
|
2002-02-11 15:41:24 -05:00
|
|
|
// Copyright: (c) Julian Smart, Robert Roebling
|
2002-02-05 11:34:33 -05:00
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_COLOUR_H_
|
|
|
|
#define _WX_COLOUR_H_
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "colour.h"
|
|
|
|
#endif
|
|
|
|
|
2002-02-11 15:41:24 -05:00
|
|
|
#include "wx/defs.h"
|
2002-02-05 11:34:33 -05:00
|
|
|
#include "wx/object.h"
|
|
|
|
#include "wx/string.h"
|
2002-02-11 15:41:24 -05:00
|
|
|
#include "wx/gdiobj.h"
|
|
|
|
#include "wx/palette.h"
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-11 15:41:24 -05:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// classes
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxDC;
|
|
|
|
class wxPaintDC;
|
|
|
|
class wxBitmap;
|
|
|
|
class wxWindow;
|
|
|
|
|
|
|
|
class wxColour;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxColour
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class wxColour: public wxGDIObject
|
2002-02-05 11:34:33 -05:00
|
|
|
{
|
|
|
|
public:
|
2002-02-11 15:41:24 -05:00
|
|
|
wxColour() { }
|
|
|
|
|
|
|
|
// Construct from RGB
|
2002-02-05 11:34:33 -05:00
|
|
|
wxColour( unsigned char red, unsigned char green, unsigned char blue );
|
|
|
|
wxColour( unsigned long colRGB ) { Set(colRGB); }
|
2002-02-11 15:41:24 -05:00
|
|
|
|
|
|
|
// Implicit conversion from the colour name
|
2002-02-05 11:34:33 -05:00
|
|
|
wxColour( const wxString &colourName ) { InitFromName(colourName); }
|
|
|
|
wxColour( const char *colourName ) { InitFromName(colourName); }
|
2002-02-11 15:41:24 -05:00
|
|
|
|
|
|
|
wxColour( const wxColour& col ) { Ref(col); }
|
|
|
|
wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
~wxColour();
|
2002-02-11 15:41:24 -05:00
|
|
|
|
|
|
|
bool Ok() const { return m_refData != NULL; }
|
|
|
|
|
|
|
|
bool operator == ( const wxColour& col ) const;
|
|
|
|
bool operator != ( const wxColour& col ) const { return !(*this == col); }
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
void Set( unsigned char red, unsigned char green, unsigned char blue );
|
|
|
|
void Set( unsigned long colRGB )
|
|
|
|
{
|
2002-02-11 15:41:24 -05:00
|
|
|
// We don't need to know sizeof(long) here because we assume that the three
|
2002-02-05 11:34:33 -05: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 15:41:24 -05:00
|
|
|
|
|
|
|
unsigned char Red() const;
|
|
|
|
unsigned char Green() const;
|
|
|
|
unsigned char Blue() const;
|
|
|
|
|
|
|
|
// Implementation part
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-11 15:41:24 -05:00
|
|
|
void CalcPixel( WXColormap cmap );
|
|
|
|
unsigned long GetPixel() const;
|
|
|
|
WXColor *GetColor() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// ref counting code
|
|
|
|
virtual wxObjectRefData *CreateRefData() const;
|
|
|
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
2002-02-05 11:34:33 -05:00
|
|
|
|
2002-02-11 15:41:24 -05:00
|
|
|
// Helper functions
|
|
|
|
void InitFromName(const wxString& colourName);
|
|
|
|
|
2002-02-05 11:34:33 -05:00
|
|
|
private:
|
2002-02-11 15:41:24 -05:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
2002-02-05 11:34:33 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2002-02-11 15:41:24 -05:00
|
|
|
|
2002-02-12 07:59:14 -05:00
|
|
|
// _WX_COLOUR_H_
|
|
|
|
|