/*========================================================================= Program: bbtk Module: $RCSfile: bbtkWxGUITextEditor.h,v $ Language: C++ Date: $Date: 2008/03/25 10:31:18 $ Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*//** * \brief Short description in one line * * Long description which * can span multiple lines */ /** * \file * \brief */ /** * \class bbtk:: * \brief */ #ifdef _USE_WXWIDGETS_ #ifndef __bbtkWxGUITextEditor_h__ #define __bbtkWxGUITextEditor_h__ #include "bbtkWx.h" #include "bbtkInterpreter.h" #include #include #include "bbtkWxGUICommand.h" namespace bbtk { class WxTextCtrlGettingKeyEvents; class WxGUITextEditor; /// Abstract class which defines the callbacks invoked by WxGUITextEditor class BBTK_EXPORT WxGUITextEditorUser { public: WxGUITextEditorUser() {} ~WxGUITextEditorUser() {} /// Callback invoked when the 'run' button is pressed virtual void WxGUITextEditorRun() {} }; //================================================================ class WxGUITextEditorPage : public wxPanel { public: WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor); ~WxGUITextEditorPage(); void SetPageName(const std::string& name) { mName = name; } const std::string& GetPageName() const { return mName; } bool AskFilename() const { return mAskFilename; } void SetAskFilename(bool a) { mAskFilename=a; } WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; } void Load(const std::string& filename); void Save(const std::string& filter); bool IsModified(); //{ return mwxInputText->IsModified(); } std::string GetText(); private: WxGUITextEditor* mEditor; WxTextCtrlGettingKeyEvents* mwxInputText; wxTextAttr* mwxInputTextAttr; std::string mName; bool mAskFilename; /* enum { ID_InputText }; */ //DECLARE_EVENT_TABLE(); } ; //================================================================ /// A text editor panel class BBTK_EXPORT WxGUITextEditor : public wxPanel { public: WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 ); ~WxGUITextEditor(); void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); void OnButtonNew(wxCommandEvent& event); void OnButtonOpen(wxCommandEvent& event); void OnButtonClose(wxCommandEvent& event); void OnButtonSave(wxCommandEvent& event); void OnButtonSaveAs(wxCommandEvent& event); void OnButtonRun(wxCommandEvent& event); // void OnButtonQuit(wxCommandEvent& event); void OnPageClose(wxAuiNotebookEvent& evt); void New(); void Open(); void Open(const std::string& filename); void Save(); // void Run(); // void Quit(); void HighlightSyntax(); void UpdateInfo(); void NewPage(const std::string& filename); WxGUITextEditorPage* GetCurrentPage(); void FocusOnCurrentPage(); void SetFileNameFilter(const std::string& filter) { mFileNameFilter = filter; } private: WxGUITextEditorUser* mUser; wxAuiManager m_mgr; wxAuiNotebook* mwxNotebook; // Interpreter* mInterpreter; // wxSplitterWindow* mwxSplit; wxButton * mwxButtonNew; wxButton * mwxButtonOpen; wxButton * mwxButtonClose; wxButton * mwxButtonSave; wxButton * mwxButtonSaveAs; wxButton * mwxButtonRun; // wxButton * mwxButtonQuit; wxStaticText* mwxPosition; std::string mFileNameFilter; public: enum { ID_ButtonNew, ID_ButtonOpen, ID_ButtonClose, ID_ButtonSave, ID_ButtonSaveAs, ID_ButtonRun // ID_ButtonQuit }; DECLARE_EVENT_TABLE() }; /// Editor in a frame class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame //, public WxGUICommandUser { public: WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size); ~WxGUITextEditorWindow(); void Open(const std::string& filename) { mEditor->Open(filename); } // void WxGUICommandEnter(const std::string& s); private : WxGUITextEditor* mEditor; }; } // namespace bbtk #endif // __bbtkWxGUITextEditor_h__ #endif //_USE_WXWIDGETS_