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
}), which may itself
26 be created by Dialog Editor. For details,
27 see
\helpref{The wxWindows resource system
}{resourceformats
},
\helpref{wxWindows resource functions
}{resourcefuncs
} and
30 An application can define an
\helpref{wxCloseEvent
}{wxcloseevent
} handler for the
31 dialog to respond to system close events.
33 \wxheading{Window styles
}
36 \begin{twocollist
}\itemsep=
0pt
37 \twocolitem{\windowstyle{wxDIALOG
\_MODAL}}{Specifies that the dialog box will be modal.
}
38 \twocolitem{\windowstyle{wxCAPTION
}}{Puts a caption on the dialog box.
}
39 \twocolitem{\windowstyle{wxDEFAULT
\_DIALOG\_STYLE}}{Equivalent to a combination of wxCAPTION, wxSYSTEM
\_MENU and wxTHICK
\_FRAME}
40 \twocolitem{\windowstyle{wxRESIZE
\_BORDER}}{Display a resizeable frame around the window.
}
41 \twocolitem{\windowstyle{wxSYSTEM
\_MENU}}{Display a system menu.
}
42 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Display a thick frame around the window.
}
43 \twocolitem{\windowstyle{wxSTAY
\_ON\_TOP}}{The dialog stays on top of all other windows (Windows only).
}
44 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
45 should not have
3D borders unless specified in the control.
}
46 \twocolitem{\windowstyle{wxDIALOG
\_NO\_PARENT}}{By default, the dialogs crated
47 with
{\tt NULL
} parent window will be given the
48 \helpref{applications top level window
}{wxappgettopwindow
} as parent. Use this
49 style to prevent this from happening and create a really orphan dialog (note
50 that this is not recommended for modal dialogs).
}
51 \twocolitem{\windowstyle{wxDIALOG
\_EX\_CONTEXTHELP}}{Under Windows, puts a query button on the
52 caption. When pressed, Windows will go into a context-sensitive help mode and wxWindows will send
53 a wxEVT
\_HELP event if the user clicked on an application window.
{\it Note
} that this is an extended
54 style and must be set by calling
\helpref{SetExtraStyle
}{wxwindowsetextrastyle
} before Create is called (two-step construction).
}
57 Under Unix or Linux, MWM (the Motif Window Manager) or other window managers
58 reckognizing the MHM hints should be running for any of these styles to have an
61 See also
\helpref{Generic window styles
}{windowstyles
}.
65 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\helpref{Resources
}{resources
},
\rtfsp
66 \helpref{Validator overview
}{validatoroverview
}
68 \latexignore{\rtfignore{\wxheading{Members
}}}
70 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
72 \func{}{wxDialog
}{\void}
76 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
77 \param{const wxString\&
}{title
},
\rtfsp
78 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
79 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
80 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
81 \param{const wxString\&
}{name = ``dialogBox"
}}
85 \wxheading{Parameters
}
87 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
89 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
91 \docparam{title
}{The title of the dialog.
}
93 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
94 either the windowing system or wxWindows, depending on platform.
}
96 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
97 either the windowing system or wxWindows, depending on platform.
}
99 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
101 \docparam{name
}{Used to associate a name with the window,
102 allowing the application user to set Motif resource values for
103 individual dialog boxes.
}
107 \helpref{wxDialog::Create
}{wxdialogcreate
}
109 \membersection{wxDialog::
\destruct{wxDialog
}}
111 \func{}{\destruct{wxDialog
}}{\void}
113 Destructor. Deletes any child windows before deleting the physical window.
115 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
117 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
119 Centres the dialog box on the display.
121 \wxheading{Parameters
}
123 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
125 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
127 \func{bool
}{Create
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
128 \param{const wxString\&
}{title
},
\rtfsp
129 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
130 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
131 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
132 \param{const wxString\&
}{name = ``dialogBox"
}}
134 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
137 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
139 \func{void
}{EndModal
}{\param{int
}{retCode
}}
141 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
144 \wxheading{Parameters
}
146 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
150 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
151 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
152 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}
154 \membersection{wxDialog::GetReturnCode
}\label{wxdialoggetreturncode
}
156 \func{int
}{GetReturnCode
}{\void}
158 Gets the return code for this window.
162 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
163 a code to the application.
167 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
168 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
170 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
172 \constfunc{wxString
}{GetTitle
}{\void}
174 Returns the title of the dialog box.
176 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
178 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
180 Iconizes or restores the dialog. Windows only.
182 \wxheading{Parameters
}
184 \docparam{iconize
}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.
}
188 Note that in Windows, iconization has no effect since dialog boxes cannot be
189 iconized. However, applications may need to explicitly restore dialog
190 boxes under Motif which have user-iconizable frames, and under Windows
191 calling
{\tt Iconize(FALSE)
} will bring the window to the front, as does
192 \rtfsp{\tt Show(TRUE)
}.
194 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
196 \constfunc{bool
}{IsIconized
}{\void}
198 Returns TRUE if the dialog box is iconized. Windows only.
202 Always returns FALSE under Windows since dialogs cannot be iconized.
204 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
206 \constfunc{bool
}{IsModal
}{\void}
208 Returns TRUE if the dialog box is modal, FALSE otherwise.
210 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
212 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
214 This member is called to allow the window to intercept keyboard events
215 before they are processed by child windows.
217 %For more information, see \helpref{wxWindow::OnCharHook}{wxwindowoncharhook}
221 wxDialog implements this handler to fake a cancel command if the escape key has been
222 pressed. This will dismiss the dialog.
224 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
226 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
228 The default handler for the wxID
\_APPLY identifier.
232 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
236 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
238 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
240 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
242 The default handler for the wxID
\_CANCEL identifier.
246 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
247 sets the return value to wxID
\_CANCEL and calls
{\bf Show(FALSE)
} if the dialog is modeless.
251 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
253 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
255 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
257 The default handler for the wxID
\_OK identifier.
262 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
263 If this returns TRUE, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
264 sets the return value to wxID
\_OK and calls
{\bf Show(FALSE)
} if the dialog is modeless.
268 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
270 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
272 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
274 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
276 \wxheading{Parameters
}
278 \docparam{event
}{The colour change event.
}
282 Changes the dialog's colour to conform to the current settings (Windows only).
283 Add an event table entry for your dialog class if you wish the behaviour
284 to be different (such as keeping a user-defined
285 background colour). If you do override this function, call wxEvent::Skip to
286 propagate the notification to child windows and controls.
290 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
292 \membersection{wxDialog::SetIcon
}\label{wxdialogseticon
}
294 \func{void
}{SetIcon
}{\param{const wxIcon\&
}{icon
}}
296 Sets the icon for this dialog.
298 \wxheading{Parameters
}
300 \docparam{icon
}{The icon to associate with this dialog.
}
302 See also
\helpref{wxIcon
}{wxicon
}.
304 \membersection{wxDialog::SetIcons
}\label{wxdialogseticons
}
306 \func{void
}{SetIcons
}{\param{const wxIconBundle\&
}{icons
}}
308 Sets the icons for this dialog.
310 \wxheading{Parameters
}
312 \docparam{icons
}{The icons to associate with this dialog.
}
314 See also
\helpref{wxIconBundle
}{wxiconbundle
}.
316 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
318 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
320 {\bf NB:
} This function is deprecated and doesn't work for all ports, just use
321 \helpref{ShowModal
}{wxdialogshowmodal
} to show a modal dialog instead.
323 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
324 until the dialog is hidden) or modeless (control returns immediately).
326 \wxheading{Parameters
}
328 \docparam{flag
}{If TRUE, the dialog will be modal, otherwise it will be modeless.
}
330 \membersection{wxDialog::SetReturnCode
}\label{wxdialogsetreturncode
}
332 \func{void
}{SetReturnCode
}{\param{int
}{retCode
}}
334 Sets the return code for this window.
336 \wxheading{Parameters
}
338 \docparam{retCode
}{The integer return code, usually a control identifier.
}
342 A return code is normally associated with a modal dialog, where
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
} returns
343 a code to the application. The function
\helpref{wxDialog::EndModal
}{wxdialogendmodal
} calls
{\bf SetReturnCode
}.
347 \helpref{wxDialog::GetReturnCode
}{wxdialoggetreturncode
},
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
348 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}
350 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
352 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
354 Sets the title of the dialog box.
356 \wxheading{Parameters
}
358 \docparam{title
}{The dialog box title.
}
360 \membersection{wxDialog::Show
}\label{wxdialogshow
}
362 \func{bool
}{Show
}{\param{const bool
}{ show
}}
364 Hides or shows the dialog.
366 \wxheading{Parameters
}
368 \docparam{show
}{If TRUE, the dialog box is shown and brought to the front;
369 otherwise the box is hidden. If FALSE and the dialog is
370 modal, control is returned to the calling program.
}
374 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
376 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
378 \func{int
}{ShowModal
}{\void}
380 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
381 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
383 \wxheading{Return value
}
385 The return value is the value set with
\helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}.
389 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
390 \helpref{wxDialog:GetReturnCode
}{wxdialoggetreturncode
},
\rtfsp
391 \helpref{wxDialog::SetReturnCode
}{wxdialogsetreturncode
}