From: Nicolas Boichat Date: Wed, 4 May 2005 15:35:53 +0000 (+0000) Subject: Remember the last window position and size. X-Git-Tag: Release-1.38.0~508 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dec2e17baf8ea0c3ce5dbcc8a035336deddfbede;p=bacula%2Fbacula Remember the last window position and size. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1990 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/wx-console/CHANGELOG b/bacula/src/wx-console/CHANGELOG index 0c6ff41503..858f4cf864 100644 --- a/bacula/src/wx-console/CHANGELOG +++ b/bacula/src/wx-console/CHANGELOG @@ -1,4 +1,7 @@ -03-05-2005: +04-05-2005 : + - Remember the last window position and size. + +03-05-2005 : - Fix compilation warnings with wxWidgets 2.6.0. - Fix wxChoice height problem under wxGTK-2.6.0 (GTK+-2.0). diff --git a/bacula/src/wx-console/main.cpp b/bacula/src/wx-console/main.cpp index 07a8dcb3f6..2dce15d778 100644 --- a/bacula/src/wx-console/main.cpp +++ b/bacula/src/wx-console/main.cpp @@ -33,6 +33,7 @@ // ---------------------------------------------------------------------------- #include +#include #include "wxbmainframe.h" @@ -66,8 +67,30 @@ IMPLEMENT_APP(MyApp) // 'Main program' equivalent: the program execution "starts" here bool MyApp::OnInit() { + long posx, posy, sizex, sizey; + int displayx, displayy; + wxConfig::Get()->Read("/Position/X", &posx, 50); + wxConfig::Get()->Read("/Position/Y", &posy, 50); + wxConfig::Get()->Read("/Size/Width", &sizex, 780); + wxConfig::Get()->Read("/Size/Height", &sizey, 500); + + wxDisplaySize(&displayx, &displayy); + + /* Check if we are on the screen... */ + if ((posx+sizex > displayx) || (posy+sizey > displayy)) { + /* Try to move the top-left corner first */ + posx = 50; + posy = 50; + if ((posx+sizex > displayx) || (posy+sizey > displayy)) { + posx = 25; + posy = 25; + sizex = displayx - 50; + sizey = displayy - 50; + } + } + wxbMainFrame *frame = wxbMainFrame::CreateInstance(_T("Bacula wx-console"), - wxPoint(50, 50), wxSize(780, 500)); + wxPoint(posx, posy), wxSize(sizex, sizey)); frame->Show(TRUE); diff --git a/bacula/src/wx-console/wxbmainframe.cpp b/bacula/src/wx-console/wxbmainframe.cpp index b261eac351..1159eb9d51 100644 --- a/bacula/src/wx-console/wxbmainframe.cpp +++ b/bacula/src/wx-console/wxbmainframe.cpp @@ -195,6 +195,11 @@ wxbMainFrame* wxbMainFrame::GetInstance() */ wxbMainFrame::~wxbMainFrame() { + wxConfig::Get()->Write("/Position/X", (long)GetPosition().x); + wxConfig::Get()->Write("/Position/Y", (long)GetPosition().y); + wxConfig::Get()->Write("/Size/Width", (long)GetSize().GetWidth()); + wxConfig::Get()->Write("/Size/Height", (long)GetSize().GetHeight()); + if (ct != NULL) { // && (!ct->IsRunning()) ct->Delete(); }