]> git.saurik.com Git - wxWidgets.git/blame - include/wx/colour.h
oops, typo in last commit
[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
23#define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
24 wxColour( unsigned char red, unsigned char green, unsigned char blue ) \
25 { Set(red, green, blue); } \
26 wxColour( unsigned long colRGB ) { Set(colRGB); } \
27 wxColour(const wxString &colourName) { Set(colourName); } \
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
39
40//-----------------------------------------------------------------------------
41// wxColourBase: this class has no data members, just some functions to avoid
42// code redundancy in all native wxColour implementations
43//-----------------------------------------------------------------------------
44
45class WXDLLEXPORT wxColourBase : public wxGDIObject
46{
47protected:
48
49 virtual void InitWith(unsigned char red, unsigned char green, unsigned char blue) = 0;
50 virtual bool FromString(const wxChar *);
51
52public:
53 wxColourBase() {}
54 virtual ~wxColourBase() {}
55
56
57 // Set() functions
58 // ---------------
59
60 void Set(unsigned char red, unsigned char green, unsigned char blue)
61 { InitWith(red,green,blue); }
62
63 // implemented in colourcmn.cpp
64 bool Set(const wxChar *str)
65 { return FromString(str); }
66
67 bool Set(const wxString &str)
68 { return Set((const wxChar *)str); }
69
70 void Set(unsigned long colRGB)
71 {
72 // we don't need to know sizeof(long) here because we assume that the three
73 // least significant bytes contain the R, G and B values
74 Set((unsigned char)colRGB,
75 (unsigned char)(colRGB >> 8),
76 (unsigned char)(colRGB >> 16));
77 }
78
79
80
81 // accessors
82 // ---------
83
84 virtual bool Ok() const = 0;
85
86 virtual unsigned char Red() const = 0;
87 virtual unsigned char Green() const = 0;
88 virtual unsigned char Blue() const = 0;
89
90 // implemented in colourcmn.cpp
91 virtual wxString GetAsString(long flags = wxC2S_NAME | wxC2S_CSS_SYNTAX) const;
92
93
94
95 // old, deprecated
96 // ---------------
97
7d01c54d
WS
98#if WXWIN_COMPATIBILITY_2_6
99 wxDEPRECATED( static wxColour CreateByName(const wxString& name) );
100 wxDEPRECATED( void InitFromName(const wxString& col) );
101#endif
40989e46
WS
102};
103
104
e45689df 105
4055ed82 106#if defined(__WXPALMOS__)
ffecfa5a
JS
107#include "wx/palmos/colour.h"
108#elif defined(__WXMSW__)
34138703
JS
109#include "wx/msw/colour.h"
110#elif defined(__WXMOTIF__)
111#include "wx/motif/colour.h"
1be7a35c 112#elif defined(__WXGTK20__)
34138703 113#include "wx/gtk/colour.h"
1be7a35c
MR
114#elif defined(__WXGTK__)
115#include "wx/gtk1/colour.h"
1e6feb95
VZ
116#elif defined(__WXMGL__)
117#include "wx/mgl/colour.h"
83df96d6
JS
118#elif defined(__WXX11__)
119#include "wx/x11/colour.h"
34138703
JS
120#elif defined(__WXMAC__)
121#include "wx/mac/colour.h"
e64df9bc
DE
122#elif defined(__WXCOCOA__)
123#include "wx/cocoa/colour.h"
1777b9bb
DW
124#elif defined(__WXPM__)
125#include "wx/os2/colour.h"
34138703
JS
126#endif
127
e4a81a2e
VZ
128#define wxColor wxColour
129
34138703
JS
130#endif
131 // _WX_COLOUR_H_BASE_