1 \section{\class{wxDialog
}}\label{wxdialog
}
3 A dialog box is a window with a title bar and sometimes a system menu, which
4 can be moved around the screen. It can contain controls and other windows and
5 is usually used to allow the user to make some choice or to answer a question.
7 \wxheading{Derived from
}
9 \helpref{wxWindow
}{wxwindow
}\\
10 \helpref{wxEvtHandler
}{wxevthandler
}\\
11 \helpref{wxObject
}{wxobject
}
13 \wxheading{Include files
}
19 There are two kinds of dialog --
{\it modal
}\ and
{\it modeless
}. A modal dialog
20 blocks program flow and user input on other windows until it is dismissed,
21 whereas a modeless dialog behaves more like a frame in that program flow
22 continues, and input on other windows is still possible. To show a modal dialog
23 you should use
\helpref{ShowModal
}{wxdialogshowmodal
} method while to show
24 dialog modelessly you simply use
\helpref{Show
}{wxdialogshow
}, just as with the
27 Note that the modal dialogs are one of the very few examples of
28 wxWindow-derived objects which may be created on the stack and not on the heap.
29 In other words, although this code snippet
33 MyAskDialog *dlg = new MyAskDialog(...);
34 if ( dlg->ShowModal() == wxID_OK )
36 //else: dialog was cancelled or some another button pressed
41 works, you can also achieve the same result by using a simpler code fragment
47 if ( dlg.ShowModal() == wxID_OK )
50 // no need to call Destroy() here
54 An application can define an
\helpref{wxCloseEvent
}{wxcloseevent
} handler for
55 the dialog to respond to system close events.
57 \wxheading{Window styles
}
60 \begin{twocollist
}\itemsep=
0pt
61 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the dialog box.
}
62 \twocolitem{\windowstyle{wxDEFAULT
\_DIALOG\_STYLE}}{Equivalent to a combination of wxCAPTION, wxCLOSE
\_BOX and wxSYSTEM
\_MENU (the last one is not used under Unix)
}
63 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Display a resizeable frame around the window.
}
64 \twocolitem{\windowstyle{wxSYSTEM
\_MENU}}{Display a system menu.
}
65 \twocolitem{\windowstyle{wxCLOSE
\_BOX}}{Displays a close box on the frame.
}
66 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Display a thick frame around the window.
}
67 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{The dialog stays on top of all other windows (Windows only).
}
68 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
69 should not have
3D borders unless specified in the control.
}
70 \twocolitem{\windowstyle{wxDIALOG
\_NO\_PARENT}}{By default, the dialogs created
71 with
{\tt NULL
} parent window will be given the
72 \helpref{applications top level window
}{wxappgettopwindow
} as parent. Use this
73 style to prevent this from happening and create a really orphan dialog (note
74 that this is not recommended for modal dialogs).
}
75 \twocolitem{\windowstyle{wxDIALOG
\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
76 caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
77 a wxEVT
\_HELP event if the user clicked on an application window.
{\it Note
}\ that this is an extended
78 style and must be set by calling
\helpref{SetExtraStyle
}{wxwindowsetextrastyle
} before Create is called (two-step construction).
}
81 Under Unix or Linux, MWM (the Motif Window Manager) or other window managers
82 recognizing the MHM hints should be running for any of these styles to have an
85 See also
\helpref{Generic window styles
}{windowstyles
}.
89 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\rtfsp
90 \helpref{Validator overview
}{validatoroverview
}
92 \latexignore{\rtfignore{\wxheading{Members
}}}
94 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
96 \func{}{wxDialog
}{\void}
100 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
101 \param{const wxString\&
}{title
},
\rtfsp
102 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
103 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
104 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
105 \param{const wxString\&
}{name = ``dialogBox"
}}
109 \wxheading{Parameters
}
111 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
113 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
115 \docparam{title
}{The title of the dialog.
}
117 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
118 either the windowing system or wxWindows, depending on platform.
}
120 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
121 either the windowing system or wxWindows, depending on platform.
}
123 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
125 \docparam{name
}{Used to associate a name with the window,
126 allowing the application user to set Motif resource values for
127 individual dialog boxes.
}
131 \helpref{wxDialog::Create
}{wxdialogcreate
}
133 \membersection{wxDialog::
\destruct{wxDialog
}}
135 \func{}{\destruct{wxDialog
}}{\void}
137 Destructor. Deletes any child windows before deleting the physical window.
139 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
141 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
143 Centres the dialog box on the display.
145 \wxheading{Parameters
}
147 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
149 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
151 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
152 \param{const wxString\&
}{title
},
\rtfsp
153 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
154 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
155 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
156 \param{const wxString\&
}{name = ``dialogBox"
}}
158 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
161 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
163 \func{void
}{EndModal
}{\param{int
}{retCode
}}
165 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
168 \wxheading{Parameters
}
170 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
174 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
175 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
176 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}
178 \membersection{wxDialog::GetReturnCode
}\label{wxdialoggetreturncode
}
180 \func{int
}{GetReturnCode
}{\void}
182 Gets the return code for this window.
186 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
187 a code to the application.
191 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
192 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
194 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
196 \constfunc{wxString
}{GetTitle
}{\void}
198 Returns the title of the dialog box.
200 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
202 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
204 Iconizes or restores the dialog. Windows only.
206 \wxheading{Parameters
}
208 \docparam{iconize
}{If true, iconizes the dialog box; if false, shows and restores it.
}
212 Note that in Windows, iconization has no effect since dialog boxes cannot be
213 iconized. However, applications may need to explicitly restore dialog
214 boxes under Motif which have user-iconizable frames, and under Windows
215 calling
{\tt Iconize(false)
} will bring the window to the front, as does
216 \rtfsp{\tt Show(true)
}.
218 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
220 \constfunc{bool
}{IsIconized
}{\void}
222 Returns true if the dialog box is iconized. Windows only.
226 Always returns false under Windows since dialogs cannot be iconized.
228 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
230 \constfunc{bool
}{IsModal
}{\void}
232 Returns true if the dialog box is modal, false otherwise.
234 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
236 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
238 This member is called to allow the window to intercept keyboard events
239 before they are processed by child windows.
241 %For more information, see \helpref{wxWindow::OnCharHook}{wxwindowoncharhook}
245 wxDialog implements this handler to fake a cancel command if the escape key has been
246 pressed. This will dismiss the dialog.
248 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
250 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
252 The default handler for the wxID
\_APPLY identifier.
256 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
260 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
262 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
264 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
266 The default handler for the wxID
\_CANCEL identifier.
270 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
271 sets the return value to wxID
\_CANCEL and calls
{\bf Show(false)
} if the dialog is modeless.
275 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
277 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
279 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
281 The default handler for the wxID
\_OK identifier.
286 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
287 If this returns true, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
288 sets the return value to wxID
\_OK and calls
{\bf Show(false)
} if the dialog is modeless.
292 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
294 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
296 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
298 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
300 \wxheading{Parameters
}
302 \docparam{event
}{The colour change event.
}
306 Changes the dialog's colour to conform to the current settings (Windows only).
307 Add an event table entry for your dialog class if you wish the behaviour
308 to be different (such as keeping a user-defined
309 background colour). If you do override this function, call wxEvent::Skip to
310 propagate the notification to child windows and controls.
314 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
316 \membersection{wxDialog::SetIcon
}\label{wxdialogseticon
}
318 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
320 Sets the icon for this dialog.
322 \wxheading{Parameters
}
324 \docparam{icon
}{The icon to associate with this dialog.
}
326 See also
\helpref{wxIcon
}{wxicon
}.
328 \membersection{wxDialog::SetIcons
}\label{wxdialogseticons
}
330 \func{void
}{SetIcons
}{\param{const wxIconBundle\&
}{icons
}}
332 Sets the icons for this dialog.
334 \wxheading{Parameters
}
336 \docparam{icons
}{The icons to associate with this dialog.
}
338 See also
\helpref{wxIconBundle
}{wxiconbundle
}.
340 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
342 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
344 {\bf NB:
} This function is deprecated and doesn't work for all ports, just use
345 \helpref{ShowModal
}{wxdialogshowmodal
} to show a modal dialog instead.
347 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
348 until the dialog is hidden) or modeless (control returns immediately).
350 \wxheading{Parameters
}
352 \docparam{flag
}{If true, the dialog will be modal, otherwise it will be modeless.
}
354 \membersection{wxDialog::SetReturnCode
}\label{wxdialogsetreturncode
}
356 \func{void
}{SetReturnCode
}{\param{int
}{retCode
}}
358 Sets the return code for this window.
360 \wxheading{Parameters
}
362 \docparam{retCode
}{The integer return code, usually a control identifier.
}
366 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
367 a code to the application. The function
\helpref{wxDialog::EndModal
}{wxdialogendmodal
} calls
{\bf SetReturnCode
}.
371 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
372 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
374 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
376 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
378 Sets the title of the dialog box.
380 \wxheading{Parameters
}
382 \docparam{title
}{The dialog box title.
}
384 \membersection{wxDialog::Show
}\label{wxdialogshow
}
386 \func{bool
}{Show
}{\param{const bool
}{ show
}}
388 Hides or shows the dialog.
390 \wxheading{Parameters
}
392 \docparam{show
}{If true, the dialog box is shown and brought to the front;
393 otherwise the box is hidden. If false and the dialog is
394 modal, control is returned to the calling program.
}
398 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
400 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
402 \func{int
}{ShowModal
}{\void}
404 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
405 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
407 \wxheading{Return value
}
409 The return value is the value set with
\helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}.
413 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
414 \helpref{wxDialog:GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
415 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}