1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
6 Date: $Date: 2008/03/25 15:47:54 $
7 Version: $Revision: 1.4 $
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; }
76 void SetAskFilename(bool a) { mAskFilename=a; }
78 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
80 void Load(const std::string& filename);
81 void Save(const std::string& filter);
83 bool IsModified(); //{ return mwxInputText->IsModified(); }
85 std::string GetText();
88 WxGUITextEditor* mEditor;
89 WxTextCtrlGettingKeyEvents* mwxInputText;
90 wxTextAttr* mwxInputTextAttr;
100 //DECLARE_EVENT_TABLE();
103 //================================================================
107 /// A text editor panel
108 class BBTK_EXPORT WxGUITextEditor : public wxPanel
111 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
114 void OnKeyDown(wxKeyEvent& event);
115 void OnKeyUp(wxKeyEvent& event);
117 void OnButtonNew(wxCommandEvent& event);
118 void OnButtonOpen(wxCommandEvent& event);
119 void OnButtonClose(wxCommandEvent& event);
120 void OnButtonSave(wxCommandEvent& event);
121 void OnButtonSaveAs(wxCommandEvent& event);
122 void OnButtonRun(wxCommandEvent& event);
123 // void OnButtonQuit(wxCommandEvent& event);
124 void OnPageClose(wxAuiNotebookEvent& evt);
128 void Open(const std::string& filename);
129 void SaveCurrentPage();
130 bool CloseCurrentPage();
131 bool CloseAllPages();
135 void HighlightSyntax();
138 void NewPage(const std::string& filename);
139 WxGUITextEditorPage* GetCurrentPage();
140 void FocusOnCurrentPage();
142 void SetFileNameFilter(const std::string& filter)
143 { mFileNameFilter = filter; }
146 WxGUITextEditorUser* mUser;
149 wxAuiNotebook* mwxNotebook;
151 // Interpreter* mInterpreter;
152 // wxSplitterWindow* mwxSplit;
154 wxButton * mwxButtonNew;
155 wxButton * mwxButtonOpen;
156 wxButton * mwxButtonClose;
157 wxButton * mwxButtonSave;
158 wxButton * mwxButtonSaveAs;
159 wxButton * mwxButtonRun;
160 // wxButton * mwxButtonQuit;
161 wxStaticText* mwxPosition;
163 std::string mFileNameFilter;
178 DECLARE_EVENT_TABLE()
183 /// Editor in a frame
184 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
185 //, public WxGUICommandUser
188 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
189 ~WxGUITextEditorWindow();
190 void Open(const std::string& filename) { mEditor->Open(filename); }
191 // void WxGUICommandEnter(const std::string& s);
196 WxGUITextEditor* mEditor;
203 #endif // __bbtkWxGUITextEditor_h__
205 #endif //_USE_WXWIDGETS_