]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/commondialogs.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / docs / doxygen / overviews / commondialogs.h
CommitLineData
15b6757b 1/////////////////////////////////////////////////////////////////////////////
d54cf7ff 2// Name: commondialogs.h
15b6757b
FM
3// Purpose: topic overview
4// Author: wxWidgets team
526954c5 5// Licence: wxWindows licence
15b6757b
FM
6/////////////////////////////////////////////////////////////////////////////
7
880efa2a
BP
8/**
9
10@page overview_cmndlg Common Dialogs
11
e7054054 12@tableofcontents
880efa2a
BP
13
14Common dialog classes and functions encapsulate commonly-needed dialog box
15requirements. They are all 'modal', grabbing the flow of control until the user
16dismisses the dialog, to make them easy to use within an application.
17
18Some dialogs have both platform-dependent and platform-independent
19implementations, so that if underlying windowing systems do not provide the
20required functionality, the generic classes and functions can stand in. For
21example, under MS Windows, wxColourDialog uses the standard colour selector.
22There is also an equivalent called wxGenericColourDialog for other platforms,
23and a macro defines wxColourDialog to be the same as wxGenericColourDialog on
24non-MS Windows platforms. However, under MS Windows, the generic dialog can
25also be used, for testing or other purposes.
26
e7054054 27@see @ref group_class_cmndlg
880efa2a
BP
28
29
880efa2a
BP
30
31@section overview_cmndlg_colour wxColourDialog Overview
32
33Classes: wxColourDialog, wxColourData
34
35The wxColourDialog presents a colour selector to the user, and returns with
36colour information.
37
38@subsection overview_cmndlg_colour_msw The MS Windows Colour Selector
39
40Under Windows, the native colour selector common dialog is used. This presents
41a dialog box with three main regions: at the top left, a palette of 48
42commonly-used colours is shown. Under this, there is a palette of 16
43'custom colours' which can be set by the application if desired. Additionally,
44the user may open up the dialog box to show a right-hand panel containing
45controls to select a precise colour, and add it to the custom colour palette.
46
47@subsection overview_cmndlg_colour_generic The Generic Colour Selector
36c9828f 48
880efa2a
BP
49Under non-MS Windows platforms, the colour selector is a simulation of most of
50the features of the MS Windows selector. Two palettes of 48 standard and 16
51custom colours are presented, with the right-hand area containing three sliders
52for the user to select a colour from red, green and blue components. This
53colour may be added to the custom colour palette, and will replace either the
54currently selected custom colour, or the first one in the palette if none is
55selected. The RGB colour sliders are not optional in the generic colour
56selector. The generic colour selector is also available under MS Windows; use
57the name wxGenericColourDialog.
58
59@subsection overview_cmndlg_colour_example Example
60
61In the samples/dialogs directory, there is an example of using the
62wxColourDialog class. Here is an excerpt, which sets various parameters of a
63wxColourData object, including a grey scale for the custom colours. If the user
64did not cancel the dialog, the application retrieves the selected colour and
65uses it to set the background of a window.
66
67@code
68wxColourData data;
69data.SetChooseFull(true);
70for (int i = 0; i < 16; i++)
71{
72 wxColour colour(i*16, i*16, i*16);
73 data.SetCustomColour(i, colour);
74}
75
76wxColourDialog dialog(this, &data);
77if (dialog.ShowModal() == wxID_OK)
78{
79 wxColourData retData = dialog.GetColourData();
80 wxColour col = retData.GetColour();
81 wxBrush brush(col, wxSOLID);
82 myWindow->SetBackground(brush);
83 myWindow->Clear();
84 myWindow->Refresh();
85}
86@endcode
36c9828f 87
d54cf7ff 88
e7054054 89
880efa2a 90@section overview_cmndlg_font wxFontDialog Overview
d54cf7ff 91
880efa2a 92Classes: wxFontDialog, wxFontData
d54cf7ff 93
880efa2a
BP
94The wxFontDialog presents a font selector to the user, and returns with font
95and colour information.
d54cf7ff 96
880efa2a 97@subsection overview_cmndlg_font_msw The MS Windows Font Selector
d54cf7ff 98
880efa2a
BP
99Under Windows, the native font selector common dialog is used. This presents a
100dialog box with controls for font name, point size, style, weight, underlining,
101strikeout and text foreground colour. A sample of the font is shown on a white
102area of the dialog box. Note that in the translation from full MS Windows fonts
103to wxWidgets font conventions, strikeout is ignored and a font family (such as
104Swiss or Modern) is deduced from the actual font name (such as Arial or
105Courier).
36c9828f 106
880efa2a 107@subsection overview_cmndlg_font_generic The Generic Font Selector
36c9828f 108
880efa2a
BP
109Under non-MS Windows platforms, the font selector is simpler. Controls for font
110family, point size, style, weight, underlining and text foreground colour are
111provided, and a sample is shown upon a white background. The generic font
112selector is also available under MS Windows; use the name wxGenericFontDialog.
36c9828f 113
880efa2a 114@subsection overview_cmndlg_font_example Example
36c9828f 115
880efa2a
BP
116In the samples/dialogs directory, there is an example of using the wxFontDialog
117class. The application uses the returned font and colour for drawing text on a
118canvas. Here is an excerpt:
36c9828f 119
880efa2a
BP
120@code
121wxFontData data;
122data.SetInitialFont(canvasFont);
123data.SetColour(canvasTextColour);
36c9828f 124
880efa2a
BP
125wxFontDialog dialog(this, &data);
126if (dialog.ShowModal() == wxID_OK)
127{
128 wxFontData retData = dialog.GetFontData();
129 canvasFont = retData.GetChosenFont();
130 canvasTextColour = retData.GetColour();
131 myWindow->Refresh();
132}
133@endcode
d54cf7ff 134
d54cf7ff 135
e7054054 136
880efa2a 137@section overview_cmndlg_print wxPrintDialog Overview
d54cf7ff 138
880efa2a 139Classes: wxPrintDialog, wxPrintData
d54cf7ff 140
880efa2a
BP
141This class represents the print and print setup common dialogs. You may obtain
142a wxPrinterDC device context from a successfully dismissed print dialog.
d54cf7ff 143
880efa2a
BP
144The samples/printing example shows how to use it: see @ref overview_printing
145for an excerpt from this example.
d54cf7ff 146
d54cf7ff 147
e7054054 148
880efa2a 149@section overview_cmndlg_file wxFileDialog Overview
36c9828f 150
880efa2a 151Classes: wxFileDialog
36c9828f 152
880efa2a
BP
153Pops up a file selector box. On Windows and GTK 2.4+, this is the common file
154selector dialog. In X, this is a file selector box with somewhat less
155functionality. The path and filename are distinct elements of a full file
156pathname.
36c9828f 157
880efa2a
BP
158If path is "", the current directory will be used. If filename is "", no
159default filename will be supplied. The wildcard determines what files are
160displayed in the file selector, and file extension supplies a type extension
161for the required filename. Flags may be a combination of wxFD_OPEN, wxFD_SAVE,
162wxFD_OVERWRITE_PROMPT, wxFD_HIDE_READONLY, wxFD_FILE_MUST_EXIST, wxFD_MULTIPLE,
163wxFD_CHANGE_DIR or 0.
36c9828f 164
880efa2a
BP
165Both the X and Windows versions implement a wildcard filter. Typing a filename
166containing wildcards (*, ?) in the filename text item, and clicking on Ok, will
167result in only those files matching the pattern being displayed. In the X
168version, supplying no default name will result in the wildcard filter being
169inserted in the filename text item; the filter is ignored if a default name is
170supplied.
d54cf7ff 171
880efa2a
BP
172The wildcard may be a specification for multiple types of file with a
173description for each, such as:
36c9828f 174
880efa2a
BP
175@verbatim
176"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
177@endverbatim
d54cf7ff 178
d54cf7ff 179
e7054054 180
880efa2a 181@section overview_cmndlg_dir wxDirDialog Overview
36c9828f 182
880efa2a 183Classes: wxDirDialog
d54cf7ff 184
880efa2a
BP
185This dialog shows a directory selector dialog, allowing the user to select a
186single directory.
d54cf7ff 187
36c9828f 188
e7054054 189
880efa2a 190@section overview_cmndlg_textentry wxTextEntryDialog Overview
d54cf7ff 191
880efa2a 192Classes: wxTextEntryDialog
d54cf7ff 193
880efa2a
BP
194This is a dialog with a text entry field. The value that the user entered is
195obtained using wxTextEntryDialog::GetValue().
d54cf7ff 196
d54cf7ff 197
e7054054 198
880efa2a 199@section overview_cmndlg_password wxPasswordEntryDialog Overview
36c9828f 200
880efa2a 201Classes: wxPasswordEntryDialog
36c9828f 202
880efa2a
BP
203This is a dialog with a password entry field. The value that the user entered
204is obtained using wxTextEntryDialog::GetValue().
36c9828f 205
d54cf7ff 206
e7054054 207
880efa2a 208@section overview_cmndlg_msg wxMessageDialog Overview
36c9828f 209
880efa2a 210Classes: wxMessageDialog
36c9828f 211
880efa2a
BP
212This dialog shows a message, plus buttons that can be chosen from OK, Cancel,
213Yes, and No. Under Windows, an optional icon can be shown, such as an
214exclamation mark or question mark.
d54cf7ff 215
880efa2a
BP
216The return value of wxMessageDialog::ShowModal() indicates which button the
217user pressed.
d54cf7ff
FM
218
219
e7054054 220
880efa2a 221@section overview_cmndlg_singlechoice wxSingleChoiceDialog Overview
36c9828f 222
880efa2a 223Classes: wxSingleChoiceDialog
d54cf7ff 224
880efa2a
BP
225This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
226can select one of them. The selection can be obtained from the dialog as an
227index, a string or client data.
36c9828f 228
d54cf7ff 229
e7054054 230
880efa2a 231@section overview_cmndlg_multichoice wxMultiChoiceDialog Overview
d54cf7ff 232
880efa2a 233Classes: wxMultiChoiceDialog
36c9828f 234
880efa2a
BP
235This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
236can select one or more of them.
36c9828f 237
d54cf7ff 238*/