*
* Nicolas Boichat, April 2004
*
+ * Version $Id$
*/
/*
- Copyright (C) 2004 Kern Sibbald and John Walker
+ Copyright (C) 2004-2005 Kern Sibbald
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
// headers
// ----------------------------------------------------------------------------
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
- #pragma hdrstop
-#endif
-
-// for all others, include the necessary headers (this file is usually all you
-// need because it includes almost all "standard" wxWindows headers)
-#ifndef WX_PRECOMP
- #include "wx/wx.h"
-#endif
+#include <wx/wxprec.h>
+#include <wx/config.h>
#include "wxbmainframe.h"
#include "csprint.h"
+void InitWinAPIWrapper();
+
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
+int generate_job_event(JCR *jcr, const char *event) { return 1; }
+
+
// ----------------------------------------------------------------------------
// resources
// ----------------------------------------------------------------------------
// 'Main program' equivalent: the program execution "starts" here
bool MyApp::OnInit()
{
- wxbMainFrame *frame = wxbMainFrame::CreateInstance(_T("Bacula wx-console"),
- wxPoint(50, 50), wxSize(780, 500));
+ long posx, posy, sizex, sizey;
+ int displayx, displayy;
+ InitWinAPIWrapper();
+ wxConfig::Get()->Read(wxT("/Position/X"), &posx, 50);
+ wxConfig::Get()->Read(wxT("/Position/Y"), &posy, 50);
+ wxConfig::Get()->Read(wxT("/Size/Width"), &sizex, 780);
+ wxConfig::Get()->Read(wxT("/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(wxT("Bacula wx-console"),
+ wxPoint(posx, posy), wxSize(sizex, sizey));
frame->Show(TRUE);
- frame->Print(wxString("Welcome to bacula wx-console ") << VERSION << " (" << BDATE << ")!\n", CS_DEBUG);
+ frame->Print(wxString(wxT("Welcome to bacula wx-console ")) << wxT(VERSION) << wxT(" (") << wxT(BDATE) << wxT(")!\n"), CS_DEBUG);
- frame->StartConsoleThread("");
+ frame->StartConsoleThread(wxT(""));
return TRUE;
}