From a3ad40ffafb9dcea1c90f1694192b1ebbaa4f97f Mon Sep 17 00:00:00 2001 From: Kevin Reed Date: Fri, 29 Sep 2006 16:00:48 +0000 Subject: [PATCH] - Fix bug that makes sure that the BSG will be displayed on the screen if the values of the previous location are corrupted for some reason svn path=/trunk/boinc/; revision=11214 --- clientgui/sg_BoincSimpleGUI.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/clientgui/sg_BoincSimpleGUI.cpp b/clientgui/sg_BoincSimpleGUI.cpp index 30f01d4d67..6f0417282c 100644 --- a/clientgui/sg_BoincSimpleGUI.cpp +++ b/clientgui/sg_BoincSimpleGUI.cpp @@ -132,8 +132,27 @@ bool CSimpleFrame::RestoreState() { pConfig->SetPath(strBaseConfigLocation); pConfig->Read(wxT("Skin"), &skinName, wxT("default")); + // Read the last coordinates of the BSG int x = pConfig->Read(wxT("X_Position"), ((wxPoint) wxDefaultPosition).x); int y = pConfig->Read(wxT("Y_Position"), ((wxPoint) wxDefaultPosition).y); + + // If either co-ordinate is less then 0 then set it equal to 0 to ensure + // it displays on the screen. + if ( x < 0 ) x = 0; + if ( y < 0 ) y = 0; + + // Read the size of the screen + int maxX = wxSystemSettings::GetSystemMetric( wxSYS_SCREEN_X ); + int maxY = wxSystemSettings::GetSystemMetric( wxSYS_SCREEN_Y ); + + // Read the size of the BSG + int width, height; + GetSize(&width, &height); + + // Max sure that it doesn't go off to the right or bottom + if ( x + width > maxX ) x=maxX-width; + if ( y + height > maxY ) y=maxY-height; + Move(x,y);