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
}
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
21 A dialog may be loaded from a wxWindows resource file (extension
{\tt wxr
}).
23 An application can define an
\helpref{OnCloseWindow
}{wxwindowonclosewindow
} handler for the
24 dialog to respond to system close events.
26 \wxheading{Window styles
}
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.
}
34 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Display a thick frame around the window.
}
35 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{The dialog stays on top of all other windows (Windows only).
}
36 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
37 should not have
3D borders unless specified in the control.
}
40 Under Motif, MWM (the Motif Window Manager) should be running for any of these styles to have an effect.
42 See also
\helpref{Generic window styles
}{windowstyles
}.
46 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\helpref{Resources
}{resources
},
\rtfsp
47 \helpref{Validator overview
}{validatoroverview
}
49 \latexignore{\rtfignore{\wxheading{Members
}}}
51 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
53 \func{}{wxDialog
}{\void}
57 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
58 \param{const wxString\&
}{title
},
\rtfsp
59 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
60 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
61 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
62 \param{const wxString\&
}{name = ``dialogBox"
}}
66 \wxheading{Parameters
}
68 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
70 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
72 \docparam{title
}{The title of the dialog.
}
74 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
75 either the windowing system or wxWindows, depending on platform.
}
77 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
78 either the windowing system or wxWindows, depending on platform.
}
80 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
82 \docparam{name
}{Used to associate a name with the window,
83 allowing the application user to set Motif resource values for
84 individual dialog boxes.
}
88 \helpref{wxDialog::Create
}{wxdialogcreate
}
90 \membersection{wxDialog::
\destruct{wxDialog
}}
92 \func{}{\destruct{wxDialog
}}{\void}
94 Destructor. Deletes any child windows before deleting the physical window.
96 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
98 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
100 Centres the dialog box on the display.
102 \wxheading{Parameters
}
104 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
106 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
108 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
109 \param{const wxString\&
}{title
},
\rtfsp
110 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
111 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
112 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
113 \param{const wxString\&
}{name = ``dialogBox"
}}
115 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
118 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
120 \func{void
}{EndModal
}{\param{int
}{retCode
}}
122 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
125 \wxheading{Parameters
}
127 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
131 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
132 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
133 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}
135 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
137 \constfunc{wxString
}{GetTitle
}{\void}
139 Returns the title of the dialog box.
141 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
143 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
145 Iconizes or restores the dialog.
147 \wxheading{Parameters
}
149 \docparam{iconize
}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.
}
153 Note that in Windows, iconization has no effect since dialog boxes cannot be
154 iconized. However, applications may need to explicitly restore dialog
155 boxes under Motif which have user-iconizable frames, and under Windows
156 calling
{\tt Iconize(FALSE)
} will bring the window to the front, as does
157 \rtfsp{\tt Show(TRUE)
}.
159 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
161 \constfunc{bool
}{IsIconized
}{\void}
163 Returns TRUE if the dialog box is iconized.
167 Always returns FALSE under Windows since dialogs cannot be iconized.
169 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
171 \constfunc{bool
}{IsModal
}{\void}
173 Returns TRUE if the dialog box is modal, FALSE otherwise.
175 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
177 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
179 This member is called to allow the window to intercept keyboard events
180 before they are processed by child windows.
182 For more information, see
\helpref{wxWindow::OnCharHook
}{wxwindowoncharhook
}
186 wxDialog implements this handler to fake a cancel command if the escape key has been
187 pressed. This will dismiss the dialog.
189 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
191 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
193 The default handler for the wxID
\_APPLY identifier.
197 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
201 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
203 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
205 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
207 The default handler for the wxID
\_CANCEL identifier.
211 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
212 sets the return value to wxID
\_CANCEL and calls
{\bf Show(FALSE)
} if the dialog is modeless.
216 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
218 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
220 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
222 The default handler for the wxID
\_OK identifier.
227 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
228 If this returns TRUE, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
229 sets the return value to wxID
\_OK and calls
{\bf Show(FALSE)
} if the dialog is modeless.
233 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
235 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
237 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
239 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
241 \wxheading{Parameters
}
243 \docparam{event
}{The colour change event.
}
247 Changes the dialog's colour to conform to the current settings (Windows only).
248 Add an event table entry for your dialog class if you wish the behaviour
249 to be different (such as keeping a user-defined
250 background colour). If you do override this function, call
\helpref{wxWindow::OnSysColourChanged
}{wxwindowonsyscolourchanged
} to
251 propagate the notification to child windows and controls.
255 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
257 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
259 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
261 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
262 until the dialog is hidden) or modeless (control returns immediately).
264 \wxheading{Parameters
}
266 \docparam{flag
}{If TRUE, the dialog will be modal, otherwise it will be modeless.
}
268 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
270 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
272 Sets the title of the dialog box.
274 \wxheading{Parameters
}
276 \docparam{title
}{The dialog box title.
}
278 \membersection{wxDialog::Show
}\label{wxdialogshow
}
280 \func{bool
}{Show
}{\param{const bool
}{ show
}}
282 Hides or shows the dialog.
284 \wxheading{Parameters
}
286 \docparam{show
}{If TRUE, the dialog box is shown and brought to the front;
287 otherwise the box is hidden. If FALSE and the dialog is
288 modal, control is returned to the calling program.
}
292 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
294 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
296 \func{int
}{ShowModal
}{\void}
298 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
299 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
301 \wxheading{Return value
}
303 The return value is the value set with
\helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}.
307 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
308 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
309 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}