]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/main.cpp
Fix header file includes.
[bacula/bacula] / bacula / src / wx-console / main.cpp
1 /*
2  *
3  *    Bacula wx-console application
4  *
5  *    Nicolas Boichat, April 2004
6  *
7  *    Version $Id$
8  */
9 /*
10    Copyright (C) 2004-2005 Kern Sibbald
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    version 2 as amended with additional clauses defined in the
15    file LICENSE in the main source directory.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
20    the file LICENSE for additional details.
21
22  */
23
24 // ============================================================================
25 // declarations
26 // ============================================================================
27
28 // ----------------------------------------------------------------------------
29 // headers
30 // ----------------------------------------------------------------------------
31
32 #include "bacula.h"
33
34 #include <wx/wxprec.h>
35 #include <wx/config.h>
36 #include <wx/intl.h>
37
38 #include "wxbmainframe.h"
39
40 #include "csprint.h"
41
42 /* Dummy functions */
43 int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
44 int generate_job_event(JCR *jcr, const char *event) { return 1; }
45
46
47 // ----------------------------------------------------------------------------
48 // resources
49 // ----------------------------------------------------------------------------
50
51 class MyApp : public wxApp
52 {
53 public:
54    virtual bool OnInit();
55 };
56
57 // ============================================================================
58 // implementation
59 // ============================================================================
60
61 IMPLEMENT_APP(MyApp)
62
63 // ----------------------------------------------------------------------------
64 // the application class
65 // ----------------------------------------------------------------------------
66
67 // 'Main program' equivalent: the program execution "starts" here
68 bool MyApp::OnInit()
69 {
70    /* wxWidgets internationalisation */
71    wxLocale m_locale;
72    m_locale.Init();
73    m_locale.AddCatalog(wxT("bacula"));
74    wxLocale::AddCatalogLookupPathPrefix(wxT(LOCALEDIR));
75
76    long posx, posy, sizex, sizey;
77    int displayx, displayy;
78    OSDependentInit();
79    wxConfig::Get()->Read(wxT("/Position/X"), &posx, 50);
80    wxConfig::Get()->Read(wxT("/Position/Y"), &posy, 50);
81    wxConfig::Get()->Read(wxT("/Size/Width"), &sizex, 780);
82    wxConfig::Get()->Read(wxT("/Size/Height"), &sizey, 500);
83    
84    wxDisplaySize(&displayx, &displayy);
85    
86    /* Check if we are on the screen... */
87    if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
88       /* Try to move the top-left corner first */
89       posx = 50;
90       posy = 50;
91       if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
92          posx = 25;
93          posy = 25;
94          sizex = displayx - 50;
95          sizey = displayy - 50;
96       }
97    }
98
99    wxbMainFrame *frame = wxbMainFrame::CreateInstance(_("Bacula wx-console"),
100                          wxPoint(posx, posy), wxSize(sizex, sizey));
101
102    frame->Show(TRUE);
103
104    frame->Print(wxString::Format(_("Welcome to bacula wx-console %s (%s)!\n"), wxT(VERSION), wxT(BDATE)), CS_DEBUG);
105
106    frame->StartConsoleThread(wxT(""));
107    
108    return TRUE;
109 }