]>
Commit | Line | Data |
---|---|---|
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 | ||
14 | A colour is an object representing a combination of Red, Green, and Blue (RGB) intensity values, | |
15 | and is used to determine drawing colours. See the | |
16 | entry for \helpref{wxColourDatabase}{wxcolourdatabase} for how a pointer to a predefined, | |
17 | named colour may be returned instead of creating a new colour. | |
18 | ||
19 | Valid RGB values are in the range 0 to 255. | |
20 | ||
8161ba08 JS |
21 | You 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 | ||
33 | Objects: | |
34 | ||
35 | {\bf wxNullColour} | |
36 | ||
37 | Pointers: | |
38 | ||
39 | {\bf wxBLACK\\ | |
40 | wxWHITE\\ | |
41 | wxRED\\ | |
42 | wxBLUE\\ | |
43 | wxGREEN\\ | |
44 | wxCYAN\\ | |
45 | wxLIGHT\_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 | ||
59 | Default constructor. | |
60 | ||
edc536d3 | 61 | \func{}{wxColour}{\param{unsigned char}{ red}, \param{unsigned char}{ green}, \param{unsigned char}{ blue}} |
a660d684 KB |
62 | |
63 | Constructs a colour from red, green and blue values. | |
64 | ||
65 | \func{}{wxColour}{\param{const wxString\& }{colourNname}} | |
66 | ||
40989e46 | 67 | Constructs a colour using the given string. See \helpref{Set}{wxcolourset3} for more info. |
a660d684 | 68 | |
1e6d9499 JS |
69 | \func{}{wxColour}{\param{const wxColour\&}{ colour}} |
70 | ||
71 | Copy 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 | ||
102 | Returns the blue intensity. | |
103 | ||
c50f92d0 | 104 | |
40989e46 WS |
105 | \membersection{wxColour::GetAsString}\label{wxcolourgetasstring} |
106 | ||
107 | \constfunc{wxString}{GetAsString}{\param{long}{ flags}} | |
108 | ||
109 | Converts this colour to a \helpref{wxString}{wxstring} | |
110 | using the given {\it flags}. | |
111 | ||
669b0c0a MR |
112 | The supported flags are {\bf wxC2S\_NAME}, to obtain the colour |
113 | name (e.g. wxColour(255,0,0) -> \texttt{``red"}), {\bf wxC2S\_CSS\_SYNTAX}, to obtain | |
40989e46 | 114 | the 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 |
116 | the colour as \texttt{``\#"} followed by 6 hexadecimal digits |
117 | (e.g. wxColour(255,0,0) -> \texttt{``\#FF0000"}). | |
118 | ||
119 | This 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 | ||
127 | Returns a pixel value which is platform-dependent. On Windows, a COLORREF is returned. | |
128 | On 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 | ||
137 | Returns the green intensity. | |
138 | ||
c50f92d0 | 139 | |
a660d684 KB |
140 | \membersection{wxColour::Ok}\label{wxcolourok} |
141 | ||
142 | \constfunc{bool}{Ok}{\void} | |
143 | ||
c50f92d0 VZ |
144 | Returns \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 | ||
151 | Returns 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 KB |
157 | |
158 | Sets the RGB intensity values. | |
159 | ||
c50f92d0 | 160 | |
40989e46 WS |
161 | \membersection{wxColour::Set}\label{wxcolourset2} |
162 | ||
163 | \func{void}{Set}{\param{unsigned long}{ RGB}} | |
164 | ||
165 | Sets the RGB intensity values extracting them from the packed long. | |
166 | ||
167 | ||
168 | \membersection{wxColour::Set}\label{wxcolourset3} | |
169 | ||
170 | \func{bool}{Set}{\param{const wxString \&}{ str}} | |
171 | ||
172 | Sets the colour using the given string. | |
173 | 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). | |
174 | ||
175 | Returns \true if the conversion was successful, \false otherwise. | |
176 | ||
78b5edc5 MR |
177 | \newsince{2.7.0} |
178 | ||
40989e46 | 179 | |
a660d684 KB |
180 | \membersection{wxColour::operator $=$}\label{wxcolourassign} |
181 | ||
182 | \func{wxColour\&}{operator $=$}{\param{const wxColour\&}{ colour}} | |
183 | ||
184 | Assignment operator, taking another colour object. | |
185 | ||
186 | \func{wxColour\&}{operator $=$}{\param{const wxString\&}{ colourName}} | |
187 | ||
188 | Assignment operator, using a colour name to be found in the colour database. | |
189 | ||
190 | \wxheading{See also} | |
191 | ||
192 | \helpref{wxColourDatabase}{wxcolourdatabase} | |
193 | ||
c50f92d0 | 194 | |
a660d684 KB |
195 | \membersection{wxColour::operator $==$}\label{wxcolourequality} |
196 | ||
197 | \func{bool}{operator $==$}{\param{const wxColour\&}{ colour}} | |
198 | ||
199 | Tests the equality of two colours by comparing individual red, green blue colours. | |
200 | ||
c50f92d0 | 201 | |
a660d684 KB |
202 | \membersection{wxColour::operator $!=$}\label{wxcolourinequality} |
203 | ||
204 | \func{bool}{operator $!=$}{\param{const wxColour\&}{ colour}} | |
205 | ||
206 | Tests the inequality of two colours by comparing individual red, green blue colours. | |
207 | ||
a660d684 KB |
208 | \section{\class{wxColourData}}\label{wxcolourdata} |
209 | ||
210 | This class holds a variety of information related to colour dialogs. | |
211 | ||
212 | \wxheading{Derived from} | |
213 | ||
214 | \helpref{wxObject}{wxobject} | |
215 | ||
954b8ae6 JS |
216 | \wxheading{Include files} |
217 | ||
218 | <wx/cmndata.h> | |
219 | ||
a660d684 KB |
220 | \wxheading{See also} |
221 | ||
222 | \helpref{wxColour}{wxcolour}, \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxColourDialog overview}{wxcolourdialogoverview} | |
223 | ||
224 | \latexignore{\rtfignore{\wxheading{Members}}} | |
225 | ||
c50f92d0 | 226 | |
f510b7b2 | 227 | \membersection{wxColourData::wxColourData}\label{wxcolourdatactor} |
a660d684 KB |
228 | |
229 | \func{}{wxColourData}{\void} | |
230 | ||
393c836c VS |
231 | Constructor. Initializes the custom colours to {\tt wxNullColour}, |
232 | the {\it data colour} setting | |
cc81d32f | 233 | to black, and the {\it choose full} setting to true. |
a660d684 | 234 | |
c50f92d0 | 235 | |
f510b7b2 | 236 | \membersection{wxColourData::\destruct{wxColourData}}\label{wxcolourdatadtor} |
a660d684 KB |
237 | |
238 | \func{}{\destruct{wxColourData}}{\void} | |
239 | ||
240 | Destructor. | |
241 | ||
c50f92d0 | 242 | |
a660d684 KB |
243 | \membersection{wxColourData::GetChooseFull}\label{wxcolourdatagetchoosefull} |
244 | ||
245 | \constfunc{bool}{GetChooseFull}{\void} | |
246 | ||
247 | Under Windows, determines whether the Windows colour dialog will display the full dialog | |
f5d9cc73 WS |
248 | with custom colour selection controls. Under PalmOS, determines whether colour dialog |
249 | will display full rgb colour picker or only available palette indexer. | |
250 | Has no meaning under other platforms. | |
a660d684 | 251 | |
cc81d32f | 252 | The default value is true. |
a660d684 | 253 | |
c50f92d0 | 254 | |
a660d684 KB |
255 | \membersection{wxColourData::GetColour}\label{wxcolourdatagetcolour} |
256 | ||
257 | \constfunc{wxColour\&}{GetColour}{\void} | |
258 | ||
259 | Gets the current colour associated with the colour dialog. | |
260 | ||
261 | The default colour is black. | |
262 | ||
c50f92d0 | 263 | |
a660d684 KB |
264 | \membersection{wxColourData::GetCustomColour}\label{wxcolourdatagetcustomcolour} |
265 | ||
eaaa6a06 | 266 | \constfunc{wxColour\&}{GetCustomColour}{\param{int}{ i}} |
a660d684 KB |
267 | |
268 | Gets the {\it i}th custom colour associated with the colour dialog. {\it i} should | |
269 | be an integer between 0 and 15. | |
270 | ||
393c836c | 271 | The default custom colours are invalid colours. |
a660d684 | 272 | |
c50f92d0 | 273 | |
a660d684 KB |
274 | \membersection{wxColourData::SetChooseFull}\label{wxcolourdatasetchoosefull} |
275 | ||
276 | \func{void}{SetChooseFull}{\param{const bool }{flag}} | |
277 | ||
278 | Under Windows, tells the Windows colour dialog to display the full dialog | |
279 | with custom colour selection controls. Under other platforms, has no effect. | |
280 | ||
cc81d32f | 281 | The default value is true. |
a660d684 | 282 | |
c50f92d0 | 283 | |
a660d684 KB |
284 | \membersection{wxColourData::SetColour}\label{wxcolourdatasetcolour} |
285 | ||
286 | \func{void}{SetColour}{\param{const wxColour\&}{ colour}} | |
287 | ||
288 | Sets the default colour for the colour dialog. | |
289 | ||
290 | The default colour is black. | |
291 | ||
c50f92d0 | 292 | |
a660d684 KB |
293 | \membersection{wxColourData::SetCustomColour}\label{wxcolourdatasetcustomcolour} |
294 | ||
f6bcfd97 | 295 | \func{void}{SetCustomColour}{\param{int}{ i}, \param{const wxColour\&}{ colour}} |
a660d684 KB |
296 | |
297 | Sets the {\it i}th custom colour for the colour dialog. {\it i} should | |
298 | be an integer between 0 and 15. | |
299 | ||
393c836c | 300 | The default custom colours are invalid colours. |
a660d684 | 301 | |
c50f92d0 | 302 | |
a660d684 KB |
303 | \membersection{wxColourData::operator $=$}\label{wxcolourdataassign} |
304 | ||
305 | \func{void}{operator $=$}{\param{const wxColourData\&}{ data}} | |
306 | ||
2edb0bde | 307 | Assignment operator for the colour data. |
a660d684 | 308 | |
c50f92d0 VZ |
309 | |
310 | ||
311 | ||
a660d684 KB |
312 | \section{\class{wxColourDatabase}}\label{wxcolourdatabase} |
313 | ||
fc2171bd | 314 | wxWidgets maintains a database of standard RGB colours for a predefined |
a660d684 | 315 | set of named colours (such as ``BLACK'', ``LIGHT GREY''). The |
edc536d3 | 316 | application may add to this set if desired by using |
c50f92d0 VZ |
317 | \helpref{AddColour}{wxcolourdatabaseaddcolour} and may use it to look up |
318 | colours by names using \helpref{Find}{wxcolourdatabasefind} or find the names | |
319 | for the standard colour suing \helpref{FindName}{wxcolourdatabasefindname}. | |
320 | ||
edc536d3 | 321 | There is one predefined instance of this class called |
c50f92d0 | 322 | {\bf wxTheColourDatabase}. |
a660d684 KB |
323 | |
324 | \wxheading{Derived from} | |
325 | ||
8f520a56 | 326 | None |
a660d684 | 327 | |
954b8ae6 JS |
328 | \wxheading{Include files} |
329 | ||
330 | <wx/gdicmn.h> | |
331 | ||
a660d684 KB |
332 | \wxheading{Remarks} |
333 | ||
c50f92d0 | 334 | The standard database contains at least the following colours: |
a660d684 KB |
335 | |
336 | AQUAMARINE, BLACK, BLUE, BLUE VIOLET, BROWN, CADET BLUE, CORAL, | |
337 | CORNFLOWER BLUE, CYAN, DARK GREY, DARK GREEN, DARK OLIVE GREEN, DARK | |
338 | ORCHID, DARK SLATE BLUE, DARK SLATE GREY DARK TURQUOISE, DIM GREY, | |
339 | FIREBRICK, FOREST GREEN, GOLD, GOLDENROD, GREY, GREEN, GREEN YELLOW, | |
340 | INDIAN RED, KHAKI, LIGHT BLUE, LIGHT GREY, LIGHT STEEL BLUE, LIME GREEN, | |
341 | MAGENTA, MAROON, MEDIUM AQUAMARINE, MEDIUM BLUE, MEDIUM FOREST GREEN, | |
342 | MEDIUM GOLDENROD, MEDIUM ORCHID, MEDIUM SEA GREEN, MEDIUM SLATE BLUE, | |
343 | MEDIUM SPRING GREEN, MEDIUM TURQUOISE, MEDIUM VIOLET RED, MIDNIGHT BLUE, | |
344 | NAVY, ORANGE, ORANGE RED, ORCHID, PALE GREEN, PINK, PLUM, PURPLE, RED, | |
345 | SALMON, SEA GREEN, SIENNA, SKY BLUE, SLATE BLUE, SPRING GREEN, STEEL | |
346 | BLUE, TAN, THISTLE, TURQUOISE, VIOLET, VIOLET RED, WHEAT, WHITE, YELLOW, | |
347 | YELLOW GREEN. | |
348 | ||
349 | \wxheading{See also} | |
350 | ||
351 | \helpref{wxColour}{wxcolour} | |
352 | ||
353 | \latexignore{\rtfignore{\wxheading{Members}}} | |
354 | ||
c50f92d0 | 355 | |
a660d684 KB |
356 | \membersection{wxColourDatabase::wxColourDatabase}\label{wxcolourdatabaseconstr} |
357 | ||
358 | \func{}{wxColourDatabase}{\void} | |
359 | ||
c50f92d0 VZ |
360 | Constructs the colour database. It will be initialized at the first use. |
361 | ||
a660d684 | 362 | |
8f520a56 MB |
363 | \membersection{wxColourDatabase::AddColour}\label{wxcolourdatabaseaddcolour} |
364 | ||
c50f92d0 VZ |
365 | \func{void}{AddColour}{\param{const wxString\& }{colourName}, \param{const wxColour\&}{colour}} |
366 | ||
8f520a56 MB |
367 | \func{void}{AddColour}{\param{const wxString\& }{colourName}, \param{wxColour* }{colour}} |
368 | ||
369 | Adds a colour to the database. If a colour with the same name already exists, | |
370 | it is replaced. | |
371 | ||
c50f92d0 | 372 | Please note that the overload taking a pointer is deprecated and will be |
fc2171bd | 373 | removed in the next wxWidgets version, please don't use it. |
c50f92d0 VZ |
374 | |
375 | ||
376 | \membersection{wxColourDatabase::Find}\label{wxcolourdatabasefind} | |
377 | ||
f6e9a818 | 378 | \func{wxColour}{Find}{\param{const wxString\& }{colourName}} |
c50f92d0 VZ |
379 | |
380 | Finds a colour given the name. Returns an invalid colour object (that is, such | |
381 | that its \helpref{Ok()}{wxcolourok} method returns \false) if the colour wasn't | |
382 | found in the database. | |
383 | ||
384 | ||
c50f92d0 | 385 | \membersection{wxColourDatabase::FindName}\label{wxcolourdatabasefindname} |
a660d684 | 386 | |
c50f92d0 | 387 | \constfunc{wxString}{FindName}{\param{const wxColour\&}{ colour}} |
a660d684 | 388 | |
c50f92d0 VZ |
389 | Finds a colour name given the colour. Returns an empty string if the colour is |
390 | not found in the database. |