1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
6 Date: $Date: 2008/03/21 14:59:39 $
7 Version: $Revision: 1.2 $
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.
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.
17 =========================================================================*//**
18 * \brief Short description in one line
20 * Long description which
21 * can span multiple lines
33 #ifdef _USE_WXWIDGETS_
36 #ifndef __bbtkWxGUITextEditor_h__
37 #define __bbtkWxGUITextEditor_h__
42 #include "bbtkInterpreter.h"
43 #include <wx/splitter.h>
44 #include <wx/aui/aui.h>
46 #include "bbtkWxGUICommand.h"
51 class WxTextCtrlGettingKeyEvents;
52 class WxGUITextEditor;
55 /// Abstract class which defines the callbacks invoked by WxGUITextEditor
56 class BBTK_EXPORT WxGUITextEditorUser
59 WxGUITextEditorUser() {}
60 ~WxGUITextEditorUser() {}
61 /// Callback invoked when the 'run' button is pressed
62 virtual void WxGUITextEditorRun() {}
65 //================================================================
66 class WxGUITextEditorPage : public wxPanel
69 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
70 ~WxGUITextEditorPage();
72 void SetPageName(const std::string& name) { mName = name; }
73 const std::string& GetPageName() const { return mName; }
75 bool AskFilename() const { return mAskFilename; }
77 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
79 void Load(const std::string& filename);
80 void Save(const std::string& filter);
82 bool IsModified(); //{ return mwxInputText->IsModified(); }
84 std::string GetText();
87 WxGUITextEditor* mEditor;
88 WxTextCtrlGettingKeyEvents* mwxInputText;
89 wxTextAttr* mwxInputTextAttr;
99 //DECLARE_EVENT_TABLE();
102 //================================================================
106 /// A text editor panel
107 class BBTK_EXPORT WxGUITextEditor : public wxPanel
110 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
113 void OnKeyDown(wxKeyEvent& event);
114 void OnKeyUp(wxKeyEvent& event);
116 void OnButtonNew(wxCommandEvent& event);
117 void OnButtonOpen(wxCommandEvent& event);
118 void OnButtonSave(wxCommandEvent& event);
119 void OnButtonRun(wxCommandEvent& event);
120 // void OnButtonQuit(wxCommandEvent& event);
121 void OnPageClose(wxAuiNotebookEvent& evt);
125 void Open(const std::string& filename);
130 void HighlightSyntax();
133 void NewPage(const std::string& filename);
134 WxGUITextEditorPage* GetCurrentPage();
135 void FocusOnCurrentPage();
137 void SetFileNameFilter(const std::string& filter)
138 { mFileNameFilter = filter; }
141 WxGUITextEditorUser* mUser;
144 wxAuiNotebook* mwxNotebook;
146 // Interpreter* mInterpreter;
147 // wxSplitterWindow* mwxSplit;
149 wxButton * mwxButtonNew;
150 wxButton * mwxButtonOpen;
151 wxButton * mwxButtonSave;
152 wxButton * mwxButtonRun;
153 // wxButton * mwxButtonQuit;
154 wxStaticText* mwxPosition;
156 std::string mFileNameFilter;
169 DECLARE_EVENT_TABLE()
174 /// Editor in a frame
175 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
176 //, public WxGUICommandUser
179 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
180 ~WxGUITextEditorWindow();
181 void Open(const std::string& filename) { mEditor->Open(filename); }
182 // void WxGUICommandEnter(const std::string& s);
187 WxGUITextEditor* mEditor;
194 #endif // __bbtkWxGUITextEditor_h__
196 #endif //_USE_WXWIDGETS_