]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/colour.h
no need to add . and .. explicitely to the catalogs search path, the new catalog...
[wxWidgets.git] / include / wx / msw / colour.h
CommitLineData
2bda0e17 1/////////////////////////////////////////////////////////////////////////////
f75aecd0 2// Name: wx/msw/colour.h
2bda0e17
KB
3// Purpose: wxColour class
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
bbcdf8bc 8// Copyright: (c) Julian Smart
65571936 9// Licence: wxWindows licence
2bda0e17
KB
10/////////////////////////////////////////////////////////////////////////////
11
bbcdf8bc
JS
12#ifndef _WX_COLOUR_H_
13#define _WX_COLOUR_H_
2bda0e17 14
2d996ed1 15#include "wx/object.h"
2bda0e17 16
f75aecd0 17// ----------------------------------------------------------------------------
2bda0e17 18// Colour
f75aecd0
VZ
19// ----------------------------------------------------------------------------
20
21class WXDLLEXPORT wxColour : public wxObject
2bda0e17 22{
2bda0e17 23public:
f75aecd0
VZ
24 // constructors
25 // ------------
26
e4a81a2e 27 // default
f75aecd0
VZ
28 wxColour() { Init(); }
29
30 // from separate RGB
31 wxColour( unsigned char red, unsigned char green, unsigned char blue )
32 { Set(red, green, blue); }
33
34 // from packed RGB
35 wxColour( unsigned long colRGB ) { Set(colRGB); }
5f83a454 36
e4a81a2e 37 // implicit conversion from the colour name
f75aecd0
VZ
38 wxColour(const wxString &colourName) { InitFromName(colourName); }
39 wxColour(const wxChar *colourName) { InitFromName(colourName); }
e4a81a2e 40
e4a81a2e 41 // dtor
f75aecd0
VZ
42 ~wxColour();
43
44
45 // other methods
46 // -------------
47
aad6765c 48 // to have the matching Create also for this class
f75aecd0 49 void Create( unsigned char red, unsigned char green, unsigned char blue )
aad6765c 50 { Set(red, green, blue); }
f75aecd0
VZ
51
52 // Set() functions
53 void Set(unsigned char red, unsigned char green, unsigned char blue);
54 void Set(unsigned long colRGB)
55 {
56 // we don't need to know sizeof(long) here because we assume that the three
57 // least significant bytes contain the R, G and B values
58 Set((unsigned char)colRGB,
aad6765c
JS
59 (unsigned char)(colRGB >> 8),
60 (unsigned char)(colRGB >> 16));
f75aecd0
VZ
61 }
62
63 // accessors
64 // ---------
65
aad6765c 66 bool Ok() const { return m_isInit; }
f75aecd0
VZ
67
68 unsigned char Red() const { return m_red; }
69 unsigned char Green() const { return m_green; }
70 unsigned char Blue() const { return m_blue; }
71
72 // comparison
73 bool operator==(const wxColour& colour) const
74 {
aad6765c
JS
75 return m_isInit == colour.m_isInit
76 && m_red == colour.m_red
77 && m_green == colour.m_green
78 && m_blue == colour.m_blue;
f75aecd0
VZ
79 }
80
81 bool operator != (const wxColour& colour) const { return !(*this == colour); }
82
83 WXCOLORREF GetPixel() const { return m_pixel; };
2bda0e17 84
aad6765c
JS
85 void InitFromName(const wxString& colourName);
86
8f177c8e 87public:
f75aecd0 88 WXCOLORREF m_pixel;
8f177c8e 89
aad6765c
JS
90protected:
91 // Helper function
92 void Init();
93
68dda785 94private:
f75aecd0
VZ
95 bool m_isInit;
96 unsigned char m_red;
97 unsigned char m_blue;
98 unsigned char m_green;
68dda785 99
68dda785 100private:
f75aecd0 101 DECLARE_DYNAMIC_CLASS(wxColour)
2bda0e17
KB
102};
103
2bda0e17 104#endif
8f177c8e 105 // _WX_COLOUR_H_