]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/dialog.tex
added a more convenient version of wxFileType::GetOpenCommand()
[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 29
f4fcc291 30An application can define an \helpref{wxCloseEvent}{wxcloseevent} handler for the
a660d684
KB
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.}
2edb0bde 46\twocolitem{\windowstyle{wxDIALOG\_NO\_PARENT}}{By default, the dialogs created
b3daa5a3
VZ
47with {\tt NULL} parent window will be given the
48\helpref{applications top level window}{wxappgettopwindow} as parent. Use this
49style to prevent this from happening and create a really orphan dialog (note
50that this is not recommended for modal dialogs).}
26a80c22
JS
51\twocolitem{\windowstyle{wxDIALOG\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
52caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
53a wxEVT\_HELP event if the user clicked on an application window. {\it Note} that this is an extended
54style and must be set by calling \helpref{SetExtraStyle}{wxwindowsetextrastyle} before Create is called (two-step construction).}
a660d684
KB
55\end{twocollist}
56
b3daa5a3 57Under Unix or Linux, MWM (the Motif Window Manager) or other window managers
2edb0bde 58recognizing the MHM hints should be running for any of these styles to have an
b3daa5a3 59effect.
a660d684
KB
60
61See also \helpref{Generic window styles}{windowstyles}.
62
63\wxheading{See also}
64
65\helpref{wxDialog overview}{wxdialogoverview}, \helpref{wxFrame}{wxframe}, \helpref{Resources}{resources},\rtfsp
66\helpref{Validator overview}{validatoroverview}
67
68\latexignore{\rtfignore{\wxheading{Members}}}
69
70\membersection{wxDialog::wxDialog}\label{wxdialogconstr}
71
72\func{}{wxDialog}{\void}
73
74Default constructor.
75
eaaa6a06 76\func{}{wxDialog}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
a660d684
KB
77\param{const wxString\& }{title},\rtfsp
78\param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
79\param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 80\param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
a660d684
KB
81\param{const wxString\& }{name = ``dialogBox"}}
82
83Constructor.
84
85\wxheading{Parameters}
86
87\docparam{parent}{Can be NULL, a frame or another dialog box.}
88
89\docparam{id}{An identifier for the dialog. A value of -1 is taken to mean a default.}
90
91\docparam{title}{The title of the dialog.}
92
93\docparam{pos}{The dialog position. A value of (-1, -1) indicates a default position, chosen by
94either the windowing system or wxWindows, depending on platform.}
95
96\docparam{size}{The dialog size. A value of (-1, -1) indicates a default size, chosen by
97either the windowing system or wxWindows, depending on platform.}
98
99\docparam{style}{The window style. See \helpref{wxDialog}{wxdialog}.}
100
101\docparam{name}{Used to associate a name with the window,
102allowing the application user to set Motif resource values for
103individual dialog boxes.}
104
105\wxheading{See also}
106
107\helpref{wxDialog::Create}{wxdialogcreate}
108
109\membersection{wxDialog::\destruct{wxDialog}}
110
111\func{}{\destruct{wxDialog}}{\void}
112
113Destructor. Deletes any child windows before deleting the physical window.
114
115\membersection{wxDialog::Centre}\label{wxdialogcentre}
116
eaaa6a06 117\func{void}{Centre}{\param{int}{ direction = wxBOTH}}
a660d684
KB
118
119Centres the dialog box on the display.
120
121\wxheading{Parameters}
122
123\docparam{direction}{May be {\tt wxHORIZONTAL}, {\tt wxVERTICAL} or {\tt wxBOTH}.}
124
125\membersection{wxDialog::Create}\label{wxdialogcreate}
126
eaaa6a06 127\func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
a660d684
KB
128\param{const wxString\& }{title},\rtfsp
129\param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
130\param{const wxSize\& }{size = wxDefaultSize},\rtfsp
eaaa6a06 131\param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
a660d684
KB
132\param{const wxString\& }{name = ``dialogBox"}}
133
134Used for two-step dialog box construction. See \helpref{wxDialog::wxDialog}{wxdialogconstr}\rtfsp
135for details.
136
137\membersection{wxDialog::EndModal}\label{wxdialogendmodal}
138
139\func{void}{EndModal}{\param{int }{retCode}}
140
141Ends a modal dialog, passing a value to be returned from the \helpref{wxDialog::ShowModal}{wxdialogshowmodal}\rtfsp
142invocation.
143
144\wxheading{Parameters}
145
146\docparam{retCode}{The value that should be returned by {\bf ShowModal}.}
147
148\wxheading{See also}
149
150\helpref{wxDialog::ShowModal}{wxdialogshowmodal},\rtfsp
6453876e
RR
151\helpref{wxDialog::GetReturnCode}{wxdialoggetreturncode},\rtfsp
152\helpref{wxDialog::SetReturnCode}{wxdialogsetreturncode}
153
154\membersection{wxDialog::GetReturnCode}\label{wxdialoggetreturncode}
155
156\func{int}{GetReturnCode}{\void}
157
158Gets the return code for this window.
159
160\wxheading{Remarks}
161
162A return code is normally associated with a modal dialog, where \helpref{wxDialog::ShowModal}{wxdialogshowmodal} returns
163a code to the application.
164
165\wxheading{See also}
166
167\helpref{wxDialog::SetReturnCode}{wxdialogsetreturncode}, \helpref{wxDialog::ShowModal}{wxdialogshowmodal},\rtfsp
168\helpref{wxDialog::EndModal}{wxdialogendmodal}
a660d684
KB
169
170\membersection{wxDialog::GetTitle}\label{wxdialoggettitle}
171
172\constfunc{wxString}{GetTitle}{\void}
173
174Returns the title of the dialog box.
175
176\membersection{wxDialog::Iconize}\label{wxdialogiconized}
177
178\func{void}{Iconize}{\param{const bool}{ iconize}}
179
6453876e 180Iconizes or restores the dialog. Windows only.
a660d684
KB
181
182\wxheading{Parameters}
183
184\docparam{iconize}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.}
185
186\wxheading{Remarks}
187
188Note that in Windows, iconization has no effect since dialog boxes cannot be
189iconized. However, applications may need to explicitly restore dialog
190boxes under Motif which have user-iconizable frames, and under Windows
191calling {\tt Iconize(FALSE)} will bring the window to the front, as does
192\rtfsp{\tt Show(TRUE)}.
193
194\membersection{wxDialog::IsIconized}\label{wxdialogisiconized}
195
196\constfunc{bool}{IsIconized}{\void}
197
6453876e 198Returns TRUE if the dialog box is iconized. Windows only.
a660d684
KB
199
200\wxheading{Remarks}
201
202Always returns FALSE under Windows since dialogs cannot be iconized.
203
204\membersection{wxDialog::IsModal}\label{wxdialogismodal}
205
206\constfunc{bool}{IsModal}{\void}
207
208Returns TRUE if the dialog box is modal, FALSE otherwise.
209
210\membersection{wxDialog::OnCharHook}\label{wxdialogoncharhook}
211
212\func{void}{OnCharHook}{\param{wxKeyEvent\&}{ event}}
213
214This member is called to allow the window to intercept keyboard events
215before they are processed by child windows.
216
f4fcc291 217%For more information, see \helpref{wxWindow::OnCharHook}{wxwindowoncharhook}
a660d684
KB
218
219\wxheading{Remarks}
220
221wxDialog implements this handler to fake a cancel command if the escape key has been
222pressed. This will dismiss the dialog.
223
224\membersection{wxDialog::OnApply}\label{wxdialogonapply}
225
226\func{void}{OnApply}{\param{wxCommandEvent\& }{event}}
227
228The default handler for the wxID\_APPLY identifier.
229
230\wxheading{Remarks}
231
232This function calls \helpref{wxWindow::Validate}{wxwindowvalidate} and \helpref{wxWindow::TransferDataToWindow}{wxwindowtransferdatatowindow}.
233
234\wxheading{See also}
235
236\helpref{wxDialog::OnOK}{wxdialogonok}, \helpref{wxDialog::OnCancel}{wxdialogoncancel}
237
238\membersection{wxDialog::OnCancel}\label{wxdialogoncancel}
239
240\func{void}{OnCancel}{\param{wxCommandEvent\& }{event}}
241
242The default handler for the wxID\_CANCEL identifier.
243
244\wxheading{Remarks}
245
246The function either calls {\bf EndModal(wxID\_CANCEL)} if the dialog is modal, or
247sets the return value to wxID\_CANCEL and calls {\bf Show(FALSE)} if the dialog is modeless.
248
249\wxheading{See also}
250
251\helpref{wxDialog::OnOK}{wxdialogonok}, \helpref{wxDialog::OnApply}{wxdialogonapply}
252
253\membersection{wxDialog::OnOK}\label{wxdialogonok}
254
255\func{void}{OnOK}{\param{wxCommandEvent\& }{event}}
256
257The default handler for the wxID\_OK identifier.
258
259\wxheading{Remarks}
260
261The function calls
262\rtfsp\helpref{wxWindow::Validate}{wxwindowvalidate}, then \helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow}.
263If this returns TRUE, the function either calls {\bf EndModal(wxID\_OK)} if the dialog is modal, or
264sets the return value to wxID\_OK and calls {\bf Show(FALSE)} if the dialog is modeless.
265
266\wxheading{See also}
267
268\helpref{wxDialog::OnCancel}{wxdialogoncancel}, \helpref{wxDialog::OnApply}{wxdialogonapply}
269
270\membersection{wxDialog::OnSysColourChanged}\label{wxdialogonsyscolourchanged}
271
272\func{void}{OnSysColourChanged}{\param{wxSysColourChangedEvent\& }{event}}
273
274The default handler for wxEVT\_SYS\_COLOUR\_CHANGED.
275
276\wxheading{Parameters}
277
278\docparam{event}{The colour change event.}
279
280\wxheading{Remarks}
281
282Changes the dialog's colour to conform to the current settings (Windows only).
283Add an event table entry for your dialog class if you wish the behaviour
284to be different (such as keeping a user-defined
f4fcc291 285background colour). If you do override this function, call wxEvent::Skip to
a660d684
KB
286propagate the notification to child windows and controls.
287
288\wxheading{See also}
289
290\helpref{wxSysColourChangedEvent}{wxsyscolourchangedevent}
291
9a6a5530
MB
292\membersection{wxDialog::SetIcon}\label{wxdialogseticon}
293
294\func{void}{SetIcon}{\param{const wxIcon\& }{icon}}
295
296Sets the icon for this dialog.
297
298\wxheading{Parameters}
299
300\docparam{icon}{The icon to associate with this dialog.}
301
302See also \helpref{wxIcon}{wxicon}.
303
304\membersection{wxDialog::SetIcons}\label{wxdialogseticons}
305
306\func{void}{SetIcons}{\param{const wxIconBundle\& }{icons}}
307
308Sets the icons for this dialog.
309
310\wxheading{Parameters}
311
312\docparam{icons}{The icons to associate with this dialog.}
313
314See also \helpref{wxIconBundle}{wxiconbundle}.
315
a660d684
KB
316\membersection{wxDialog::SetModal}\label{wxdialogsetmodal}
317
318\func{void}{SetModal}{\param{const bool}{ flag}}
319
f6bcfd97
BP
320{\bf NB:} This function is deprecated and doesn't work for all ports, just use
321\helpref{ShowModal}{wxdialogshowmodal} to show a modal dialog instead.
322
a660d684
KB
323Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
324until the dialog is hidden) or modeless (control returns immediately).
325
326\wxheading{Parameters}
327
328\docparam{flag}{If TRUE, the dialog will be modal, otherwise it will be modeless.}
329
6453876e
RR
330\membersection{wxDialog::SetReturnCode}\label{wxdialogsetreturncode}
331
332\func{void}{SetReturnCode}{\param{int }{retCode}}
333
334Sets the return code for this window.
335
336\wxheading{Parameters}
337
338\docparam{retCode}{The integer return code, usually a control identifier.}
339
340\wxheading{Remarks}
341
342A return code is normally associated with a modal dialog, where \helpref{wxDialog::ShowModal}{wxdialogshowmodal} returns
343a code to the application. The function \helpref{wxDialog::EndModal}{wxdialogendmodal} calls {\bf SetReturnCode}.
344
345\wxheading{See also}
346
d7cb14ce 347\helpref{wxDialog::GetReturnCode}{wxdialoggetreturncode}, \helpref{wxDialog::ShowModal}{wxdialogshowmodal},\rtfsp
6453876e
RR
348\helpref{wxDialog::EndModal}{wxdialogendmodal}
349
a660d684
KB
350\membersection{wxDialog::SetTitle}\label{wxdialogsettitle}
351
352\func{void}{SetTitle}{\param{const wxString\& }{ title}}
353
354Sets the title of the dialog box.
355
356\wxheading{Parameters}
357
358\docparam{title}{The dialog box title.}
359
360\membersection{wxDialog::Show}\label{wxdialogshow}
361
362\func{bool}{Show}{\param{const bool}{ show}}
363
364Hides or shows the dialog.
365
366\wxheading{Parameters}
367
368\docparam{show}{If TRUE, the dialog box is shown and brought to the front;
369otherwise the box is hidden. If FALSE and the dialog is
370modal, control is returned to the calling program.}
371
372\wxheading{Remarks}
373
374The preferred way of dismissing a modal dialog is to use \helpref{wxDialog::EndModal}{wxdialogendmodal}.
375
376\membersection{wxDialog::ShowModal}\label{wxdialogshowmodal}
377
378\func{int}{ShowModal}{\void}
379
380Shows a modal dialog. Program flow does not return until the dialog has been dismissed with\rtfsp
381\helpref{wxDialog::EndModal}{wxdialogendmodal}.
382
383\wxheading{Return value}
384
d7cb14ce 385The return value is the value set with \helpref{wxDialog::SetReturnCode}{wxdialogsetreturncode}.
a660d684
KB
386
387\wxheading{See also}
388
389\helpref{wxDialog::EndModal}{wxdialogendmodal},\rtfsp
d7cb14ce
JS
390\helpref{wxDialog:GetReturnCode}{wxdialoggetreturncode},\rtfsp
391\helpref{wxDialog::SetReturnCode}{wxdialogsetreturncode}
a660d684 392