1999-06-29 08:34:18 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/dialog.h
|
|
|
|
// Purpose: wxDialogBase class
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 29.06.99
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-06-29 08:34:18 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_DIALOG_H_BASE_
|
|
|
|
#define _WX_DIALOG_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2001-09-15 18:13:08 -04:00
|
|
|
#include "wx/toplevel.h"
|
2013-08-27 18:49:53 -04:00
|
|
|
#include "wx/containr.h"
|
2013-10-01 08:19:56 -04:00
|
|
|
#include "wx/sharedptr.h"
|
1999-06-28 18:04:40 -04:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSizer;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxStdDialogButtonSizer;
|
2007-12-29 11:35:39 -05:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDialogLayoutAdapter;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxDialog;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxButton;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxScrolledWindow;
|
2010-08-19 11:41:18 -04:00
|
|
|
class wxTextSizerWrapper;
|
2004-12-31 13:57:25 -05:00
|
|
|
|
2010-05-10 17:09:50 -04:00
|
|
|
// Also see the bit summary table in wx/toplevel.h.
|
|
|
|
|
2011-09-17 07:06:11 -04:00
|
|
|
#define wxDIALOG_NO_PARENT 0x00000020 // Don't make owned by apps top window
|
2004-04-13 08:22:34 -04:00
|
|
|
|
2005-03-14 12:15:06 -05:00
|
|
|
#define wxDEFAULT_DIALOG_STYLE (wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
|
2004-04-13 08:22:34 -04:00
|
|
|
|
2007-12-29 11:35:39 -05:00
|
|
|
// Layout adaptation levels, for SetLayoutAdaptationLevel
|
|
|
|
|
|
|
|
// Don't do any layout adaptation
|
|
|
|
#define wxDIALOG_ADAPTATION_NONE 0
|
|
|
|
|
|
|
|
// Only look for wxStdDialogButtonSizer for non-scrolling part
|
|
|
|
#define wxDIALOG_ADAPTATION_STANDARD_SIZER 1
|
|
|
|
|
|
|
|
// Also look for any suitable sizer for non-scrolling part
|
|
|
|
#define wxDIALOG_ADAPTATION_ANY_SIZER 2
|
|
|
|
|
|
|
|
// Also look for 'loose' standard buttons for non-scrolling part
|
|
|
|
#define wxDIALOG_ADAPTATION_LOOSE_BUTTONS 3
|
|
|
|
|
|
|
|
// Layout adaptation mode, for 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
|
|
|
|
};
|
|
|
|
|
2009-05-13 03:01:51 -04:00
|
|
|
enum wxDialogModality
|
|
|
|
{
|
2009-08-21 06:41:26 -04:00
|
|
|
wxDIALOG_MODALITY_NONE = 0,
|
|
|
|
wxDIALOG_MODALITY_WINDOW_MODAL = 1,
|
|
|
|
wxDIALOG_MODALITY_APP_MODAL = 2
|
2009-05-13 03:01:51 -04:00
|
|
|
};
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxDialogNameStr[];
|
2003-05-12 15:52:43 -04:00
|
|
|
|
2013-08-27 18:49:53 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDialogBase : public wxNavigationEnabled<wxTopLevelWindow>
|
1999-06-28 17:39:49 -04:00
|
|
|
{
|
1999-06-29 08:34:18 -04:00
|
|
|
public:
|
2013-08-24 01:04:11 -04:00
|
|
|
wxDialogBase();
|
2001-09-23 20:34:14 -04:00
|
|
|
virtual ~wxDialogBase() { }
|
|
|
|
|
2006-08-20 10:02:51 -04:00
|
|
|
// define public wxDialog methods to be implemented by the derived classes
|
2006-08-19 18:56:11 -04:00
|
|
|
virtual int ShowModal() = 0;
|
|
|
|
virtual void EndModal(int retCode) = 0;
|
|
|
|
virtual bool IsModal() const = 0;
|
2009-05-13 03:01:51 -04:00
|
|
|
// show the dialog frame-modally (needs a parent), using app-modal
|
|
|
|
// dialogs on platforms that don't support it
|
2010-01-23 15:06:48 -05:00
|
|
|
virtual void ShowWindowModal () ;
|
2009-05-13 03:01:51 -04:00
|
|
|
virtual void SendWindowModalDialogEvent ( wxEventType type );
|
2001-09-23 20:34:14 -04:00
|
|
|
|
2013-09-06 13:09:20 -04:00
|
|
|
template<typename Functor>
|
|
|
|
void ShowWindowModalThenDo(const Functor& onEndModal);
|
|
|
|
|
2005-03-14 12:15:06 -05:00
|
|
|
// Modal dialogs have a return code - usually the id of the last
|
1999-06-29 08:34:18 -04:00
|
|
|
// pressed button
|
|
|
|
void SetReturnCode(int returnCode) { m_returnCode = returnCode; }
|
|
|
|
int GetReturnCode() const { return m_returnCode; }
|
|
|
|
|
2006-08-20 06:30:26 -04:00
|
|
|
// Set the identifier for the affirmative button: this button will close
|
|
|
|
// the dialog after validating data and calling TransferDataFromWindow()
|
|
|
|
void SetAffirmativeId(int affirmativeId);
|
2005-03-14 12:15:06 -05:00
|
|
|
int GetAffirmativeId() const { return m_affirmativeId; }
|
|
|
|
|
2006-08-20 06:30:26 -04:00
|
|
|
// Set identifier for Esc key translation: the button with this id will
|
|
|
|
// close the dialog without doing anything else; special value wxID_NONE
|
|
|
|
// means to not handle Esc at all while wxID_ANY means to map Esc to
|
|
|
|
// wxID_CANCEL if present and GetAffirmativeId() otherwise
|
|
|
|
void SetEscapeId(int escapeId);
|
2005-07-14 19:07:10 -04:00
|
|
|
int GetEscapeId() const { return m_escapeId; }
|
|
|
|
|
2009-05-09 12:55:37 -04:00
|
|
|
// Find the parent to use for modal dialog: try to use the specified parent
|
|
|
|
// but fall back to the current active window or main application window as
|
|
|
|
// last resort if it is unsuitable.
|
|
|
|
//
|
2010-04-17 20:05:37 -04:00
|
|
|
// As this function is often called from the ctor, the window style may be
|
|
|
|
// not set yet and hence must be passed explicitly to it so that we could
|
|
|
|
// check whether it contains wxDIALOG_NO_PARENT bit.
|
|
|
|
//
|
2009-05-09 12:55:37 -04:00
|
|
|
// This function always returns a valid top level window or NULL.
|
2010-04-17 20:05:37 -04:00
|
|
|
wxWindow *GetParentForModalDialog(wxWindow *parent, long style) const;
|
|
|
|
|
|
|
|
// This overload can only be used for already initialized windows, i.e. not
|
|
|
|
// from the ctor. It uses the current window parent and style.
|
|
|
|
wxWindow *GetParentForModalDialog() const
|
|
|
|
{
|
|
|
|
return GetParentForModalDialog(GetParent(), GetWindowStyle());
|
|
|
|
}
|
2007-04-22 16:34:41 -04:00
|
|
|
|
2003-05-23 14:59:07 -04:00
|
|
|
#if wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
2010-08-19 11:41:18 -04:00
|
|
|
// splits text up at newlines and places the lines into a vertical
|
2016-12-01 03:43:29 -05:00
|
|
|
// wxBoxSizer, with the given maximum width, lines will not be wrapped
|
|
|
|
// for negative values of widthMax
|
|
|
|
wxSizer *CreateTextSizer(const wxString& message, int widthMax = -1);
|
2010-08-19 11:41:18 -04:00
|
|
|
|
|
|
|
// same as above but uses a customized wxTextSizerWrapper to create
|
|
|
|
// non-standard controls for the lines
|
2016-12-01 03:43:29 -05:00
|
|
|
wxSizer *CreateTextSizer(const wxString& message,
|
|
|
|
wxTextSizerWrapper& wrapper,
|
|
|
|
int widthMax = -1);
|
2003-05-23 14:59:07 -04:00
|
|
|
#endif // wxUSE_STATTEXT // && wxUSE_TEXTCTRL
|
2001-09-23 20:34:14 -04:00
|
|
|
|
2006-10-09 17:10:22 -04:00
|
|
|
// returns a horizontal wxBoxSizer containing the given buttons
|
|
|
|
//
|
|
|
|
// notice that the returned sizer can be NULL if no buttons are put in the
|
|
|
|
// sizer (this mostly happens under smart phones and other atypical
|
|
|
|
// platforms which have hardware buttons replacing OK/Cancel and such)
|
|
|
|
wxSizer *CreateButtonSizer(long flags);
|
|
|
|
|
2010-08-30 17:48:16 -04:00
|
|
|
// returns a sizer containing the given one and a static line separating it
|
|
|
|
// from the preceding elements if it's appropriate for the current platform
|
|
|
|
wxSizer *CreateSeparatedSizer(wxSizer *sizer);
|
|
|
|
|
2006-10-09 17:10:22 -04:00
|
|
|
// returns the sizer containing CreateButtonSizer() below a separating
|
|
|
|
// static line for the platforms which use static lines for items
|
|
|
|
// separation (i.e. not Mac)
|
2010-08-30 17:48:16 -04:00
|
|
|
//
|
|
|
|
// this is just a combination of CreateButtonSizer() and
|
|
|
|
// CreateSeparatedSizer()
|
2006-10-09 17:10:22 -04:00
|
|
|
wxSizer *CreateSeparatedButtonSizer(long flags);
|
|
|
|
|
2006-01-15 05:06:15 -05:00
|
|
|
#if wxUSE_BUTTON
|
2004-12-31 13:57:25 -05:00
|
|
|
wxStdDialogButtonSizer *CreateStdDialogButtonSizer( long flags );
|
2001-06-26 16:59:19 -04:00
|
|
|
#endif // wxUSE_BUTTON
|
1999-06-29 08:34:18 -04:00
|
|
|
|
2007-12-29 11:35:39 -05:00
|
|
|
// Do layout adaptation
|
|
|
|
virtual bool DoLayoutAdaptation();
|
|
|
|
|
|
|
|
// Can we do layout adaptation?
|
|
|
|
virtual bool CanDoLayoutAdaptation();
|
|
|
|
|
|
|
|
// Returns a content window if there is one. This can be used by the layout adapter, for
|
|
|
|
// example to make the pages of a book control into scrolling windows
|
|
|
|
virtual wxWindow* GetContentWindow() const { return NULL; }
|
|
|
|
|
|
|
|
// Add an id to the list of main button identifiers that should be in the button sizer
|
|
|
|
void AddMainButtonId(wxWindowID id) { m_mainButtonIds.Add((int) id); }
|
|
|
|
wxArrayInt& GetMainButtonIds() { return m_mainButtonIds; }
|
|
|
|
|
|
|
|
// Is this id in the main button id array?
|
|
|
|
bool IsMainButtonId(wxWindowID id) const { return (m_mainButtonIds.Index((int) id) != wxNOT_FOUND); }
|
|
|
|
|
|
|
|
// Level of adaptation, from none (Level 0) to full (Level 3). To disable adaptation,
|
|
|
|
// set level 0, for example in your dialog constructor. You might
|
|
|
|
// do this if you know that you are displaying on a large screen and you don't want the
|
|
|
|
// dialog changed.
|
|
|
|
void SetLayoutAdaptationLevel(int level) { m_layoutAdaptationLevel = level; }
|
|
|
|
int GetLayoutAdaptationLevel() const { return m_layoutAdaptationLevel; }
|
|
|
|
|
|
|
|
/// Override global adaptation enabled/disabled status
|
|
|
|
void SetLayoutAdaptationMode(wxDialogLayoutAdaptationMode mode) { m_layoutAdaptationMode = mode; }
|
|
|
|
wxDialogLayoutAdaptationMode GetLayoutAdaptationMode() const { return m_layoutAdaptationMode; }
|
|
|
|
|
|
|
|
// Returns true if the adaptation has been done
|
|
|
|
void SetLayoutAdaptationDone(bool adaptationDone) { m_layoutAdaptationDone = adaptationDone; }
|
|
|
|
bool GetLayoutAdaptationDone() const { return m_layoutAdaptationDone; }
|
|
|
|
|
|
|
|
// Set layout adapter class, returning old adapter
|
|
|
|
static wxDialogLayoutAdapter* SetLayoutAdapter(wxDialogLayoutAdapter* adapter);
|
|
|
|
static wxDialogLayoutAdapter* GetLayoutAdapter() { return sm_layoutAdapter; }
|
|
|
|
|
|
|
|
// Global switch for layout adaptation
|
|
|
|
static bool IsLayoutAdaptationEnabled() { return sm_layoutAdaptation; }
|
|
|
|
static void EnableLayoutAdaptation(bool enable) { sm_layoutAdaptation = enable; }
|
|
|
|
|
2009-05-13 03:01:51 -04:00
|
|
|
// modality kind
|
2010-01-25 12:12:07 -05:00
|
|
|
virtual wxDialogModality GetModality() const;
|
2000-07-15 15:51:35 -04:00
|
|
|
protected:
|
2006-08-19 18:36:10 -04:00
|
|
|
// emulate click of a button with the given id if it's present in the dialog
|
|
|
|
//
|
|
|
|
// return true if button was "clicked" or false if we don't have it
|
|
|
|
bool EmulateButtonClickIfPresent(int id);
|
|
|
|
|
|
|
|
// this function is used by OnCharHook() to decide whether the given key
|
|
|
|
// should close the dialog
|
|
|
|
//
|
|
|
|
// for most platforms the default implementation (which just checks for
|
|
|
|
// Esc) is sufficient, but Mac port also adds Cmd-. here and other ports
|
|
|
|
// could do something different if needed
|
|
|
|
virtual bool IsEscapeKey(const wxKeyEvent& event);
|
|
|
|
|
2006-08-19 18:56:11 -04:00
|
|
|
// end either modal or modeless dialog, for the modal dialog rc is used as
|
|
|
|
// the dialog return code
|
|
|
|
void EndDialog(int rc);
|
|
|
|
|
2006-08-20 06:30:26 -04:00
|
|
|
// call Validate() and TransferDataFromWindow() and close dialog with
|
|
|
|
// wxID_OK return code
|
|
|
|
void AcceptAndClose();
|
|
|
|
|
2005-03-14 12:15:06 -05:00
|
|
|
// The return code from modal dialog
|
1999-06-29 08:34:18 -04:00
|
|
|
int m_returnCode;
|
2001-09-15 18:13:08 -04:00
|
|
|
|
2005-03-14 12:15:06 -05:00
|
|
|
// The identifier for the affirmative button (usually wxID_OK)
|
|
|
|
int m_affirmativeId;
|
|
|
|
|
2005-09-25 16:17:01 -04:00
|
|
|
// The identifier for cancel button (usually wxID_CANCEL)
|
|
|
|
int m_escapeId;
|
|
|
|
|
2007-12-29 11:35:39 -05:00
|
|
|
// Flags whether layout adaptation has been done for this dialog
|
|
|
|
bool m_layoutAdaptationDone;
|
|
|
|
|
|
|
|
// Extra button identifiers to be taken as 'main' button identifiers
|
|
|
|
// to be placed in the non-scrolling area
|
|
|
|
wxArrayInt m_mainButtonIds;
|
|
|
|
|
|
|
|
// Adaptation level
|
|
|
|
int m_layoutAdaptationLevel;
|
|
|
|
|
|
|
|
// Local override for global adaptation enabled status
|
|
|
|
wxDialogLayoutAdaptationMode m_layoutAdaptationMode;
|
|
|
|
|
|
|
|
// Global layout adapter
|
|
|
|
static wxDialogLayoutAdapter* sm_layoutAdapter;
|
|
|
|
|
|
|
|
// Global adaptation switch
|
|
|
|
static bool sm_layoutAdaptation;
|
|
|
|
|
2006-08-19 18:36:10 -04:00
|
|
|
private:
|
2009-05-09 08:26:15 -04:00
|
|
|
// helper of GetParentForModalDialog(): returns the passed in window if it
|
|
|
|
// can be used as our parent or NULL if it can't
|
|
|
|
wxWindow *CheckIfCanBeUsedAsParent(wxWindow *parent) const;
|
|
|
|
|
2010-09-09 16:53:26 -04:00
|
|
|
// Helper of OnCharHook() and OnCloseWindow(): find the appropriate button
|
|
|
|
// for closing the dialog and send a click event for it.
|
|
|
|
//
|
|
|
|
// Return true if we found a button to close the dialog and "clicked" it or
|
|
|
|
// false otherwise.
|
|
|
|
bool SendCloseButtonClickEvent();
|
|
|
|
|
2006-08-19 18:36:10 -04:00
|
|
|
// handle Esc key presses
|
|
|
|
void OnCharHook(wxKeyEvent& event);
|
|
|
|
|
2006-08-19 18:56:11 -04:00
|
|
|
// handle closing the dialog window
|
|
|
|
void OnCloseWindow(wxCloseEvent& event);
|
|
|
|
|
|
|
|
// handle the standard buttons
|
2006-08-20 10:02:51 -04:00
|
|
|
void OnButton(wxCommandEvent& event);
|
2006-08-19 18:56:11 -04:00
|
|
|
|
|
|
|
// update the background colour
|
|
|
|
void OnSysColourChanged(wxSysColourChangedEvent& event);
|
|
|
|
|
|
|
|
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxDialogBase);
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_EVENT_TABLE();
|
1999-06-28 17:39:49 -04:00
|
|
|
};
|
|
|
|
|
2007-12-29 11:35:39 -05:00
|
|
|
/*!
|
|
|
|
* Base class for layout adapters - code that, for example, turns a dialog into a
|
|
|
|
* scrolling dialog if there isn't enough screen space. You can derive further
|
|
|
|
* adapter classes to do any other kind of adaptation, such as applying a watermark, or adding
|
|
|
|
* a help mechanism.
|
|
|
|
*/
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxDialogLayoutAdapter: public wxObject
|
2007-12-29 11:35:39 -05:00
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxDialogLayoutAdapter);
|
2007-12-29 11:35:39 -05:00
|
|
|
public:
|
|
|
|
wxDialogLayoutAdapter() {}
|
|
|
|
|
|
|
|
// Override this function to indicate that adaptation should be done
|
|
|
|
virtual bool CanDoLayoutAdaptation(wxDialog* dialog) = 0;
|
|
|
|
|
|
|
|
// Override this function to do the adaptation
|
|
|
|
virtual bool DoLayoutAdaptation(wxDialog* dialog) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* Standard adapter. Does scrolling adaptation for paged and regular dialogs.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxStandardDialogLayoutAdapter: public wxDialogLayoutAdapter
|
2007-12-29 11:35:39 -05:00
|
|
|
{
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_CLASS(wxStandardDialogLayoutAdapter);
|
2007-12-29 11:35:39 -05:00
|
|
|
public:
|
|
|
|
wxStandardDialogLayoutAdapter() {}
|
|
|
|
|
|
|
|
// Overrides
|
|
|
|
|
|
|
|
// Indicate that adaptation should be done
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool CanDoLayoutAdaptation(wxDialog* dialog) wxOVERRIDE;
|
2007-12-29 11:35:39 -05:00
|
|
|
|
|
|
|
// Do layout adaptation
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual bool DoLayoutAdaptation(wxDialog* dialog) wxOVERRIDE;
|
2007-12-29 11:35:39 -05:00
|
|
|
|
|
|
|
// Implementation
|
|
|
|
|
|
|
|
// Create the scrolled window
|
|
|
|
virtual wxScrolledWindow* CreateScrolledWindow(wxWindow* parent);
|
|
|
|
|
2010-11-10 08:51:57 -05:00
|
|
|
#if wxUSE_BUTTON
|
2007-12-29 11:35:39 -05:00
|
|
|
// Find a standard or horizontal box sizer
|
|
|
|
virtual wxSizer* FindButtonSizer(bool stdButtonSizer, wxDialog* dialog, wxSizer* sizer, int& retBorder, int accumlatedBorder = 0);
|
|
|
|
|
|
|
|
// Check if this sizer contains standard buttons, and so can be repositioned in the dialog
|
|
|
|
virtual bool IsOrdinaryButtonSizer(wxDialog* dialog, wxBoxSizer* sizer);
|
|
|
|
|
|
|
|
// Check if this is a standard button
|
|
|
|
virtual bool IsStandardButton(wxDialog* dialog, wxButton* button);
|
|
|
|
|
|
|
|
// Find 'loose' main buttons in the existing layout and add them to the standard dialog sizer
|
|
|
|
virtual bool FindLooseButtons(wxDialog* dialog, wxStdDialogButtonSizer* buttonSizer, wxSizer* sizer, int& count);
|
2010-11-10 08:51:57 -05:00
|
|
|
#endif // wxUSE_BUTTON
|
2007-12-29 11:35:39 -05:00
|
|
|
|
|
|
|
// Reparent the controls to the scrolled window, except those in buttonSizer
|
|
|
|
virtual void ReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
|
|
|
|
static void DoReparentControls(wxWindow* parent, wxWindow* reparentTo, wxSizer* buttonSizer = NULL);
|
|
|
|
|
|
|
|
// A function to fit the dialog around its contents, and then adjust for screen size.
|
|
|
|
// If scrolled windows are passed, scrolling is enabled in the required orientation(s).
|
|
|
|
virtual bool FitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
|
|
|
|
virtual bool FitWithScrolling(wxDialog* dialog, wxWindowList& windows);
|
|
|
|
static bool DoFitWithScrolling(wxDialog* dialog, wxScrolledWindow* scrolledWindow);
|
|
|
|
static bool DoFitWithScrolling(wxDialog* dialog, wxWindowList& windows);
|
|
|
|
|
|
|
|
// Find whether scrolling will be necessary for the dialog, returning wxVERTICAL, wxHORIZONTAL or both
|
|
|
|
virtual int MustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);
|
|
|
|
static int DoMustScroll(wxDialog* dialog, wxSize& windowSize, wxSize& displaySize);
|
|
|
|
};
|
2001-09-15 18:13:08 -04:00
|
|
|
|
2015-08-27 04:17:32 -04:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
2001-09-18 18:33:38 -04:00
|
|
|
#include "wx/univ/dialog.h"
|
|
|
|
#else
|
2012-01-14 20:05:28 -05:00
|
|
|
#if defined(__WXMSW__)
|
2001-09-18 18:33:38 -04:00
|
|
|
#include "wx/msw/dialog.h"
|
|
|
|
#elif defined(__WXMOTIF__)
|
|
|
|
#include "wx/motif/dialog.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK20__)
|
2001-09-18 18:33:38 -04:00
|
|
|
#include "wx/gtk/dialog.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/dialog.h"
|
2001-09-18 18:33:38 -04:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 15:17:41 -04:00
|
|
|
#include "wx/osx/dialog.h"
|
2014-08-23 21:50:11 -04:00
|
|
|
#elif defined(__WXQT__)
|
|
|
|
#include "wx/qt/dialog.h"
|
2001-09-18 18:33:38 -04:00
|
|
|
#endif
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
2009-05-13 03:01:51 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxWindowModalDialogEvent : public wxCommandEvent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxWindowModalDialogEvent (wxEventType commandType = wxEVT_NULL, int id = 0)
|
|
|
|
: wxCommandEvent(commandType, id) { }
|
|
|
|
|
|
|
|
wxDialog *GetDialog() const
|
|
|
|
{ return wxStaticCast(GetEventObject(), wxDialog); }
|
2009-08-21 06:41:26 -04:00
|
|
|
|
|
|
|
int GetReturnCode() const
|
2009-05-13 03:01:51 -04:00
|
|
|
{ return GetDialog()->GetReturnCode(); }
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxEvent *Clone() const wxOVERRIDE { return new wxWindowModalDialogEvent (*this); }
|
2009-05-13 03:01:51 -04:00
|
|
|
|
|
|
|
private:
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxWindowModalDialogEvent);
|
2009-05-13 03:01:51 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_WINDOW_MODAL_DIALOG_CLOSED , wxWindowModalDialogEvent );
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxWindowModalDialogEventFunction)(wxWindowModalDialogEvent &);
|
|
|
|
|
|
|
|
#define wxWindowModalDialogEventHandler(func) \
|
|
|
|
wxEVENT_HANDLER_CAST(wxWindowModalDialogEventFunction, func)
|
|
|
|
|
2011-12-24 10:43:05 -05:00
|
|
|
#define EVT_WINDOW_MODAL_DIALOG_CLOSED(winid, func) \
|
|
|
|
wx__DECLARE_EVT1(wxEVT_WINDOW_MODAL_DIALOG_CLOSED, winid, wxWindowModalDialogEventHandler(func))
|
|
|
|
|
2013-09-06 13:09:20 -04:00
|
|
|
template<typename Functor>
|
|
|
|
class wxWindowModalDialogEventFunctor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxWindowModalDialogEventFunctor(const Functor& f)
|
2013-10-01 08:19:56 -04:00
|
|
|
: m_f(new Functor(f))
|
2013-09-06 13:09:20 -04:00
|
|
|
{}
|
|
|
|
|
|
|
|
void operator()(wxWindowModalDialogEvent& event)
|
|
|
|
{
|
2013-10-01 08:19:56 -04:00
|
|
|
if ( m_f )
|
|
|
|
{
|
|
|
|
// We only want to call this handler once. Also, by deleting
|
|
|
|
// the functor here, its data (such as wxWindowPtr pointing to
|
|
|
|
// the dialog) are freed immediately after exiting this operator().
|
|
|
|
wxSharedPtr<Functor> functor(m_f);
|
|
|
|
m_f.reset();
|
|
|
|
|
|
|
|
(*functor)(event.GetReturnCode());
|
|
|
|
}
|
|
|
|
else // was already called once
|
2013-09-06 13:09:20 -04:00
|
|
|
{
|
|
|
|
event.Skip();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2013-10-01 08:19:56 -04:00
|
|
|
wxSharedPtr<Functor> m_f;
|
2013-09-06 13:09:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
template<typename Functor>
|
|
|
|
void wxDialogBase::ShowWindowModalThenDo(const Functor& onEndModal)
|
|
|
|
{
|
|
|
|
Bind(wxEVT_WINDOW_MODAL_DIALOG_CLOSED,
|
|
|
|
wxWindowModalDialogEventFunctor<Functor>(onEndModal));
|
|
|
|
ShowWindowModal();
|
2013-10-10 12:05:07 -04:00
|
|
|
}
|
2013-09-06 13:09:20 -04:00
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_DIALOG_H_BASE_
|