[dasher: 4/217] Splitter position is remembered in app settings together with window size.



commit 818830b00ef148b73ba493ae39e657651c4474c9
Author: ipomoena <ipomoena users noreply github com>
Date:   Thu Jun 18 15:42:06 2015 -0700

    Splitter position is remembered in app settings together with window size.

 Src/Win32/AppSettings.cpp    |   12 ++++++------
 Src/Win32/AppSettings.h      |    7 ++++---
 Src/Win32/DasherWindow.cpp   |   12 ++++++++----
 Src/Win32/Widgets/Splitter.h |    5 +++++
 4 files changed, 23 insertions(+), 13 deletions(-)
---
diff --git a/Src/Win32/AppSettings.cpp b/Src/Win32/AppSettings.cpp
index cce7f95..40d88fc 100644
--- a/Src/Win32/AppSettings.cpp
+++ b/Src/Win32/AppSettings.cpp
@@ -232,16 +232,16 @@ bool CAppSettings::LoadSetting(const std::string &Key, std::string *Value) {
 
 /////////////////////////////////////////////////////////////////////////////
 
-static TCHAR FormatWindowPlacement[] = TEXT("%u,%u,%d,%d,%d,%d,%d,%d,%d,%d");
+static TCHAR FormatWindowPlacement[] = TEXT("%u,%u,%d,%d,%d,%d,%d,%d,%d,%d,%d");
 
 /////////////////////////////////////////////////////////////////////////////
 #ifndef _WIN32_WCE
 
-void CAppSettings::SaveSetting(const std::string &Key, const LPWINDOWPLACEMENT pwp) {
+void CAppSettings::SaveSetting(const std::string &Key, const LPWINDOWPLACEMENT pwp, int sp) {
   DASHER_ASSERT(pwp != NULL);
 
   TCHAR t[200];
-  _stprintf(t, FormatWindowPlacement, pwp->flags, pwp->showCmd, pwp->ptMinPosition.x, pwp->ptMinPosition.y, 
pwp->ptMaxPosition.x, pwp->ptMaxPosition.y, pwp->rcNormalPosition.left, pwp->rcNormalPosition.top, 
pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom);
+  _stprintf(t, FormatWindowPlacement, pwp->flags, pwp->showCmd, pwp->ptMinPosition.x, pwp->ptMinPosition.y, 
pwp->ptMaxPosition.x, pwp->ptMaxPosition.y, pwp->rcNormalPosition.left, pwp->rcNormalPosition.top, 
pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom,sp);
 
   Tstring ts(t);
   SaveSettingT(Key, ts);
@@ -250,7 +250,7 @@ void CAppSettings::SaveSetting(const std::string &Key, const LPWINDOWPLACEMENT p
 
 /////////////////////////////////////////////////////////////////////////////
 
-bool CAppSettings::LoadSetting(const std::string &Key, LPWINDOWPLACEMENT pwp) {
+bool CAppSettings::LoadSetting(const std::string &Key, LPWINDOWPLACEMENT pwp, int* psp) {
   DASHER_ASSERT(pwp != NULL);
 
   Tstring str;
@@ -264,9 +264,9 @@ bool CAppSettings::LoadSetting(const std::string &Key, LPWINDOWPLACEMENT pwp) {
                        &wp.ptMinPosition.x, &wp.ptMinPosition.y,
                        &wp.ptMaxPosition.x, &wp.ptMaxPosition.y,
                        &wp.rcNormalPosition.left, &wp.rcNormalPosition.top,
-                       &wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom);
+                       &wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom, psp);
 
-  if(nRead != 10)
+  if(nRead < 10)
     return false;
   wp.length = sizeof(wp);
 
diff --git a/Src/Win32/AppSettings.h b/Src/Win32/AppSettings.h
index f238de1..ffff633 100644
--- a/Src/Win32/AppSettings.h
+++ b/Src/Win32/AppSettings.h
@@ -48,12 +48,13 @@ public:
   void GetPermittedValues(int iParameter, std::vector<std::string> &vList);
 
   #ifndef _WIN32_WCE
-  bool LoadSetting(const std::string & Key, LPWINDOWPLACEMENT pwp);
-  void SaveSetting(const std::string & Key, const LPWINDOWPLACEMENT pwp);
-#endif
+  bool LoadSetting(const std::string & Key, LPWINDOWPLACEMENT pwp, int* psp);
+  void SaveSetting(const std::string & Key, const LPWINDOWPLACEMENT pwp, int sp);
+
 
   void SetHwnd(HWND hWnd) {
     m_hWnd = hWnd;
+#endif
   };
 
   void SetDasher(Dasher::CDasher *pDasher) {
diff --git a/Src/Win32/DasherWindow.cpp b/Src/Win32/DasherWindow.cpp
index 5be485b..71a62b7 100644
--- a/Src/Win32/DasherWindow.cpp
+++ b/Src/Win32/DasherWindow.cpp
@@ -121,7 +121,7 @@ HWND CDasherWindow::Create() {
   m_pSpeedAlphabetBar = new CStatusControl(m_pAppSettings);
   m_pSpeedAlphabetBar->Create(hWnd);
 
-  m_pSplitter = new CSplitter(this, 200);
+  m_pSplitter = new CSplitter(this, 100);
   HWND hSplitter =  m_pSplitter->Create(hWnd);
   
   if (!hSplitter)
@@ -183,16 +183,20 @@ void CDasherWindow::SaveWindowState() const {
   wp.length = sizeof(WINDOWPLACEMENT);
   
   if(GetWindowPlacement(&wp)) {//function call succeeds
-    m_pAppSettings->SaveSetting("WindowState", &wp);
+    m_pAppSettings->SaveSetting("WindowState", &wp, m_pSplitter->GetPos());
   }
+
 #endif
 }
 
 bool CDasherWindow::LoadWindowState() {
 #ifndef _WIN32_WCE
   WINDOWPLACEMENT wp;
-  
-  if(m_pAppSettings->LoadSetting("WindowState", &wp)) {
+  int splitterPos= -1;
+  if(m_pAppSettings->LoadSetting("WindowState", &wp, &splitterPos)) {
+         if (splitterPos != -1) {
+                 m_pSplitter->SetPos(splitterPos);
+         }
          if(SetWindowPlacement(&wp))
       return true;
   }
diff --git a/Src/Win32/Widgets/Splitter.h b/Src/Win32/Widgets/Splitter.h
index 45556b8..14883b2 100644
--- a/Src/Win32/Widgets/Splitter.h
+++ b/Src/Win32/Widgets/Splitter.h
@@ -52,6 +52,11 @@ public:
                return m_iPos;
        }
 
+       void SetPos(int Pos)
+       {
+               m_iPos = Pos;
+       }
+
        static ATL::CWndClassInfo& GetWndClassInfo() 
   { 
 


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