3 * Main frame header file
5 * Nicolas Boichat, July 2004
10 Copyright (C) 2004-2006 Kern Sibbald
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.
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.
24 #ifndef WXBMAINFRAME_H
25 #define WXBMAINFRAME_H
27 #include "wx/wxprec.h"
33 // for all others, include the necessary headers (this file is usually all you
34 // need because it includes almost all "standard" wxWindows headers)
39 #include <wx/textctrl.h>
40 #include <wx/tokenzr.h>
41 #include <wx/notebook.h>
43 #include <wx/dynarray.h>
45 #include "console_thread.h"
49 #include "wxbhistorytextctrl.h"
51 WX_DEFINE_ARRAY(wxbDataParser*, wxbDataParsers);
53 // ----------------------------------------------------------------------------
54 // wxbPrintObject - Used by wxbThreadEvent to contain data sent by director
55 // ----------------------------------------------------------------------------
57 class wxbPrintObject: public wxObject {
61 wxbPrintObject(wxString str, int status): wxObject() {
63 this->status = status;
66 wxbPrintObject(const wxbPrintObject& pe) {
68 this->status = pe.status;
72 // ----------------------------------------------------------------------------
73 // wxbThreadEvent - Event used by wxbTHREAD_EVENT
74 // ----------------------------------------------------------------------------
76 class wxbThreadEvent: public wxEvent {
78 wxbThreadEvent(int id);
80 wxbThreadEvent(const wxbThreadEvent& te);
81 virtual wxEvent *Clone() const;
82 wxbPrintObject* GetEventPrintObject();
83 void SetEventPrintObject(wxbPrintObject* object);
86 // Define a new frame type: this is going to be our main frame
87 class wxbMainFrame : public wxFrame
90 /* this class is a singleton */
91 static wxbMainFrame* CreateInstance(const wxString& title, const wxPoint& pos, const wxSize& size, long style = wxDEFAULT_FRAME_STYLE);
92 static wxbMainFrame* GetInstance();
94 /* event handlers (these functions should _not_ be virtual) */
95 void OnQuit(wxCommandEvent& event);
96 void OnAbout(wxCommandEvent& event);
97 void OnChangeConfig(wxCommandEvent& event);
98 void OnEditConfig(wxCommandEvent& event);
99 void OnConnect(wxCommandEvent& event);
100 void OnDisconnect(wxCommandEvent& event);
101 void OnEnter(wxCommandEvent& event);
102 void OnPrint(wxbThreadEvent& event);
104 /* Enable and disable panels */
106 void DisablePanels(void* except = NULL);
108 void EnableConsole(bool enable = true);
111 * Prints data received from director to the console,
112 * and forwards it to the panels
114 void Print(wxString str, int status);
116 /* Sends data to the director */
117 void Send(wxString str);
120 * Starts the thread interacting with the director
121 * If config is not empty, uses this config file.
123 void StartConsoleThread(const wxString& config);
125 /* Register a new wxbDataParser */
126 void Register(wxbDataParser* dp);
128 /* Unregister a wxbDataParser */
129 void Unregister(wxbDataParser* dp);
131 console_thread* ct; /* thread interacting with the director */
134 /* private constructor, singleton */
135 wxbMainFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style);
138 static wxbMainFrame *frame; /* this */
142 wxNotebook *notebook; /* main notebook */
143 wxTextCtrl *consoleCtrl; /* wxTextCtrl containing graphical console */
144 wxStaticText *helpCtrl; /* wxStaticText showing help messages */
145 wxbHistoryTextCtrl *typeCtrl; /* wxbHistoryTextCtrl for console user input */
146 wxButton *sendButton; /* wxButton used to send data */
148 wxbPanel **panels; /* panels array, contained in the notebook */
149 wxbDataParsers parsers; /* Data parsers, which need to receive director informations */
151 wxbPromptParser* promptparser; /* prompt parser catching uncatched questions */
153 bool lockedbyconsole; /* true if the panels have been locked by something typed in the console */
155 wxString configfile; /* configfile used */
157 wxString consoleBuffer; /* Buffer used to print in the console line by line */
159 // any class wishing to process wxWindows events must use this macro
160 DECLARE_EVENT_TABLE()
163 #endif // WXBMAINFRAME_H