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