bbtkWxGUITextEditor.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkWxGUITextEditor.h,v $
00004   Language:  C++
00005   Date:      $Date: 2009/12/04 10:48:34 $
00006   Version:   $Revision: 1.10 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00031 
00048 #ifdef _USE_WXWIDGETS_
00049 
00050         
00051 #ifndef __bbtkWxGUITextEditor_h__
00052 #define __bbtkWxGUITextEditor_h__
00053 
00054 
00055 #include "bbtkWx.h"
00056 
00057 #include "bbtkInterpreter.h"
00058 #include <wx/splitter.h>
00059 #include <wx/aui/aui.h>
00060 
00061 #include "bbtkWxGUICommand.h"
00062 
00063 namespace bbtk
00064 {
00065 
00066   class WxTextCtrlGettingKeyEvents;
00067 //   typedef wxTextCtrl WxTextCtrlGettingKeyEvents;
00068         class WxGUITextEditor;
00069  
00070 
00072   class BBTK_EXPORT WxGUITextEditorUser
00073   {
00074   public:
00075     WxGUITextEditorUser() {}
00076     virtual ~WxGUITextEditorUser() {}
00078     virtual void WxGUITextEditorRun() {}
00079     virtual void WxGUITextEditorRunBBI() {} 
00080         virtual void WxGUITextEditorGraphSimple() {}
00081         virtual void WxGUITextEditorGraphDetail() {}
00082           
00083   };
00084 
00085   //================================================================
00086   class WxGUITextEditorPage : public wxPanel
00087   {
00088   public:
00089     WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
00090     ~WxGUITextEditorPage();
00091 
00092     void SetPageName(const std::string& name) { mName = name; }
00093     const std::string& GetPageName() const { return mName; }
00094 
00095     bool AskFilename() const { return mAskFilename; }
00096     void SetAskFilename(bool a) { mAskFilename=a; }
00097 
00098     WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
00099 
00100     void Load(const std::string& filename);
00101     void Save(const std::string& filter);
00102         void SaveFile(const std::string& filename);
00103 
00104           
00105     bool IsModified(); //{ return mwxInputText->IsModified(); }
00106    
00107     std::string GetText();
00108 
00109   private:
00110     WxGUITextEditor* mEditor;
00111     WxTextCtrlGettingKeyEvents* mwxInputText;
00112     wxTextAttr* mwxInputTextAttr;
00113         wxFont* mFixedFont;
00114     std::string mName;
00115     bool mAskFilename;
00116 
00117     /*
00118     enum
00119     {
00120       ID_InputText
00121     };
00122     */
00123     //DECLARE_EVENT_TABLE();
00124 
00125   } ;
00126   //================================================================
00127 
00128 
00129 
00131   class BBTK_EXPORT WxGUITextEditor : public wxPanel
00132   {
00133   public:
00134     WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
00135     ~WxGUITextEditor();
00136 
00137     void OnKeyDown(wxKeyEvent& event);
00138     void OnKeyUp(wxKeyEvent& event);
00139 
00140     void OnToolLeftClick(wxCommandEvent& event);
00141     void OnToolRightClick(wxCommandEvent& event);
00142 
00143     void OnPageClose(wxAuiNotebookEvent& evt);
00144 
00145     void New();
00146     void Open();
00147     void Open(const std::string& filename);
00148     void SaveCurrentPage();
00149     bool CloseCurrentPage();
00150     bool CloseAllPages();
00151     //   void Run();
00152     //    void Quit();
00153 
00154     void HighlightSyntax();
00155     void UpdateInfo();
00156 
00157     void NewPage(const std::string& filename);
00158     WxGUITextEditorPage* GetCurrentPage();
00159     void FocusOnCurrentPage();
00160 
00161     void SetFileNameFilter(const std::string& filter)
00162     { mFileNameFilter = filter; }
00163 
00164   private:
00165     WxGUITextEditorUser* mUser;
00166 
00167 //    wxAuiManager m_mgr;
00168 //    wxAuiNotebook*
00169         wxNotebook* mwxNotebook;
00170  
00171     wxToolBar* mwxToolBar;
00172 
00173     wxStaticText* mwxPosition;
00174 
00175     std::string mFileNameFilter;
00176 
00177    public:
00178           
00179      enum
00180     {
00181       ID_ButtonNew,
00182       ID_ButtonOpen,
00183       ID_ButtonClose,
00184       ID_ButtonSave,
00185       ID_ButtonSaveAs,
00186       ID_ButtonRun,
00187           ID_ButtonRunBBI,
00188           ID_ButtonGraphSimple,
00189           ID_ButtonGraphDetail
00190       //      ID_ButtonQuit
00191     };
00192     
00193     DECLARE_EVENT_TABLE()
00194         
00195   };
00196 
00197   
00199   class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
00200                                               //, public WxGUICommandUser
00201   {
00202   public:
00203     WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
00204     ~WxGUITextEditorWindow();
00205     void Open(const std::string& filename) { mEditor->Open(filename); }
00206     //    void WxGUICommandEnter(const std::string& s);
00207 
00208 
00209   private :
00210     
00211     WxGUITextEditor* mEditor;
00212   };
00213   
00214 
00215 } // namespace bbtk
00216 
00217 
00218 #endif // __bbtkWxGUITextEditor_h__
00219 
00220 #endif //_USE_WXWIDGETS_

Generated on Thu May 31 14:12:04 2012 for BBTK by  doxygen 1.5.7.1