]> git.saurik.com Git - wxWidgets.git/blame - include/wx/palmos/colour.h
cleanup - added whitespace around operators, some blank lines, fixed comment typos...
[wxWidgets.git] / include / wx / palmos / colour.h
CommitLineData
ffecfa5a
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/palmos/colour.h
3// Purpose: wxColour class
e1d63b79 4// Author: William Osborne - minimal working wxPalmOS port
ffecfa5a
JS
5// Modified by:
6// Created: 10/13/04
e1d63b79 7// RCS-ID: $Id$
ffecfa5a
JS
8// Copyright: (c) William Osborne
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_COLOUR_H_
13#define _WX_COLOUR_H_
14
ffecfa5a
JS
15#include "wx/object.h"
16
17// ----------------------------------------------------------------------------
18// Colour
19// ----------------------------------------------------------------------------
20
21class WXDLLEXPORT wxColour : public wxObject
22{
23public:
24 // constructors
25 // ------------
26
27 // default
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); }
36
37 // implicit conversion from the colour name
38 wxColour(const wxString &colourName) { InitFromName(colourName); }
39 wxColour(const wxChar *colourName) { InitFromName(colourName); }
40
41
42 // copy ctors and assignment operators
43 wxColour(const wxColour& col);
44 wxColour& operator=( const wxColour& col);
45
46 // dtor
47 ~wxColour();
48
49
50 // other methods
51 // -------------
52
53 // to have the matching Create also for this class
54 void Create( unsigned char red, unsigned char green, unsigned char blue )
55 { Set(red, green, blue); }
56
57 // Set() functions
58 void Set(unsigned char red, unsigned char green, unsigned char blue);
59 void Set(unsigned long colRGB)
60 {
61 // we don't need to know sizeof(long) here because we assume that the three
62 // least significant bytes contain the R, G and B values
63 Set((unsigned char)colRGB,
64 (unsigned char)(colRGB >> 8),
65 (unsigned char)(colRGB >> 16));
66 }
67
68 // accessors
69 // ---------
70
71 bool Ok() const { return m_isInit; }
72
73 unsigned char Red() const { return m_red; }
74 unsigned char Green() const { return m_green; }
75 unsigned char Blue() const { return m_blue; }
76
77 // comparison
78 bool operator==(const wxColour& colour) const
79 {
80 return m_isInit == colour.m_isInit
81 && m_red == colour.m_red
82 && m_green == colour.m_green
83 && m_blue == colour.m_blue;
84 }
85
86 bool operator != (const wxColour& colour) const { return !(*this == colour); }
87
88 WXCOLORREF GetPixel() const { return m_pixel; };
89
90 void InitFromName(const wxString& colourName);
91
92public:
93 WXCOLORREF m_pixel;
94
95protected:
96 // Helper function
97 void Init();
98
99private:
100 bool m_isInit;
101 unsigned char m_red;
102 unsigned char m_blue;
103 unsigned char m_green;
104
105private:
106 DECLARE_DYNAMIC_CLASS(wxColour)
107};
108
109#endif
110 // _WX_COLOUR_H_