1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
6 Date: $Date: 2008/07/23 11:46:11 $
7 Version: $Revision: 1.6 $
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 virtual ~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 OnToolLeftClick(wxCommandEvent& event);
118 void OnToolRightClick(wxCommandEvent& event);
120 void OnPageClose(wxAuiNotebookEvent& evt);
124 void Open(const std::string& filename);
125 void SaveCurrentPage();
126 bool CloseCurrentPage();
127 bool CloseAllPages();
131 void HighlightSyntax();
134 void NewPage(const std::string& filename);
135 WxGUITextEditorPage* GetCurrentPage();
136 void FocusOnCurrentPage();
138 void SetFileNameFilter(const std::string& filter)
139 { mFileNameFilter = filter; }
142 WxGUITextEditorUser* mUser;
145 wxAuiNotebook* mwxNotebook;
147 wxToolBar* mwxToolBar;
149 wxStaticText* mwxPosition;
151 std::string mFileNameFilter;
166 DECLARE_EVENT_TABLE()
171 /// Editor in a frame
172 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
173 //, public WxGUICommandUser
176 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
177 ~WxGUITextEditorWindow();
178 void Open(const std::string& filename) { mEditor->Open(filename); }
179 // void WxGUICommandEnter(const std::string& s);
184 WxGUITextEditor* mEditor;
191 #endif // __bbtkWxGUITextEditor_h__
193 #endif //_USE_WXWIDGETS_