]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxConsole.h
* Created an invisible frame child of WxConsole to be temporary parent of all widgets...
[bbtk.git] / kernel / src / bbtkWxConsole.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkWxConsole.h,v $
5   Language:  C++
6   Date:      $Date: 2008/03/07 11:37:48 $
7   Version:   $Revision: 1.7 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*//**
18  * \brief Short description in one line
19  * 
20  * Long description which 
21  * can span multiple lines
22  */
23 /**
24  * \file 
25  * \brief 
26  */
27 /**
28  * \class bbtk::
29  * \brief 
30  */
31
32
33 #ifdef _USE_WXWIDGETS_
34
35         
36 #ifndef __bbtkWxConsole_h__
37 #define __bbtkWxConsole_h__
38
39 #include <wx/aui/aui.h>
40 #include "bbtkWx.h"
41 #include <wx/notebook.h>
42 #include <wx/html/htmlwin.h>
43
44
45 #include "bbtkInterpreter.h"
46 #include "bbtkWxBrowser.h"
47
48 namespace bbtk
49 {
50
51   class WxTextCtrlStreamRedirector;
52
53   /// A console in which user can enter commands
54   class BBTK_EXPORT WxConsole : public wxFrame
55   {
56   public:
57     WxConsole( wxWindow *parent, wxString title, wxSize size);
58     ~WxConsole();
59
60     //    static WxConsole* GetInstance() { return mInstance; }
61     
62     /// Returns the Interpreter used 
63     /// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT 
64     /// (DIFFERENT WORKSPACES)
65     Interpreter* GetInterpreter() { return mInterpreter; }
66     /// Returns the Interpreter used (const)
67     const Interpreter* GetInterpreter() const { return mInterpreter; }
68
69     /// Sets the inputs of the workspace : 
70     /// the map is passed as is to the Executer
71     void SetInputs(const std::map<std::string,std::string>& m)
72     { mInterpreter->SetInputs(m); }
73     
74     /// Puts the executer in "no exec" mode, 
75     /// which creates but does not execute pipelines.
76     void SetNoExecMode(bool b) { mInterpreter->SetNoExecMode(b); }
77
78     void SetDialogMode(Interpreter::DialogModeType t) 
79     { mInterpreter->SetDialogMode(t); }
80     
81     /// Runs the interpretation of a file
82     void InterpretFile( const std::string& filename) 
83     { mInterpreter->InterpretFile(filename); }
84
85     void OnMenuQuit(wxCommandEvent& event);
86     void OnMenuAbout(wxCommandEvent& event);
87     void OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event));
88     void OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event));
89     void OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event));
90    
91     void OnBtnGo(wxCommandEvent& event);
92     void OnCommandEnter(wxCommandEvent& event);
93     void OnCommandChar(wxCommandEvent& event);
94
95     void OnBtnInclude(wxCommandEvent& event);
96     void OnBtnReset(wxCommandEvent& event);
97     void OnBtnConfig(wxCommandEvent& event);
98     void OnBtnGraphS(wxCommandEvent& event);
99     void OnBtnGraphD(wxCommandEvent& event);
100     void OnBtnHelp(wxCommandEvent& event);
101     
102     
103     void ShowHtmlPage(std::string&);
104
105   private:
106     Interpreter* mInterpreter;
107     wxTextCtrl* mwxTextHistory;
108 //EED    wxTextCtrl* mwxTextCommand;
109     wxComboBox* mwxTextCommand;
110     wxTextAttr* mwxTextHistoryAttr;
111     wxTextAttr* mwxTextCommandAttr;
112 //EED    wxNotebook* mwxNotebook;
113    wxAuiNotebook* mwxNotebook;
114     wxPanel *mwxPageCommand, *mwxPageHelp;
115     WxTextCtrlStreamRedirector* mRedirect_cout;
116     WxTextCtrlStreamRedirector* mRedirect_cerr;
117     WxBrowser* mwxHtmlWindow;
118     // static WxConsole* mInstance;
119     
120     wxPanel*    CreateBtnsCtrlPanel(wxWindow *parent);
121     void                CommandString(wxString line );
122  
123   public:
124           
125      enum
126     {
127       ID_Menu_Quit = 1,
128       ID_Menu_About,
129       ID_Menu_CreatePackage,
130       ID_Menu_CreateBlackBox,
131       ID_Menu_ShowImageGraph,
132       ID_Text_Command,
133       ID_Text_History,
134
135     };
136     
137     DECLARE_EVENT_TABLE()
138         
139   };
140
141   
142 } // namespace bbtk
143
144
145 #endif // __bbtkWxConsole_h__
146
147 #endif //_USE_WXWIDGETS_