3 * Main frame header file
5 * Nicolas Boichat, July 2004
9 Copyright (C) 2004 Kern Sibbald and John Walker
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.
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.
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.
26 #ifndef WXBMAINFRAME_H
27 #define WXBMAINFRAME_H
29 #include "wx/wxprec.h"
35 // for all others, include the necessary headers (this file is usually all you
36 // need because it includes almost all "standard" wxWindows headers)
41 #include <wx/textctrl.h>
42 #include <wx/tokenzr.h>
43 #include <wx/notebook.h>
45 #include <wx/dynarray.h>
47 #include "console_thread.h"
51 #include "wxbhistorytextctrl.h"
53 WX_DEFINE_ARRAY(wxbDataParser*, wxbDataParsers);
55 // ----------------------------------------------------------------------------
56 // wxbPrintObject - Used by wxbThreadEvent to contain data sent by director
57 // ----------------------------------------------------------------------------
59 class wxbPrintObject: public wxObject {
63 wxbPrintObject(wxString str, int status): wxObject() {
65 this->status = status;
68 wxbPrintObject(const wxbPrintObject& pe) {
70 this->status = pe.status;
74 // ----------------------------------------------------------------------------
75 // wxbThreadEvent - Event used by wxbTHREAD_EVENT
76 // ----------------------------------------------------------------------------
78 class wxbThreadEvent: public wxEvent {
80 wxbThreadEvent(int id);
82 wxbThreadEvent(const wxbThreadEvent& te);
83 virtual wxEvent *Clone() const;
84 wxbPrintObject* GetEventPrintObject();
85 void SetEventPrintObject(wxbPrintObject* object);
88 // Define a new frame type: this is going to be our main frame
89 class wxbMainFrame : public wxFrame
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();
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);
106 /* Enable and disable panels */
108 void DisablePanels(void* except = NULL);
110 void EnableConsole(bool enable = true);
113 * Prints data received from director to the console,
114 * and forwards it to the panels
116 void Print(wxString str, int status);
118 /* Sends data to the director */
119 void Send(wxString str);
122 * Starts the thread interacting with the director
123 * If config is not empty, uses this config file.
125 void StartConsoleThread(const wxString& config);
127 /* Register a new wxbDataParser */
128 void Register(wxbDataParser* dp);
130 /* Unregister a wxbDataParser */
131 void Unregister(wxbDataParser* dp);
133 console_thread* ct; /* thread interacting with the director */
136 /* private constructor, singleton */
137 wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
140 static wxbMainFrame *frame; /* this */
144 wxNotebook *notebook; /* main notebook */
145 wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
146 wxbHistoryTextCtrl *typeCtrl; /* wxbHistoryTextCtrl for console user input */
147 wxButton *sendButton; /* wxButton used to send data */
149 wxbPanel **panels; /* panels array, contained in the notebook */
150 wxbDataParsers parsers; /* Data parsers, which need to receive director informations */
152 wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */
154 bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */
156 wxString configfile; /* configfile used */
158 wxString consoleBuffer; /* Buffer used to print in the console line by line */
160 // any class wishing to process wxWindows events must use this macro
161 DECLARE_EVENT_TABLE()
164 #endif // WXBMAINFRAME_H