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
}
31 \wxheading{Predefined objects
}
49 \helpref{wxColourDatabase
}{wxcolourdatabase
},
\helpref{wxPen
}{wxpen
},
\helpref{wxBrush
}{wxbrush
},
\rtfsp
50 \helpref{wxColourDialog
}{wxcolourdialog
},
\helpref{wxSystemSettings
}{wxsystemsettings
}
52 \latexignore{\rtfignore{\wxheading{Members
}}}
55 \membersection{wxColour::wxColour
}\label{wxcolourconstr
}
57 \func{}{wxColour
}{\void}
61 \func{}{wxColour
}{\param{unsigned char
}{ red
},
\param{unsigned char
}{ green
},
\param{unsigned char
}{ blue
},
\param{unsigned char
}{ alpha=wxALPHA
\_OPAQUE}}
63 Constructs a colour from red, green, blue and alpha values.
65 \func{}{wxColour
}{\param{const wxString\&
}{colourNname
}}
67 Constructs a colour using the given string. See
\helpref{Set
}{wxcolourset
} for more info.
69 \func{}{wxColour
}{\param{const wxColour\&
}{ colour
}}
73 \wxheading{Parameters
}
75 \docparam{red
}{The red value.
}
77 \docparam{green
}{The green value.
}
79 \docparam{blue
}{The blue value.
}
81 \docparam{alpha
}{The alpha value. Alpha values range from
0 (wxALPHA
\_TRANSPARENT) to
255 (wxALPHA
\_OPAQUE).
}
83 \docparam{colourName
}{The colour name.
}
85 \docparam{colour
}{The colour to copy.
}
89 \helpref{wxColourDatabase
}{wxcolourdatabase
}
91 \pythonnote{Constructors supported by wxPython are:
\par
92 \indented{2cm
}{\begin{twocollist
}
93 \twocolitem{{\bf wxColour(red=
0, green=
0, blue=
0)
}}{}
94 \twocolitem{{\bf wxNamedColour(name)
}}{}
100 \membersection{wxColour::Alpha
}\label{wxcolouralpha
}
102 \constfunc{unsigned char
}{Alpha
}{\void}
104 Returns the alpha value, on platforms where alpha is not yet supported, this always returns wxALPHA
\_OPAQUE.
107 \membersection{wxColour::Blue
}\label{wxcolourblue
}
109 \constfunc{unsigned char
}{Blue
}{\void}
111 Returns the blue intensity.
114 \membersection{wxColour::GetAsString
}\label{wxcolourgetasstring
}
116 \constfunc{wxString
}{GetAsString
}{\param{long
}{ flags
}}
118 Converts this colour to a
\helpref{wxString
}{wxstring
}
119 using the given
{\it flags
}.
121 The supported flags are
\textbf{wxC2S
\_NAME}, to obtain the colour name (e.g.
122 wxColour(
255,
0,
0) ->
\texttt{``red"
}),
\textbf{wxC2S
\_CSS\_SYNTAX}, to obtain
123 the colour in the
\texttt{``rgb(r,g,b)"
} or
\texttt{``rgba(r,g,b,a)"
} syntax
124 (e.g. wxColour(
255,
0,
0,
85) ->
\texttt{``rgba(
255,
0,
0,
0.333)"
}), and
125 \textbf{wxC2S
\_HTML\_SYNTAX}, to obtain the colour as
\texttt{``\#"
} followed
126 by
6 hexadecimal digits (e.g. wxColour(
255,
0,
0) ->
\texttt{``\#FF0000"
}).
128 This function never fails and always returns a non-empty string but asserts if
129 the colour has alpha channel (i.e. is non opaque) but
130 \textbf{wxC2S
\_CSS\_SYNTAX} (which is the only one supporting alpha) is not
136 \membersection{wxColour::GetPixel
}\label{wxcolourgetpixel
}
138 \constfunc{long
}{GetPixel
}{\void}
140 Returns a pixel value which is platform-dependent. On Windows, a COLORREF is returned.
141 On X, an allocated pixel value is returned.
143 -
1 is returned if the pixel is invalid (on X, unallocated).
146 \membersection{wxColour::Green
}\label{wxcolourgreen
}
148 \constfunc{unsigned char
}{Green
}{\void}
150 Returns the green intensity.
153 \membersection{wxColour::IsOk
}\label{wxcolourisok
}
155 \constfunc{bool
}{IsOk
}{\void}
157 Returns
\true if the colour object is valid (the colour has been initialised with RGB values).
160 \membersection{wxColour::Red
}\label{wxcolourred
}
162 \constfunc{unsigned char
}{Red
}{\void}
164 Returns the red intensity.
167 \membersection{wxColour::Set
}\label{wxcolourset
}
169 \func{void
}{Set
}{\param{unsigned char
}{ red
},
\param{unsigned char
}{ green
},
\param{unsigned char
}{ blue
},
\param{unsigned char
}{ alpha=wxALPHA
\_OPAQUE}}
171 \func{void
}{Set
}{\param{unsigned long
}{ RGB
}}
173 \func{bool
}{Set
}{\param{const wxString \&
}{ str
}}
175 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).
177 When using third form, Set() accepts: colour names (those listed in
178 \helpref{wxTheColourDatabase
}{wxcolourdatabase
}), the CSS-like
179 \texttt{``rgb(r,g,b)"
} or
\texttt{``rgba(r,g,b,a)"
} syntax (case insensitive)
180 and the HTML-like syntax (i.e.
\texttt{``\#"
} followed by
6 hexadecimal digits
181 for red, green, blue components).
183 Returns
\true if the conversion was successful,
\false otherwise.
188 \membersection{wxColour::operator $=$
}\label{wxcolourassign
}
190 \func{wxColour\&
}{operator $=$
}{\param{const wxColour\&
}{ colour
}}
192 Assignment operator, taking another colour object.
194 \func{wxColour\&
}{operator $=$
}{\param{const wxString\&
}{ colourName
}}
196 Assignment operator, using a colour name to be found in the colour database.
200 \helpref{wxColourDatabase
}{wxcolourdatabase
}
203 \membersection{wxColour::operator $==$
}\label{wxcolourequality
}
205 \func{bool
}{operator $==$
}{\param{const wxColour\&
}{ colour
}}
207 Tests the equality of two colours by comparing individual red, green, blue colours and alpha values.
210 \membersection{wxColour::operator $!=$
}\label{wxcolourinequality
}
212 \func{bool
}{operator $!=$
}{\param{const wxColour\&
}{ colour
}}
214 Tests the inequality of two colours by comparing individual red, green, blue colours and alpha values.
216 \section{\class{wxColourData
}}\label{wxcolourdata
}
218 This class holds a variety of information related to colour dialogs.
220 \wxheading{Derived from
}
222 \helpref{wxObject
}{wxobject
}
224 \wxheading{Include files
}
230 \helpref{wxColour
}{wxcolour
},
\helpref{wxColourDialog
}{wxcolourdialog
},
\helpref{wxColourDialog overview
}{wxcolourdialogoverview
}
232 \latexignore{\rtfignore{\wxheading{Members
}}}
235 \membersection{wxColourData::wxColourData
}\label{wxcolourdatactor
}
237 \func{}{wxColourData
}{\void}
239 Constructor. Initializes the custom colours to
{\tt wxNullColour
},
240 the
{\it data colour
} setting
241 to black, and the
{\it choose full
} setting to true.
244 \membersection{wxColourData::
\destruct{wxColourData
}}\label{wxcolourdatadtor
}
246 \func{}{\destruct{wxColourData
}}{\void}
251 \membersection{wxColourData::GetChooseFull
}\label{wxcolourdatagetchoosefull
}
253 \constfunc{bool
}{GetChooseFull
}{\void}
255 Under Windows, determines whether the Windows colour dialog will display the full dialog
256 with custom colour selection controls. Under PalmOS, determines whether colour dialog
257 will display full rgb colour picker or only available palette indexer.
258 Has no meaning under other platforms.
260 The default value is true.
263 \membersection{wxColourData::GetColour
}\label{wxcolourdatagetcolour
}
265 \constfunc{wxColour\&
}{GetColour
}{\void}
267 Gets the current colour associated with the colour dialog.
269 The default colour is black.
272 \membersection{wxColourData::GetCustomColour
}\label{wxcolourdatagetcustomcolour
}
274 \constfunc{wxColour\&
}{GetCustomColour
}{\param{int
}{ i
}}
276 Gets the
{\it i
}th custom colour associated with the colour dialog.
{\it i
} should
277 be an integer between
0 and
15.
279 The default custom colours are invalid colours.
282 \membersection{wxColourData::SetChooseFull
}\label{wxcolourdatasetchoosefull
}
284 \func{void
}{SetChooseFull
}{\param{const bool
}{flag
}}
286 Under Windows, tells the Windows colour dialog to display the full dialog
287 with custom colour selection controls. Under other platforms, has no effect.
289 The default value is true.
292 \membersection{wxColourData::SetColour
}\label{wxcolourdatasetcolour
}
294 \func{void
}{SetColour
}{\param{const wxColour\&
}{ colour
}}
296 Sets the default colour for the colour dialog.
298 The default colour is black.
301 \membersection{wxColourData::SetCustomColour
}\label{wxcolourdatasetcustomcolour
}
303 \func{void
}{SetCustomColour
}{\param{int
}{ i
},
\param{const wxColour\&
}{ colour
}}
305 Sets the
{\it i
}th custom colour for the colour dialog.
{\it i
} should
306 be an integer between
0 and
15.
308 The default custom colours are invalid colours.
311 \membersection{wxColourData::operator $=$
}\label{wxcolourdataassign
}
313 \func{void
}{operator $=$
}{\param{const wxColourData\&
}{ data
}}
315 Assignment operator for the colour data.
320 \section{\class{wxColourDatabase
}}\label{wxcolourdatabase
}
322 wxWidgets maintains a database of standard RGB colours for a predefined
323 set of named colours (such as ``BLACK'', ``LIGHT GREY''). The
324 application may add to this set if desired by using
325 \helpref{AddColour
}{wxcolourdatabaseaddcolour
} and may use it to look up
326 colours by names using
\helpref{Find
}{wxcolourdatabasefind
} or find the names
327 for the standard colour suing
\helpref{FindName
}{wxcolourdatabasefindname
}.
329 There is one predefined instance of this class called
330 {\bf wxTheColourDatabase
}.
332 \wxheading{Derived from
}
336 \wxheading{Include files
}
342 The standard database contains at least the following colours:
344 AQUAMARINE, BLACK, BLUE, BLUE VIOLET, BROWN, CADET BLUE, CORAL,
345 CORNFLOWER BLUE, CYAN, DARK GREY, DARK GREEN, DARK OLIVE GREEN, DARK
346 ORCHID, DARK SLATE BLUE, DARK SLATE GREY DARK TURQUOISE, DIM GREY,
347 FIREBRICK, FOREST GREEN, GOLD, GOLDENROD, GREY, GREEN, GREEN YELLOW,
348 INDIAN RED, KHAKI, LIGHT BLUE, LIGHT GREY, LIGHT STEEL BLUE, LIME GREEN,
349 MAGENTA, MAROON, MEDIUM AQUAMARINE, MEDIUM BLUE, MEDIUM FOREST GREEN,
350 MEDIUM GOLDENROD, MEDIUM ORCHID, MEDIUM SEA GREEN, MEDIUM SLATE BLUE,
351 MEDIUM SPRING GREEN, MEDIUM TURQUOISE, MEDIUM VIOLET RED, MIDNIGHT BLUE,
352 NAVY, ORANGE, ORANGE RED, ORCHID, PALE GREEN, PINK, PLUM, PURPLE, RED,
353 SALMON, SEA GREEN, SIENNA, SKY BLUE, SLATE BLUE, SPRING GREEN, STEEL
354 BLUE, TAN, THISTLE, TURQUOISE, VIOLET, VIOLET RED, WHEAT, WHITE, YELLOW,
359 \helpref{wxColour
}{wxcolour
}
361 \latexignore{\rtfignore{\wxheading{Members
}}}
364 \membersection{wxColourDatabase::wxColourDatabase
}\label{wxcolourdatabaseconstr
}
366 \func{}{wxColourDatabase
}{\void}
368 Constructs the colour database. It will be initialized at the first use.
371 \membersection{wxColourDatabase::AddColour
}\label{wxcolourdatabaseaddcolour
}
373 \func{void
}{AddColour
}{\param{const wxString\&
}{colourName
},
\param{const wxColour\&
}{colour
}}
375 \func{void
}{AddColour
}{\param{const wxString\&
}{colourName
},
\param{wxColour*
}{colour
}}
377 Adds a colour to the database. If a colour with the same name already exists,
380 Please note that the overload taking a pointer is deprecated and will be
381 removed in the next wxWidgets version, please don't use it.
384 \membersection{wxColourDatabase::Find
}\label{wxcolourdatabasefind
}
386 \func{wxColour
}{Find
}{\param{const wxString\&
}{colourName
}}
388 Finds a colour given the name. Returns an invalid colour object (that is, such
389 that its
\helpref{Ok()
}{wxcolourisok
} method returns
\false) if the colour wasn't
390 found in the database.
393 \membersection{wxColourDatabase::FindName
}\label{wxcolourdatabasefindname
}
395 \constfunc{wxString
}{FindName
}{\param{const wxColour\&
}{ colour
}}
397 Finds a colour name given the colour. Returns an empty string if the colour is
398 not found in the database.