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