From 19d2721fba58563201e588f07f671cc1eff53e08 Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Sat, 1 Mar 2014 03:52:48 -0800 Subject: [PATCH] MGR: If user moves SimpleView window, immediately save its new position to registry / config file --- clientgui/sg_BoincSimpleFrame.cpp | 20 ++++++++++++++------ clientgui/sg_BoincSimpleFrame.h | 2 ++ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/clientgui/sg_BoincSimpleFrame.cpp b/clientgui/sg_BoincSimpleFrame.cpp index e64c64ed78..a7dad057d6 100755 --- a/clientgui/sg_BoincSimpleFrame.cpp +++ b/clientgui/sg_BoincSimpleFrame.cpp @@ -76,6 +76,7 @@ BEGIN_EVENT_TABLE(CSimpleFrame, CBOINCBaseFrame) EVT_MENU(ID_HELPBOINCWEBSITE, CSimpleFrame::OnHelpBOINC) EVT_MENU(wxID_ABOUT, CSimpleFrame::OnHelpAbout) EVT_MENU(ID_EVENTLOG, CSimpleFrame::OnEventLog) + EVT_MOVE(CSimpleFrame::OnMove) #ifdef __WXMAC__ EVT_MENU(wxID_PREFERENCES, CSimpleFrame::OnPreferences) #endif @@ -304,8 +305,7 @@ CSimpleFrame::~CSimpleFrame() { } -bool CSimpleFrame::SaveState() { - CBOINCBaseFrame::SaveState(); +bool CSimpleFrame::SaveWindowPosition() { wxConfigBase* pConfig = wxConfigBase::Get(FALSE); wxString strBaseConfigLocation = wxString(wxT("/Simple")); wxPoint pos = GetPosition(); @@ -318,24 +318,32 @@ bool CSimpleFrame::SaveState() { // pointer, return false. if (!pConfig) return false; - // - // Save Frame State - // pConfig->SetPath(strBaseConfigLocation); pConfig->Write(wxT("XPos"), pos.x); pConfig->Write(wxT("YPos"), pos.y); - return true; } +bool CSimpleFrame::SaveState() { + CBOINCBaseFrame::SaveState(); + return SaveWindowPosition(); +} + + bool CSimpleFrame::RestoreState() { CBOINCBaseFrame::RestoreState(); return true; } +void CSimpleFrame::OnMove(wxMoveEvent& event) { + SaveWindowPosition(); + event.Skip(); +} + + int CSimpleFrame::_GetCurrentViewPage() { if (isMessagesDlgOpen()) { return VW_SGUI | VW_SMSG; diff --git a/clientgui/sg_BoincSimpleFrame.h b/clientgui/sg_BoincSimpleFrame.h index a6f503d5b2..ebe2e05f59 100644 --- a/clientgui/sg_BoincSimpleFrame.h +++ b/clientgui/sg_BoincSimpleFrame.h @@ -124,8 +124,10 @@ public: void SetMsgsDlgOpen(CDlgMessages* newDlgPtr) { dlgMsgsPtr = newDlgPtr; } bool isMessagesDlgOpen() { return (dlgMsgsPtr != NULL); } + bool SaveWindowPosition(); bool SaveState(); bool RestoreState(); + void OnMove(wxMoveEvent& event); protected: virtual int _GetCurrentViewPage();