]> 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/20 09:51:29 $
7   Version:   $Revision: 1.5 $
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 #include "bbtkWxGUICommand.h"
46
47 namespace bbtk
48 {
49
50   class WxStreamRedirector;
51   class WxTextCtrlGettingKeyEvents;
52
53   /// A bbs editor panel
54   class BBTK_EXPORT WxEditor : public wxPanel
55   {
56   public:
57     WxEditor( wxWindow *parent );
58     ~WxEditor();
59
60     void OnKeyDown(wxKeyEvent& event);
61     void OnKeyUp(wxKeyEvent& event);
62
63     void OnButtonNew(wxCommandEvent& event);
64     void OnButtonOpen(wxCommandEvent& event);
65     void OnButtonSave(wxCommandEvent& event);
66     void OnButtonRun(wxCommandEvent& event);
67     void OnButtonQuit(wxCommandEvent& event);
68
69     void New();
70     void Open();
71     void Open(const std::string& filename);
72     bool AskSave();
73     void Save();
74     void Run();
75     void Quit();
76
77     void HighlightSyntax();
78     void UpdatePosition();
79
80
81   private:
82     Interpreter* mInterpreter;
83     wxSplitterWindow* mwxSplit;
84     WxTextCtrlGettingKeyEvents* mwxInputText;
85     wxTextAttr* mwxInputTextAttr;
86     WxTextCtrlGettingKeyEvents* mwxOutputText;
87     wxTextAttr* mwxOutputTextAttr;
88     wxButton *  mwxButtonNew; 
89     wxButton *  mwxButtonOpen; 
90     wxButton *  mwxButtonSave; 
91     wxButton *  mwxButtonRun; 
92     wxButton *  mwxButtonQuit; 
93     wxStaticText* mwxPosition;
94     WxStreamRedirector* mRedirect_cout;
95     WxStreamRedirector* mRedirect_cerr;
96    public:
97           
98      enum
99     {
100       ID_InputText,
101       ID_OutputText,
102       ID_ButtonNew,
103       ID_ButtonOpen,
104       ID_ButtonSave,
105       ID_ButtonRun,
106       ID_ButtonQuit
107     };
108     
109     DECLARE_EVENT_TABLE()
110         
111   };
112
113
114   /// Editor in a frame 
115   class BBTK_EXPORT WxEditorWindow : public wxFrame, public WxGUICommandUser
116   {
117   public:
118     WxEditorWindow( wxWindow *parent, wxString title, wxSize size);
119     ~WxEditorWindow();
120     void Open(const std::string& filename) { mEditor->Open(filename); }
121     void WxGUICommandEnter(const std::string& s);
122
123
124   private :
125     
126     WxEditor* mEditor;
127   };
128   
129 } // namespace bbtk
130
131
132 #endif // __bbtkWxEditor_h__
133
134 #endif //_USE_WXWIDGETS_