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 (Unix 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 Unix or Linux, MWM (the Motif Window Manager) or other window managers reckognizing
45 the MHM hints should be running for any of these styles to have an effect.
47 See also
\helpref{Generic window styles
}{windowstyles
}.
51 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\helpref{Resources
}{resources
},
\rtfsp
52 \helpref{Validator overview
}{validatoroverview
}
54 \latexignore{\rtfignore{\wxheading{Members
}}}
56 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
58 \func{}{wxDialog
}{\void}
62 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
63 \param{const wxString\&
}{title
},
\rtfsp
64 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
65 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
66 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
67 \param{const wxString\&
}{name = ``dialogBox"
}}
71 \wxheading{Parameters
}
73 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
75 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
77 \docparam{title
}{The title of the dialog.
}
79 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
80 either the windowing system or wxWindows, depending on platform.
}
82 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
83 either the windowing system or wxWindows, depending on platform.
}
85 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
87 \docparam{name
}{Used to associate a name with the window,
88 allowing the application user to set Motif resource values for
89 individual dialog boxes.
}
93 \helpref{wxDialog::Create
}{wxdialogcreate
}
95 \membersection{wxDialog::
\destruct{wxDialog
}}
97 \func{}{\destruct{wxDialog
}}{\void}
99 Destructor. Deletes any child windows before deleting the physical window.
101 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
103 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
105 Centres the dialog box on the display.
107 \wxheading{Parameters
}
109 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
111 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
113 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
114 \param{const wxString\&
}{title
},
\rtfsp
115 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
116 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
117 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
118 \param{const wxString\&
}{name = ``dialogBox"
}}
120 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
123 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
125 \func{void
}{EndModal
}{\param{int
}{retCode
}}
127 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
130 \wxheading{Parameters
}
132 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
136 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
137 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
138 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}
140 \membersection{wxDialog::GetReturnCode
}\label{wxdialoggetreturncode
}
142 \func{int
}{GetReturnCode
}{\void}
144 Gets the return code for this window.
148 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
149 a code to the application.
153 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
154 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
156 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
158 \constfunc{wxString
}{GetTitle
}{\void}
160 Returns the title of the dialog box.
162 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
164 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
166 Iconizes or restores the dialog. Windows only.
168 \wxheading{Parameters
}
170 \docparam{iconize
}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.
}
174 Note that in Windows, iconization has no effect since dialog boxes cannot be
175 iconized. However, applications may need to explicitly restore dialog
176 boxes under Motif which have user-iconizable frames, and under Windows
177 calling
{\tt Iconize(FALSE)
} will bring the window to the front, as does
178 \rtfsp{\tt Show(TRUE)
}.
180 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
182 \constfunc{bool
}{IsIconized
}{\void}
184 Returns TRUE if the dialog box is iconized. Windows only.
188 Always returns FALSE under Windows since dialogs cannot be iconized.
190 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
192 \constfunc{bool
}{IsModal
}{\void}
194 Returns TRUE if the dialog box is modal, FALSE otherwise.
196 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
198 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
200 This member is called to allow the window to intercept keyboard events
201 before they are processed by child windows.
203 For more information, see
\helpref{wxWindow::OnCharHook
}{wxwindowoncharhook
}
207 wxDialog implements this handler to fake a cancel command if the escape key has been
208 pressed. This will dismiss the dialog.
210 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
212 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
214 The default handler for the wxID
\_APPLY identifier.
218 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
222 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
224 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
226 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
228 The default handler for the wxID
\_CANCEL identifier.
232 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
233 sets the return value to wxID
\_CANCEL and calls
{\bf Show(FALSE)
} if the dialog is modeless.
237 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
239 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
241 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
243 The default handler for the wxID
\_OK identifier.
248 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
249 If this returns TRUE, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
250 sets the return value to wxID
\_OK and calls
{\bf Show(FALSE)
} if the dialog is modeless.
254 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
256 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
258 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
260 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
262 \wxheading{Parameters
}
264 \docparam{event
}{The colour change event.
}
268 Changes the dialog's colour to conform to the current settings (Windows only).
269 Add an event table entry for your dialog class if you wish the behaviour
270 to be different (such as keeping a user-defined
271 background colour). If you do override this function, call
\helpref{wxWindow::OnSysColourChanged
}{wxwindowonsyscolourchanged
} to
272 propagate the notification to child windows and controls.
276 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
278 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
280 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
282 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
283 until the dialog is hidden) or modeless (control returns immediately).
285 \wxheading{Parameters
}
287 \docparam{flag
}{If TRUE, the dialog will be modal, otherwise it will be modeless.
}
289 \membersection{wxDialog::SetReturnCode
}\label{wxdialogsetreturncode
}
291 \func{void
}{SetReturnCode
}{\param{int
}{retCode
}}
293 Sets the return code for this window.
295 \wxheading{Parameters
}
297 \docparam{retCode
}{The integer return code, usually a control identifier.
}
301 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
302 a code to the application. The function
\helpref{wxDialog::EndModal
}{wxdialogendmodal
} calls
{\bf SetReturnCode
}.
306 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
307 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
309 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
311 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
313 Sets the title of the dialog box.
315 \wxheading{Parameters
}
317 \docparam{title
}{The dialog box title.
}
319 \membersection{wxDialog::Show
}\label{wxdialogshow
}
321 \func{bool
}{Show
}{\param{const bool
}{ show
}}
323 Hides or shows the dialog.
325 \wxheading{Parameters
}
327 \docparam{show
}{If TRUE, the dialog box is shown and brought to the front;
328 otherwise the box is hidden. If FALSE and the dialog is
329 modal, control is returned to the calling program.
}
333 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
335 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
337 \func{int
}{ShowModal
}{\void}
339 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
340 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
342 \wxheading{Return value
}
344 The return value is the value set with
\helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}.
348 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
349 \helpref{wxDialog:GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
350 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}