lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master fb91253 12/13: Revert "Store the last selecte


From: Greg Chicares
Subject: [lmi-commits] [lmi] master fb91253 12/13: Revert "Store the last selected page of MvcController persistently"
Date: Tue, 8 May 2018 19:51:07 -0400 (EDT)

branch: master
commit fb912535b69d4d28ca1745f9372f0c611bca6c41
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Revert "Store the last selected page of MvcController persistently"
    
    This reverts commit e4f1a40cf81bcb9ca65777cb193e198582229cf3. It was
    worth experimenting with the "persistent" behavior, but the original
    behavior is preferred.
---
 mvc_controller.cpp | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/mvc_controller.cpp b/mvc_controller.cpp
index 6914184..04a7b68 100644
--- a/mvc_controller.cpp
+++ b/mvc_controller.cpp
@@ -44,7 +44,6 @@
 #include <wx/checkbox.h>
 #include <wx/ctrlsub.h>
 #include <wx/datectrl.h>
-#include <wx/persist/bookctrl.h>
 #include <wx/radiobox.h>
 #include <wx/spinctrl.h>
 #include <wx/textctrl.h>
@@ -57,6 +56,11 @@
 
 namespace
 {
+/// Open new bookcontrol to page selected in most recent instance.
+///
+/// A page selection is maintained for each bookcontrol resource.
+
+std::map<std::string,std::size_t> last_selected_page;
 
 /// Custom event to trigger a call to SetFocus(). This action requires
 /// a custom event because wxFocusEvent does not change focus--it only
@@ -111,16 +115,7 @@ MvcController::MvcController
     //   https://lists.nongnu.org/archive/html/lmi/2018-03/msg00041.html
     SetIcons(TopWindow().GetIcons());
 
-    // Use resource file name as the unique identifier of the particular
-    // controller, as different controllers use different book controls with
-    // different number of pages, and so shouldn't reuse the last saved page of
-    // each other.
-    //
-    // For cosmetic purposes, remove the ".xrc" suffix of the resource file
-    // name as it doesn't really make much sense in the config file/registry
-    // context.
-    wxString const name{view_.ResourceFileName()};
-    wxPersistentRegisterAndRestore(&BookControl(), name.BeforeLast('.'));
+    
BookControl().ChangeSelection(last_selected_page[view_.ResourceFileName()]);
 
     // This assignment must follow the call to LoadDialog().
     // Initialization to 'parent' in the ctor-initializer-list
@@ -737,6 +732,10 @@ void MvcController::UponPageChanged(wxBookCtrlBaseEvent& 
event)
 {
     event.Skip();
 
+    int const z = event.GetSelection();
+    LMI_ASSERT(wxNOT_FOUND != z);
+    last_selected_page[view_.ResourceFileName()] = z;
+
     ConditionallyEnable();
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]