]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/dialog.tex
Various documentation changes, makefile fixes
[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{Remarks}
14
15 There are two kinds of dialog - {\it modal} and {\it modeless}. A modal dialog
16 blocks program flow and user input on other windows until it is dismissed, whereas a modeless dialog behaves more
17 like a frame in that program flow continues, and input on other windows is still possible.
18 You specify the type of dialog with the {\bf wxDIALOG\_MODAL} and {\bf wxDIALOG\_MODELESS} window
19 styles.
20
21 A dialog may be loaded from a wxWindows resource file (extension {\tt wxr}).
22
23 An application can define an \helpref{OnCloseWindow}{wxwindowonclosewindow} handler for the
24 dialog 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
36 should not have 3D borders unless specified in the control.}
37 \end{twocollist}
38
39 Under Motif, MWM (the Motif Window Manager) should be running for any of these styles to have an effect.
40
41 See 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
54 Default constructor.
55
56 \func{}{wxDialog}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
57 \param{const wxString\& }{title},\rtfsp
58 \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
59 \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
60 \param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
61 \param{const wxString\& }{name = ``dialogBox"}}
62
63 Constructor.
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
74 either 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
77 either 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,
82 allowing the application user to set Motif resource values for
83 individual 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
93 Destructor. Deletes any child windows before deleting the physical window.
94
95 \membersection{wxDialog::Centre}\label{wxdialogcentre}
96
97 \func{void}{Centre}{\param{int}{ direction = wxBOTH}}
98
99 Centres 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
107 \func{bool}{Create}{\param{wxWindow* }{parent}, \param{wxWindowID }{id},\rtfsp
108 \param{const wxString\& }{title},\rtfsp
109 \param{const wxPoint\& }{pos = wxDefaultPosition},\rtfsp
110 \param{const wxSize\& }{size = wxDefaultSize},\rtfsp
111 \param{long}{ style = wxDEFAULT\_DIALOG\_STYLE},\rtfsp
112 \param{const wxString\& }{name = ``dialogBox"}}
113
114 Used for two-step dialog box construction. See \helpref{wxDialog::wxDialog}{wxdialogconstr}\rtfsp
115 for details.
116
117 \membersection{wxDialog::EndModal}\label{wxdialogendmodal}
118
119 \func{void}{EndModal}{\param{int }{retCode}}
120
121 Ends a modal dialog, passing a value to be returned from the \helpref{wxDialog::ShowModal}{wxdialogshowmodal}\rtfsp
122 invocation.
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
138 Returns the title of the dialog box.
139
140 \membersection{wxDialog::Iconize}\label{wxdialogiconized}
141
142 \func{void}{Iconize}{\param{const bool}{ iconize}}
143
144 Iconizes 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
152 Note that in Windows, iconization has no effect since dialog boxes cannot be
153 iconized. However, applications may need to explicitly restore dialog
154 boxes under Motif which have user-iconizable frames, and under Windows
155 calling {\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
162 Returns TRUE if the dialog box is iconized.
163
164 \wxheading{Remarks}
165
166 Always returns FALSE under Windows since dialogs cannot be iconized.
167
168 \membersection{wxDialog::IsModal}\label{wxdialogismodal}
169
170 \constfunc{bool}{IsModal}{\void}
171
172 Returns 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
178 This member is called to allow the window to intercept keyboard events
179 before they are processed by child windows.
180
181 For more information, see \helpref{wxWindow::OnCharHook}{wxwindowoncharhook}
182
183 \wxheading{Remarks}
184
185 wxDialog implements this handler to fake a cancel command if the escape key has been
186 pressed. This will dismiss the dialog.
187
188 \membersection{wxDialog::OnApply}\label{wxdialogonapply}
189
190 \func{void}{OnApply}{\param{wxCommandEvent\& }{event}}
191
192 The default handler for the wxID\_APPLY identifier.
193
194 \wxheading{Remarks}
195
196 This 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
206 The default handler for the wxID\_CANCEL identifier.
207
208 \wxheading{Remarks}
209
210 The function either calls {\bf EndModal(wxID\_CANCEL)} if the dialog is modal, or
211 sets 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
221 The default handler for the wxID\_OK identifier.
222
223 \wxheading{Remarks}
224
225 The function calls
226 \rtfsp\helpref{wxWindow::Validate}{wxwindowvalidate}, then \helpref{wxWindow::TransferDataFromWindow}{wxwindowtransferdatafromwindow}.
227 If this returns TRUE, the function either calls {\bf EndModal(wxID\_OK)} if the dialog is modal, or
228 sets 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
238 The default handler for wxEVT\_SYS\_COLOUR\_CHANGED.
239
240 \wxheading{Parameters}
241
242 \docparam{event}{The colour change event.}
243
244 \wxheading{Remarks}
245
246 Changes the dialog's colour to conform to the current settings (Windows only).
247 Add an event table entry for your dialog class if you wish the behaviour
248 to be different (such as keeping a user-defined
249 background colour). If you do override this function, call \helpref{wxWindow::OnSysColourChanged}{wxwindowonsyscolourchanged} to
250 propagate 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
260 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
261 until 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
271 Sets 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
281 Hides or shows the dialog.
282
283 \wxheading{Parameters}
284
285 \docparam{show}{If TRUE, the dialog box is shown and brought to the front;
286 otherwise the box is hidden. If FALSE and the dialog is
287 modal, control is returned to the calling program.}
288
289 \wxheading{Remarks}
290
291 The 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
297 Shows 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
302 The 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