1 \section{\class{wxDialog
}}\label{wxdialog
}
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.
6 \wxheading{Derived from
}
8 \helpref{wxPanel
}{wxpanel
}\\
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, whereas a modeless dialog behaves more
21 like a frame in that program flow continues, and input on other windows is still possible.
22 You specify the type of dialog with the
{\bf wxDIALOG
\_MODAL} and
{\bf wxDIALOG
\_MODELESS} window
25 A dialog may be loaded from a wxWindows resource file (extension
{\tt wxr
}).
27 An application can define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
28 dialog to respond to system close events.
30 \wxheading{Window styles
}
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}
36 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Display a resizeable frame around the window (Motif only).
}
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).
}
40 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
41 should not have
3D borders unless specified in the control.
}
44 Under Motif, MWM (the Motif Window Manager) should be running for any of these styles to have an effect.
46 See also
\helpref{Generic window styles
}{windowstyles
}.
50 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\helpref{Resources
}{resources
},
\rtfsp
51 \helpref{Validator overview
}{validatoroverview
}
53 \latexignore{\rtfignore{\wxheading{Members
}}}
55 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
57 \func{}{wxDialog
}{\void}
61 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
62 \param{const wxString\&
}{title
},
\rtfsp
63 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
64 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
65 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
66 \param{const wxString\&
}{name = ``dialogBox"
}}
70 \wxheading{Parameters
}
72 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
74 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
76 \docparam{title
}{The title of the dialog.
}
78 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
79 either the windowing system or wxWindows, depending on platform.
}
81 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
82 either the windowing system or wxWindows, depending on platform.
}
84 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
86 \docparam{name
}{Used to associate a name with the window,
87 allowing the application user to set Motif resource values for
88 individual dialog boxes.
}
92 \helpref{wxDialog::Create
}{wxdialogcreate
}
94 \membersection{wxDialog::
\destruct{wxDialog
}}
96 \func{}{\destruct{wxDialog
}}{\void}
98 Destructor. Deletes any child windows before deleting the physical window.
100 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
102 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
104 Centres the dialog box on the display.
106 \wxheading{Parameters
}
108 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
110 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
112 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
113 \param{const wxString\&
}{title
},
\rtfsp
114 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
115 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
116 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
117 \param{const wxString\&
}{name = ``dialogBox"
}}
119 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
122 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
124 \func{void
}{EndModal
}{\param{int
}{retCode
}}
126 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
129 \wxheading{Parameters
}
131 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
135 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
136 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
137 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}
139 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
141 \constfunc{wxString
}{GetTitle
}{\void}
143 Returns the title of the dialog box.
145 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
147 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
149 Iconizes or restores the dialog.
151 \wxheading{Parameters
}
153 \docparam{iconize
}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.
}
157 Note that in Windows, iconization has no effect since dialog boxes cannot be
158 iconized. However, applications may need to explicitly restore dialog
159 boxes under Motif which have user-iconizable frames, and under Windows
160 calling
{\tt Iconize(FALSE)
} will bring the window to the front, as does
161 \rtfsp{\tt Show(TRUE)
}.
163 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
165 \constfunc{bool
}{IsIconized
}{\void}
167 Returns TRUE if the dialog box is iconized.
171 Always returns FALSE under Windows since dialogs cannot be iconized.
173 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
175 \constfunc{bool
}{IsModal
}{\void}
177 Returns TRUE if the dialog box is modal, FALSE otherwise.
179 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
181 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
183 This member is called to allow the window to intercept keyboard events
184 before they are processed by child windows.
186 For more information, see
\helpref{wxWindow::OnCharHook
}{wxwindowoncharhook
}
190 wxDialog implements this handler to fake a cancel command if the escape key has been
191 pressed. This will dismiss the dialog.
193 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
195 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
197 The default handler for the wxID
\_APPLY identifier.
201 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
205 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
207 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
209 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
211 The default handler for the wxID
\_CANCEL identifier.
215 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
216 sets the return value to wxID
\_CANCEL and calls
{\bf Show(FALSE)
} if the dialog is modeless.
220 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
222 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
224 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
226 The default handler for the wxID
\_OK identifier.
231 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
232 If this returns TRUE, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
233 sets the return value to wxID
\_OK and calls
{\bf Show(FALSE)
} if the dialog is modeless.
237 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
239 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
241 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
243 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
245 \wxheading{Parameters
}
247 \docparam{event
}{The colour change event.
}
251 Changes the dialog's colour to conform to the current settings (Windows only).
252 Add an event table entry for your dialog class if you wish the behaviour
253 to be different (such as keeping a user-defined
254 background colour). If you do override this function, call
\helpref{wxWindow::OnSysColourChanged
}{wxwindowonsyscolourchanged
} to
255 propagate the notification to child windows and controls.
259 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
261 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
263 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
265 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
266 until the dialog is hidden) or modeless (control returns immediately).
268 \wxheading{Parameters
}
270 \docparam{flag
}{If TRUE, the dialog will be modal, otherwise it will be modeless.
}
272 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
274 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
276 Sets the title of the dialog box.
278 \wxheading{Parameters
}
280 \docparam{title
}{The dialog box title.
}
282 \membersection{wxDialog::Show
}\label{wxdialogshow
}
284 \func{bool
}{Show
}{\param{const bool
}{ show
}}
286 Hides or shows the dialog.
288 \wxheading{Parameters
}
290 \docparam{show
}{If TRUE, the dialog box is shown and brought to the front;
291 otherwise the box is hidden. If FALSE and the dialog is
292 modal, control is returned to the calling program.
}
296 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
298 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
300 \func{int
}{ShowModal
}{\void}
302 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
303 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
305 \wxheading{Return value
}
307 The return value is the value set with
\helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}.
311 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
312 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
313 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}