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{wxTopLevelWindow
}{wxtoplevelwindow
}\\
10 \helpref{wxWindow
}{wxwindow
}\\
11 \helpref{wxEvtHandler
}{wxevthandler
}\\
12 \helpref{wxObject
}{wxobject
}
14 \wxheading{Include files
}
20 There are two kinds of dialog --
{\it modal
}\ and
{\it modeless
}. A modal dialog
21 blocks program flow and user input on other windows until it is dismissed,
22 whereas a modeless dialog behaves more like a frame in that program flow
23 continues, and input in other windows is still possible. To show a modal dialog
24 you should use the
\helpref{ShowModal
}{wxdialogshowmodal
} method while to show
25 a dialog modelessly you simply use
\helpref{Show
}{wxdialogshow
}, just as with
28 Note that the modal dialog is one of the very few examples of
29 wxWindow-derived objects which may be created on the stack and not on the heap.
30 In other words, although this code snippet:
35 MyAskDialog *dlg = new MyAskDialog(...);
36 if ( dlg->ShowModal() == wxID_OK )
38 //else: dialog was cancelled or some another button pressed
44 works, you can also achieve the same result by using a simpler code fragment
51 if ( dlg.ShowModal() == wxID_OK )
54 // no need to call Destroy() here
58 An application can define a
\helpref{wxCloseEvent
}{wxcloseevent
} handler for
59 the dialog to respond to system close events.
61 \wxheading{Window styles
}
64 \begin{twocollist
}\itemsep=
0pt
65 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the dialog box.
}
66 \twocolitem{\windowstyle{wxDEFAULT
\_DIALOG\_STYLE}}{Equivalent to a combination of wxCAPTION, wxCLOSE
\_BOX and wxSYSTEM
\_MENU (the last one is not used under Unix)
}
67 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Display a resizeable frame around the window.
}
68 \twocolitem{\windowstyle{wxSYSTEM
\_MENU}}{Display a system menu.
}
69 \twocolitem{\windowstyle{wxCLOSE
\_BOX}}{Displays a close box on the frame.
}
70 \twocolitem{\windowstyle{wxMAXIMIZE
\_BOX}}{Displays a maximize box on the dialog.
}
71 \twocolitem{\windowstyle{wxMINIMIZE
\_BOX}}{Displays a minimize box on the dialog.
}
72 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Display a thick frame around the window.
}
73 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{The dialog stays on top of all other windows.
}
74 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
75 should not have
3D borders unless specified in the control.
}
76 \twocolitem{\windowstyle{wxDIALOG
\_NO\_PARENT}}{By default, a dialog created
77 with a
{\tt NULL
} parent window will be given the
78 \helpref{application's top level window
}{wxappgettopwindow
} as parent. Use this
79 style to prevent this from happening and create an orphan dialog. This is not recommended for modal dialogs.
}
80 \twocolitem{\windowstyle{wxDIALOG
\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
81 caption. When pressed, Windows will go into a context-sensitive help mode and wxWidgets will send
82 a wxEVT
\_HELP event if the user clicked on an application window.
{\it Note
}\ that this is an extended
83 style and must be set by calling
\helpref{SetExtraStyle
}{wxwindowsetextrastyle
} before Create is called (two-step construction).
}
84 \twocolitem{\windowstyle{wxDIALOG
\_EX\_METAL}}{On Mac OS X, frames with this style will be shown with a metallic look. This is an
{\it extra
} style.
}
87 Under Unix or Linux, MWM (the Motif Window Manager) or other window managers
88 recognizing the MHM hints should be running for any of these styles to have an
91 See also
\helpref{Generic window styles
}{windowstyles
}.
95 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\rtfsp
96 \helpref{Validator overview
}{validatoroverview
}
98 \latexignore{\rtfignore{\wxheading{Members
}}}
101 \membersection{wxDialog::wxDialog
}\label{wxdialogctor
}
103 \func{}{wxDialog
}{\void}
107 \func{}{wxDialog
}{\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"
}}
116 \wxheading{Parameters
}
118 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
120 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
122 \docparam{title
}{The title of the dialog.
}
124 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
125 either the windowing system or wxWidgets, depending on platform.
}
127 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
128 either the windowing system or wxWidgets, depending on platform.
}
130 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
132 \docparam{name
}{Used to associate a name with the window,
133 allowing the application user to set Motif resource values for
134 individual dialog boxes.
}
138 \helpref{wxDialog::Create
}{wxdialogcreate
}
141 \membersection{wxDialog::
\destruct{wxDialog
}}\label{wxdialogdtor
}
143 \func{}{\destruct{wxDialog
}}{\void}
145 Destructor. Deletes any child windows before deleting the physical window.
148 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
150 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
152 Centres the dialog box on the display.
154 \wxheading{Parameters
}
156 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
159 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
161 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
162 \param{const wxString\&
}{title
},
\rtfsp
163 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
164 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
165 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
166 \param{const wxString\&
}{name = ``dialogBox"
}}
168 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogctor
}\rtfsp
172 \membersection{wxDialog::CreateButtonSizer
}\label{wxdialogcreatebuttonsizer
}
174 \func{wxSizer*
}{CreateButtonSizer
}{\param{long
}{ flags
}}
176 Creates a sizer with standard buttons.
{\it flags
} is a bit list
177 of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxHELP, wxNO
\_DEFAULT.
179 The sizer lays out the buttons in a manner appropriate to the platform.
181 This function simply calls
\helpref{CreateStdDialogButtonSizer
}{wxdialogcreatestddialogbuttonsizer
}.
184 \membersection{wxDialog::CreateStdDialogButtonSizer
}\label{wxdialogcreatestddialogbuttonsizer
}
186 \func{wxStdDialogButtonSizer*
}{CreateStdDialogButtonSizer
}{\param{long
}{ flags
}}
188 Creates a
\helpref{wxStdDialogButtonSizer
}{wxstddialogbuttonsizer
} with standard buttons.
{\it flags
} is a bit list
189 of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxHELP, wxNO
\_DEFAULT.
191 The sizer lays out the buttons in a manner appropriate to the platform.
194 \membersection{wxDialog::DoOK
}\label{wxdialogdook
}
196 \func{virtual bool
}{DoOK
}{\void}
198 This function is called when the titlebar OK button is pressed (PocketPC only).
199 A command event for the identifier returned by GetAffirmativeId is sent by
200 default. You can override this function. If the function returns false, wxWidgets
201 will call Close() for the dialog.
204 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
206 \func{void
}{EndModal
}{\param{int
}{retCode
}}
208 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
211 \wxheading{Parameters
}
213 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
217 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
218 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
219 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}
222 \membersection{wxDialog::GetAffirmativeId
}\label{wxdialoggetaffirmativeid
}
224 \constfunc{int
}{GetAffirmativeId
}{\void}
226 Gets the identifier to be used when the user presses an OK button in a PocketPC titlebar.
230 \helpref{wxDialog::SetAffirmativeId
}{wxdialogsetaffirmativeid
}
233 \membersection{wxDialog::GetEscapeId
}\label{wxdialoggetescapeid
}
235 \constfunc{int
}{GetEscapeId
}{\void}
237 Gets the identifier of the button to map presses of
\texttt{\textsc{ESC
}}
242 \helpref{wxDialog::SetEscapeId
}{wxdialogsetescapeid
}
245 \membersection{wxDialog::GetReturnCode
}\label{wxdialoggetreturncode
}
247 \func{int
}{GetReturnCode
}{\void}
249 Gets the return code for this window.
253 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
254 a code to the application.
258 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
259 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
262 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
264 \constfunc{wxString
}{GetTitle
}{\void}
266 Returns the title of the dialog box.
269 \membersection{wxDialog::GetToolBar
}\label{wxdialoggettoolbar
}
271 \constfunc{wxToolBar*
}{GetToolBar
}{\void}
273 On PocketPC, a dialog is automatically provided with an empty toolbar. GetToolBar
274 allows you to access the toolbar and add tools to it. Removing tools and adding
275 arbitrary controls are not currently supported.
277 This function is not available on any other platform.
280 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
282 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
284 Iconizes or restores the dialog. Windows only.
286 \wxheading{Parameters
}
288 \docparam{iconize
}{If true, iconizes the dialog box; if false, shows and restores it.
}
292 Note that in Windows, iconization has no effect since dialog boxes cannot be
293 iconized. However, applications may need to explicitly restore dialog
294 boxes under Motif which have user-iconizable frames, and under Windows
295 calling
{\tt Iconize(false)
} will bring the window to the front, as does
296 \rtfsp{\tt Show(true)
}.
299 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
301 \constfunc{bool
}{IsIconized
}{\void}
303 Returns true if the dialog box is iconized. Windows only.
307 Always returns false under Windows since dialogs cannot be iconized.
310 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
312 \constfunc{bool
}{IsModal
}{\void}
314 Returns true if the dialog box is modal, false otherwise.
317 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
319 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
321 The default handler for the wxID
\_APPLY identifier.
325 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
329 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
332 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
334 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
336 The default handler for the wxID
\_CANCEL identifier.
340 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
341 sets the return value to wxID
\_CANCEL and calls
{\bf Show(false)
} if the dialog is modeless.
345 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
348 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
350 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
352 The default handler for the wxID
\_OK identifier.
357 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
358 If this returns true, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
359 sets the return value to wxID
\_OK and calls
{\bf Show(false)
} if the dialog is modeless.
363 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
366 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
368 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
370 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
372 \wxheading{Parameters
}
374 \docparam{event
}{The colour change event.
}
378 Changes the dialog's colour to conform to the current settings (Windows only).
379 Add an event table entry for your dialog class if you wish the behaviour
380 to be different (such as keeping a user-defined
381 background colour). If you do override this function, call wxEvent::Skip to
382 propagate the notification to child windows and controls.
386 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
389 \membersection{wxDialog::SetAffirmativeId
}\label{wxdialogsetaffirmativeid
}
391 \func{void
}{SetAffirmativeId
}{\param{int
}{id
}}
393 Sets the identifier to be used when the user presses an OK button in a PocketPC titlebar.
394 By default, this is wxID
\_OK.
398 \helpref{wxDialog::GetAffirmativeId
}{wxdialoggetaffirmativeid
}
401 \membersection{wxDialog::SetEscapeId
}\label{wxdialogsetescapeid
}
403 \func{void
}{SetEscapeId
}{\param{int
}{id
}}
405 Sets the identifier to be used when the user presses
\texttt{\textsc{ESC
}}
406 button in the dialog. By default, this is
\texttt{wxID
\_ANY} meaning that
407 the first suitable button is used: if there a
\texttt{wxID
\_CANCEL} button, it
408 is activated, otherwise
\texttt{wxID
\_OK} button is activated if present.
409 Another possible special value for
\arg{id
} is
\texttt{wxID
\_NONE} meaning that
410 \texttt{\textsc{ESC
}} presses should be ignored. If another value is given, it
411 is interpreted as the id of the button to map the escape key to.
414 \membersection{wxDialog::SetIcon
}\label{wxdialogseticon
}
416 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
418 Sets the icon for this dialog.
420 \wxheading{Parameters
}
422 \docparam{icon
}{The icon to associate with this dialog.
}
424 See also
\helpref{wxIcon
}{wxicon
}.
427 \membersection{wxDialog::SetIcons
}\label{wxdialogseticons
}
429 \func{void
}{SetIcons
}{\param{const wxIconBundle\&
}{icons
}}
431 Sets the icons for this dialog.
433 \wxheading{Parameters
}
435 \docparam{icons
}{The icons to associate with this dialog.
}
437 See also
\helpref{wxIconBundle
}{wxiconbundle
}.
440 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
442 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
444 {\bf NB:
} This function is deprecated and doesn't work for all ports, just use
445 \helpref{ShowModal
}{wxdialogshowmodal
} to show a modal dialog instead.
447 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
448 until the dialog is hidden) or modeless (control returns immediately).
450 \wxheading{Parameters
}
452 \docparam{flag
}{If true, the dialog will be modal, otherwise it will be modeless.
}
455 \membersection{wxDialog::SetReturnCode
}\label{wxdialogsetreturncode
}
457 \func{void
}{SetReturnCode
}{\param{int
}{retCode
}}
459 Sets the return code for this window.
461 \wxheading{Parameters
}
463 \docparam{retCode
}{The integer return code, usually a control identifier.
}
467 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
468 a code to the application. The function
\helpref{wxDialog::EndModal
}{wxdialogendmodal
} calls
{\bf SetReturnCode
}.
472 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
473 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
476 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
478 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
480 Sets the title of the dialog box.
482 \wxheading{Parameters
}
484 \docparam{title
}{The dialog box title.
}
487 \membersection{wxDialog::Show
}\label{wxdialogshow
}
489 \func{bool
}{Show
}{\param{const bool
}{ show
}}
491 Hides or shows the dialog.
493 \wxheading{Parameters
}
495 \docparam{show
}{If true, the dialog box is shown and brought to the front;
496 otherwise the box is hidden. If false and the dialog is
497 modal, control is returned to the calling program.
}
501 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
504 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
506 \func{int
}{ShowModal
}{\void}
508 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
509 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
511 \wxheading{Return value
}
513 The return value is the value set with
\helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}.
517 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
518 \helpref{wxDialog:GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
519 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}