]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxEditor.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxEditor.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkWxEditor.h,v $
5   Language:  C++
6   Date:      $Date: 2008/03/18 15:31:51 $
7   Version:   $Revision: 1.3 $
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 __bbtkWxEditor_h__
37 #define __bbtkWxEditor_h__
38
39
40 #include "bbtkWx.h"
41
42 #include "bbtkInterpreter.h"
43 #include <wx/splitter.h>
44
45 namespace bbtk
46 {
47
48   class WxStreamRedirector;
49   class WxTextCtrlGettingKeyEvents;
50
51   /// A bbs editor panel
52   class BBTK_EXPORT WxEditor : public wxPanel
53   {
54   public:
55     WxEditor( wxWindow *parent );
56     ~WxEditor();
57
58     void OnKeyPress(wxKeyEvent& event);
59
60     void OnButtonNew(wxCommandEvent& event);
61     void OnButtonOpen(wxCommandEvent& event);
62     void OnButtonSave(wxCommandEvent& event);
63     void OnButtonRun(wxCommandEvent& event);
64     void OnButtonQuit(wxCommandEvent& event);
65
66     void New();
67     void Open();
68     void Open(const std::string& filename);
69     bool AskSave();
70     void Save();
71     void Run();
72     void Quit();
73
74     void HighlightSyntax();
75     
76   private:
77     Interpreter* mInterpreter;
78     wxSplitterWindow* mwxSplit;
79     WxTextCtrlGettingKeyEvents* mwxInputText;
80     wxTextAttr* mwxInputTextAttr;
81     WxTextCtrlGettingKeyEvents* mwxOutputText;
82     wxTextAttr* mwxOutputTextAttr;
83     wxBitmapButton *  mwxButtonNew; 
84     wxButton *  mwxButtonOpen; 
85     wxButton *  mwxButtonSave; 
86     wxButton *  mwxButtonRun; 
87     wxButton *  mwxButtonQuit; 
88     wxStaticText* mwxPosition;
89     WxStreamRedirector* mRedirect_cout;
90     WxStreamRedirector* mRedirect_cerr;
91    public:
92           
93      enum
94     {
95       ID_InputText,
96       ID_OutputText,
97       ID_ButtonNew,
98       ID_ButtonOpen,
99       ID_ButtonSave,
100       ID_ButtonRun,
101       ID_ButtonQuit
102     };
103     
104     DECLARE_EVENT_TABLE()
105         
106   };
107
108
109   /// Editor in a frame 
110   class BBTK_EXPORT WxEditorWindow : public wxFrame
111   {
112   public:
113     WxEditorWindow( wxWindow *parent, wxString title, wxSize size);
114     ~WxEditorWindow();
115     void Open(const std::string& filename) { mEditor->Open(filename); }
116   private :
117     
118     WxEditor* mEditor;
119   };
120   
121 } // namespace bbtk
122
123
124 #endif // __bbtkWxEditor_h__
125
126 #endif //_USE_WXWIDGETS_