Open generic wxPreferencesEditor at last shown page.

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
This commit is contained in:
Vadim Zeitlin
2013-05-16 14:42:52 +00:00
parent 2c544b4026
commit f3c0bcfab0

View File

@@ -65,6 +65,16 @@ public:
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;
};
@@ -156,17 +166,32 @@ private:
class wxModalPreferencesEditorImpl : public wxGenericPreferencesEditorImplBase
{
public:
wxModalPreferencesEditorImpl()
{
m_currentPage = -1;
}
virtual void Show(wxWindow* parent)
{
wxScopedPtr<wxGenericPrefsDialog> dlg(CreateDialog(parent));
dlg->Fit();
dlg->ShowModal();
// 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
}
private:
int m_currentPage;
};
#endif // !wxHAS_PREF_EDITOR_MODELESS