]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/colour.h
wxLaunchDefaultBrowser() now supports wxBROWSER_NEW_WINDOW flag (and it actually...
[wxWidgets.git] / include / wx / x11 / colour.h
CommitLineData
83df96d6
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
3// Purpose: wxColour class
3cd0b8c5 4// Author: Julian Smart, Robert Roebling
83df96d6
JS
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
3cd0b8c5 8// Copyright: (c) Julian Smart, Robert Roebling
65571936 9// Licence: wxWindows licence
83df96d6
JS
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_COLOUR_H_
13#define _WX_COLOUR_H_
14
3cd0b8c5 15#include "wx/defs.h"
83df96d6
JS
16#include "wx/object.h"
17#include "wx/string.h"
3cd0b8c5
RR
18#include "wx/gdiobj.h"
19#include "wx/palette.h"
83df96d6 20
3cd0b8c5
RR
21//-----------------------------------------------------------------------------
22// classes
23//-----------------------------------------------------------------------------
24
968eb2ef
MW
25class WXDLLIMPEXP_CORE wxDC;
26class WXDLLIMPEXP_CORE wxPaintDC;
27class WXDLLIMPEXP_CORE wxBitmap;
28class WXDLLIMPEXP_CORE wxWindow;
3cd0b8c5 29
968eb2ef 30class WXDLLIMPEXP_CORE wxColour;
3cd0b8c5
RR
31
32//-----------------------------------------------------------------------------
33// wxColour
34//-----------------------------------------------------------------------------
35
aad6765c 36class WXDLLEXPORT wxColour: public wxGDIObject
83df96d6 37{
83df96d6 38public:
3cd0b8c5 39 wxColour() { }
aad6765c 40
3cd0b8c5 41 // Construct from RGB
83df96d6
JS
42 wxColour( unsigned char red, unsigned char green, unsigned char blue );
43 wxColour( unsigned long colRGB ) { Set(colRGB); }
3cd0b8c5
RR
44
45 // Implicit conversion from the colour name
83df96d6 46 wxColour( const wxString &colourName ) { InitFromName(colourName); }
2b5f62a0
VZ
47 wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
48#if wxUSE_UNICODE
49 wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
50#endif
3cd0b8c5 51
564a150b
VZ
52 // Get colour from name or wxNullColour
53 static wxColour CreateByName(const wxString& name);
54
3cd0b8c5
RR
55 wxColour( const wxColour& col ) { Ref(col); }
56 wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
57
83df96d6 58 ~wxColour();
3cd0b8c5
RR
59
60 bool Ok() const { return m_refData != NULL; }
aad6765c 61
3cd0b8c5
RR
62 bool operator == ( const wxColour& col ) const;
63 bool operator != ( const wxColour& col ) const { return !(*this == col); }
64
83df96d6
JS
65 void Set( unsigned char red, unsigned char green, unsigned char blue );
66 void Set( unsigned long colRGB )
67 {
3cd0b8c5 68 // We don't need to know sizeof(long) here because we assume that the three
83df96d6
JS
69 // least significant bytes contain the R, G and B values
70 Set((unsigned char)colRGB,
71 (unsigned char)(colRGB >> 8),
72 (unsigned char)(colRGB >> 16));
73 }
3cd0b8c5
RR
74
75 unsigned char Red() const;
76 unsigned char Green() const;
77 unsigned char Blue() const;
78
79 // Implementation part
aad6765c 80
3cd0b8c5
RR
81 void CalcPixel( WXColormap cmap );
82 unsigned long GetPixel() const;
83 WXColor *GetColor() const;
84
aad6765c
JS
85 void InitFromName(const wxString& colourName);
86
3cd0b8c5
RR
87protected:
88 // ref counting code
89 virtual wxObjectRefData *CreateRefData() const;
90 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
aad6765c 91
3cd0b8c5 92
83df96d6 93private:
3cd0b8c5 94 DECLARE_DYNAMIC_CLASS(wxColour)
83df96d6
JS
95};
96
97#endif
3cd0b8c5 98
e5053ade
JS
99// _WX_COLOUR_H_
100