]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/dialog.tex
fixed the description of wxSafeYield()
[wxWidgets.git] / docs / latex / wx / dialog.tex
1 \section{\class{wxDialog}}\label{wxdialog}
2
3 A dialog box is a window with a title bar and sometimes a system menu, which can be moved around
4 the screen. It can contain controls and other windows.
5
6 \wxheading{Derived from}
7
8 \helpref{wxPanel}{wxpanel}\\
9 \helpref{wxWindow}{wxwindow}\\
10 \helpref{wxEvtHandler}{wxevthandler}\\
11 \helpref{wxObject}{wxobject}
12
13 \wxheading{Include files}
14
15 <wx/dialog.h>
16
17 \wxheading{Remarks}
18
19 There are two kinds of dialog - {\it modal} and {\it modeless}. A modal dialog
20 blocks program flow and user input on other windows until it is dismissed, whereas a modeless dialog behaves more
21 like a frame in that program flow continues, and input on other windows is still possible.
22 You specify the type of dialog with the {\bf wxDIALOG\_MODAL} and {\bf wxDIALOG\_MODELESS} window
23 styles.
24
25 A dialog may be loaded from a wxWindows resource file (extension {\tt wxr}).
26
27 An application can define an \helpref{OnCloseWindow}{wxwindowonclosewindow} handler for the
28 dialog to respond to system close events.
29
30 \wxheading{Window styles}
31
32 \twocolwidtha{5cm}
33 \begin{twocollist}\itemsep=0pt
34 \twocolitem{\windowstyle{wxCAPTION}}{Puts a caption on the dialog box (Motif only).}
35 \twocolitem{\windowstyle{wxDEFAULT\_DIALOG\_STYLE}}{Equivalent to a combination of wxCAPTION, wxSYSTEM\_MENU and wxTHICK\_FRAME}
36 \twocolitem{\windowstyle{wxRESIZE\_BORDER}}{Display a resizeable frame around the window (Motif only).}
37 \twocolitem{\windowstyle{wxSYSTEM\_MENU}}{Display a system menu.}
38 \twocolitem{\windowstyle{wxTHICK\_FRAME}}{Display a thick frame around the window.}
39 \twocolitem{\windowstyle{wxSTAY\_ON\_TOP}}{The dialog stays on top of all other windows (Windows only).}
40 \twocolitem{\windowstyle{wxNO\_3D}}{Under Windows, specifies that the child controls
41 should not have 3D borders unless specified in the control.}
42 \end{twocollist}
43
44 Under Motif, MWM (the Motif Window Manager) should be running for any of these styles to have an effect.
45
46 See also \helpref{Generic window styles}{windowstyles}.
47
48 \wxheading{See also}
49
50 \helpref{wxDialog overview}{wxdialogoverview}, \helpref{wxFrame}{wxframe}, \helpref{Resources}{resources},\rtfsp
51 \helpref{Validator overview}{validatoroverview}
52
53 \latexignore{\rtfignore{\wxheading{Members}}}
54
55 \membersection{wxDialog::wxDialog}\label{wxdialogconstr}
56
57 \func{}{wxDialog}{\void}
58
59 Default constructor.
60
61 \func{}{wxDialog}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
62 \param{const wxString\& }{title},\rtfsp
63 \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
64 \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
65 \param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
66 \param{const wxString\& }{name = ``dialogBox"}}
67
68 Constructor.
69
70 \wxheading{Parameters}
71
72 \docparam{parent}{Can be NULL, a frame or another dialog box.}
73
74 \docparam{id}{An identifier for the dialog. A value of -1 is taken to mean a default.}
75
76 \docparam{title}{The title of the dialog.}
77
78 \docparam{pos}{The dialog position. A value of (-1, -1) indicates a default position, chosen by
79 either the windowing system or wxWindows, depending on platform.}
80
81 \docparam{size}{The dialog size. A value of (-1, -1) indicates a default size, chosen by
82 either the windowing system or wxWindows, depending on platform.}
83
84 \docparam{style}{The window style. See \helpref{wxDialog}{wxdialog}.}
85
86 \docparam{name}{Used to associate a name with the window,
87 allowing the application user to set Motif resource values for
88 individual dialog boxes.}
89
90 \wxheading{See also}
91
92 \helpref{wxDialog::Create}{wxdialogcreate}
93
94 \membersection{wxDialog::\destruct{wxDialog}}
95
96 \func{}{\destruct{wxDialog}}{\void}
97
98 Destructor. Deletes any child windows before deleting the physical window.
99
100 \membersection{wxDialog::Centre}\label{wxdialogcentre}
101
102 \func{void}{Centre}{\param{int}{ direction = wxBOTH}}
103
104 Centres the dialog box on the display.
105
106 \wxheading{Parameters}
107
108 \docparam{direction}{May be {\tt wxHORIZONTAL}, {\tt wxVERTICAL} or {\tt wxBOTH}.}
109
110 \membersection{wxDialog::Create}\label{wxdialogcreate}
111
112 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
113 \param{const wxString\& }{title},\rtfsp
114 \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
115 \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
116 \param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
117 \param{const wxString\& }{name = ``dialogBox"}}
118
119 Used for two-step dialog box construction. See \helpref{wxDialog::wxDialog}{wxdialogconstr}\rtfsp
120 for details.
121
122 \membersection{wxDialog::EndModal}\label{wxdialogendmodal}
123
124 \func{void}{EndModal}{\param{int }{retCode}}
125
126 Ends a modal dialog, passing a value to be returned from the \helpref{wxDialog::ShowModal}{wxdialogshowmodal}\rtfsp
127 invocation.
128
129 \wxheading{Parameters}
130
131 \docparam{retCode}{The value that should be returned by {\bf ShowModal}.}
132
133 \wxheading{See also}
134
135 \helpref{wxDialog::ShowModal}{wxdialogshowmodal},\rtfsp
136 \helpref{wxWindow::GetReturnCode}{wxwindowgetreturncode},\rtfsp
137 \helpref{wxWindow::SetReturnCode}{wxwindowsetreturncode}
138
139 \membersection{wxDialog::GetTitle}\label{wxdialoggettitle}
140
141 \constfunc{wxString}{GetTitle}{\void}
142
143 Returns the title of the dialog box.
144
145 \membersection{wxDialog::Iconize}\label{wxdialogiconized}
146
147 \func{void}{Iconize}{\param{const bool}{ iconize}}
148
149 Iconizes or restores the dialog.
150
151 \wxheading{Parameters}
152
153 \docparam{iconize}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.}
154
155 \wxheading{Remarks}
156
157 Note that in Windows, iconization has no effect since dialog boxes cannot be
158 iconized. However, applications may need to explicitly restore dialog
159 boxes under Motif which have user-iconizable frames, and under Windows
160 calling {\tt Iconize(FALSE)} will bring the window to the front, as does
161 \rtfsp{\tt Show(TRUE)}.
162
163 \membersection{wxDialog::IsIconized}\label{wxdialogisiconized}
164
165 \constfunc{bool}{IsIconized}{\void}
166
167 Returns TRUE if the dialog box is iconized.
168
169 \wxheading{Remarks}
170
171 Always returns FALSE under Windows since dialogs cannot be iconized.
172
173 \membersection{wxDialog::IsModal}\label{wxdialogismodal}
174
175 \constfunc{bool}{IsModal}{\void}
176
177 Returns TRUE if the dialog box is modal, FALSE otherwise.
178
179 \membersection{wxDialog::OnCharHook}\label{wxdialogoncharhook}
180
181 \func{void}{OnCharHook}{\param{wxKeyEvent\&}{ event}}
182
183 This member is called to allow the window to intercept keyboard events
184 before they are processed by child windows.
185
186 For more information, see \helpref{wxWindow::OnCharHook}{wxwindowoncharhook}
187
188 \wxheading{Remarks}
189
190 wxDialog implements this handler to fake a cancel command if the escape key has been
191 pressed. This will dismiss the dialog.
192
193 \membersection{wxDialog::OnApply}\label{wxdialogonapply}
194
195 \func{void}{OnApply}{\param{wxCommandEvent\& }{event}}
196
197 The default handler for the wxID\_APPLY identifier.
198
199 \wxheading{Remarks}
200
201 This function calls \helpref{wxWindow::Validate}{wxwindowvalidate} and \helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow}.
202
203 \wxheading{See also}
204
205 \helpref{wxDialog::OnOK}{wxdialogonok}, \helpref{wxDialog::OnCancel}{wxdialogoncancel}
206
207 \membersection{wxDialog::OnCancel}\label{wxdialogoncancel}
208
209 \func{void}{OnCancel}{\param{wxCommandEvent\& }{event}}
210
211 The default handler for the wxID\_CANCEL identifier.
212
213 \wxheading{Remarks}
214
215 The function either calls {\bf EndModal(wxID\_CANCEL)} if the dialog is modal, or
216 sets the return value to wxID\_CANCEL and calls {\bf Show(FALSE)} if the dialog is modeless.
217
218 \wxheading{See also}
219
220 \helpref{wxDialog::OnOK}{wxdialogonok}, \helpref{wxDialog::OnApply}{wxdialogonapply}
221
222 \membersection{wxDialog::OnOK}\label{wxdialogonok}
223
224 \func{void}{OnOK}{\param{wxCommandEvent\& }{event}}
225
226 The default handler for the wxID\_OK identifier.
227
228 \wxheading{Remarks}
229
230 The function calls
231 \rtfsp\helpref{wxWindow::Validate}{wxwindowvalidate}, then \helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow}.
232 If this returns TRUE, the function either calls {\bf EndModal(wxID\_OK)} if the dialog is modal, or
233 sets the return value to wxID\_OK and calls {\bf Show(FALSE)} if the dialog is modeless.
234
235 \wxheading{See also}
236
237 \helpref{wxDialog::OnCancel}{wxdialogoncancel}, \helpref{wxDialog::OnApply}{wxdialogonapply}
238
239 \membersection{wxDialog::OnSysColourChanged}\label{wxdialogonsyscolourchanged}
240
241 \func{void}{OnSysColourChanged}{\param{wxSysColourChangedEvent\& }{event}}
242
243 The default handler for wxEVT\_SYS\_COLOUR\_CHANGED.
244
245 \wxheading{Parameters}
246
247 \docparam{event}{The colour change event.}
248
249 \wxheading{Remarks}
250
251 Changes the dialog's colour to conform to the current settings (Windows only).
252 Add an event table entry for your dialog class if you wish the behaviour
253 to be different (such as keeping a user-defined
254 background colour). If you do override this function, call \helpref{wxWindow::OnSysColourChanged}{wxwindowonsyscolourchanged} to
255 propagate the notification to child windows and controls.
256
257 \wxheading{See also}
258
259 \helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent}
260
261 \membersection{wxDialog::SetModal}\label{wxdialogsetmodal}
262
263 \func{void}{SetModal}{\param{const bool}{ flag}}
264
265 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
266 until the dialog is hidden) or modeless (control returns immediately).
267
268 \wxheading{Parameters}
269
270 \docparam{flag}{If TRUE, the dialog will be modal, otherwise it will be modeless.}
271
272 \membersection{wxDialog::SetTitle}\label{wxdialogsettitle}
273
274 \func{void}{SetTitle}{\param{const wxString\& }{ title}}
275
276 Sets the title of the dialog box.
277
278 \wxheading{Parameters}
279
280 \docparam{title}{The dialog box title.}
281
282 \membersection{wxDialog::Show}\label{wxdialogshow}
283
284 \func{bool}{Show}{\param{const bool}{ show}}
285
286 Hides or shows the dialog.
287
288 \wxheading{Parameters}
289
290 \docparam{show}{If TRUE, the dialog box is shown and brought to the front;
291 otherwise the box is hidden. If FALSE and the dialog is
292 modal, control is returned to the calling program.}
293
294 \wxheading{Remarks}
295
296 The preferred way of dismissing a modal dialog is to use \helpref{wxDialog::EndModal}{wxdialogendmodal}.
297
298 \membersection{wxDialog::ShowModal}\label{wxdialogshowmodal}
299
300 \func{int}{ShowModal}{\void}
301
302 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with\rtfsp
303 \helpref{wxDialog::EndModal}{wxdialogendmodal}.
304
305 \wxheading{Return value}
306
307 The return value is the value set with \helpref{wxWindow::SetReturnCode}{wxwindowsetreturncode}.
308
309 \wxheading{See also}
310
311 \helpref{wxDialog::EndModal}{wxdialogendmodal},\rtfsp
312 \helpref{wxWindow::GetReturnCode}{wxwindowgetreturncode},\rtfsp
313 \helpref{wxWindow::SetReturnCode}{wxwindowsetreturncode}
314
315