]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/commondialogs.h
4f4f35d47e1ef5bc4de680bacbb6dee459489f62
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: commondialogs.h
3 // Purpose: topic overview
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page overview_cmndlg Common Dialogs
21 @li wxPasswordEntryDialog
23 @li wxSingleChoiceDialog
24 @li wxMultiChoiceDialog
26 Common dialog classes and functions encapsulate commonly-needed dialog box
27 requirements. They are all 'modal', grabbing the flow of control until the user
28 dismisses the dialog, to make them easy to use within an application.
30 Some dialogs have both platform-dependent and platform-independent
31 implementations, so that if underlying windowing systems do not provide the
32 required functionality, the generic classes and functions can stand in. For
33 example, under MS Windows, wxColourDialog uses the standard colour selector.
34 There is also an equivalent called wxGenericColourDialog for other platforms,
35 and a macro defines wxColourDialog to be the same as wxGenericColourDialog on
36 non-MS Windows platforms. However, under MS Windows, the generic dialog can
37 also be used, for testing or other purposes.
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
54 @section overview_cmndlg_colour wxColourDialog Overview
56 Classes: wxColourDialog, wxColourData
58 The wxColourDialog presents a colour selector to the user, and returns with
61 @subsection overview_cmndlg_colour_msw The MS Windows Colour Selector
63 Under Windows, the native colour selector common dialog is used. This presents
64 a dialog box with three main regions: at the top left, a palette of 48
65 commonly-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,
67 the user may open up the dialog box to show a right-hand panel containing
68 controls to select a precise colour, and add it to the custom colour palette.
70 @subsection overview_cmndlg_colour_generic The Generic Colour Selector
72 Under non-MS Windows platforms, the colour selector is a simulation of most of
73 the features of the MS Windows selector. Two palettes of 48 standard and 16
74 custom colours are presented, with the right-hand area containing three sliders
75 for the user to select a colour from red, green and blue components. This
76 colour may be added to the custom colour palette, and will replace either the
77 currently selected custom colour, or the first one in the palette if none is
78 selected. The RGB colour sliders are not optional in the generic colour
79 selector. The generic colour selector is also available under MS Windows; use
80 the name wxGenericColourDialog.
82 @subsection overview_cmndlg_colour_example Example
84 In the samples/dialogs directory, there is an example of using the
85 wxColourDialog class. Here is an excerpt, which sets various parameters of a
86 wxColourData object, including a grey scale for the custom colours. If the user
87 did not cancel the dialog, the application retrieves the selected colour and
88 uses it to set the background of a window.
92 data.SetChooseFull(true);
93 for (int i = 0; i < 16; i++)
95 wxColour colour(i*16, i*16, i*16);
96 data.SetCustomColour(i, colour);
99 wxColourDialog dialog(this, &data);
100 if (dialog.ShowModal() == wxID_OK)
102 wxColourData retData = dialog.GetColourData();
103 wxColour col = retData.GetColour();
104 wxBrush brush(col, wxSOLID);
105 myWindow->SetBackground(brush);
112 @section overview_cmndlg_font wxFontDialog Overview
114 Classes: wxFontDialog, wxFontData
116 The wxFontDialog presents a font selector to the user, and returns with font
117 and colour information.
119 @subsection overview_cmndlg_font_msw The MS Windows Font Selector
121 Under Windows, the native font selector common dialog is used. This presents a
122 dialog box with controls for font name, point size, style, weight, underlining,
123 strikeout and text foreground colour. A sample of the font is shown on a white
124 area of the dialog box. Note that in the translation from full MS Windows fonts
125 to wxWidgets font conventions, strikeout is ignored and a font family (such as
126 Swiss or Modern) is deduced from the actual font name (such as Arial or
129 @subsection overview_cmndlg_font_generic The Generic Font Selector
131 Under non-MS Windows platforms, the font selector is simpler. Controls for font
132 family, point size, style, weight, underlining and text foreground colour are
133 provided, and a sample is shown upon a white background. The generic font
134 selector is also available under MS Windows; use the name wxGenericFontDialog.
136 @subsection overview_cmndlg_font_example Example
138 In the samples/dialogs directory, there is an example of using the wxFontDialog
139 class. The application uses the returned font and colour for drawing text on a
140 canvas. Here is an excerpt:
144 data.SetInitialFont(canvasFont);
145 data.SetColour(canvasTextColour);
147 wxFontDialog dialog(this, &data);
148 if (dialog.ShowModal() == wxID_OK)
150 wxFontData retData = dialog.GetFontData();
151 canvasFont = retData.GetChosenFont();
152 canvasTextColour = retData.GetColour();
158 @section overview_cmndlg_print wxPrintDialog Overview
160 Classes: wxPrintDialog, wxPrintData
162 This class represents the print and print setup common dialogs. You may obtain
163 a wxPrinterDC device context from a successfully dismissed print dialog.
165 The samples/printing example shows how to use it: see @ref overview_printing
166 for an excerpt from this example.
169 @section overview_cmndlg_file wxFileDialog Overview
171 Classes: wxFileDialog
173 Pops up a file selector box. On Windows and GTK 2.4+, this is the common file
174 selector dialog. In X, this is a file selector box with somewhat less
175 functionality. The path and filename are distinct elements of a full file
178 If path is "", the current directory will be used. If filename is "", no
179 default filename will be supplied. The wildcard determines what files are
180 displayed in the file selector, and file extension supplies a type extension
181 for the required filename. Flags may be a combination of wxFD_OPEN, wxFD_SAVE,
182 wxFD_OVERWRITE_PROMPT, wxFD_HIDE_READONLY, wxFD_FILE_MUST_EXIST, wxFD_MULTIPLE,
183 wxFD_CHANGE_DIR or 0.
185 Both the X and Windows versions implement a wildcard filter. Typing a filename
186 containing wildcards (*, ?) in the filename text item, and clicking on Ok, will
187 result in only those files matching the pattern being displayed. In the X
188 version, supplying no default name will result in the wildcard filter being
189 inserted in the filename text item; the filter is ignored if a default name is
192 The wildcard may be a specification for multiple types of file with a
193 description for each, such as:
196 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
200 @section overview_cmndlg_dir wxDirDialog Overview
204 This dialog shows a directory selector dialog, allowing the user to select a
208 @section overview_cmndlg_textentry wxTextEntryDialog Overview
210 Classes: wxTextEntryDialog
212 This is a dialog with a text entry field. The value that the user entered is
213 obtained using wxTextEntryDialog::GetValue().
216 @section overview_cmndlg_password wxPasswordEntryDialog Overview
218 Classes: wxPasswordEntryDialog
220 This is a dialog with a password entry field. The value that the user entered
221 is obtained using wxTextEntryDialog::GetValue().
224 @section overview_cmndlg_msg wxMessageDialog Overview
226 Classes: wxMessageDialog
228 This dialog shows a message, plus buttons that can be chosen from OK, Cancel,
229 Yes, and No. Under Windows, an optional icon can be shown, such as an
230 exclamation mark or question mark.
232 The return value of wxMessageDialog::ShowModal() indicates which button the
236 @section overview_cmndlg_singlechoice wxSingleChoiceDialog Overview
238 Classes: wxSingleChoiceDialog
240 This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
241 can select one of them. The selection can be obtained from the dialog as an
242 index, a string or client data.
245 @section overview_cmndlg_multichoice wxMultiChoiceDialog Overview
247 Classes: wxMultiChoiceDialog
249 This dialog shows a list of choices, plus OK and (optionally) Cancel. The user
250 can select one or more of them.