1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxColour docs
5 %% Modified by: Francesco Montorsi
8 %% Copyright: (c) wxWidgets
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxColour
}}\label{wxcolour
}
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.
19 Valid RGB values are in the range
0 to
255.
21 You can retrieve the current system colour settings with
\helpref{wxSystemSettings
}{wxsystemsettings
}.
23 \wxheading{Derived from
}
25 \helpref{wxObject
}{wxobject
}
27 \wxheading{Include files
}
33 \helpref{wxCore
}{librarieslist
}
35 \wxheading{Predefined objects
}
53 \helpref{wxColourDatabase
}{wxcolourdatabase
},
\helpref{wxPen
}{wxpen
},
\helpref{wxBrush
}{wxbrush
},
\rtfsp
54 \helpref{wxColourDialog
}{wxcolourdialog
},
\helpref{wxSystemSettings
}{wxsystemsettings
}
56 \latexignore{\rtfignore{\wxheading{Members
}}}
59 \membersection{wxColour::wxColour
}\label{wxcolourconstr
}
61 \func{}{wxColour
}{\void}
65 \func{}{wxColour
}{\param{unsigned char
}{ red
},
\param{unsigned char
}{ green
},
\param{unsigned char
}{ blue
},
\param{unsigned char
}{ alpha=wxALPHA
\_OPAQUE}}
67 Constructs a colour from red, green, blue and alpha values.
69 \func{}{wxColour
}{\param{const wxString\&
}{colourNname
}}
71 Constructs a colour using the given string. See
\helpref{Set
}{wxcolourset
} for more info.
73 \func{}{wxColour
}{\param{const wxColour\&
}{ colour
}}
77 \wxheading{Parameters
}
79 \docparam{red
}{The red value.
}
81 \docparam{green
}{The green value.
}
83 \docparam{blue
}{The blue value.
}
85 \docparam{alpha
}{The alpha value. Alpha values range from
0 (wxALPHA
\_TRANSPARENT) to
255 (wxALPHA
\_OPAQUE).
}
87 \docparam{colourName
}{The colour name.
}
89 \docparam{colour
}{The colour to copy.
}
93 \helpref{wxColourDatabase
}{wxcolourdatabase
}
95 \pythonnote{Constructors supported by wxPython are:
\par
96 \indented{2cm
}{\begin{twocollist
}
97 \twocolitem{{\bf wxColour(red=
0, green=
0, blue=
0)
}}{}
98 \twocolitem{{\bf wxNamedColour(name)
}}{}
104 \membersection{wxColour::Alpha
}\label{wxcolouralpha
}
106 \constfunc{unsigned char
}{Alpha
}{\void}
108 Returns the alpha value, on platforms where alpha is not yet supported, this always returns wxALPHA
\_OPAQUE.
111 \membersection{wxColour::Blue
}\label{wxcolourblue
}
113 \constfunc{unsigned char
}{Blue
}{\void}
115 Returns the blue intensity.
118 \membersection{wxColour::GetAsString
}\label{wxcolourgetasstring
}
120 \constfunc{wxString
}{GetAsString
}{\param{long
}{ flags
}}
122 Converts this colour to a
\helpref{wxString
}{wxstring
}
123 using the given
{\it flags
}.
125 The supported flags are
\textbf{wxC2S
\_NAME}, to obtain the colour name (e.g.
126 wxColour(
255,
0,
0) ->
\texttt{``red"
}),
\textbf{wxC2S
\_CSS\_SYNTAX}, to obtain
127 the 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
130 by
6 hexadecimal digits (e.g. wxColour(
255,
0,
0) ->
\texttt{``\#FF0000"
}).
132 This function never fails and always returns a non-empty string but asserts if
133 the colour has alpha channel (i.e. is non opaque) but
134 \textbf{wxC2S
\_CSS\_SYNTAX} (which is the only one supporting alpha) is not
140 \membersection{wxColour::GetPixel
}\label{wxcolourgetpixel
}
142 \constfunc{long
}{GetPixel
}{\void}
144 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is returned.
145 On X, an allocated pixel value is returned.
147 -
1 is returned if the pixel is invalid (on X, unallocated).
150 \membersection{wxColour::Green
}\label{wxcolourgreen
}
152 \constfunc{unsigned char
}{Green
}{\void}
154 Returns the green intensity.
157 \membersection{wxColour::IsOk
}\label{wxcolourisok
}
159 \constfunc{bool
}{IsOk
}{\void}
161 Returns
\true if the colour object is valid (the colour has been initialised with RGB values).
164 \membersection{wxColour::Red
}\label{wxcolourred
}
166 \constfunc{unsigned char
}{Red
}{\void}
168 Returns the red intensity.
171 \membersection{wxColour::Set
}\label{wxcolourset
}
173 \func{void
}{Set
}{\param{unsigned char
}{ red
},
\param{unsigned char
}{ green
},
\param{unsigned char
}{ blue
},
\param{unsigned char
}{ alpha=wxALPHA
\_OPAQUE}}
175 \func{void
}{Set
}{\param{unsigned long
}{ RGB
}}
177 \func{bool
}{Set
}{\param{const wxString \&
}{ str
}}
179 Sets the RGB intensity values using the given values (first overload), extracting them from the packed long (second overload), using the given string (third overloard).
181 When 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)
184 and the HTML-like syntax (i.e.
\texttt{``\#"
} followed by
6 hexadecimal digits
185 for red, green, blue components).
187 Returns
\true if the conversion was successful,
\false otherwise.
192 \membersection{wxColour::operator $=$
}\label{wxcolourassign
}
194 \func{wxColour\&
}{operator $=$
}{\param{const wxColour\&
}{ colour
}}
196 Assignment operator, taking another colour object.
198 \func{wxColour\&
}{operator $=$
}{\param{const wxString\&
}{ colourName
}}
200 Assignment operator, using a colour name to be found in the colour database.
204 \helpref{wxColourDatabase
}{wxcolourdatabase
}
207 \membersection{wxColour::operator $==$
}\label{wxcolourequality
}
209 \func{bool
}{operator $==$
}{\param{const wxColour\&
}{ colour
}}
211 Tests the equality of two colours by comparing individual red, green, blue colours and alpha values.
214 \membersection{wxColour::operator $!=$
}\label{wxcolourinequality
}
216 \func{bool
}{operator $!=$
}{\param{const wxColour\&
}{ colour
}}
218 Tests the inequality of two colours by comparing individual red, green, blue colours and alpha values.
220 \section{\class{wxColourData
}}\label{wxcolourdata
}
222 This class holds a variety of information related to colour dialogs.
224 \wxheading{Derived from
}
226 \helpref{wxObject
}{wxobject
}
228 \wxheading{Include files
}
234 \helpref{wxCore
}{librarieslist
}
238 \helpref{wxColour
}{wxcolour
},
\helpref{wxColourDialog
}{wxcolourdialog
},
\helpref{wxColourDialog overview
}{wxcolourdialogoverview
}
240 \latexignore{\rtfignore{\wxheading{Members
}}}
243 \membersection{wxColourData::wxColourData
}\label{wxcolourdatactor
}
245 \func{}{wxColourData
}{\void}
247 Constructor. Initializes the custom colours to
{\tt wxNullColour
},
248 the
{\it data colour
} setting
249 to black, and the
{\it choose full
} setting to true.
252 \membersection{wxColourData::
\destruct{wxColourData
}}\label{wxcolourdatadtor
}
254 \func{}{\destruct{wxColourData
}}{\void}
259 \membersection{wxColourData::GetChooseFull
}\label{wxcolourdatagetchoosefull
}
261 \constfunc{bool
}{GetChooseFull
}{\void}
263 Under Windows, determines whether the Windows colour dialog will display the full dialog
264 with custom colour selection controls. Under PalmOS, determines whether colour dialog
265 will display full rgb colour picker or only available palette indexer.
266 Has no meaning under other platforms.
268 The default value is true.
271 \membersection{wxColourData::GetColour
}\label{wxcolourdatagetcolour
}
273 \constfunc{wxColour\&
}{GetColour
}{\void}
275 Gets the current colour associated with the colour dialog.
277 The default colour is black.
280 \membersection{wxColourData::GetCustomColour
}\label{wxcolourdatagetcustomcolour
}
282 \constfunc{wxColour\&
}{GetCustomColour
}{\param{int
}{ i
}}
284 Gets the
{\it i
}th custom colour associated with the colour dialog.
{\it i
} should
285 be an integer between
0 and
15.
287 The default custom colours are invalid colours.
290 \membersection{wxColourData::SetChooseFull
}\label{wxcolourdatasetchoosefull
}
292 \func{void
}{SetChooseFull
}{\param{const bool
}{flag
}}
294 Under Windows, tells the Windows colour dialog to display the full dialog
295 with custom colour selection controls. Under other platforms, has no effect.
297 The default value is true.
300 \membersection{wxColourData::SetColour
}\label{wxcolourdatasetcolour
}
302 \func{void
}{SetColour
}{\param{const wxColour\&
}{ colour
}}
304 Sets the default colour for the colour dialog.
306 The default colour is black.
309 \membersection{wxColourData::SetCustomColour
}\label{wxcolourdatasetcustomcolour
}
311 \func{void
}{SetCustomColour
}{\param{int
}{ i
},
\param{const wxColour\&
}{ colour
}}
313 Sets the
{\it i
}th custom colour for the colour dialog.
{\it i
} should
314 be an integer between
0 and
15.
316 The default custom colours are invalid colours.
319 \membersection{wxColourData::operator $=$
}\label{wxcolourdataassign
}
321 \func{void
}{operator $=$
}{\param{const wxColourData\&
}{ data
}}
323 Assignment operator for the colour data.
328 \section{\class{wxColourDatabase
}}\label{wxcolourdatabase
}
330 wxWidgets maintains a database of standard RGB colours for a predefined
331 set of named colours (such as ``BLACK'', ``LIGHT GREY''). The
332 application may add to this set if desired by using
333 \helpref{AddColour
}{wxcolourdatabaseaddcolour
} and may use it to look up
334 colours by names using
\helpref{Find
}{wxcolourdatabasefind
} or find the names
335 for the standard colour suing
\helpref{FindName
}{wxcolourdatabasefindname
}.
337 There is one predefined instance of this class called
338 {\bf wxTheColourDatabase
}.
340 \wxheading{Derived from
}
344 \wxheading{Include files
}
350 \helpref{wxCore
}{librarieslist
}
354 The standard database contains at least the following colours:
356 AQUAMARINE, BLACK, BLUE, BLUE VIOLET, BROWN, CADET BLUE, CORAL,
357 CORNFLOWER BLUE, CYAN, DARK GREY, DARK GREEN, DARK OLIVE GREEN, DARK
358 ORCHID, DARK SLATE BLUE, DARK SLATE GREY DARK TURQUOISE, DIM GREY,
359 FIREBRICK, FOREST GREEN, GOLD, GOLDENROD, GREY, GREEN, GREEN YELLOW,
360 INDIAN RED, KHAKI, LIGHT BLUE, LIGHT GREY, LIGHT STEEL BLUE, LIME GREEN,
361 MAGENTA, MAROON, MEDIUM AQUAMARINE, MEDIUM BLUE, MEDIUM FOREST GREEN,
362 MEDIUM GOLDENROD, MEDIUM ORCHID, MEDIUM SEA GREEN, MEDIUM SLATE BLUE,
363 MEDIUM SPRING GREEN, MEDIUM TURQUOISE, MEDIUM VIOLET RED, MIDNIGHT BLUE,
364 NAVY, ORANGE, ORANGE RED, ORCHID, PALE GREEN, PINK, PLUM, PURPLE, RED,
365 SALMON, SEA GREEN, SIENNA, SKY BLUE, SLATE BLUE, SPRING GREEN, STEEL
366 BLUE, TAN, THISTLE, TURQUOISE, VIOLET, VIOLET RED, WHEAT, WHITE, YELLOW,
371 \helpref{wxColour
}{wxcolour
}
373 \latexignore{\rtfignore{\wxheading{Members
}}}
376 \membersection{wxColourDatabase::wxColourDatabase
}\label{wxcolourdatabaseconstr
}
378 \func{}{wxColourDatabase
}{\void}
380 Constructs the colour database. It will be initialized at the first use.
383 \membersection{wxColourDatabase::AddColour
}\label{wxcolourdatabaseaddcolour
}
385 \func{void
}{AddColour
}{\param{const wxString\&
}{colourName
},
\param{const wxColour\&
}{colour
}}
387 \func{void
}{AddColour
}{\param{const wxString\&
}{colourName
},
\param{wxColour*
}{colour
}}
389 Adds a colour to the database. If a colour with the same name already exists,
392 Please note that the overload taking a pointer is deprecated and will be
393 removed in the next wxWidgets version, please don't use it.
396 \membersection{wxColourDatabase::Find
}\label{wxcolourdatabasefind
}
398 \func{wxColour
}{Find
}{\param{const wxString\&
}{colourName
}}
400 Finds a colour given the name. Returns an invalid colour object (that is, such
401 that its
\helpref{Ok()
}{wxcolourisok
} method returns
\false) if the colour wasn't
402 found in the database.
405 \membersection{wxColourDatabase::FindName
}\label{wxcolourdatabasefindname
}
407 \constfunc{wxString
}{FindName
}{\param{const wxColour\&
}{ colour
}}
409 Finds a colour name given the colour. Returns an empty string if the colour is
410 not found in the database.