1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
5 Date: $Date: 2009/12/04 10:48:34 $
6 Version: $Revision: 1.10 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Short description in one line
35 * Long description which
36 * can span multiple lines
48 #ifdef _USE_WXWIDGETS_
51 #ifndef __bbtkWxGUITextEditor_h__
52 #define __bbtkWxGUITextEditor_h__
57 #include "bbtkInterpreter.h"
58 #include <wx/splitter.h>
59 #include <wx/aui/aui.h>
61 #include "bbtkWxGUICommand.h"
66 class WxTextCtrlGettingKeyEvents;
67 // typedef wxTextCtrl WxTextCtrlGettingKeyEvents;
68 class WxGUITextEditor;
71 /// Abstract class which defines the callbacks invoked by WxGUITextEditor
72 class BBTK_EXPORT WxGUITextEditorUser
75 WxGUITextEditorUser() {}
76 virtual ~WxGUITextEditorUser() {}
77 /// Callback invoked when the 'run' button is pressed
78 virtual void WxGUITextEditorRun() {}
79 virtual void WxGUITextEditorRunBBI() {}
80 virtual void WxGUITextEditorGraphSimple() {}
81 virtual void WxGUITextEditorGraphDetail() {}
85 //================================================================
86 class WxGUITextEditorPage : public wxPanel
89 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
90 ~WxGUITextEditorPage();
92 void SetPageName(const std::string& name) { mName = name; }
93 const std::string& GetPageName() const { return mName; }
95 bool AskFilename() const { return mAskFilename; }
96 void SetAskFilename(bool a) { mAskFilename=a; }
98 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
100 void Load(const std::string& filename);
101 void Save(const std::string& filter);
102 void SaveFile(const std::string& filename);
105 bool IsModified(); //{ return mwxInputText->IsModified(); }
107 std::string GetText();
110 WxGUITextEditor* mEditor;
111 WxTextCtrlGettingKeyEvents* mwxInputText;
112 wxTextAttr* mwxInputTextAttr;
123 //DECLARE_EVENT_TABLE();
126 //================================================================
130 /// A text editor panel
131 class BBTK_EXPORT WxGUITextEditor : public wxPanel
134 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
137 void OnKeyDown(wxKeyEvent& event);
138 void OnKeyUp(wxKeyEvent& event);
140 void OnToolLeftClick(wxCommandEvent& event);
141 void OnToolRightClick(wxCommandEvent& event);
143 void OnPageClose(wxAuiNotebookEvent& evt);
147 void Open(const std::string& filename);
148 void SaveCurrentPage();
149 bool CloseCurrentPage();
150 bool CloseAllPages();
154 void HighlightSyntax();
157 void NewPage(const std::string& filename);
158 WxGUITextEditorPage* GetCurrentPage();
159 void FocusOnCurrentPage();
161 void SetFileNameFilter(const std::string& filter)
162 { mFileNameFilter = filter; }
165 WxGUITextEditorUser* mUser;
167 // wxAuiManager m_mgr;
169 wxNotebook* mwxNotebook;
171 wxToolBar* mwxToolBar;
173 wxStaticText* mwxPosition;
175 std::string mFileNameFilter;
188 ID_ButtonGraphSimple,
193 DECLARE_EVENT_TABLE()
198 /// Editor in a frame
199 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
200 //, public WxGUICommandUser
203 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
204 ~WxGUITextEditorWindow();
205 void Open(const std::string& filename) { mEditor->Open(filename); }
206 // void WxGUICommandEnter(const std::string& s);
211 WxGUITextEditor* mEditor;
218 #endif // __bbtkWxGUITextEditor_h__
220 #endif //_USE_WXWIDGETS_