2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: dialog.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxDialog
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
/**
|
|
|
|
Modes used for wxDialog::SetLayoutAdaptationMode().
|
|
|
|
*/
|
|
|
|
enum wxDialogLayoutAdaptationMode
|
|
|
|
{
|
|
|
|
wxDIALOG_ADAPTATION_MODE_DEFAULT = 0, ///< Use global adaptation enabled status.
|
|
|
|
wxDIALOG_ADAPTATION_MODE_ENABLED = 1, ///< Enable this dialog overriding global status.
|
|
|
|
wxDIALOG_ADAPTATION_MODE_DISABLED = 2 ///< Disable this dialog overriding global status.
|
|
|
|
};
|
|
|
|
|
2012-12-22 03:00:04 -05:00
|
|
|
#define wxDIALOG_NO_PARENT 0x00000020 ///< Don't make owned by apps top window
|
|
|
|
|
2011-09-26 23:34:29 -04:00
|
|
|
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
|
|
|
|
|
2012-12-22 03:00:04 -05:00
|
|
|
|
|
|
|
#define wxDIALOG_ADAPTATION_NONE 0 ///< Don't do any layout adaptation
|
|
|
|
#define wxDIALOG_ADAPTATION_STANDARD_SIZER 1 ///< Only look for wxStdDialogButtonSizer for non-scrolling part
|
|
|
|
#define wxDIALOG_ADAPTATION_ANY_SIZER 2 ///< Also look for any suitable sizer for non-scrolling part
|
|
|
|
#define wxDIALOG_ADAPTATION_LOOSE_BUTTONS 3 ///< Also look for 'loose' standard buttons for non-scrolling part
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDialog
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
A dialog box is a window with a title bar and sometimes a system menu,
|
|
|
|
which can be moved around the screen. It can contain controls and other
|
|
|
|
windows and is often used to allow the user to make some choice or to
|
|
|
|
answer a question.
|
|
|
|
|
|
|
|
Dialogs can be made scrollable, automatically, for computers with low
|
|
|
|
resolution screens: please see @ref overview_dialog_autoscrolling for
|
|
|
|
further details.
|
|
|
|
|
2013-10-26 12:25:50 -04:00
|
|
|
Dialogs usually contain either a single button allowing to close the
|
2008-04-20 19:50:56 -04:00
|
|
|
dialog or two buttons, one accepting the changes and the other one
|
|
|
|
discarding them (such button, if present, is automatically activated if the
|
|
|
|
user presses the "Esc" key). By default, buttons with the standard wxID_OK
|
|
|
|
and wxID_CANCEL identifiers behave as expected. Starting with wxWidgets 2.7
|
|
|
|
it is also possible to use a button with a different identifier instead,
|
|
|
|
see SetAffirmativeId() and SetEscapeId().
|
|
|
|
|
|
|
|
Also notice that the CreateButtonSizer() should be used to create the
|
|
|
|
buttons appropriate for the current platform and positioned correctly
|
|
|
|
(including their order which is platform-dependent).
|
|
|
|
|
|
|
|
@section dialog_modal Modal and Modeless
|
|
|
|
|
|
|
|
There are two kinds of dialog, modal and modeless. A modal dialog blocks
|
|
|
|
program flow and user input on other windows until it is dismissed, whereas
|
|
|
|
a modeless dialog behaves more like a frame in that program flow continues,
|
|
|
|
and input in other windows is still possible. To show a modal dialog you
|
|
|
|
should use the ShowModal() method while to show a dialog modelessly you
|
|
|
|
simply use Show(), just as with frames.
|
|
|
|
|
|
|
|
Note that the modal dialog is one of the very few examples of
|
|
|
|
wxWindow-derived objects which may be created on the stack and not on the
|
|
|
|
heap. In other words, while most windows would be created like this:
|
|
|
|
|
|
|
|
@code
|
|
|
|
void AskUser()
|
|
|
|
{
|
|
|
|
MyAskDialog *dlg = new MyAskDialog(...);
|
|
|
|
if ( dlg->ShowModal() == wxID_OK )
|
|
|
|
// ...
|
|
|
|
//else: dialog was cancelled or some another button pressed
|
|
|
|
|
|
|
|
dlg->Destroy();
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
You can achieve the same result with dialogs by using simpler code:
|
|
|
|
|
|
|
|
@code
|
|
|
|
void AskUser()
|
|
|
|
{
|
|
|
|
MyAskDialog dlg(...);
|
|
|
|
if ( dlg.ShowModal() == wxID_OK )
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// no need to call Destroy() here
|
|
|
|
}
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
An application can define a wxCloseEvent handler for the dialog to respond
|
|
|
|
to system close events.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCAPTION}
|
2008-03-08 08:52:38 -05:00
|
|
|
Puts a caption on the dialog box.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDEFAULT_DIALOG_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
Equivalent to a combination of wxCAPTION, wxCLOSE_BOX and
|
2008-04-20 19:50:56 -04:00
|
|
|
wxSYSTEM_MENU (the last one is not used under Unix).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxRESIZE_BORDER}
|
2011-04-03 16:31:32 -04:00
|
|
|
Display a resizable frame around the window.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxSYSTEM_MENU}
|
2008-03-08 08:52:38 -05:00
|
|
|
Display a system menu.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxCLOSE_BOX}
|
2008-03-08 08:52:38 -05:00
|
|
|
Displays a close box on the frame.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxMAXIMIZE_BOX}
|
2008-03-08 08:52:38 -05:00
|
|
|
Displays a maximize box on the dialog.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxMINIMIZE_BOX}
|
2008-03-08 08:52:38 -05:00
|
|
|
Displays a minimize box on the dialog.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTHICK_FRAME}
|
2008-03-08 08:52:38 -05:00
|
|
|
Display a thick frame around the window.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxSTAY_ON_TOP}
|
2008-03-08 08:52:38 -05:00
|
|
|
The dialog stays on top of all other windows.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxNO_3D}
|
2012-02-04 06:45:53 -05:00
|
|
|
This style is obsolete and doesn't do anything any more, don't use
|
|
|
|
it in any new code.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIALOG_NO_PARENT}
|
2008-03-08 08:52:38 -05:00
|
|
|
By default, a dialog created with a @NULL parent window will be
|
2008-04-20 19:50:56 -04:00
|
|
|
given the @ref wxApp::GetTopWindow() "application's top level window"
|
|
|
|
as parent. Use this style to prevent this from happening and create
|
|
|
|
an orphan dialog. This is not recommended for modal dialogs.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIALOG_EX_CONTEXTHELP}
|
2008-03-08 08:52:38 -05:00
|
|
|
Under Windows, puts a query button on the caption. When pressed,
|
|
|
|
Windows will go into a context-sensitive help mode and wxWidgets
|
2011-01-06 14:52:14 -05:00
|
|
|
will send a @c wxEVT_HELP event if the user clicked on an application
|
2008-03-08 08:52:38 -05:00
|
|
|
window. Note that this is an extended style and must be set by
|
2008-04-20 19:50:56 -04:00
|
|
|
calling SetExtraStyle() before Create is called (two-step
|
2008-03-08 08:52:38 -05:00
|
|
|
construction).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxDIALOG_EX_METAL}
|
2016-02-23 07:05:44 -05:00
|
|
|
On OS X, frames with this style will be shown with a metallic
|
2008-03-08 08:52:38 -05:00
|
|
|
look. This is an extra style.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
Under Unix or Linux, MWM (the Motif Window Manager) or other window
|
|
|
|
managers recognizing the MHM hints should be running for any of these
|
|
|
|
styles to have an effect.
|
|
|
|
|
2008-11-23 18:53:45 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxCloseEvent}
|
2008-11-23 18:53:45 -05:00
|
|
|
@event{EVT_CLOSE(func)}
|
|
|
|
The dialog is being closed by the user or programmatically (see wxWindow::Close).
|
|
|
|
The user may generate this event clicking the close button
|
|
|
|
(typically the 'X' on the top-right of the title bar) if it's present
|
|
|
|
(see the @c wxCLOSE_BOX style) or by clicking a button with the
|
|
|
|
@c wxID_CANCEL or @c wxID_OK ids.
|
2009-02-18 12:58:51 -05:00
|
|
|
@event{EVT_INIT_DIALOG(func)}
|
|
|
|
Process a @c wxEVT_INIT_DIALOG event. See wxInitDialogEvent.
|
2008-11-23 18:53:45 -05:00
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
|
|
|
@category{cmndlg}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see @ref overview_dialog, wxFrame, @ref overview_validator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxDialog : public wxTopLevelWindow
|
|
|
|
{
|
|
|
|
public:
|
2008-04-20 19:50:56 -04:00
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Can be @NULL, a frame or another dialog box.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-04-20 19:50:56 -04:00
|
|
|
An identifier for the dialog. A value of -1 is taken to mean a
|
|
|
|
default.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param title
|
2008-03-09 08:33:59 -04:00
|
|
|
The title of the dialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-04-20 19:50:56 -04:00
|
|
|
The dialog position. The value wxDefaultPosition indicates a
|
|
|
|
default position, chosen by either the windowing system or
|
|
|
|
wxWidgets, depending on platform.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-04-20 19:50:56 -04:00
|
|
|
The dialog size. The value wxDefaultSize indicates a default size,
|
|
|
|
chosen by either the windowing system or wxWidgets, depending on
|
|
|
|
platform.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-04-20 19:50:56 -04:00
|
|
|
The window style.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-04-20 19:50:56 -04:00
|
|
|
Used to associate a name with the window, allowing the application
|
|
|
|
user to set Motif resource values for individual dialog boxes.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see Create()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
wxDialog(wxWindow* parent, wxWindowID id, const wxString& title,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_DIALOG_STYLE,
|
2008-11-08 10:17:16 -05:00
|
|
|
const wxString& name = wxDialogNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-11-24 19:24:58 -05:00
|
|
|
Destructor.
|
|
|
|
|
|
|
|
Deletes any child windows before deleting the physical window.
|
|
|
|
|
|
|
|
See @ref overview_windowdeletion for more info.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxDialog();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Adds an identifier to be regarded as a main button for the
|
|
|
|
non-scrolling area of a dialog.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void AddMainButtonId(wxWindowID id);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns @true if this dialog can and should perform layout adaptation
|
|
|
|
using DoLayoutAdaptation(), usually if the dialog is too large to fit
|
|
|
|
on the display.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-15 06:37:43 -05:00
|
|
|
virtual bool CanDoLayoutAdaptation();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Centres the dialog box on the display.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param direction
|
2008-03-09 08:33:59 -04:00
|
|
|
May be wxHORIZONTAL, wxVERTICAL or wxBOTH.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void Centre(int direction = wxBOTH);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Used for two-step dialog box construction.
|
|
|
|
|
|
|
|
@see wxDialog()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-04-20 19:50:56 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id, const wxString& title,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
2008-11-08 10:17:16 -05:00
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = wxDEFAULT_DIALOG_STYLE,
|
2008-09-29 06:52:37 -04:00
|
|
|
const wxString& name = wxDialogNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Creates a sizer with standard buttons. @a flags is a bit list of the
|
|
|
|
following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY, wxCLOSE, wxHELP,
|
|
|
|
wxNO_DEFAULT.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The sizer lays out the buttons in a manner appropriate to the platform.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
This function uses CreateStdDialogButtonSizer() internally for most
|
|
|
|
platforms but doesn't create the sizer at all for the platforms with
|
|
|
|
hardware buttons (such as smartphones) for which it sets up the
|
|
|
|
hardware buttons appropriately and returns @NULL, so don't forget to
|
|
|
|
test that the return value is valid before using it.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxSizer* CreateButtonSizer(long flags);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Creates a sizer with standard buttons using CreateButtonSizer()
|
|
|
|
separated from the rest of the dialog contents by a horizontal
|
|
|
|
wxStaticLine.
|
|
|
|
|
|
|
|
@note Just like CreateButtonSizer(), this function may return @NULL if
|
|
|
|
no buttons were created.
|
2010-08-30 17:48:16 -04:00
|
|
|
|
|
|
|
This is a combination of CreateButtonSizer() and
|
|
|
|
CreateSeparatedSizer().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxSizer* CreateSeparatedButtonSizer(long flags);
|
|
|
|
|
2010-08-30 17:48:16 -04:00
|
|
|
/**
|
|
|
|
Returns the sizer containing the given one with a separating
|
|
|
|
wxStaticLine if necessarily.
|
|
|
|
|
|
|
|
This function is useful for creating the sizer containing footer-like
|
|
|
|
contents in dialog boxes. It will add a separating static line only if
|
|
|
|
it conforms to the current platform convention (currently it is not
|
|
|
|
added under Mac where the use of static lines for grouping is
|
|
|
|
discouraged and is added elsewhere).
|
|
|
|
|
|
|
|
@since 2.9.2
|
|
|
|
|
|
|
|
@param sizer The sizer to wrap, must be non-@NULL.
|
|
|
|
@return The sizer wrapping the input one or possibly the input sizer
|
|
|
|
itself if no wrapping is necessary.
|
|
|
|
*/
|
|
|
|
wxSizer *CreateSeparatedSizer(wxSizer *sizer);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Creates a wxStdDialogButtonSizer with standard buttons. @a flags is a
|
|
|
|
bit list of the following flags: wxOK, wxCANCEL, wxYES, wxNO, wxAPPLY,
|
|
|
|
wxCLOSE, wxHELP, wxNO_DEFAULT.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The sizer lays out the buttons in a manner appropriate to the platform.
|
|
|
|
*/
|
|
|
|
wxStdDialogButtonSizer* CreateStdDialogButtonSizer(long flags);
|
|
|
|
|
2012-04-09 23:27:22 -04:00
|
|
|
/**
|
|
|
|
Splits text up at newlines and places the lines into wxStaticText
|
2016-12-01 03:43:29 -05:00
|
|
|
objects with the specified maximum width in a vertical wxBoxSizer.
|
|
|
|
|
2016-12-01 08:54:08 -05:00
|
|
|
If @a widthMax has its default value of -1, only explicit new line
|
|
|
|
characters in @a message are taken into account. Otherwise, lines are
|
|
|
|
broken either after a new line or wrapped, at word boundary, if their
|
|
|
|
width would become bigger than the specified maximal width.
|
|
|
|
|
|
|
|
@param widthMax Specifies the text's maximum width (this argument is
|
|
|
|
available since version 3.1.1, previous versions always behaved as if
|
|
|
|
the maximal width of -1 was specified).
|
2016-12-01 03:43:29 -05:00
|
|
|
|
|
|
|
@see wxStaticText::Wrap(int width)
|
2012-04-09 23:27:22 -04:00
|
|
|
*/
|
2016-12-01 03:43:29 -05:00
|
|
|
wxSizer *CreateTextSizer(const wxString& message, int widthMax = -1);
|
2012-04-09 23:27:22 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Performs layout adaptation, usually if the dialog is too large to fit
|
|
|
|
on the display.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-15 06:37:43 -05:00
|
|
|
virtual bool DoLayoutAdaptation();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
A static function enabling or disabling layout adaptation for all
|
|
|
|
dialogs.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static void EnableLayoutAdaptation(bool enable);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Ends a modal dialog, passing a value to be returned from the
|
|
|
|
ShowModal() invocation.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param retCode
|
2008-03-09 08:33:59 -04:00
|
|
|
The value that should be returned by ShowModal.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see ShowModal(), GetReturnCode(), SetReturnCode()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual void EndModal(int retCode);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Gets the identifier of the button which works like standard OK button
|
|
|
|
in this dialog.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetAffirmativeId()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetAffirmativeId() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Override this to return a window containing the main content of the
|
|
|
|
dialog. This is particularly useful when the dialog implements pages,
|
|
|
|
such as wxPropertySheetDialog, and allows the
|
|
|
|
@ref overview_dialog "layout adaptation code" to know that only the
|
|
|
|
pages need to be made scrollable.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual wxWindow* GetContentWindow() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Gets the identifier of the button to map presses of @c ESC button to.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetEscapeId()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
int GetEscapeId() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns @true if the dialog has been adapted, usually by making it
|
|
|
|
scrollable to work with a small display.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
bool GetLayoutAdaptationDone() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Gets a value representing the aggressiveness of search for buttons and
|
|
|
|
sizers to be in the non-scrolling part of a layout-adapted dialog. Zero
|
|
|
|
switches off adaptation, and 3 allows search for standard buttons
|
|
|
|
anywhere in the dialog.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
int GetLayoutAdaptationLevel() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the adaptation mode, overriding the global adaptation flag.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
A static function getting the current layout adapter object.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxDialogLayoutAdapter* GetLayoutAdapter();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns an array of identifiers to be regarded as the main buttons for
|
|
|
|
the non-scrolling area of a dialog.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
wxArrayInt& GetMainButtonIds();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Gets the return code for this window.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@remarks A return code is normally associated with a modal dialog,
|
|
|
|
where ShowModal() returns a code to the application.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see SetReturnCode(), ShowModal(), EndModal()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
int GetReturnCode() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
On PocketPC, a dialog is automatically provided with an empty toolbar.
|
2008-04-20 19:50:56 -04:00
|
|
|
This function allows you to access the toolbar and add tools to it.
|
|
|
|
Removing tools and adding arbitrary controls are not currently
|
|
|
|
supported.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
This function is not available on any other platform.
|
2008-11-15 06:37:43 -05:00
|
|
|
|
|
|
|
@onlyfor{wxmsw}
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-09 12:24:26 -04:00
|
|
|
wxToolBar* GetToolBar() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Iconizes or restores the dialog. Windows only.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param iconize
|
2008-03-09 08:33:59 -04:00
|
|
|
If @true, iconizes the dialog box; if @false, shows and restores it.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Note that in Windows, iconization has no effect since dialog
|
2008-04-20 19:50:56 -04:00
|
|
|
boxes cannot be iconized. However, applications may need to
|
|
|
|
explicitly restore dialog boxes under Motif which have
|
|
|
|
user-iconizable frames, and under Windows calling
|
|
|
|
Iconize(@false) will bring the window to the front, as does
|
|
|
|
Show(@true).
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-28 11:36:26 -04:00
|
|
|
virtual void Iconize(bool iconize = true);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the dialog box is iconized. Windows only.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@remarks Always returns @false under Windows since dialogs cannot be
|
2008-03-09 08:33:59 -04:00
|
|
|
iconized.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual bool IsIconized() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
A static function returning @true if layout adaptation is enabled for
|
|
|
|
all dialogs.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static bool IsLayoutAdaptationEnabled();
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Returns @true if @a id is in the array of identifiers to be regarded as
|
|
|
|
the main buttons for the non-scrolling area of a dialog.
|
|
|
|
|
2008-11-15 06:37:43 -05:00
|
|
|
@onlyfor{wxmsw}
|
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-15 06:37:43 -05:00
|
|
|
bool IsMainButtonId(wxWindowID id) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the dialog box is modal, @false otherwise.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsModal() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the identifier to be used as OK button. When the button with this
|
2008-04-20 19:50:56 -04:00
|
|
|
identifier is pressed, the dialog calls wxWindow::Validate() and
|
|
|
|
wxWindow::TransferDataFromWindow() and, if they both return @true,
|
2010-10-23 14:56:06 -04:00
|
|
|
closes the dialog with the affirmative id return code.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
Also, when the user presses a hardware OK button on the devices having
|
|
|
|
one or the special OK button in the PocketPC title bar, an event with
|
|
|
|
this id is generated.
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
By default, the affirmative id is wxID_OK.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetAffirmativeId(), SetEscapeId()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetAffirmativeId(int id);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Sets the identifier of the button which should work like the standard
|
2008-04-20 19:50:56 -04:00
|
|
|
"Cancel" button in this dialog. When the button with this id is
|
|
|
|
clicked, the dialog is closed. Also, when the user presses @c ESC key
|
|
|
|
in the dialog or closes the dialog using the close button in the title
|
|
|
|
bar, this is mapped to the click of the button with the specified id.
|
|
|
|
|
|
|
|
By default, the escape id is the special value wxID_ANY meaning that
|
|
|
|
wxID_CANCEL button is used if it's present in the dialog and otherwise
|
|
|
|
the button with GetAffirmativeId() is used. Another special value for
|
|
|
|
@a id is wxID_NONE meaning that @c ESC presses should be ignored. If
|
|
|
|
any other value is given, it is interpreted as the id of the button to
|
|
|
|
map the escape key to.
|
2014-09-03 07:21:08 -04:00
|
|
|
|
|
|
|
@note This method should be used for custom modal dialog implemented in
|
|
|
|
wxWidgets itself, native dialogs such as wxMessageDialog or
|
|
|
|
wxFileDialog, handle @c ESC presses in their own way which cannot be
|
|
|
|
customized.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetEscapeId(int id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the icon for this dialog.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param icon
|
2008-03-09 08:33:59 -04:00
|
|
|
The icon to associate with this dialog.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
@see wxIcon
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetIcon(const wxIcon& icon);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the icons for this dialog.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param icons
|
2008-03-09 08:33:59 -04:00
|
|
|
The icons to associate with this dialog.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
|
|
|
@see wxIconBundle
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetIcons(const wxIconBundle& icons);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Marks the dialog as having been adapted, usually by making it
|
|
|
|
scrollable to work with a small display.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetLayoutAdaptationDone(bool done);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the aggressiveness of search for buttons and sizers to be in the
|
2008-04-20 19:50:56 -04:00
|
|
|
non-scrolling part of a layout-adapted dialog. Zero switches off
|
|
|
|
adaptation, and 3 allows search for standard buttons anywhere in the
|
|
|
|
dialog.
|
|
|
|
|
|
|
|
@see @ref overview_dialog_autoscrolling (for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetLayoutAdaptationLevel(int level);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Sets the adaptation mode, overriding the global adaptation flag.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see wxDialogLayoutAdaptationMode, @ref overview_dialog_autoscrolling
|
|
|
|
(for more on layout adaptation)
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
A static function for setting the current layout adapter object,
|
|
|
|
returning the old adapter. If you call this, you should delete the old
|
|
|
|
adapter object.
|
|
|
|
|
|
|
|
@see wxDialogLayoutAdapter, @ref overview_dialog_autoscrolling
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the return code for this window.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
A return code is normally associated with a modal dialog, where
|
|
|
|
ShowModal() returns a code to the application. The function EndModal()
|
|
|
|
calls SetReturnCode().
|
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param retCode
|
2008-03-09 08:33:59 -04:00
|
|
|
The integer return code, usually a control identifier.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetReturnCode(), ShowModal(), EndModal()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
void SetReturnCode(int retCode);
|
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Hides or shows the dialog. The preferred way of dismissing a modal
|
|
|
|
dialog is to use EndModal().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param show
|
2008-04-20 19:50:56 -04:00
|
|
|
If @true, the dialog box is shown and brought to the front,
|
|
|
|
otherwise the box is hidden. If @false and the dialog is modal,
|
|
|
|
control is returned to the calling program.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool Show(bool show = 1);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2011-01-16 18:24:29 -05:00
|
|
|
Shows an application-modal dialog.
|
2008-06-22 10:40:25 -04:00
|
|
|
|
|
|
|
Program flow does not return until the dialog has been dismissed with
|
|
|
|
EndModal().
|
|
|
|
|
|
|
|
Notice that it is possible to call ShowModal() for a dialog which had
|
|
|
|
been previously shown with Show(), this allows to make an existing
|
|
|
|
modeless dialog modal. However ShowModal() can't be called twice
|
|
|
|
without intervening EndModal() calls.
|
2008-04-20 19:50:56 -04:00
|
|
|
|
2009-03-01 16:01:39 -05:00
|
|
|
Note that this function creates a temporary event loop which takes
|
|
|
|
precedence over the application's main event loop (see wxEventLoopBase)
|
|
|
|
and which is destroyed when the dialog is dismissed.
|
2009-03-08 08:08:39 -04:00
|
|
|
This also results in a call to wxApp::ProcessPendingEvents().
|
2009-03-01 16:01:39 -05:00
|
|
|
|
2008-05-10 21:38:53 -04:00
|
|
|
@return The value set with SetReturnCode().
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2013-09-06 13:09:20 -04:00
|
|
|
@see ShowWindowModal(), ShowWindowModalThenDo(),
|
|
|
|
EndModal(), GetReturnCode(), SetReturnCode()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual int ShowModal();
|
2011-01-16 18:24:29 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Shows a dialog modal to the parent top level window only.
|
|
|
|
|
|
|
|
Unlike ShowModal(), dialogs shown with this function only prevent the
|
|
|
|
user from interacting with their parent frame only but not with the
|
|
|
|
rest of the application. They also don't block the program execution
|
|
|
|
but instead return immediately, as Show(), and generate a
|
2013-09-06 13:09:07 -04:00
|
|
|
wxEVT_WINDOW_MODAL_DIALOG_CLOSED event (wxWindowModalDialogEvent)
|
|
|
|
later when the dialog is closed.
|
2011-01-16 18:24:29 -05:00
|
|
|
|
|
|
|
Currently this function is only fully implemented in wxOSX ports, under
|
|
|
|
the other platforms it behaves like ShowModal() (but also sends the
|
|
|
|
above mentioned event).
|
|
|
|
|
2013-09-06 13:09:20 -04:00
|
|
|
@see wxWindowModalDialogEvent, ShowWindowModalThenDo()
|
2013-09-06 13:09:07 -04:00
|
|
|
|
2011-01-16 18:24:29 -05:00
|
|
|
@since 2.9.0
|
|
|
|
*/
|
|
|
|
void ShowWindowModal();
|
2013-09-06 13:09:20 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Shows a dialog modal to the parent top level window only and call a
|
|
|
|
functor after the dialog is closed.
|
|
|
|
|
|
|
|
Same as the other ShowWindowModal() overload, but calls the functor
|
|
|
|
passed as the argument upon completion, instead of generating the
|
|
|
|
wxEVT_WINDOW_MODAL_DIALOG_CLOSED event.
|
|
|
|
|
|
|
|
This form is particularly useful in combination with C++11 lambdas,
|
|
|
|
when it allows writing window-modal very similarly to how ShowModal()
|
|
|
|
is used (with the notable exception of not being able to create
|
|
|
|
the dialog on stack):
|
|
|
|
|
|
|
|
@code
|
|
|
|
wxWindowPtr<wxDialog> dlg(new wxMessageDialog(this, "Hello!"));
|
|
|
|
|
|
|
|
dlg->ShowWindowModalThenDo([this,dlg](int retcode){
|
|
|
|
if ( retcode == wxID_OK )
|
|
|
|
DoSomething();
|
|
|
|
// dlg is implicitly destroyed here, because the pointer was
|
|
|
|
// explicitly captured by the lambda
|
|
|
|
});
|
|
|
|
@endcode
|
|
|
|
|
|
|
|
@param onEndModal Function object to call when the dialog is
|
|
|
|
closed. The functor is called with a single
|
|
|
|
integer argument, dialog's return code.
|
|
|
|
|
|
|
|
@note The dialog instance must not be destroyed until @a onEndModal
|
2013-10-26 12:25:50 -04:00
|
|
|
is called. The best way to ensure that is to use wxWindowPtr
|
2013-09-06 13:09:20 -04:00
|
|
|
to hold a pointer and include it in the lambda's capture,
|
|
|
|
by value (not reference!), as shown in the example above.
|
|
|
|
|
|
|
|
@since 3.0
|
|
|
|
|
|
|
|
@see wxWindowPtr<T>
|
|
|
|
*/
|
|
|
|
template<typename Functor>
|
|
|
|
void ShowWindowModalThenDo(const Functor& onEndModal);
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxDialogLayoutAdapter
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2011-04-03 16:31:32 -04:00
|
|
|
This abstract class is the base for classes that help wxWidgets perform
|
2008-04-20 19:50:56 -04:00
|
|
|
run-time layout adaptation of dialogs. Principally, this is to cater for
|
|
|
|
small displays by making part of the dialog scroll, but the application
|
|
|
|
developer may find other uses for layout adaption.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
By default, there is one instance of wxStandardDialogLayoutAdapter which
|
|
|
|
can perform adaptation for most custom dialogs and dialogs with book
|
|
|
|
controls such as wxPropertySheetDialog.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-04-20 19:50:56 -04:00
|
|
|
@category{winlayout}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-04-20 19:50:56 -04:00
|
|
|
@see @ref overview_dialog_autoscrolling
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
class wxDialogLayoutAdapter
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
Default constructor.
|
|
|
|
*/
|
|
|
|
wxDialogLayoutAdapter();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Override this to returns @true if adaptation can and should be done.
|
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-04-20 19:50:56 -04:00
|
|
|
Override this to perform layout adaptation, such as making parts of the
|
|
|
|
dialog scroll and resizing the dialog to fit the display. Normally this
|
|
|
|
function will be called just before the dialog is shown.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-29 06:52:37 -04:00
|
|
|
virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2011-09-25 00:30:49 -04:00
|
|
|
|
2013-09-06 13:09:07 -04:00
|
|
|
/**
|
|
|
|
Event sent by wxDialog::ShowWindowModal() when the dialog closes.
|
|
|
|
|
|
|
|
@since 2.9.0
|
|
|
|
*/
|
2011-09-25 00:30:49 -04:00
|
|
|
class wxWindowModalDialogEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
2013-09-06 13:09:07 -04:00
|
|
|
/// Constructor
|
2011-09-25 00:30:49 -04:00
|
|
|
wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0);
|
|
|
|
|
2013-09-06 13:09:07 -04:00
|
|
|
/// Return the corresponding dialog.
|
2011-09-25 00:30:49 -04:00
|
|
|
wxDialog *GetDialog() const;
|
2013-09-06 13:09:07 -04:00
|
|
|
|
|
|
|
/// Return the dialog's return code.
|
2011-09-25 00:30:49 -04:00
|
|
|
int GetReturnCode() const;
|
2013-09-06 13:09:07 -04:00
|
|
|
|
|
|
|
/// Clone the event.
|
2011-09-25 00:30:49 -04:00
|
|
|
virtual wxEvent *Clone() const;
|
|
|
|
};
|