]>
Commit | Line | Data |
---|---|---|
15b6757b | 1 | ///////////////////////////////////////////////////////////////////////////// |
d54cf7ff | 2 | // Name: commondialogs.h |
15b6757b FM |
3 | // Purpose: topic overview |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
15b6757b FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
880efa2a BP |
9 | /** |
10 | ||
11 | @page overview_cmndlg Common Dialogs | |
12 | ||
13 | Classes: | |
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 | ||
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. | |
29 | ||
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. | |
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 | ||
56 | Classes: wxColourDialog, wxColourData | |
57 | ||
58 | The wxColourDialog presents a colour selector to the user, and returns with | |
59 | colour information. | |
60 | ||
61 | @subsection overview_cmndlg_colour_msw The MS Windows Colour Selector | |
62 | ||
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. | |
69 | ||
70 | @subsection overview_cmndlg_colour_generic The Generic Colour Selector | |
36c9828f | 71 | |
880efa2a BP |
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. | |
81 | ||
82 | @subsection overview_cmndlg_colour_example Example | |
83 | ||
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. | |
89 | ||
90 | @code | |
91 | wxColourData data; | |
92 | data.SetChooseFull(true); | |
93 | for (int i = 0; i < 16; i++) | |
94 | { | |
95 | wxColour colour(i*16, i*16, i*16); | |
96 | data.SetCustomColour(i, colour); | |
97 | } | |
98 | ||
99 | wxColourDialog dialog(this, &data); | |
100 | if (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 | |
36c9828f | 110 | |
d54cf7ff | 111 | |
880efa2a | 112 | @section overview_cmndlg_font wxFontDialog Overview |
d54cf7ff | 113 | |
880efa2a | 114 | Classes: wxFontDialog, wxFontData |
d54cf7ff | 115 | |
880efa2a BP |
116 | The wxFontDialog presents a font selector to the user, and returns with font |
117 | and colour information. | |
d54cf7ff | 118 | |
880efa2a | 119 | @subsection overview_cmndlg_font_msw The MS Windows Font Selector |
d54cf7ff | 120 | |
880efa2a BP |
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 | |
127 | Courier). | |
36c9828f | 128 | |
880efa2a | 129 | @subsection overview_cmndlg_font_generic The Generic Font Selector |
36c9828f | 130 | |
880efa2a BP |
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. | |
36c9828f | 135 | |
880efa2a | 136 | @subsection overview_cmndlg_font_example Example |
36c9828f | 137 | |
880efa2a BP |
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: | |
36c9828f | 141 | |
880efa2a BP |
142 | @code |
143 | wxFontData data; | |
144 | data.SetInitialFont(canvasFont); | |
145 | data.SetColour(canvasTextColour); | |
36c9828f | 146 | |
880efa2a BP |
147 | wxFontDialog dialog(this, &data); |
148 | if (dialog.ShowModal() == wxID_OK) | |
149 | { | |
150 | wxFontData retData = dialog.GetFontData(); | |
151 | canvasFont = retData.GetChosenFont(); | |
152 | canvasTextColour = retData.GetColour(); | |
153 | myWindow->Refresh(); | |
154 | } | |
155 | @endcode | |
d54cf7ff | 156 | |
d54cf7ff | 157 | |
880efa2a | 158 | @section overview_cmndlg_print wxPrintDialog Overview |
d54cf7ff | 159 | |
880efa2a | 160 | Classes: wxPrintDialog, wxPrintData |
d54cf7ff | 161 | |
880efa2a BP |
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. | |
d54cf7ff | 164 | |
880efa2a BP |
165 | The samples/printing example shows how to use it: see @ref overview_printing |
166 | for an excerpt from this example. | |
d54cf7ff | 167 | |
d54cf7ff | 168 | |
880efa2a | 169 | @section overview_cmndlg_file wxFileDialog Overview |
36c9828f | 170 | |
880efa2a | 171 | Classes: wxFileDialog |
36c9828f | 172 | |
880efa2a BP |
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 | |
176 | pathname. | |
36c9828f | 177 | |
880efa2a BP |
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. | |
36c9828f | 184 | |
880efa2a BP |
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 | |
190 | supplied. | |
d54cf7ff | 191 | |
880efa2a BP |
192 | The wildcard may be a specification for multiple types of file with a |
193 | description for each, such as: | |
36c9828f | 194 | |
880efa2a BP |
195 | @verbatim |
196 | "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif" | |
197 | @endverbatim | |
d54cf7ff | 198 | |
d54cf7ff | 199 | |
880efa2a | 200 | @section overview_cmndlg_dir wxDirDialog Overview |
36c9828f | 201 | |
880efa2a | 202 | Classes: wxDirDialog |
d54cf7ff | 203 | |
880efa2a BP |
204 | This dialog shows a directory selector dialog, allowing the user to select a |
205 | single directory. | |
d54cf7ff | 206 | |
36c9828f | 207 | |
880efa2a | 208 | @section overview_cmndlg_textentry wxTextEntryDialog Overview |
d54cf7ff | 209 | |
880efa2a | 210 | Classes: wxTextEntryDialog |
d54cf7ff | 211 | |
880efa2a BP |
212 | This is a dialog with a text entry field. The value that the user entered is |
213 | obtained using wxTextEntryDialog::GetValue(). | |
d54cf7ff | 214 | |
d54cf7ff | 215 | |
880efa2a | 216 | @section overview_cmndlg_password wxPasswordEntryDialog Overview |
36c9828f | 217 | |
880efa2a | 218 | Classes: wxPasswordEntryDialog |
36c9828f | 219 | |
880efa2a BP |
220 | This is a dialog with a password entry field. The value that the user entered |
221 | is obtained using wxTextEntryDialog::GetValue(). | |
36c9828f | 222 | |
d54cf7ff | 223 | |
880efa2a | 224 | @section overview_cmndlg_msg wxMessageDialog Overview |
36c9828f | 225 | |
880efa2a | 226 | Classes: wxMessageDialog |
36c9828f | 227 | |
880efa2a BP |
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. | |
d54cf7ff | 231 | |
880efa2a BP |
232 | The return value of wxMessageDialog::ShowModal() indicates which button the |
233 | user pressed. | |
d54cf7ff FM |
234 | |
235 | ||
880efa2a | 236 | @section overview_cmndlg_singlechoice wxSingleChoiceDialog Overview |
36c9828f | 237 | |
880efa2a | 238 | Classes: wxSingleChoiceDialog |
d54cf7ff | 239 | |
880efa2a BP |
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. | |
36c9828f | 243 | |
d54cf7ff | 244 | |
880efa2a | 245 | @section overview_cmndlg_multichoice wxMultiChoiceDialog Overview |
d54cf7ff | 246 | |
880efa2a | 247 | Classes: wxMultiChoiceDialog |
36c9828f | 248 | |
880efa2a BP |
249 | This dialog shows a list of choices, plus OK and (optionally) Cancel. The user |
250 | can select one or more of them. | |
36c9828f | 251 | |
d54cf7ff | 252 | */ |
36c9828f | 253 |