]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbmainframe.h
This commit was manufactured by cvs2svn to create tag
[bacula/bacula] / bacula / src / wx-console / wxbmainframe.h
1 /*
2  *
3  *   Main frame header file
4  *
5  *    Nicolas Boichat, July 2004
6  *
7  *    Version $Id$
8  */
9 /*
10    Copyright (C) 2004 Kern Sibbald and John Walker
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    as published by the Free Software Foundation; either version 2
15    of the License, or (at your option) any later version.
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    GNU General Public License for more details.
21
22    You should have received a copy of the GNU General Public License
23    along with this program; if not, write to the Free Software
24    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifndef WXBMAINFRAME_H
28 #define WXBMAINFRAME_H
29
30 #include "wx/wxprec.h"
31
32 #ifdef __BORLANDC__
33    #pragma hdrstop
34 #endif
35
36 // for all others, include the necessary headers (this file is usually all you
37 // need because it includes almost all "standard" wxWindows headers)
38 #ifndef WX_PRECOMP
39    #include "wx/wx.h"
40 #endif
41
42 #include <wx/textctrl.h>
43 #include <wx/tokenzr.h>
44 #include <wx/notebook.h>
45
46 #include <wx/dynarray.h>
47
48 #include "console_thread.h"
49
50 #include "wxbutils.h"
51
52 #include "wxbhistorytextctrl.h"
53
54 WX_DEFINE_ARRAY(wxbDataParser*, wxbDataParsers);
55
56 // ----------------------------------------------------------------------------
57 // wxbPrintObject - Used by wxbThreadEvent to contain data sent by director
58 // ----------------------------------------------------------------------------
59
60 class wxbPrintObject: public wxObject {
61    public:
62       wxString str;
63       int status;
64       wxbPrintObject(wxString str, int status): wxObject() {
65          this->str = str;
66          this->status = status;
67       }
68
69       wxbPrintObject(const wxbPrintObject& pe) {
70          this->str = pe.str;
71          this->status = pe.status;
72       }
73 };
74
75 // ----------------------------------------------------------------------------
76 // wxbThreadEvent - Event used by wxbTHREAD_EVENT
77 // ----------------------------------------------------------------------------
78
79 class wxbThreadEvent: public wxEvent {
80    public:
81       wxbThreadEvent(int id);
82       ~wxbThreadEvent();
83       wxbThreadEvent(const wxbThreadEvent& te);
84       virtual wxEvent *Clone() const;
85       wxbPrintObject* GetEventPrintObject();
86       void SetEventPrintObject(wxbPrintObject* object);
87 };
88
89 // Define a new frame type: this is going to be our main frame
90 class wxbMainFrame : public wxFrame
91 {
92 public:
93    /* this class is a singleton */
94    static wxbMainFrame* CreateInstance(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
95    static wxbMainFrame* GetInstance();
96
97    /* event handlers (these functions should _not_ be virtual) */
98    void OnQuit(wxCommandEvent& event);
99    void OnAbout(wxCommandEvent& event);
100    void OnChangeConfig(wxCommandEvent& event);
101    void OnEditConfig(wxCommandEvent& event);
102    void OnConnect(wxCommandEvent& event);
103    void OnDisconnect(wxCommandEvent& event);
104    void OnEnter(wxCommandEvent& event);
105    void OnPrint(wxbThreadEvent& event);
106
107    /* Enable and disable panels */
108    void EnablePanels();
109    void DisablePanels(void* except = NULL);
110
111    void EnableConsole(bool enable = true);
112
113    /*
114     *  Prints data received from director to the console,
115     *  and forwards it to the panels
116     */
117    void Print(wxString str, int status);
118
119    /* Sends data to the director */
120    void Send(wxString str);
121
122    /*
123     *  Starts the thread interacting with the director
124     *  If config is not empty, uses this config file.
125     */
126    void StartConsoleThread(const wxString& config);
127
128    /* Register a new wxbDataParser */
129    void Register(wxbDataParser* dp);
130
131    /* Unregister a wxbDataParser */
132    void Unregister(wxbDataParser* dp);
133
134    console_thread* ct; /* thread interacting with the director */
135
136 private:
137    /* private constructor, singleton */
138    wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
139    ~wxbMainFrame();
140
141    static wxbMainFrame *frame; /* this */
142
143    wxMenu *menuFile;
144
145    wxNotebook *notebook; /* main notebook */
146    wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
147    wxStaticText *helpCtrl; /* wxStaticText showing help messages */
148    wxbHistoryTextCtrl *typeCtrl; /* wxbHistoryTextCtrl for console user input */
149    wxButton *sendButton; /* wxButton used to send data */
150
151    wxbPanel **panels; /* panels array, contained in the notebook */
152    wxbDataParsers parsers; /* Data parsers, which need to receive director informations */
153
154    wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */
155
156    bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */
157
158    wxString configfile; /* configfile used */
159
160    wxString consoleBuffer; /* Buffer used to print in the console line by line */
161
162    // any class wishing to process wxWindows events must use this macro
163    DECLARE_EVENT_TABLE()
164 };
165
166 #endif // WXBMAINFRAME_H