]> git.saurik.com Git - wxWidgets.git/blame - include/wx/colour.h
Commited FRM's stockitem patch (empty stock items).
[wxWidgets.git] / include / wx / colour.h
CommitLineData
99d80019
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/colour.h
40989e46 3// Purpose: wxColourBase definition
99d80019 4// Author: Julian Smart
40989e46 5// Modified by: Francesco Montorsi
99d80019
JS
6// Created:
7// RCS-ID: $Id$
8// Copyright: Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_COLOUR_H_BASE_
13#define _WX_COLOUR_H_BASE_
14
e45689df 15#include "wx/defs.h"
40989e46
WS
16#include "wx/gdiobj.h"
17
18
7d01c54d 19// the standard wxColour constructors;
40989e46
WS
20// this macro avoids to repeat these lines across all colour.h files, since
21// Set() is a virtual function and thus cannot be called by wxColourBase
22// constructors
fa8bc37b
SC
23#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
24 wxColour( unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = 255 ) \
25 { Set(red, green, blue, alpha); } \
26 wxColour( unsigned long colRGB ) { Set(colRGB); } \
27 wxColour(const wxString &colourName) { Set(colourName); } \
40989e46
WS
28 wxColour(const wxChar *colourName) { Set(colourName); }
29
30
7d01c54d 31// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
40989e46
WS
32#define wxC2S_NAME 1 // return colour name, when possible
33#define wxC2S_CSS_SYNTAX 2 // return colour in rgb(r,g,b) syntax
34#define wxC2S_HTML_SYNTAX 4 // return colour in #rrggbb syntax
35
36
37class WXDLLEXPORT wxColour;
38
a69aabc3
SC
39const unsigned char wxALPHA_TRANSPARENT = 0;
40const unsigned char wxALPHA_OPAQUE = 0xff;
40989e46
WS
41
42//-----------------------------------------------------------------------------
43// wxColourBase: this class has no data members, just some functions to avoid
44// code redundancy in all native wxColour implementations
45//-----------------------------------------------------------------------------
46
47class WXDLLEXPORT wxColourBase : public wxGDIObject
48{
49protected:
50
51 virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue) = 0;
fa8bc37b
SC
52
53 // this will be overridden in alpha supporting classes
151dab11 54 virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue, unsigned char WXUNUSED(alpha))
fa8bc37b
SC
55 {
56 InitWith( red, green, blue ) ;
57 }
58
40989e46
WS
59 virtual bool FromString(const wxChar *);
60
61public:
62 wxColourBase() {}
63 virtual ~wxColourBase() {}
64
65
66 // Set() functions
67 // ---------------
68
a69aabc3 69 void Set(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha = wxALPHA_OPAQUE)
fa8bc37b 70 { InitWith(red,green,blue, alpha); }
40989e46
WS
71
72 // implemented in colourcmn.cpp
73 bool Set(const wxChar *str)
74 { return FromString(str); }
75
76 bool Set(const wxString &str)
77 { return Set((const wxChar *)str); }
78
79 void Set(unsigned long colRGB)
80 {
81 // we don't need to know sizeof(long) here because we assume that the three
82 // least significant bytes contain the R, G and B values
83 Set((unsigned char)colRGB,
84 (unsigned char)(colRGB >> 8),
85 (unsigned char)(colRGB >> 16));
86 }
87
88
89
90 // accessors
91 // ---------
92
93 virtual bool Ok() const = 0;
94
95 virtual unsigned char Red() const = 0;
96 virtual unsigned char Green() const = 0;
97 virtual unsigned char Blue() const = 0;
fa8bc37b 98 virtual unsigned char Alpha() const
a69aabc3 99 { return wxALPHA_OPAQUE ; }
40989e46
WS
100
101 // implemented in colourcmn.cpp
102 virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
103
104
105
106 // old, deprecated
107 // ---------------
108
7d01c54d
WS
109#if WXWIN_COMPATIBILITY_2_6
110 wxDEPRECATED( static wxColour CreateByName(const wxString& name) );
111 wxDEPRECATED( void InitFromName(const wxString& col) );
112#endif
40989e46
WS
113};
114
115
e45689df 116
4055ed82 117#if defined(__WXPALMOS__)
803c61bf 118#include "wx/generic/colour.h"
ffecfa5a 119#elif defined(__WXMSW__)
34138703
JS
120#include "wx/msw/colour.h"
121#elif defined(__WXMOTIF__)
122#include "wx/motif/colour.h"
1be7a35c 123#elif defined(__WXGTK20__)
34138703 124#include "wx/gtk/colour.h"
1be7a35c
MR
125#elif defined(__WXGTK__)
126#include "wx/gtk1/colour.h"
1e6feb95 127#elif defined(__WXMGL__)
3da12c22 128#include "wx/generic/colour.h"
b3c86150
VS
129#elif defined(__WXDFB__)
130#include "wx/generic/colour.h"
83df96d6
JS
131#elif defined(__WXX11__)
132#include "wx/x11/colour.h"
34138703
JS
133#elif defined(__WXMAC__)
134#include "wx/mac/colour.h"
e64df9bc
DE
135#elif defined(__WXCOCOA__)
136#include "wx/cocoa/colour.h"
1777b9bb
DW
137#elif defined(__WXPM__)
138#include "wx/os2/colour.h"
34138703
JS
139#endif
140
e4a81a2e
VZ
141#define wxColor wxColour
142
34138703
JS
143#endif
144 // _WX_COLOUR_H_BASE_