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 (Motif only).
}
34 \twocolitem{\windowstyle{wxTHICK
\_FRAME}}{Display a thick frame around the window (Motif only).
}
35 \twocolitem{\windowstyle{wxNO
\_3D}}{Under Windows, specifies that the child controls
36 should not have
3D borders unless specified in the control.
}
39 Under Motif, MWM (the Motif Window Manager) should be running for any of these styles to have an effect.
41 See also
\helpref{Generic window styles
}{windowstyles
}.
45 \helpref{wxDialog overview
}{wxdialogoverview
},
\helpref{wxFrame
}{wxframe
},
\helpref{Resources
}{resources
},
\rtfsp
46 \helpref{Validator overview
}{validatoroverview
}
48 \latexignore{\rtfignore{\wxheading{Members
}}}
50 \membersection{wxDialog::wxDialog
}\label{wxdialogconstr
}
52 \func{}{wxDialog
}{\void}
56 \func{}{wxDialog
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{id
},
\rtfsp
57 \param{const wxString\&
}{title
},
\rtfsp
58 \param{const wxPoint\&
}{pos = wxDefaultPosition
},
\rtfsp
59 \param{const wxSize\&
}{size = wxDefaultSize
},
\rtfsp
60 \param{long
}{ style = wxDEFAULT
\_DIALOG\_STYLE},
\rtfsp
61 \param{const wxString\&
}{name = ``dialogBox"
}}
65 \wxheading{Parameters
}
67 \docparam{parent
}{Can be NULL, a frame or another dialog box.
}
69 \docparam{id
}{An identifier for the dialog. A value of -
1 is taken to mean a default.
}
71 \docparam{title
}{The title of the dialog.
}
73 \docparam{pos
}{The dialog position. A value of (-
1, -
1) indicates a default position, chosen by
74 either the windowing system or wxWindows, depending on platform.
}
76 \docparam{size
}{The dialog size. A value of (-
1, -
1) indicates a default size, chosen by
77 either the windowing system or wxWindows, depending on platform.
}
79 \docparam{style
}{The window style. See
\helpref{wxDialog
}{wxdialog
}.
}
81 \docparam{name
}{Used to associate a name with the window,
82 allowing the application user to set Motif resource values for
83 individual dialog boxes.
}
87 \helpref{wxDialog::Create
}{wxdialogcreate
}
89 \membersection{wxDialog::
\destruct{wxDialog
}}
91 \func{}{\destruct{wxDialog
}}{\void}
93 Destructor. Deletes any child windows before deleting the physical window.
95 \membersection{wxDialog::Centre
}\label{wxdialogcentre
}
97 \func{void
}{Centre
}{\param{int
}{ direction = wxBOTH
}}
99 Centres the dialog box on the display.
101 \wxheading{Parameters
}
103 \docparam{direction
}{May be
{\tt wxHORIZONTAL
},
{\tt wxVERTICAL
} or
{\tt wxBOTH
}.
}
105 \membersection{wxDialog::Create
}\label{wxdialogcreate
}
107 \func{bool
}{Create
}{\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"
}}
114 Used for two-step dialog box construction. See
\helpref{wxDialog::wxDialog
}{wxdialogconstr
}\rtfsp
117 \membersection{wxDialog::EndModal
}\label{wxdialogendmodal
}
119 \func{void
}{EndModal
}{\param{int
}{retCode
}}
121 Ends a modal dialog, passing a value to be returned from the
\helpref{wxDialog::ShowModal
}{wxdialogshowmodal
}\rtfsp
124 \wxheading{Parameters
}
126 \docparam{retCode
}{The value that should be returned by
{\bf ShowModal
}.
}
130 \helpref{wxDialog::ShowModal
}{wxdialogshowmodal
},
\rtfsp
131 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
132 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}
134 \membersection{wxDialog::GetTitle
}\label{wxdialoggettitle
}
136 \constfunc{wxString
}{GetTitle
}{\void}
138 Returns the title of the dialog box.
140 \membersection{wxDialog::Iconize
}\label{wxdialogiconized
}
142 \func{void
}{Iconize
}{\param{const bool
}{ iconize
}}
144 Iconizes or restores the dialog.
146 \wxheading{Parameters
}
148 \docparam{iconize
}{If TRUE, iconizes the dialog box; if FALSE, shows and restores it.
}
152 Note that in Windows, iconization has no effect since dialog boxes cannot be
153 iconized. However, applications may need to explicitly restore dialog
154 boxes under Motif which have user-iconizable frames, and under Windows
155 calling
{\tt Iconize(FALSE)
} will bring the window to the front, as does
156 \rtfsp{\tt Show(TRUE)
}.
158 \membersection{wxDialog::IsIconized
}\label{wxdialogisiconized
}
160 \constfunc{bool
}{IsIconized
}{\void}
162 Returns TRUE if the dialog box is iconized.
166 Always returns FALSE under Windows since dialogs cannot be iconized.
168 \membersection{wxDialog::IsModal
}\label{wxdialogismodal
}
170 \constfunc{bool
}{IsModal
}{\void}
172 Returns TRUE if the dialog box is modal, FALSE otherwise.
174 \membersection{wxDialog::OnCharHook
}\label{wxdialogoncharhook
}
176 \func{void
}{OnCharHook
}{\param{wxKeyEvent\&
}{ event
}}
178 This member is called to allow the window to intercept keyboard events
179 before they are processed by child windows.
181 For more information, see
\helpref{wxWindow::OnCharHook
}{wxwindowoncharhook
}
185 wxDialog implements this handler to fake a cancel command if the escape key has been
186 pressed. This will dismiss the dialog.
188 \membersection{wxDialog::OnApply
}\label{wxdialogonapply
}
190 \func{void
}{OnApply
}{\param{wxCommandEvent\&
}{event
}}
192 The default handler for the wxID
\_APPLY identifier.
196 This function calls
\helpref{wxWindow::Validate
}{wxwindowvalidate
} and
\helpref{wxWindow::TransferDataToWindow
}{wxwindowtransferdatatowindow
}.
200 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnCancel
}{wxdialogoncancel
}
202 \membersection{wxDialog::OnCancel
}\label{wxdialogoncancel
}
204 \func{void
}{OnCancel
}{\param{wxCommandEvent\&
}{event
}}
206 The default handler for the wxID
\_CANCEL identifier.
210 The function either calls
{\bf EndModal(wxID
\_CANCEL)
} if the dialog is modal, or
211 sets the return value to wxID
\_CANCEL and calls
{\bf Show(FALSE)
} if the dialog is modeless.
215 \helpref{wxDialog::OnOK
}{wxdialogonok
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
217 \membersection{wxDialog::OnOK
}\label{wxdialogonok
}
219 \func{void
}{OnOK
}{\param{wxCommandEvent\&
}{event
}}
221 The default handler for the wxID
\_OK identifier.
226 \rtfsp\helpref{wxWindow::Validate
}{wxwindowvalidate
}, then
\helpref{wxWindow::TransferDataFromWindow
}{wxwindowtransferdatafromwindow
}.
227 If this returns TRUE, the function either calls
{\bf EndModal(wxID
\_OK)
} if the dialog is modal, or
228 sets the return value to wxID
\_OK and calls
{\bf Show(FALSE)
} if the dialog is modeless.
232 \helpref{wxDialog::OnCancel
}{wxdialogoncancel
},
\helpref{wxDialog::OnApply
}{wxdialogonapply
}
234 \membersection{wxDialog::OnSysColourChanged
}\label{wxdialogonsyscolourchanged
}
236 \func{void
}{OnSysColourChanged
}{\param{wxSysColourChangedEvent\&
}{event
}}
238 The default handler for wxEVT
\_SYS\_COLOUR\_CHANGED.
240 \wxheading{Parameters
}
242 \docparam{event
}{The colour change event.
}
246 Changes the dialog's colour to conform to the current settings (Windows only).
247 Add an event table entry for your dialog class if you wish the behaviour
248 to be different (such as keeping a user-defined
249 background colour). If you do override this function, call
\helpref{wxWindow::OnSysColourChanged
}{wxwindowonsyscolourchanged
} to
250 propagate the notification to child windows and controls.
254 \helpref{wxSysColourChangedEvent
}{wxsyscolourchangedevent
}
256 \membersection{wxDialog::SetModal
}\label{wxdialogsetmodal
}
258 \func{void
}{SetModal
}{\param{const bool
}{ flag
}}
260 Allows the programmer to specify whether the dialog box is modal (wxDialog::Show blocks control
261 until the dialog is hidden) or modeless (control returns immediately).
263 \wxheading{Parameters
}
265 \docparam{flag
}{If TRUE, the dialog will be modal, otherwise it will be modeless.
}
267 \membersection{wxDialog::SetTitle
}\label{wxdialogsettitle
}
269 \func{void
}{SetTitle
}{\param{const wxString\&
}{ title
}}
271 Sets the title of the dialog box.
273 \wxheading{Parameters
}
275 \docparam{title
}{The dialog box title.
}
277 \membersection{wxDialog::Show
}\label{wxdialogshow
}
279 \func{bool
}{Show
}{\param{const bool
}{ show
}}
281 Hides or shows the dialog.
283 \wxheading{Parameters
}
285 \docparam{show
}{If TRUE, the dialog box is shown and brought to the front;
286 otherwise the box is hidden. If FALSE and the dialog is
287 modal, control is returned to the calling program.
}
291 The preferred way of dismissing a modal dialog is to use
\helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
293 \membersection{wxDialog::ShowModal
}\label{wxdialogshowmodal
}
295 \func{int
}{ShowModal
}{\void}
297 Shows a modal dialog. Program flow does not return until the dialog has been dismissed with
\rtfsp
298 \helpref{wxDialog::EndModal
}{wxdialogendmodal
}.
300 \wxheading{Return value
}
302 The return value is the value set with
\helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}.
306 \helpref{wxDialog::EndModal
}{wxdialogendmodal
},
\rtfsp
307 \helpref{wxWindow::GetReturnCode
}{wxwindowgetreturncode
},
\rtfsp
308 \helpref{wxWindow::SetReturnCode
}{wxwindowsetreturncode
}