]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUITextEditor.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUITextEditor.cxx
index 7de71068cb5abaf552737309a7d6c7bebbd4d0f3..e2f7fe46eada0f9f3346205ff88feac0f3089e44 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/21 11:46:41 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2008/03/21 14:59:39 $
+  Version:   $Revision: 1.2 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -96,42 +96,6 @@ namespace bbtk
   //================================================================
   
   
-  //================================================================
-  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; }
-
-    WxTextCtrlGettingKeyEvents* GetTextCtrl() { return mwxInputText; }
-
-    void Load(const std::string& filename);
-    void Save(const std::string& filter);
-
-    bool IsModified() { return mwxInputText->IsModified(); }
-   
-  private:
-    WxGUITextEditor* mEditor;
-    WxTextCtrlGettingKeyEvents* mwxInputText;
-    wxTextAttr* mwxInputTextAttr;
-    std::string mName;
-    bool mAskFilename;
-
-    /*
-    enum
-    {
-      ID_InputText
-    };
-    */
-    //DECLARE_EVENT_TABLE();
-
-  } ;
-  //================================================================
 
   //================================================================  
   /*  BEGIN_EVENT_TABLE(WxGUITextEditorPage, wxPanel)
@@ -185,6 +149,13 @@ namespace bbtk
   }
   //================================================================
 
+  bool WxGUITextEditorPage::IsModified()
+   { return mwxInputText->IsModified(); }
+
+  std::string WxGUITextEditorPage::GetText()
+  {
+    return wx2std(GetTextCtrl()->GetValue());
+  }
 
   //================================================================
   void WxGUITextEditorPage::Load(const std::string& filename)
@@ -228,8 +199,10 @@ namespace bbtk
   //================================================================
   
   //================================================================
-  WxGUITextEditor::WxGUITextEditor( wxWindow *parent )
+  WxGUITextEditor::WxGUITextEditor( wxWindow *parent,
+                                   WxGUITextEditorUser* user )
     : wxPanel(parent, -1),
+      mUser(user),
       mFileNameFilter("*.*")
   {
     std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
@@ -276,10 +249,10 @@ namespace bbtk
     mwxButtonSave = new wxBitmapButton( btnsCtrlPanel,ID_ButtonSave,bmp_save);//_T("Save")  );
     btnsSizer->Add( mwxButtonSave );
 
-    /*
     wxBitmap bmp_run(cc_run_xpm);
     mwxButtonRun = new wxBitmapButton( btnsCtrlPanel,ID_ButtonRun,bmp_run);//_T("Run")  );
     btnsSizer->Add( mwxButtonRun );
+    /*
     wxBitmap bmp_quit(cc_exit_xpm);
     mwxButtonQuit = new wxBitmapButton( btnsCtrlPanel,ID_ButtonQuit,bmp_quit);//_T("Quit")  );
     btnsSizer->Add( mwxButtonQuit );
@@ -435,14 +408,16 @@ namespace bbtk
     if (AskSave()) GetParent()->Close();
   }
   //================================================================  
-
+  */
 
   //================================================================  
   void WxGUITextEditor::OnButtonRun(wxCommandEvent& event) 
   { 
-    Run(); 
+    if (mUser!=0) mUser->WxGUITextEditorRun();
     FocusOnCurrentPage();
   }
+
+  /*
   void WxGUITextEditor::Run()
   {
     std::cout << "-------------- RUN ---------------"<<std::endl;
@@ -552,7 +527,7 @@ namespace bbtk
     EVT_BUTTON(WxGUITextEditor::ID_ButtonNew, WxGUITextEditor::OnButtonNew)
     EVT_BUTTON(WxGUITextEditor::ID_ButtonOpen, WxGUITextEditor::OnButtonOpen)
     EVT_BUTTON(WxGUITextEditor::ID_ButtonSave, WxGUITextEditor::OnButtonSave)
-  //    EVT_BUTTON(WxGUITextEditor::ID_ButtonRun, WxGUITextEditor::OnButtonRun)
+    EVT_BUTTON(WxGUITextEditor::ID_ButtonRun, WxGUITextEditor::OnButtonRun)
   //    EVT_BUTTON(WxGUITextEditor::ID_ButtonQuit, WxGUITextEditor::OnButtonQuit)
     EVT_AUINOTEBOOK_PAGE_CLOSE(wxID_ANY, WxGUITextEditor::OnPageClose)
     END_EVENT_TABLE()