2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.11 $
34 =========================================================================*/
40 * \brief Short description in one line
42 * Long description which
43 * can span multiple lines
55 #ifdef _USE_WXWIDGETS_
58 #ifndef __bbtkWxGUITextEditor_h__
59 #define __bbtkWxGUITextEditor_h__
64 #include "bbtkInterpreter.h"
65 #include <wx/splitter.h>
66 #include <wx/aui/aui.h>
68 #include "bbtkWxGUICommand.h"
73 class WxTextCtrlGettingKeyEvents;
74 // typedef wxTextCtrl WxTextCtrlGettingKeyEvents;
75 class WxGUITextEditor;
78 /// Abstract class which defines the callbacks invoked by WxGUITextEditor
79 class BBTK_EXPORT WxGUITextEditorUser
82 WxGUITextEditorUser() {}
83 virtual ~WxGUITextEditorUser() {}
84 /// Callback invoked when the 'run' button is pressed
85 virtual void WxGUITextEditorRun() {}
86 virtual void WxGUITextEditorRunBBI() {}
87 virtual void WxGUITextEditorGraphSimple() {}
88 virtual void WxGUITextEditorGraphDetail() {}
92 //================================================================
93 class WxGUITextEditorPage : public wxPanel
96 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
97 ~WxGUITextEditorPage();
99 void SetPageName(const std::string& name) { mName = name; }
100 const std::string& GetPageName() const { return mName; }
102 bool AskFilename() const { return mAskFilename; }
103 void SetAskFilename(bool a) { mAskFilename=a; }
105 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
107 void Load(const std::string& filename);
108 void Save(const std::string& filter);
109 void SaveFile(const std::string& filename);
112 bool IsModified(); //{ return mwxInputText->IsModified(); }
114 std::string GetText();
117 WxGUITextEditor* mEditor;
118 WxTextCtrlGettingKeyEvents* mwxInputText;
119 wxTextAttr* mwxInputTextAttr;
130 //DECLARE_EVENT_TABLE();
133 //================================================================
137 /// A text editor panel
138 class BBTK_EXPORT WxGUITextEditor : public wxPanel
141 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
144 void OnKeyDown(wxKeyEvent& event);
145 void OnKeyUp(wxKeyEvent& event);
147 void OnToolLeftClick(wxCommandEvent& event);
148 void OnToolRightClick(wxCommandEvent& event);
150 void OnPageClose(wxAuiNotebookEvent& evt);
154 void Open(const std::string& filename);
155 void SaveCurrentPage();
156 bool CloseCurrentPage();
157 bool CloseAllPages();
161 void HighlightSyntax();
164 void NewPage(const std::string& filename);
165 WxGUITextEditorPage* GetCurrentPage();
166 void FocusOnCurrentPage();
168 void SetFileNameFilter(const std::string& filter)
169 { mFileNameFilter = filter; }
172 WxGUITextEditorUser* mUser;
174 // wxAuiManager m_mgr;
176 wxNotebook* mwxNotebook;
178 wxToolBar* mwxToolBar;
180 wxStaticText* mwxPosition;
182 std::string mFileNameFilter;
195 ID_ButtonGraphSimple,
200 DECLARE_EVENT_TABLE()
205 /// Editor in a frame
206 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
207 //, public WxGUICommandUser
210 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
211 ~WxGUITextEditorWindow();
212 void Open(const std::string& filename) { mEditor->Open(filename); }
213 // void WxGUICommandEnter(const std::string& s);
218 WxGUITextEditor* mEditor;
225 #endif // __bbtkWxGUITextEditor_h__
227 #endif //_USE_WXWIDGETS_