]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxEditor.h
4505af376636cfdeb45a3279ea0e6888451f7914
[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/19 08:03:59 $
7   Version:   $Revision: 1.4 $
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 OnKeyDown(wxKeyEvent& event);
59     void OnKeyUp(wxKeyEvent& event);
60
61     void OnButtonNew(wxCommandEvent& event);
62     void OnButtonOpen(wxCommandEvent& event);
63     void OnButtonSave(wxCommandEvent& event);
64     void OnButtonRun(wxCommandEvent& event);
65     void OnButtonQuit(wxCommandEvent& event);
66
67     void New();
68     void Open();
69     void Open(const std::string& filename);
70     bool AskSave();
71     void Save();
72     void Run();
73     void Quit();
74
75     void HighlightSyntax();
76     void UpdatePosition();
77
78   private:
79     Interpreter* mInterpreter;
80     wxSplitterWindow* mwxSplit;
81     WxTextCtrlGettingKeyEvents* mwxInputText;
82     wxTextAttr* mwxInputTextAttr;
83     WxTextCtrlGettingKeyEvents* mwxOutputText;
84     wxTextAttr* mwxOutputTextAttr;
85     wxBitmapButton *  mwxButtonNew; 
86     wxButton *  mwxButtonOpen; 
87     wxButton *  mwxButtonSave; 
88     wxButton *  mwxButtonRun; 
89     wxButton *  mwxButtonQuit; 
90     wxStaticText* mwxPosition;
91     WxStreamRedirector* mRedirect_cout;
92     WxStreamRedirector* mRedirect_cerr;
93    public:
94           
95      enum
96     {
97       ID_InputText,
98       ID_OutputText,
99       ID_ButtonNew,
100       ID_ButtonOpen,
101       ID_ButtonSave,
102       ID_ButtonRun,
103       ID_ButtonQuit
104     };
105     
106     DECLARE_EVENT_TABLE()
107         
108   };
109
110
111   /// Editor in a frame 
112   class BBTK_EXPORT WxEditorWindow : public wxFrame
113   {
114   public:
115     WxEditorWindow( wxWindow *parent, wxString title, wxSize size);
116     ~WxEditorWindow();
117     void Open(const std::string& filename) { mEditor->Open(filename); }
118   private :
119     
120     WxEditor* mEditor;
121   };
122   
123 } // namespace bbtk
124
125
126 #endif // __bbtkWxEditor_h__
127
128 #endif //_USE_WXWIDGETS_