]> git.sur5r.net Git - bacula/bacula/commitdiff
Remember the last window position and size.
authorNicolas Boichat <nicolas@boichat.ch>
Wed, 4 May 2005 15:35:53 +0000 (15:35 +0000)
committerNicolas Boichat <nicolas@boichat.ch>
Wed, 4 May 2005 15:35:53 +0000 (15:35 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1990 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/wx-console/CHANGELOG
bacula/src/wx-console/main.cpp
bacula/src/wx-console/wxbmainframe.cpp

index 0c6ff41503948ac1cb7819b48922337259b5fb56..858f4cf864a501e7fc73c321797fad207b1567c1 100644 (file)
@@ -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).
 
index 07a8dcb3f6bddb6d97e174a9e0b8b6b60fe7967b..2dce15d7789a56ecf6ad7462b2c0acbff1303ecb 100644 (file)
@@ -33,6 +33,7 @@
 // ----------------------------------------------------------------------------
 
 #include <wx/wxprec.h>
+#include <wx/config.h>
 
 #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);
 
index b261eac351482b7dee6dd3ace0e644dd7620cd46..1159eb9d516caab56b2748e1ad73a14688210760 100644 (file)
@@ -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();
    }