This is very convenient under systems using a modal dialog for the preferences
editor implementation (such as MSW), as it allows to do several changes in the
same page without having to select it manually every time.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74005
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
m_notebook->AddPage(win, page->GetName());
}
m_notebook->AddPage(win, page->GetName());
}
+ int GetSelectedPage() const
+ {
+ return m_notebook->GetSelection();
+ }
+
+ void SelectPage(int page)
+ {
+ m_notebook->ChangeSelection(page);
+ }
+
private:
wxNotebook *m_notebook;
};
private:
wxNotebook *m_notebook;
};
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
{
public:
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
{
public:
+ wxModalPreferencesEditorImpl()
+ {
+ m_currentPage = -1;
+ }
+
virtual void Show(wxWindow* parent)
{
wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
dlg->Fit();
virtual void Show(wxWindow* parent)
{
wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
dlg->Fit();
+
+ // Restore the previously selected page, if any.
+ if ( m_currentPage != -1 )
+ dlg->SelectPage(m_currentPage);
+
+ // Don't remember the last selected page if the dialog was cancelled.
+ if ( dlg->ShowModal() != wxID_CANCEL )
+ m_currentPage = dlg->GetSelectedPage();
}
virtual void Dismiss()
{
// nothing to do
}
}
virtual void Dismiss()
{
// nothing to do
}
+
+private:
+ int m_currentPage;
};
#endif // !wxHAS_PREF_EDITOR_MODELESS
};
#endif // !wxHAS_PREF_EDITOR_MODELESS