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