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