]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/colour.h
Updated html version of stc.h
[wxWidgets.git] / include / wx / gtk1 / colour.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: colour.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10
11 #ifndef __GTKCOLOURH__
12 #define __GTKCOLOURH__
13
14 #ifdef __GNUG__
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"
22 #include "wx/palette.h"
23
24 //-----------------------------------------------------------------------------
25 // classes
26 //-----------------------------------------------------------------------------
27
28 class wxDC;
29 class wxPaintDC;
30 class wxBitmap;
31 class wxWindow;
32
33 class wxColour;
34
35 //-----------------------------------------------------------------------------
36 // wxColour
37 //-----------------------------------------------------------------------------
38
39 class wxColour: public wxGDIObject
40 {
41 public:
42 wxColour() { }
43
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); }
50 wxColour( const char *colourName ) { InitFromName(colourName); }
51 #if wxUSE_UNICODE
52 wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); }
53 #endif
54
55
56 wxColour( const wxColour& col )
57 : wxGDIObject()
58 { Ref(col); }
59 wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
60
61 ~wxColour();
62
63 bool Ok() const { return m_refData != NULL; }
64
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
83 // Implementation part
84 void CalcPixel( GdkColormap *cmap );
85 int GetPixel() const;
86 GdkColor *GetColor() const;
87
88 protected:
89 // ref counting code
90 virtual wxObjectRefData *CreateRefData() const;
91 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
92
93 // Helper functions
94 void InitFromName(const wxString& colourName);
95
96 private:
97 DECLARE_DYNAMIC_CLASS(wxColour)
98 };
99
100 #endif // __GTKCOLOURH__