1 /*=========================================================================
4 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
6 Date: $Date: 2008/10/03 14:27:52 $
7 Version: $Revision: 1.7 $
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 // typedef wxTextCtrl WxTextCtrlGettingKeyEvents;
53 class WxGUITextEditor;
56 /// Abstract class which defines the callbacks invoked by WxGUITextEditor
57 class BBTK_EXPORT WxGUITextEditorUser
60 WxGUITextEditorUser() {}
61 virtual ~WxGUITextEditorUser() {}
62 /// Callback invoked when the 'run' button is pressed
63 virtual void WxGUITextEditorRun() {}
66 //================================================================
67 class WxGUITextEditorPage : public wxPanel
70 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
71 ~WxGUITextEditorPage();
73 void SetPageName(const std::string& name) { mName = name; }
74 const std::string& GetPageName() const { return mName; }
76 bool AskFilename() const { return mAskFilename; }
77 void SetAskFilename(bool a) { mAskFilename=a; }
79 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
81 void Load(const std::string& filename);
82 void Save(const std::string& filter);
84 bool IsModified(); //{ return mwxInputText->IsModified(); }
86 std::string GetText();
89 WxGUITextEditor* mEditor;
90 WxTextCtrlGettingKeyEvents* mwxInputText;
91 wxTextAttr* mwxInputTextAttr;
101 //DECLARE_EVENT_TABLE();
104 //================================================================
108 /// A text editor panel
109 class BBTK_EXPORT WxGUITextEditor : public wxPanel
112 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
115 void OnKeyDown(wxKeyEvent& event);
116 void OnKeyUp(wxKeyEvent& event);
118 void OnToolLeftClick(wxCommandEvent& event);
119 void OnToolRightClick(wxCommandEvent& event);
121 void OnPageClose(wxAuiNotebookEvent& evt);
125 void Open(const std::string& filename);
126 void SaveCurrentPage();
127 bool CloseCurrentPage();
128 bool CloseAllPages();
132 void HighlightSyntax();
135 void NewPage(const std::string& filename);
136 WxGUITextEditorPage* GetCurrentPage();
137 void FocusOnCurrentPage();
139 void SetFileNameFilter(const std::string& filter)
140 { mFileNameFilter = filter; }
143 WxGUITextEditorUser* mUser;
145 // wxAuiManager m_mgr;
147 wxNotebook* mwxNotebook;
149 wxToolBar* mwxToolBar;
151 wxStaticText* mwxPosition;
153 std::string mFileNameFilter;
168 DECLARE_EVENT_TABLE()
173 /// Editor in a frame
174 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
175 //, public WxGUICommandUser
178 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
179 ~WxGUITextEditorWindow();
180 void Open(const std::string& filename) { mEditor->Open(filename); }
181 // void WxGUICommandEnter(const std::string& s);
186 WxGUITextEditor* mEditor;
193 #endif // __bbtkWxGUITextEditor_h__
195 #endif //_USE_WXWIDGETS_