MGR: If user moves SimpleView window, immediately save its new position to registry / config file

This commit is contained in:
Charlie Fenton 2014-03-01 03:52:48 -08:00
parent 0d25479c38
commit 19d2721fba
2 changed files with 16 additions and 6 deletions

View File

@ -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;

View File

@ -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();