]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/colour.h
delete children in ~wxWindow dtor and not in the base class ~wxWindowNative as it...
[wxWidgets.git] / include / wx / gtk / colour.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: colour.h
3// Purpose:
4// Author: Robert Roebling
dbf858b5 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef __GTKCOLOURH__
12#define __GTKCOLOURH__
13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
c801d85f
KB
15#pragma interface
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/string.h"
21#include "wx/gdiobj.h"
401ec7b6 22#include "wx/palette.h"
c801d85f
KB
23
24//-----------------------------------------------------------------------------
25// classes
26//-----------------------------------------------------------------------------
27
28class wxDC;
29class wxPaintDC;
30class wxBitmap;
31class wxWindow;
32
33class wxColour;
34
35//-----------------------------------------------------------------------------
36// wxColour
37//-----------------------------------------------------------------------------
38
39class wxColour: public wxGDIObject
40{
e4a81a2e 41public:
c89f5c02 42 wxColour() { }
aad6765c 43
c89f5c02
RR
44 // Construct from RGB
45 wxColour( unsigned char red, unsigned char green, unsigned char blue );
46 wxColour( unsigned long colRGB ) { Set(colRGB); }
47
48 // Implicit conversion from the colour name
49 wxColour( const wxString &colourName ) { InitFromName(colourName); }
2b5f62a0 50 wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); }
401eb3de
RR
51#if wxUSE_UNICODE
52 wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
53#endif
54
c89f5c02 55
d84afea9
GD
56 wxColour( const wxColour& col )
57 : wxGDIObject()
58 { Ref(col); }
c89f5c02
RR
59 wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
60
61 ~wxColour();
62
63 bool Ok() const { return m_refData != NULL; }
aad6765c 64
c89f5c02
RR
65 bool operator == ( const wxColour& col ) const;
66 bool operator != ( const wxColour& col ) const { return !(*this == col); }
67
68 void Set( unsigned char red, unsigned char green, unsigned char blue );
69 void Set( unsigned long colRGB )
70 {
71 // We don't need to know sizeof(long) here because we assume that the three
72 // least significant bytes contain the R, G and B values
73 Set((unsigned char)colRGB,
74 (unsigned char)(colRGB >> 8),
75 (unsigned char)(colRGB >> 16));
76 }
77
78 unsigned char Red() const;
79 unsigned char Green() const;
80 unsigned char Blue() const;
81
82
4e6b8309
VZ
83 // Get colour from name or wxNullColour
84 static wxColour CreateByName(const wxString& name);
85
c89f5c02
RR
86 // Implementation part
87 void CalcPixel( GdkColormap *cmap );
88 int GetPixel() const;
89 GdkColor *GetColor() const;
c0ac1c32 90
aad6765c
JS
91 void InitFromName(const wxString& colourName);
92
68dda785 93protected:
c89f5c02
RR
94 // ref counting code
95 virtual wxObjectRefData *CreateRefData() const;
96 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
aad6765c 97
68dda785
VZ
98
99private:
c89f5c02 100 DECLARE_DYNAMIC_CLASS(wxColour)
c801d85f 101};
c0ac1c32 102
c801d85f 103#endif // __GTKCOLOURH__