]> git.saurik.com Git - wxWidgets.git/blame - include/wx/x11/colour.h
Fixed conflicts with Robert's similar fixes; fixed toolbar size calculation
[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
83df96d6
JS
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_COLOUR_H_
13#define _WX_COLOUR_H_
14
15#ifdef __GNUG__
16#pragma interface "colour.h"
17#endif
18
3cd0b8c5 19#include "wx/defs.h"
83df96d6
JS
20#include "wx/object.h"
21#include "wx/string.h"
3cd0b8c5
RR
22#include "wx/gdiobj.h"
23#include "wx/palette.h"
83df96d6 24
3cd0b8c5
RR
25//-----------------------------------------------------------------------------
26// classes
27//-----------------------------------------------------------------------------
28
29class wxDC;
30class wxPaintDC;
31class wxBitmap;
32class wxWindow;
33
34class wxColour;
35
36//-----------------------------------------------------------------------------
37// wxColour
38//-----------------------------------------------------------------------------
39
40class wxColour: public wxGDIObject
83df96d6 41{
83df96d6 42public:
3cd0b8c5
RR
43 wxColour() { }
44
45 // Construct from RGB
83df96d6
JS
46 wxColour( unsigned char red, unsigned char green, unsigned char blue );
47 wxColour( unsigned long colRGB ) { Set(colRGB); }
3cd0b8c5
RR
48
49 // Implicit conversion from the colour name
83df96d6
JS
50 wxColour( const wxString &colourName ) { InitFromName(colourName); }
51 wxColour( const char *colourName ) { InitFromName(colourName); }
3cd0b8c5
RR
52
53 wxColour( const wxColour& col ) { Ref(col); }
54 wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
55
83df96d6 56 ~wxColour();
3cd0b8c5
RR
57
58 bool Ok() const { return m_refData != NULL; }
59
60 bool operator == ( const wxColour& col ) const;
61 bool operator != ( const wxColour& col ) const { return !(*this == col); }
62
83df96d6
JS
63 void Set( unsigned char red, unsigned char green, unsigned char blue );
64 void Set( unsigned long colRGB )
65 {
3cd0b8c5 66 // We don't need to know sizeof(long) here because we assume that the three
83df96d6
JS
67 // least significant bytes contain the R, G and B values
68 Set((unsigned char)colRGB,
69 (unsigned char)(colRGB >> 8),
70 (unsigned char)(colRGB >> 16));
71 }
3cd0b8c5
RR
72
73 unsigned char Red() const;
74 unsigned char Green() const;
75 unsigned char Blue() const;
76
77 // Implementation part
83df96d6 78
3cd0b8c5
RR
79 void CalcPixel( WXColormap cmap );
80 unsigned long GetPixel() const;
81 WXColor *GetColor() const;
82
83protected:
84 // ref counting code
85 virtual wxObjectRefData *CreateRefData() const;
86 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
83df96d6 87
3cd0b8c5
RR
88 // Helper functions
89 void InitFromName(const wxString& colourName);
90
83df96d6 91private:
3cd0b8c5 92 DECLARE_DYNAMIC_CLASS(wxColour)
83df96d6
JS
93};
94
95#endif
3cd0b8c5 96
e5053ade
JS
97// _WX_COLOUR_H_
98