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