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