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