]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/wxbmainframe.h
Add wx-console directory
[bacula/bacula] / bacula / src / wx-console / wxbmainframe.h
1 /*
2    Copyright (C) 2004 Kern Sibbald and John Walker
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License
6    as published by the Free Software Foundation; either version 2
7    of the License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
17  */
18
19 #ifndef WXBMAINFRAME_H
20 #define WXBMAINFRAME_H
21
22 #include "wx/wxprec.h"
23
24 #ifdef __BORLANDC__
25    #pragma hdrstop
26 #endif
27
28 // for all others, include the necessary headers (this file is usually all you
29 // need because it includes almost all "standard" wxWindows headers)
30 #ifndef WX_PRECOMP
31    #include "wx/wx.h"
32 #endif
33
34 #include <wx/textctrl.h>
35 #include <wx/tokenzr.h>
36 #include <wx/notebook.h>
37
38 //#include "bacula.h"
39 //#include "console_conf.h"
40
41 #include "console_thread.h"
42
43 #include "wxbpanel.h"
44
45 // ----------------------------------------------------------------------------
46 // wxbPrintObject - Used by wxbThreadEvent to contain data sent by director
47 // ----------------------------------------------------------------------------
48
49 class wxbPrintObject: public wxObject {
50    public:
51       wxString str;
52       int status;
53       wxbPrintObject(wxString str, int status): wxObject() {
54          this->str = str;
55          this->status = status;
56       }
57
58       wxbPrintObject(const wxbPrintObject& pe) {
59          this->str = pe.str;
60          this->status = pe.status;
61       }
62 };
63
64 // ----------------------------------------------------------------------------
65 // wxbThreadEvent - Event used by wxbTHREAD_EVENT
66 // ----------------------------------------------------------------------------
67
68 class wxbThreadEvent: public wxEvent {
69    public:
70       wxbThreadEvent(int id);
71       ~wxbThreadEvent();
72       wxbThreadEvent(const wxbThreadEvent& te);
73       virtual wxEvent *Clone() const;
74       wxbPrintObject* GetEventPrintObject();
75       void SetEventPrintObject(wxbPrintObject* object);
76 };
77
78 // Define a new frame type: this is going to be our main frame
79 class wxbMainFrame : public wxFrame
80 {
81 public:
82    /* this class is a singleton */
83    static wxbMainFrame* CreateInstance(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
84    static wxbMainFrame* GetInstance();
85
86     // event handlers (these functions should _not_ be virtual)
87    void OnQuit(wxCommandEvent& event);
88    void OnAbout(wxCommandEvent& event);
89    void OnEnter(wxCommandEvent& event);
90    void OnPrint(wxbThreadEvent& event);
91
92    /*
93     *  Prints data received from director to the console,
94     *  and forwards it to the panels
95     */
96    void Print(wxString str, int status);
97
98    /* Sends data to the director */
99    void Send(wxString str);
100
101    /*
102     *  Starts the thread interacting with the director
103     */
104    void StartConsoleThread();
105
106 private:
107    /* private constructor, singleton */
108    wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
109    ~wxbMainFrame();
110
111    wxNotebook *notebook; /* main notebook */
112    wxTextCtrl *typeCtrl; /* wxTextCtrl for console user input */
113    wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
114
115    wxbPanel **panels; /* panels array, contained in the notebook, and which need to receive console communication */
116
117    console_thread* ct; /* thread interacting with the director */
118
119    static wxbMainFrame *frame; /* this */
120
121    // any class wishing to process wxWindows events must use this macro
122    DECLARE_EVENT_TABLE()
123 };
124
125 #endif // WXBMAINFRAME_H
126