]> git.saurik.com Git - wxWidgets.git/commitdiff
Open generic wxPreferencesEditor at last shown page.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 May 2013 14:42:52 +0000 (14:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 May 2013 14:42:52 +0000 (14:42 +0000)
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

src/generic/preferencesg.cpp

index 98170cf0719234083f9e06f08002cb5693d6af68..72624a93eca129d1640f3b3056b87e06aa4dc77a 100644 (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