3 * Main frame header file
5 * Nicolas Boichat, July 2004
10 Bacula® - The Network Backup Solution
12 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
14 The main author of Bacula is Kern Sibbald, with contributions from
15 many others, a complete list can be found in the file AUTHORS.
16 This program is Free Software; you can redistribute it and/or
17 modify it under the terms of version two of the GNU General Public
18 License as published by the Free Software Foundation plus additions
19 that are listed in the file LICENSE.
21 This program is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 Bacula® is a registered trademark of John Walker.
32 The licensor of Bacula is the Free Software Foundation Europe
33 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34 Switzerland, email:ftf@fsfeurope.org.
37 #ifndef WXBMAINFRAME_H
38 #define WXBMAINFRAME_H
40 #include "wx/wxprec.h"
46 // for all others, include the necessary headers (this file is usually all you
47 // need because it includes almost all "standard" wxWindows headers)
52 #include <wx/textctrl.h>
53 #include <wx/tokenzr.h>
54 #include <wx/notebook.h>
56 #include <wx/dynarray.h>
58 #include "console_thread.h"
62 #include "wxbhistorytextctrl.h"
64 WX_DEFINE_ARRAY(wxbDataParser*, wxbDataParsers);
66 // ----------------------------------------------------------------------------
67 // wxbPrintObject - Used by wxbThreadEvent to contain data sent by director
68 // ----------------------------------------------------------------------------
70 class wxbPrintObject: public wxObject {
74 wxbPrintObject(wxString str, int status): wxObject() {
76 this->status = status;
79 wxbPrintObject(const wxbPrintObject& pe) {
81 this->status = pe.status;
85 // ----------------------------------------------------------------------------
86 // wxbThreadEvent - Event used by wxbTHREAD_EVENT
87 // ----------------------------------------------------------------------------
89 DECLARE_LOCAL_EVENT_TYPE(wxbTHREAD_EVENT, -1)
91 class wxbThreadEvent: public wxEvent {
93 wxbThreadEvent(int id);
95 wxbThreadEvent(const wxbThreadEvent& te);
96 virtual wxEvent *Clone() const;
97 wxbPrintObject* GetEventPrintObject();
98 void SetEventPrintObject(wxbPrintObject* object);
101 // Define a new frame type: this is going to be our main frame
102 class wxbMainFrame : public wxFrame
105 /* this class is a singleton */
106 static wxbMainFrame* CreateInstance(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
107 static wxbMainFrame* GetInstance();
109 /* event handlers (these functions should _not_ be virtual) */
110 void OnQuit(wxCommandEvent& event);
111 void OnAbout(wxCommandEvent& event);
112 void OnChangeConfig(wxCommandEvent& event);
113 void OnEditConfig(wxCommandEvent& event);
114 void OnConnect(wxCommandEvent& event);
115 void OnDisconnect(wxCommandEvent& event);
116 void OnEnter(wxCommandEvent& event);
117 void OnPrint(wxbThreadEvent& event);
119 /* Enable and disable panels */
121 void DisablePanels(void* except = NULL);
123 void EnableConsole(bool enable = true);
126 * Prints data received from director to the console,
127 * and forwards it to the panels
129 void Print(wxString str, int status);
131 /* Sends data to the director */
132 void Send(wxString str);
135 * Starts the thread interacting with the director
136 * If config is not empty, uses this config file.
138 void StartConsoleThread(const wxString& config);
140 /* Register a new wxbDataParser */
141 void Register(wxbDataParser* dp);
143 /* Unregister a wxbDataParser */
144 void Unregister(wxbDataParser* dp);
146 console_thread* ct; /* thread interacting with the director */
149 /* private constructor, singleton */
150 wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
153 static wxbMainFrame *frame; /* this */
157 wxNotebook *notebook; /* main notebook */
158 wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
159 wxStaticText *helpCtrl; /* wxStaticText showing help messages */
160 wxbHistoryTextCtrl *typeCtrl; /* wxbHistoryTextCtrl for console user input */
161 wxButton *sendButton; /* wxButton used to send data */
163 wxbPanel **panels; /* panels array, contained in the notebook */
164 wxbDataParsers parsers; /* Data parsers, which need to receive director informations */
166 wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */
168 bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */
170 wxString configfile; /* configfile used */
172 wxString consoleBuffer; /* Buffer used to print in the console line by line */
174 // any class wishing to process wxWindows events must use this macro
175 DECLARE_EVENT_TABLE()
178 #endif // WXBMAINFRAME_H