]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/colour.h
added wxDynamicLibrary::GetSymbolAorW()
[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
12028905 15#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
f75aecd0 16 #pragma interface "colour.h"
2bda0e17 17#endif
f75aecd0 18
2d996ed1 19#include "wx/object.h"
2bda0e17 20
f75aecd0 21// ----------------------------------------------------------------------------
2bda0e17 22// Colour
f75aecd0
VZ
23// ----------------------------------------------------------------------------
24
25class WXDLLEXPORT wxColour : public wxObject
2bda0e17 26{
2bda0e17 27public:
f75aecd0
VZ
28 // constructors
29 // ------------
30
e4a81a2e 31 // default
f75aecd0
VZ
32 wxColour() { Init(); }
33
34 // from separate RGB
35 wxColour( unsigned char red, unsigned char green, unsigned char blue )
36 { Set(red, green, blue); }
37
38 // from packed RGB
39 wxColour( unsigned long colRGB ) { Set(colRGB); }
5f83a454 40
e4a81a2e 41 // implicit conversion from the colour name
f75aecd0
VZ
42 wxColour(const wxString &colourName) { InitFromName(colourName); }
43 wxColour(const wxChar *colourName) { InitFromName(colourName); }
e4a81a2e 44
5f83a454 45
e4a81a2e 46 // copy ctors and assignment operators
f75aecd0
VZ
47 wxColour(const wxColour& col);
48 wxColour& operator=( const wxColour& col);
e4a81a2e
VZ
49
50 // dtor
f75aecd0
VZ
51 ~wxColour();
52
53
54 // other methods
55 // -------------
56
aad6765c 57 // to have the matching Create also for this class
f75aecd0 58 void Create( unsigned char red, unsigned char green, unsigned char blue )
aad6765c 59 { Set(red, green, blue); }
f75aecd0
VZ
60
61 // Set() functions
62 void Set(unsigned char red, unsigned char green, unsigned char blue);
63 void Set(unsigned long colRGB)
64 {
65 // we don't need to know sizeof(long) here because we assume that the three
66 // least significant bytes contain the R, G and B values
67 Set((unsigned char)colRGB,
aad6765c
JS
68 (unsigned char)(colRGB >> 8),
69 (unsigned char)(colRGB >> 16));
f75aecd0
VZ
70 }
71
72 // accessors
73 // ---------
74
aad6765c 75 bool Ok() const { return m_isInit; }
f75aecd0
VZ
76
77 unsigned char Red() const { return m_red; }
78 unsigned char Green() const { return m_green; }
79 unsigned char Blue() const { return m_blue; }
80
81 // comparison
82 bool operator==(const wxColour& colour) const
83 {
aad6765c
JS
84 return m_isInit == colour.m_isInit
85 && m_red == colour.m_red
86 && m_green == colour.m_green
87 && m_blue == colour.m_blue;
f75aecd0
VZ
88 }
89
90 bool operator != (const wxColour& colour) const { return !(*this == colour); }
91
92 WXCOLORREF GetPixel() const { return m_pixel; };
2bda0e17 93
aad6765c
JS
94 void InitFromName(const wxString& colourName);
95
8f177c8e 96public:
f75aecd0 97 WXCOLORREF m_pixel;
8f177c8e 98
aad6765c
JS
99protected:
100 // Helper function
101 void Init();
102
68dda785 103private:
f75aecd0
VZ
104 bool m_isInit;
105 unsigned char m_red;
106 unsigned char m_blue;
107 unsigned char m_green;
68dda785 108
68dda785 109private:
f75aecd0 110 DECLARE_DYNAMIC_CLASS(wxColour)
2bda0e17
KB
111};
112
2bda0e17 113#endif
8f177c8e 114 // _WX_COLOUR_H_