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