1 /*=========================================================================
3 Module: $RCSfile: bbtkWxGUITextEditor.h,v $
5 Date: $Date: 2008/10/17 08:18:15 $
6 Version: $Revision: 1.8 $
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() {}
81 //================================================================
82 class WxGUITextEditorPage : public wxPanel
85 WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
86 ~WxGUITextEditorPage();
88 void SetPageName(const std::string& name) { mName = name; }
89 const std::string& GetPageName() const { return mName; }
91 bool AskFilename() const { return mAskFilename; }
92 void SetAskFilename(bool a) { mAskFilename=a; }
94 WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
96 void Load(const std::string& filename);
97 void Save(const std::string& filter);
99 bool IsModified(); //{ return mwxInputText->IsModified(); }
101 std::string GetText();
104 WxGUITextEditor* mEditor;
105 WxTextCtrlGettingKeyEvents* mwxInputText;
106 wxTextAttr* mwxInputTextAttr;
116 //DECLARE_EVENT_TABLE();
119 //================================================================
123 /// A text editor panel
124 class BBTK_EXPORT WxGUITextEditor : public wxPanel
127 WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
130 void OnKeyDown(wxKeyEvent& event);
131 void OnKeyUp(wxKeyEvent& event);
133 void OnToolLeftClick(wxCommandEvent& event);
134 void OnToolRightClick(wxCommandEvent& event);
136 void OnPageClose(wxAuiNotebookEvent& evt);
140 void Open(const std::string& filename);
141 void SaveCurrentPage();
142 bool CloseCurrentPage();
143 bool CloseAllPages();
147 void HighlightSyntax();
150 void NewPage(const std::string& filename);
151 WxGUITextEditorPage* GetCurrentPage();
152 void FocusOnCurrentPage();
154 void SetFileNameFilter(const std::string& filter)
155 { mFileNameFilter = filter; }
158 WxGUITextEditorUser* mUser;
160 // wxAuiManager m_mgr;
162 wxNotebook* mwxNotebook;
164 wxToolBar* mwxToolBar;
166 wxStaticText* mwxPosition;
168 std::string mFileNameFilter;
183 DECLARE_EVENT_TABLE()
188 /// Editor in a frame
189 class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
190 //, public WxGUICommandUser
193 WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
194 ~WxGUITextEditorWindow();
195 void Open(const std::string& filename) { mEditor->Open(filename); }
196 // void WxGUICommandEnter(const std::string& s);
201 WxGUITextEditor* mEditor;
208 #endif // __bbtkWxGUITextEditor_h__
210 #endif //_USE_WXWIDGETS_