]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/doxygen/overviews/commondialogs.h
wxMessageBox off the main thread lost result code.
[wxWidgets.git] / docs / doxygen / overviews / commondialogs.h
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: commondialogs.h
3// Purpose: topic overview
4// Author: wxWidgets team
5// Licence: wxWindows licence
6/////////////////////////////////////////////////////////////////////////////
7
8/**
9
10@page overview_cmndlg Common Dialogs
11
12@tableofcontents
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
27@see @ref group_class_cmndlg
28
29
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
48
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
87
88
89
90@section overview_cmndlg_font wxFontDialog Overview
91
92Classes: wxFontDialog, wxFontData
93
94The wxFontDialog presents a font selector to the user, and returns with font
95and colour information.
96
97@subsection overview_cmndlg_font_msw The MS Windows Font Selector
98
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).
106
107@subsection overview_cmndlg_font_generic The Generic Font Selector
108
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.
113
114@subsection overview_cmndlg_font_example Example
115
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:
119
120@code
121wxFontData data;
122data.SetInitialFont(canvasFont);
123data.SetColour(canvasTextColour);
124
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
134
135
136
137@section overview_cmndlg_print wxPrintDialog Overview
138
139Classes: wxPrintDialog, wxPrintData
140
141This class represents the print and print setup common dialogs. You may obtain
142a wxPrinterDC device context from a successfully dismissed print dialog.
143
144The samples/printing example shows how to use it: see @ref overview_printing
145for an excerpt from this example.
146
147
148
149@section overview_cmndlg_file wxFileDialog Overview
150
151Classes: wxFileDialog
152
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.
157
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.
164
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.
171
172The wildcard may be a specification for multiple types of file with a
173description for each, such as:
174
175@verbatim
176"BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
177@endverbatim
178
179
180
181@section overview_cmndlg_dir wxDirDialog Overview
182
183Classes: wxDirDialog
184
185This dialog shows a directory selector dialog, allowing the user to select a
186single directory.
187
188
189
190@section overview_cmndlg_textentry wxTextEntryDialog Overview
191
192Classes: wxTextEntryDialog
193
194This is a dialog with a text entry field. The value that the user entered is
195obtained using wxTextEntryDialog::GetValue().
196
197
198
199@section overview_cmndlg_password wxPasswordEntryDialog Overview
200
201Classes: wxPasswordEntryDialog
202
203This is a dialog with a password entry field. The value that the user entered
204is obtained using wxTextEntryDialog::GetValue().
205
206
207
208@section overview_cmndlg_msg wxMessageDialog Overview
209
210Classes: wxMessageDialog
211
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.
215
216The return value of wxMessageDialog::ShowModal() indicates which button the
217user pressed.
218
219
220
221@section overview_cmndlg_singlechoice wxSingleChoiceDialog Overview
222
223Classes: wxSingleChoiceDialog
224
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.
228
229
230
231@section overview_cmndlg_multichoice wxMultiChoiceDialog Overview
232
233Classes: wxMultiChoiceDialog
234
235This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
236can select one or more of them.
237
238*/