]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tcommdlg.tex
Missed labels to replace number of 'topicNNN' in anchors. Consistent use of -dtor...
[wxWidgets.git] / docs / latex / wx / tcommdlg.tex
CommitLineData
a660d684
KB
1\section{Common dialogs overview}\label{commondialogsoverview}
2
3Classes: \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxFontDialog}{wxfontdialog},
4\rtfsp\helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxFileDialog}{wxfiledialog},\rtfsp
5\helpref{wxDirDialog}{wxdirdialog}, \helpref{wxTextEntryDialog}{wxtextentrydialog},\rtfsp
6\helpref{wxMessageDialog}{wxmessagedialog}, \helpref{wxSingleChoiceDialog}{wxsinglechoicedialog},\rtfsp
04bf08b7 7\helpref{wxMultiChoiceDialog}{wxmultichoicedialog}
a660d684
KB
8
9Common dialog classes and functions encapsulate commonly-needed dialog box requirements.
10They are all `modal', grabbing the flow of control until the user dismisses the dialog,
11to make them easy to use within an application.
12
13Some dialogs have both platform-dependent and platform-independent implementations,
f70c0443 14so that if underlying windowing systems do not provide the required functionality,
a660d684
KB
15the generic classes and functions can stand in. For example, under MS Windows, wxColourDialog
16uses the standard colour selector. There is also an equivalent called wxGenericColourDialog
17for other platforms, and a macro defines wxColourDialog to be the same as wxGenericColourDialog
18on non-MS Windows platforms. However, under MS Windows, the generic dialog can also be
19used, for testing or other purposes.
20
21\subsection{wxColourDialog overview}\label{wxcolourdialogoverview}
22
23Classes: \helpref{wxColourDialog}{wxcolourdialog}, \helpref{wxColourData}{wxcolourdata}
24
25The wxColourDialog presents a colour selector to the user, and returns
26with colour information.
27
28{\bf The MS Windows colour selector}
29
30Under Windows, the native colour selector common dialog is used. This
31presents a dialog box with three main regions: at the top left, a
32palette of 48 commonly-used colours is shown. Under this, there is a
33palette of 16 `custom colours' which can be set by the application if
34desired. Additionally, the user may open up the dialog box to show
35a right-hand panel containing controls to select a precise colour, and add
36it to the custom colour palette.
37
38{\bf The generic colour selector}
39
40Under non-MS Windows platforms, the colour selector is a simulation of
41most of the features of the MS Windows selector. Two palettes of 48
42standard and 16 custom colours are presented, with the right-hand area
43containing three sliders for the user to select a colour from red,
44green and blue components. This colour may be added to the custom colour
45palette, and will replace either the currently selected custom colour,
46or the first one in the palette if none is selected. The RGB colour sliders
47are not optional in the generic colour selector. The generic colour
48selector is also available under MS Windows; use the name
49wxGenericColourDialog.
50
51{\bf Example}
52
53In the samples/dialogs directory, there is an example of using
54the wxColourDialog class. Here is an excerpt, which
55sets various parameters of a wxColourData object, including
56a grey scale for the custom colours. If the user did not cancel
57the dialog, the application retrieves the selected colour and
fe604ccd 58uses it to set the background of a window.
a660d684
KB
59
60\begin{verbatim}
61 wxColourData data;
cc81d32f 62 data.SetChooseFull(true);
a660d684
KB
63 for (int i = 0; i < 16; i++)
64 {
65 wxColour colour(i*16, i*16, i*16);
66 data.SetCustomColour(i, colour);
67 }
68
69 wxColourDialog dialog(this, &data);
70 if (dialog.ShowModal() == wxID_OK)
71 {
72 wxColourData retData = dialog.GetColourData();
73 wxColour col = retData.GetColour();
74 wxBrush brush(col, wxSOLID);
fe604ccd
JS
75 myWindow->SetBackground(brush);
76 myWindow->Clear();
77 myWindow->Refresh();
a660d684
KB
78 }
79\end{verbatim}
80
81
82\subsection{wxFontDialog overview}\label{wxfontdialogoverview}
83
84Classes: \helpref{wxFontDialog}{wxfontdialog}, \helpref{wxFontData}{wxfontdata}
85
86The wxFontDialog presents a font selector to the user, and returns
87with font and colour information.
88
89{\bf The MS Windows font selector}
90
91Under Windows, the native font selector common dialog is used. This
92presents a dialog box with controls for font name, point size, style, weight,
93underlining, strikeout and text foreground colour. A sample of the
94font is shown on a white area of the dialog box. Note that
fc2171bd 95in the translation from full MS Windows fonts to wxWidgets font
a660d684
KB
96conventions, strikeout is ignored and a font family (such as
97Swiss or Modern) is deduced from the actual font name (such as Arial
04bf08b7 98or Courier).
a660d684
KB
99
100{\bf The generic font selector}
101
102Under non-MS Windows platforms, the font selector is simpler.
103Controls for font family, point size, style, weight,
104underlining and text foreground colour are provided, and
105a sample is shown upon a white background. The generic font selector
106is also available under MS Windows; use the name wxGenericFontDialog.
107
a660d684
KB
108{\bf Example}
109
110In the samples/dialogs directory, there is an example of using
111the wxFontDialog class. The application uses the returned font
112and colour for drawing text on a canvas. Here is an excerpt:
113
114\begin{verbatim}
115 wxFontData data;
116 data.SetInitialFont(canvasFont);
117 data.SetColour(canvasTextColour);
118
119 wxFontDialog dialog(this, &data);
120 if (dialog.ShowModal() == wxID_OK)
121 {
122 wxFontData retData = dialog.GetFontData();
123 canvasFont = retData.GetChosenFont();
124 canvasTextColour = retData.GetColour();
fe604ccd 125 myWindow->Refresh();
a660d684
KB
126 }
127\end{verbatim}
128
129\subsection{wxPrintDialog overview}\label{wxprintdialogoverview}
130
131Classes: \helpref{wxPrintDialog}{wxprintdialog}, \helpref{wxPrintData}{wxprintdata}
132
133This class represents the print and print setup common dialogs.
134You may obtain a \helpref{wxPrinterDC}{wxprinterdc} device context from
135a successfully dismissed print dialog.
136
137The samples/printing example shows how to use it: see \helpref{Printing overview}{printingoverview} for
138an excerpt from this example.
139
140\subsection{wxFileDialog overview}\label{wxfiledialogoverview}
141
142Classes: \helpref{wxFileDialog}{wxfiledialog}
143
144Pops up a file selector box. In Windows, this is the common file selector
145dialog. In X, this is a file selector box with somewhat less functionality.
146The path and filename are distinct elements of a full file pathname.
147If path is ``", the current directory will be used. If filename is ``",
148no default filename will be supplied. The wildcard determines what files
149are displayed in the file selector, and file extension supplies a type
150extension for the required filename. Flags may be a combination of wxOPEN,
cddfbd9f 151wxSAVE, wxOVERWRITE\_PROMPT, wxHIDE\_READONLY, wxFILE\_MUST\_EXIST or 0.
a660d684
KB
152
153Both the X and Windows versions implement a wildcard filter. Typing a
154filename containing wildcards (*, ?) in the filename text item, and
155clicking on Ok, will result in only those files matching the pattern being
156displayed. In the X version, supplying no default name will result in the
157wildcard filter being inserted in the filename text item; the filter is
158ignored if a default name is supplied.
159
cddfbd9f 160The wildcard may be a specification for multiple
a660d684
KB
161types of file with a description for each, such as:
162
163\begin{verbatim}
2b5f62a0 164 "BMP files (*.bmp)|*.bmp|GIF files (*.gif)|*.gif"
a660d684
KB
165\end{verbatim}
166
167\subsection{wxDirDialog overview}\label{wxdirdialogoverview}
168
169Classes: \helpref{wxDirDialog}{wxdirdialog}
170
171This dialog shows a directory selector dialog, allowing the user to select a single
172directory.
173
174\subsection{wxTextEntryDialog overview}\label{wxtextentrydialogoverview}
175
176Classes: \helpref{wxTextEntryDialog}{wxtextentrydialog}
177
178This is a dialog with a text entry field. The value that the user
179entered is obtained using \helpref{wxTextEntryDialog::GetValue}{wxtextentrydialoggetvalue}.
180
181\subsection{wxMessageDialog overview}\label{wxmessagedialogoverview}
182
183Classes: \helpref{wxMessageDialog}{wxmessagedialog}
184
185This dialog shows a message, plus buttons that can be chosen from OK, Cancel, Yes, and No.
186Under Windows, an optional icon can be shown, such as an exclamation mark or question mark.
187
188The return value of \helpref{wxMessageDialog::ShowModal}{wxmessagedialogshowmodal} indicates
189which button the user pressed.
190
191\subsection{wxSingleChoiceDialog overview}\label{wxsinglechoicedialogoverview}
192
193Classes: \helpref{wxSingleChoiceDialog}{wxsinglechoicedialog}
194
195This dialog shows a list of choices, plus OK and (optionally) Cancel. The user can
196select one of them. The selection can be obtained from the dialog as an index,
197a string or client data.
198
04bf08b7 199\subsection{wxMultiChoiceDialog overview}\label{wxmultichoicedialogoverview}
a660d684 200
04bf08b7 201Classes: \helpref{wxMultiChoiceDialog}{wxmultichoicedialog}
a660d684
KB
202
203This dialog shows a list of choices, plus OK and (optionally) Cancel. The user can
5b6aa0ff
JS
204select one or more of them.
205