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: 2008/10/17 08:18:15 $
00006   Version:   $Revision: 1.8 $
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   };
00080 
00081   //================================================================
00082   class WxGUITextEditorPage : public wxPanel
00083   {
00084   public:
00085     WxGUITextEditorPage(wxWindow* parent, WxGUITextEditor* editor);
00086     ~WxGUITextEditorPage();
00087 
00088     void SetPageName(const std::string& name) { mName = name; }
00089     const std::string& GetPageName() const { return mName; }
00090 
00091     bool AskFilename() const { return mAskFilename; }
00092     void SetAskFilename(bool a) { mAskFilename=a; }
00093 
00094     WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
00095 
00096     void Load(const std::string& filename);
00097     void Save(const std::string& filter);
00098 
00099     bool IsModified(); //{ return mwxInputText->IsModified(); }
00100    
00101     std::string GetText();
00102 
00103   private:
00104     WxGUITextEditor* mEditor;
00105     WxTextCtrlGettingKeyEvents* mwxInputText;
00106     wxTextAttr* mwxInputTextAttr;
00107     std::string mName;
00108     bool mAskFilename;
00109 
00110     /*
00111     enum
00112     {
00113       ID_InputText
00114     };
00115     */
00116     //DECLARE_EVENT_TABLE();
00117 
00118   } ;
00119   //================================================================
00120 
00121 
00122 
00124   class BBTK_EXPORT WxGUITextEditor : public wxPanel
00125   {
00126   public:
00127     WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
00128     ~WxGUITextEditor();
00129 
00130     void OnKeyDown(wxKeyEvent& event);
00131     void OnKeyUp(wxKeyEvent& event);
00132 
00133     void OnToolLeftClick(wxCommandEvent& event);
00134     void OnToolRightClick(wxCommandEvent& event);
00135 
00136     void OnPageClose(wxAuiNotebookEvent& evt);
00137 
00138     void New();
00139     void Open();
00140     void Open(const std::string& filename);
00141     void SaveCurrentPage();
00142     bool CloseCurrentPage();
00143     bool CloseAllPages();
00144     //   void Run();
00145     //    void Quit();
00146 
00147     void HighlightSyntax();
00148     void UpdateInfo();
00149 
00150     void NewPage(const std::string& filename);
00151     WxGUITextEditorPage* GetCurrentPage();
00152     void FocusOnCurrentPage();
00153 
00154     void SetFileNameFilter(const std::string& filter)
00155     { mFileNameFilter = filter; }
00156 
00157   private:
00158     WxGUITextEditorUser* mUser;
00159 
00160 //    wxAuiManager m_mgr;
00161 //    wxAuiNotebook*
00162         wxNotebook* mwxNotebook;
00163  
00164     wxToolBar* mwxToolBar;
00165 
00166     wxStaticText* mwxPosition;
00167 
00168     std::string mFileNameFilter;
00169 
00170    public:
00171           
00172      enum
00173     {
00174       ID_ButtonNew,
00175       ID_ButtonOpen,
00176       ID_ButtonClose,
00177       ID_ButtonSave,
00178       ID_ButtonSaveAs,
00179       ID_ButtonRun
00180       //      ID_ButtonQuit
00181     };
00182     
00183     DECLARE_EVENT_TABLE()
00184         
00185   };
00186 
00187   
00189   class BBTK_EXPORT WxGUITextEditorWindow : public wxFrame
00190                                               //, public WxGUICommandUser
00191   {
00192   public:
00193     WxGUITextEditorWindow( wxWindow *parent, wxString title, wxSize size);
00194     ~WxGUITextEditorWindow();
00195     void Open(const std::string& filename) { mEditor->Open(filename); }
00196     //    void WxGUICommandEnter(const std::string& s);
00197 
00198 
00199   private :
00200     
00201     WxGUITextEditor* mEditor;
00202   };
00203   
00204 
00205 } // namespace bbtk
00206 
00207 
00208 #endif // __bbtkWxGUITextEditor_h__
00209 
00210 #endif //_USE_WXWIDGETS_

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6