]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/colour.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxColourBase definition
4 // Author: Julian Smart
5 // Modified by: Francesco Montorsi
8 // Copyright: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_COLOUR_H_BASE_
13 #define _WX_COLOUR_H_BASE_
16 #include "wx/gdiobj.h"
19 class WXDLLEXPORT wxColour
;
21 // the standard wxColour constructors;
22 // this macro avoids to repeat these lines across all colour.h files, since
23 // Set() is a virtual function and thus cannot be called by wxColourBase
25 #define DEFINE_STD_WXCOLOUR_CONSTRUCTORS \
26 wxColour( ChannelType red, ChannelType green, ChannelType blue, \
27 ChannelType alpha = wxALPHA_OPAQUE ) \
28 { Set(red, green, blue, alpha); } \
29 wxColour( unsigned long colRGB ) { Set(colRGB); } \
30 wxColour(const wxString &colourName) { Set(colourName); } \
31 wxColour(const wxChar *colourName) { Set(colourName); }
34 // flags for wxColour -> wxString conversion (see wxColour::GetAsString)
35 #define wxC2S_NAME 1 // return colour name, when possible
36 #define wxC2S_CSS_SYNTAX 2 // return colour in rgb(r,g,b) syntax
37 #define wxC2S_HTML_SYNTAX 4 // return colour in #rrggbb syntax
40 const unsigned char wxALPHA_TRANSPARENT
= 0;
41 const unsigned char wxALPHA_OPAQUE
= 0xff;
43 // ----------------------------------------------------------------------------
45 // ----------------------------------------------------------------------------
48 #include "wx/variant.h"
49 DECLARE_VARIANT_OBJECT_EXPORTED(wxColour
,WXDLLEXPORT
)
52 //-----------------------------------------------------------------------------
53 // wxColourBase: this class has no data members, just some functions to avoid
54 // code redundancy in all native wxColour implementations
55 //-----------------------------------------------------------------------------
57 class WXDLLEXPORT wxColourBase
: public wxGDIObject
60 // type of a single colour component
61 typedef unsigned char ChannelType
;
64 virtual ~wxColourBase() {}
70 void Set(ChannelType red
,
73 ChannelType alpha
= wxALPHA_OPAQUE
)
74 { InitRGBA(red
,green
,blue
, alpha
); }
76 // implemented in colourcmn.cpp
77 bool Set(const wxChar
*str
)
78 { return FromString(str
); }
80 bool Set(const wxString
&str
)
81 { return FromString(str
); }
83 void Set(unsigned long colRGB
)
85 // we don't need to know sizeof(long) here because we assume that the three
86 // least significant bytes contain the R, G and B values
87 Set((ChannelType
)colRGB
,
88 (ChannelType
)(colRGB
>> 8),
89 (ChannelType
)(colRGB
>> 16));
97 virtual bool Ok() const = 0;
99 virtual ChannelType
Red() const = 0;
100 virtual ChannelType
Green() const = 0;
101 virtual ChannelType
Blue() const = 0;
102 virtual ChannelType
Alpha() const
103 { return wxALPHA_OPAQUE
; }
105 // implemented in colourcmn.cpp
106 virtual wxString
GetAsString(long flags
= wxC2S_NAME
| wxC2S_CSS_SYNTAX
) const;
113 #if WXWIN_COMPATIBILITY_2_6
114 wxDEPRECATED( static wxColour
CreateByName(const wxString
& name
) );
115 wxDEPRECATED( void InitFromName(const wxString
& col
) );
120 InitRGBA(ChannelType r
, ChannelType g
, ChannelType b
, ChannelType a
) = 0;
122 virtual bool FromString(const wxChar
*s
);
127 #if defined(__WXPALMOS__)
128 #include "wx/generic/colour.h"
129 #elif defined(__WXMSW__)
130 #include "wx/msw/colour.h"
131 #elif defined(__WXMOTIF__)
132 #include "wx/motif/colour.h"
133 #elif defined(__WXGTK20__)
134 #include "wx/gtk/colour.h"
135 #elif defined(__WXGTK__)
136 #include "wx/gtk1/colour.h"
137 #elif defined(__WXMGL__)
138 #include "wx/generic/colour.h"
139 #elif defined(__WXDFB__)
140 #include "wx/generic/colour.h"
141 #elif defined(__WXX11__)
142 #include "wx/x11/colour.h"
143 #elif defined(__WXMAC__)
144 #include "wx/mac/colour.h"
145 #elif defined(__WXCOCOA__)
146 #include "wx/cocoa/colour.h"
147 #elif defined(__WXPM__)
148 #include "wx/os2/colour.h"
151 #define wxColor wxColour
153 #endif // _WX_COLOUR_H_BASE_