]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUITextEditor.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUITextEditor.h
index 77f712671cc86a2d941eadd1eeca97c1b6e4d6ff..2bc6efb78e0796465add621fd53be07db8288f74 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.h,v $
   Language:  C++
-  Date:      $Date: 2008/03/21 11:46:41 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/05/14 12:32:26 $
+  Version:   $Revision: 1.5 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -49,30 +49,83 @@ namespace bbtk
 {
 
   class WxTextCtrlGettingKeyEvents;
-  class WxGUITextEditorPage;
+  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();
 
-  /// A bbs editor panel
+  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 );
+    WxGUITextEditor( wxWindow *parent, WxGUITextEditorUser* user = 0 );
     ~WxGUITextEditor();
 
     void OnKeyDown(wxKeyEvent& event);
     void OnKeyUp(wxKeyEvent& event);
 
-    void OnButtonNew(wxCommandEvent& event);
-    void OnButtonOpen(wxCommandEvent& event);
-    void OnButtonSave(wxCommandEvent& event);
-    //    void OnButtonRun(wxCommandEvent& event);
-    //    void OnButtonQuit(wxCommandEvent& event);
+    void OnToolLeftClick(wxCommandEvent& event);
+    void OnToolRightClick(wxCommandEvent& event);
+
     void OnPageClose(wxAuiNotebookEvent& evt);
 
     void New();
     void Open();
     void Open(const std::string& filename);
-    void Save();
-    //    void Run();
+    void SaveCurrentPage();
+    bool CloseCurrentPage();
+    bool CloseAllPages();
+    //   void Run();
     //    void Quit();
 
     void HighlightSyntax();
@@ -86,17 +139,13 @@ namespace bbtk
     { mFileNameFilter = filter; }
 
   private:
+    WxGUITextEditorUser* mUser;
+
     wxAuiManager m_mgr;
     wxAuiNotebook* mwxNotebook;
  
-    //   Interpreter* mInterpreter;
-    //    wxSplitterWindow* mwxSplit;
-
-    wxButton *  mwxButtonNew; 
-    wxButton *  mwxButtonOpen; 
-    wxButton *  mwxButtonSave; 
-    //    wxButton *  mwxButtonRun; 
-    //    wxButton *  mwxButtonQuit; 
+    wxToolBar* mwxToolBar;
+
     wxStaticText* mwxPosition;
 
     std::string mFileNameFilter;
@@ -107,8 +156,10 @@ namespace bbtk
     {
       ID_ButtonNew,
       ID_ButtonOpen,
-      ID_ButtonSave
-      //      ID_ButtonRun,
+      ID_ButtonClose,
+      ID_ButtonSave,
+      ID_ButtonSaveAs,
+      ID_ButtonRun
       //      ID_ButtonQuit
     };