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