1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
5 Date: $Date: 2009/04/15 15:45:50 $
6 Version: $Revision: 1.9 $
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;
122 //DECLARE_EVENT_TABLE();
125 //================================================================
129 /// A text editor panel
130 class BBTK_EXPORT WxGUITextEditor : public wxPanel
133 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
136 void OnKeyDown(wxKeyEvent& event);
137 void OnKeyUp(wxKeyEvent& event);
139 void OnToolLeftClick(wxCommandEvent& event);
140 void OnToolRightClick(wxCommandEvent& event);
142 void OnPageClose(wxAuiNotebookEvent& evt);
146 void Open(const std::string& filename);
147 void SaveCurrentPage();
148 bool CloseCurrentPage();
149 bool CloseAllPages();
153 void HighlightSyntax();
156 void NewPage(const std::string& filename);
157 WxGUITextEditorPage* GetCurrentPage();
158 void FocusOnCurrentPage();
160 void SetFileNameFilter(const std::string& filter)
161 { mFileNameFilter = filter; }
164 WxGUITextEditorUser* mUser;
166 // wxAuiManager m_mgr;
168 wxNotebook* mwxNotebook;
170 wxToolBar* mwxToolBar;
172 wxStaticText* mwxPosition;
174 std::string mFileNameFilter;
187 ID_ButtonGraphSimple,
192 DECLARE_EVENT_TABLE()
197 /// Editor in a frame
198 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
199 //, public WxGUICommandUser
202 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
203 ~WxGUITextEditorWindow();
204 void Open(const std::string& filename) { mEditor->Open(filename); }
205 // void WxGUICommandEnter(const std::string& s);
210 WxGUITextEditor* mEditor;
217 #endif // __bbtkWxGUITextEditor_h__
219 #endif //_USE_WXWIDGETS_