Allow wxPreferencesEditor::Dismiss() to work when using modal dialogs too.
The modal dialog case is not really different, the dialog may still need to be dismissed if the associated object doesn't exist any longer. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74010 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -104,8 +104,7 @@ public:
|
|||||||
// platform, i.e. depending on whether the dialog is modal or not.
|
// platform, i.e. depending on whether the dialog is modal or not.
|
||||||
virtual void Show(wxWindow* parent);
|
virtual void Show(wxWindow* parent);
|
||||||
|
|
||||||
// Hide the currently shown dialog, if any. This doesn't do anything on the
|
// Hide the currently shown dialog, if any. This is typically used to
|
||||||
// platforms using modal preferences dialogs but should be called to
|
|
||||||
// dismiss the dialog if the object whose preferences it is editing was
|
// dismiss the dialog if the object whose preferences it is editing was
|
||||||
// closed.
|
// closed.
|
||||||
void Dismiss();
|
void Dismiss();
|
||||||
|
@@ -82,9 +82,8 @@ public:
|
|||||||
/**
|
/**
|
||||||
Hide the currently shown dialog, if any.
|
Hide the currently shown dialog, if any.
|
||||||
|
|
||||||
This doesn't do anything on the platforms using modal preferences
|
This is typically called to dismiss the dialog if the object whose
|
||||||
dialogs (e.g. Windows) but should be called to dismiss the dialog if
|
preferences it is editing was closed.
|
||||||
the object whose preferences it is editing was closed.
|
|
||||||
*/
|
*/
|
||||||
void Dismiss();
|
void Dismiss();
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#include "wx/sizer.h"
|
#include "wx/sizer.h"
|
||||||
#include "wx/sharedptr.h"
|
#include "wx/sharedptr.h"
|
||||||
#include "wx/scopedptr.h"
|
#include "wx/scopedptr.h"
|
||||||
|
#include "wx/scopeguard.h"
|
||||||
#include "wx/vector.h"
|
#include "wx/vector.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -193,12 +194,19 @@ class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
|
|||||||
public:
|
public:
|
||||||
wxModalPreferencesEditorImpl()
|
wxModalPreferencesEditorImpl()
|
||||||
{
|
{
|
||||||
|
m_dlg = NULL;
|
||||||
m_currentPage = -1;
|
m_currentPage = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Show(wxWindow* parent)
|
virtual void Show(wxWindow* parent)
|
||||||
{
|
{
|
||||||
wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
|
wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
|
||||||
|
|
||||||
|
// Store it for Dismiss() but ensure that the pointer is reset to NULL
|
||||||
|
// when the dialog is destroyed on leaving this function.
|
||||||
|
m_dlg = dlg.get();
|
||||||
|
wxON_BLOCK_EXIT_NULL(m_dlg);
|
||||||
|
|
||||||
dlg->Fit();
|
dlg->Fit();
|
||||||
|
|
||||||
// Restore the previously selected page, if any.
|
// Restore the previously selected page, if any.
|
||||||
@@ -212,11 +220,18 @@ public:
|
|||||||
|
|
||||||
virtual void Dismiss()
|
virtual void Dismiss()
|
||||||
{
|
{
|
||||||
// nothing to do
|
if ( m_dlg )
|
||||||
|
{
|
||||||
|
m_dlg->EndModal(wxID_CANCEL);
|
||||||
|
m_dlg = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
wxGenericPrefsDialog* m_dlg;
|
||||||
int m_currentPage;
|
int m_currentPage;
|
||||||
|
|
||||||
|
wxDECLARE_NO_COPY_CLASS(wxModalPreferencesEditorImpl);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline
|
inline
|
||||||
|
Reference in New Issue
Block a user