]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/colour.tex
wxPlatformInfo::IsUsingUniversalWidgets() was broken by design, it couldn't work...
[wxWidgets.git] / docs / latex / wx / colour.tex
CommitLineData
edc536d3
WS
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: colour.tex
3%% Purpose: wxColour docs
4%% Author:
40989e46 5%% Modified by: Francesco Montorsi
edc536d3
WS
6%% Created:
7%% RCS-ID: $Id$
8%% Copyright: (c) wxWidgets
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
a660d684
KB
12\section{\class{wxColour}}\label{wxcolour}
13
14A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values,
15and is used to determine drawing colours. See the
16entry for \helpref{wxColourDatabase}{wxcolourdatabase} for how a pointer to a predefined,
17named colour may be returned instead of creating a new colour.
18
19Valid RGB values are in the range 0 to 255.
20
8161ba08
JS
21You can retrieve the current system colour settings with \helpref{wxSystemSettings}{wxsystemsettings}.
22
a660d684
KB
23\wxheading{Derived from}
24
25\helpref{wxObject}{wxobject}
26
954b8ae6
JS
27\wxheading{Include files}
28
29<wx/colour.h>
30
20e85460
JS
31\wxheading{Predefined objects}
32
33Objects:
34
35{\bf wxNullColour}
36
37Pointers:
38
39{\bf wxBLACK\\
40wxWHITE\\
41wxRED\\
42wxBLUE\\
43wxGREEN\\
44wxCYAN\\
45wxLIGHT\_GREY}
46
a660d684
KB
47\wxheading{See also}
48
49\helpref{wxColourDatabase}{wxcolourdatabase}, \helpref{wxPen}{wxpen}, \helpref{wxBrush}{wxbrush},\rtfsp
8161ba08 50\helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxSystemSettings}{wxsystemsettings}
a660d684
KB
51
52\latexignore{\rtfignore{\wxheading{Members}}}
53
c50f92d0 54
a660d684
KB
55\membersection{wxColour::wxColour}\label{wxcolourconstr}
56
57\func{}{wxColour}{\void}
58
59Default constructor.
60
edc536d3 61\func{}{wxColour}{\param{unsigned char}{ red}, \param{unsigned char}{ green}, \param{unsigned char}{ blue}}
a660d684
KB
62
63Constructs a colour from red, green and blue values.
64
65\func{}{wxColour}{\param{const wxString\& }{colourNname}}
66
7f9d7dea 67Constructs a colour using the given string. See \helpref{Set}{wxcolourset} for more info.
a660d684 68
1e6d9499
JS
69\func{}{wxColour}{\param{const wxColour\&}{ colour}}
70
71Copy constructor.
72
a660d684
KB
73\wxheading{Parameters}
74
75\docparam{red}{The red value.}
76
77\docparam{green}{The green value.}
78
79\docparam{blue}{The blue value.}
80
81\docparam{colourName}{The colour name.}
82
1e6d9499
JS
83\docparam{colour}{The colour to copy.}
84
a660d684
KB
85\wxheading{See also}
86
87\helpref{wxColourDatabase}{wxcolourdatabase}
88
06d20283
RD
89\pythonnote{Constructors supported by wxPython are:\par
90\indented{2cm}{\begin{twocollist}
c9110876
VS
91\twocolitem{{\bf wxColour(red=0, green=0, blue=0)}}{}
92\twocolitem{{\bf wxNamedColour(name)}}{}
06d20283
RD
93\end{twocollist}}
94}
95
96
c50f92d0 97
a660d684
KB
98\membersection{wxColour::Blue}\label{wxcolourblue}
99
100\constfunc{unsigned char}{Blue}{\void}
101
102Returns the blue intensity.
103
c50f92d0 104
40989e46
WS
105\membersection{wxColour::GetAsString}\label{wxcolourgetasstring}
106
107\constfunc{wxString}{GetAsString}{\param{long}{ flags}}
108
109Converts this colour to a \helpref{wxString}{wxstring}
110using the given {\it flags}.
111
669b0c0a
MR
112The supported flags are {\bf wxC2S\_NAME}, to obtain the colour
113name (e.g. wxColour(255,0,0) -> \texttt{``red"}), {\bf wxC2S\_CSS\_SYNTAX}, to obtain
40989e46 114the colour in the \texttt{``rgb(r,g,b)"} syntax
669b0c0a 115(e.g. wxColour(255,0,0) -> \texttt{``rgb(255,0,0)"}), and {\bf wxC2S\_HTML\_SYNTAX}, to obtain
40989e46
WS
116the colour as \texttt{``\#"} followed by 6 hexadecimal digits
117(e.g. wxColour(255,0,0) -> \texttt{``\#FF0000"}).
118
119This function never fails and always returns a non-empty string.
120
78b5edc5 121\newsince{2.7.0}
40989e46 122
a660d684
KB
123\membersection{wxColour::GetPixel}\label{wxcolourgetpixel}
124
125\constfunc{long}{GetPixel}{\void}
126
127Returns a pixel value which is platform-dependent. On Windows, a COLORREF is returned.
128On X, an allocated pixel value is returned.
129
130-1 is returned if the pixel is invalid (on X, unallocated).
131
c50f92d0 132
a660d684
KB
133\membersection{wxColour::Green}\label{wxcolourgreen}
134
135\constfunc{unsigned char}{Green}{\void}
136
137Returns the green intensity.
138
c50f92d0 139
a660d684
KB
140\membersection{wxColour::Ok}\label{wxcolourok}
141
142\constfunc{bool}{Ok}{\void}
143
c50f92d0
VZ
144Returns \true if the colour object is valid (the colour has been initialised with RGB values).
145
a660d684
KB
146
147\membersection{wxColour::Red}\label{wxcolourred}
148
149\constfunc{unsigned char}{Red}{\void}
150
151Returns the red intensity.
152
c50f92d0 153
a660d684
KB
154\membersection{wxColour::Set}\label{wxcolourset}
155
edc536d3 156\func{void}{Set}{\param{unsigned char}{ red}, \param{unsigned char}{ green}, \param{unsigned char}{ blue}}
a660d684 157
40989e46
WS
158\func{void}{Set}{\param{unsigned long}{ RGB}}
159
40989e46
WS
160\func{bool}{Set}{\param{const wxString \&}{ str}}
161
aaa6f9ba
RD
162Sets the RGB intensity values using the given values (first overload), extracting them from the packed long (second overload), using the given string (third overloard).
163
164When using third form, Set() accepts: colour names (those listed in \helpref{wxTheColourDatabase}{wxcolourdatabase}), the CSS-like \texttt{``RGB(r,g,b)"} syntax (case insensitive) and the HTML-like syntax (i.e. \texttt{``\#"} followed by 6 hexadecimal digits for red, green, blue components).
40989e46
WS
165
166Returns \true if the conversion was successful, \false otherwise.
167
78b5edc5
MR
168\newsince{2.7.0}
169
40989e46 170
a660d684
KB
171\membersection{wxColour::operator $=$}\label{wxcolourassign}
172
173\func{wxColour\&}{operator $=$}{\param{const wxColour\&}{ colour}}
174
175Assignment operator, taking another colour object.
176
177\func{wxColour\&}{operator $=$}{\param{const wxString\&}{ colourName}}
178
179Assignment operator, using a colour name to be found in the colour database.
180
181\wxheading{See also}
182
183\helpref{wxColourDatabase}{wxcolourdatabase}
184
c50f92d0 185
a660d684
KB
186\membersection{wxColour::operator $==$}\label{wxcolourequality}
187
188\func{bool}{operator $==$}{\param{const wxColour\&}{ colour}}
189
190Tests the equality of two colours by comparing individual red, green blue colours.
191
c50f92d0 192
a660d684
KB
193\membersection{wxColour::operator $!=$}\label{wxcolourinequality}
194
195\func{bool}{operator $!=$}{\param{const wxColour\&}{ colour}}
196
197Tests the inequality of two colours by comparing individual red, green blue colours.
198
a660d684
KB
199\section{\class{wxColourData}}\label{wxcolourdata}
200
201This class holds a variety of information related to colour dialogs.
202
203\wxheading{Derived from}
204
205\helpref{wxObject}{wxobject}
206
954b8ae6
JS
207\wxheading{Include files}
208
209<wx/cmndata.h>
210
a660d684
KB
211\wxheading{See also}
212
213\helpref{wxColour}{wxcolour}, \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxColourDialog overview}{wxcolourdialogoverview}
214
215\latexignore{\rtfignore{\wxheading{Members}}}
216
c50f92d0 217
f510b7b2 218\membersection{wxColourData::wxColourData}\label{wxcolourdatactor}
a660d684
KB
219
220\func{}{wxColourData}{\void}
221
393c836c
VS
222Constructor. Initializes the custom colours to {\tt wxNullColour},
223the {\it data colour} setting
cc81d32f 224to black, and the {\it choose full} setting to true.
a660d684 225
c50f92d0 226
f510b7b2 227\membersection{wxColourData::\destruct{wxColourData}}\label{wxcolourdatadtor}
a660d684
KB
228
229\func{}{\destruct{wxColourData}}{\void}
230
231Destructor.
232
c50f92d0 233
a660d684
KB
234\membersection{wxColourData::GetChooseFull}\label{wxcolourdatagetchoosefull}
235
236\constfunc{bool}{GetChooseFull}{\void}
237
238Under Windows, determines whether the Windows colour dialog will display the full dialog
f5d9cc73
WS
239with custom colour selection controls. Under PalmOS, determines whether colour dialog
240will display full rgb colour picker or only available palette indexer.
241Has no meaning under other platforms.
a660d684 242
cc81d32f 243The default value is true.
a660d684 244
c50f92d0 245
a660d684
KB
246\membersection{wxColourData::GetColour}\label{wxcolourdatagetcolour}
247
248\constfunc{wxColour\&}{GetColour}{\void}
249
250Gets the current colour associated with the colour dialog.
251
252The default colour is black.
253
c50f92d0 254
a660d684
KB
255\membersection{wxColourData::GetCustomColour}\label{wxcolourdatagetcustomcolour}
256
eaaa6a06 257\constfunc{wxColour\&}{GetCustomColour}{\param{int}{ i}}
a660d684
KB
258
259Gets the {\it i}th custom colour associated with the colour dialog. {\it i} should
260be an integer between 0 and 15.
261
393c836c 262The default custom colours are invalid colours.
a660d684 263
c50f92d0 264
a660d684
KB
265\membersection{wxColourData::SetChooseFull}\label{wxcolourdatasetchoosefull}
266
267\func{void}{SetChooseFull}{\param{const bool }{flag}}
268
269Under Windows, tells the Windows colour dialog to display the full dialog
270with custom colour selection controls. Under other platforms, has no effect.
271
cc81d32f 272The default value is true.
a660d684 273
c50f92d0 274
a660d684
KB
275\membersection{wxColourData::SetColour}\label{wxcolourdatasetcolour}
276
277\func{void}{SetColour}{\param{const wxColour\&}{ colour}}
278
279Sets the default colour for the colour dialog.
280
281The default colour is black.
282
c50f92d0 283
a660d684
KB
284\membersection{wxColourData::SetCustomColour}\label{wxcolourdatasetcustomcolour}
285
f6bcfd97 286\func{void}{SetCustomColour}{\param{int}{ i}, \param{const wxColour\&}{ colour}}
a660d684
KB
287
288Sets the {\it i}th custom colour for the colour dialog. {\it i} should
289be an integer between 0 and 15.
290
393c836c 291The default custom colours are invalid colours.
a660d684 292
c50f92d0 293
a660d684
KB
294\membersection{wxColourData::operator $=$}\label{wxcolourdataassign}
295
296\func{void}{operator $=$}{\param{const wxColourData\&}{ data}}
297
2edb0bde 298Assignment operator for the colour data.
a660d684 299
c50f92d0
VZ
300
301
302
a660d684
KB
303\section{\class{wxColourDatabase}}\label{wxcolourdatabase}
304
fc2171bd 305wxWidgets maintains a database of standard RGB colours for a predefined
a660d684 306set of named colours (such as ``BLACK'', ``LIGHT GREY''). The
edc536d3 307application may add to this set if desired by using
c50f92d0
VZ
308\helpref{AddColour}{wxcolourdatabaseaddcolour} and may use it to look up
309colours by names using \helpref{Find}{wxcolourdatabasefind} or find the names
310for the standard colour suing \helpref{FindName}{wxcolourdatabasefindname}.
311
edc536d3 312There is one predefined instance of this class called
c50f92d0 313{\bf wxTheColourDatabase}.
a660d684
KB
314
315\wxheading{Derived from}
316
8f520a56 317None
a660d684 318
954b8ae6
JS
319\wxheading{Include files}
320
321<wx/gdicmn.h>
322
a660d684
KB
323\wxheading{Remarks}
324
c50f92d0 325The standard database contains at least the following colours:
a660d684
KB
326
327AQUAMARINE, BLACK, BLUE, BLUE VIOLET, BROWN, CADET BLUE, CORAL,
328CORNFLOWER BLUE, CYAN, DARK GREY, DARK GREEN, DARK OLIVE GREEN, DARK
329ORCHID, DARK SLATE BLUE, DARK SLATE GREY DARK TURQUOISE, DIM GREY,
330FIREBRICK, FOREST GREEN, GOLD, GOLDENROD, GREY, GREEN, GREEN YELLOW,
331INDIAN RED, KHAKI, LIGHT BLUE, LIGHT GREY, LIGHT STEEL BLUE, LIME GREEN,
332MAGENTA, MAROON, MEDIUM AQUAMARINE, MEDIUM BLUE, MEDIUM FOREST GREEN,
333MEDIUM GOLDENROD, MEDIUM ORCHID, MEDIUM SEA GREEN, MEDIUM SLATE BLUE,
334MEDIUM SPRING GREEN, MEDIUM TURQUOISE, MEDIUM VIOLET RED, MIDNIGHT BLUE,
335NAVY, ORANGE, ORANGE RED, ORCHID, PALE GREEN, PINK, PLUM, PURPLE, RED,
336SALMON, SEA GREEN, SIENNA, SKY BLUE, SLATE BLUE, SPRING GREEN, STEEL
337BLUE, TAN, THISTLE, TURQUOISE, VIOLET, VIOLET RED, WHEAT, WHITE, YELLOW,
338YELLOW GREEN.
339
340\wxheading{See also}
341
342\helpref{wxColour}{wxcolour}
343
344\latexignore{\rtfignore{\wxheading{Members}}}
345
c50f92d0 346
a660d684
KB
347\membersection{wxColourDatabase::wxColourDatabase}\label{wxcolourdatabaseconstr}
348
349\func{}{wxColourDatabase}{\void}
350
c50f92d0
VZ
351Constructs the colour database. It will be initialized at the first use.
352
a660d684 353
8f520a56
MB
354\membersection{wxColourDatabase::AddColour}\label{wxcolourdatabaseaddcolour}
355
c50f92d0
VZ
356\func{void}{AddColour}{\param{const wxString\& }{colourName}, \param{const wxColour\&}{colour}}
357
8f520a56
MB
358\func{void}{AddColour}{\param{const wxString\& }{colourName}, \param{wxColour* }{colour}}
359
360Adds a colour to the database. If a colour with the same name already exists,
361it is replaced.
362
c50f92d0 363Please note that the overload taking a pointer is deprecated and will be
fc2171bd 364removed in the next wxWidgets version, please don't use it.
c50f92d0
VZ
365
366
367\membersection{wxColourDatabase::Find}\label{wxcolourdatabasefind}
368
f6e9a818 369\func{wxColour}{Find}{\param{const wxString\& }{colourName}}
c50f92d0
VZ
370
371Finds a colour given the name. Returns an invalid colour object (that is, such
372that its \helpref{Ok()}{wxcolourok} method returns \false) if the colour wasn't
373found in the database.
374
375
c50f92d0 376\membersection{wxColourDatabase::FindName}\label{wxcolourdatabasefindname}
a660d684 377
c50f92d0 378\constfunc{wxString}{FindName}{\param{const wxColour\&}{ colour}}
a660d684 379
c50f92d0
VZ
380Finds a colour name given the colour. Returns an empty string if the colour is
381not found in the database.