]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUITextEditor.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUITextEditor.cxx
index cec220f89f954cdf855135a6f37e355bfe68b697..a61de17e9a919d1610bd391a42414687c87ca537 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/26 15:04:46 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2008/04/24 12:56:40 $
+  Version:   $Revision: 1.11 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -36,6 +36,7 @@
 #include "bbtkWxGUITextEditor.h"
 #include "bbtkWxBlackBox.h"
 #include "bbtkConfigurationFile.h"
+#include "bbtkUtilities.h"
 
 #include "icons/cc_new.xpm"
 #include "icons/cc_open.xpm"
@@ -170,8 +171,8 @@ namespace bbtk
   //================================================================
   void WxGUITextEditorPage::Load(const std::string& filename)
   {
-    std::cout << "-------------- LOAD ---------------"<<std::endl;
-    std::cout << "'" << filename << "'"<<std::endl;
+    //    std::cout << "-------------- LOAD ---------------"<<std::endl;
+    //    std::cout << "'" << filename << "'"<<std::endl;
     //std::string oldFilename = mFilename;
     mName = filename;
     mAskFilename = false;
@@ -182,7 +183,7 @@ namespace bbtk
   //================================================================
   void WxGUITextEditorPage::Save(const std::string& filter)
   {
-    std::cout << "-------------- SAVE ---------------"<<std::endl;
+    //    std::cout << "-------------- SAVE ---------------"<<std::endl;
     if (mAskFilename)
       {
        wxFileDialog* fd = new wxFileDialog(this,_T("Save file"),_T(""),
@@ -197,12 +198,12 @@ namespace bbtk
          }
        else 
          {
-           std::cout << "-------------- CANCELLED ---------------"
-                     <<std::endl;
+           //      std::cout << "-------------- CANCELLED ---------------"
+           //                <<std::endl;
            return;
          } 
       }
-    std::cout << "file [" << mName << "]" <<std::endl;
+    //    std::cout << "file [" << mName << "]" <<std::endl;
     mwxInputText->SaveFile(std2wx(mName));
     mwxInputText->SetModified(false);
   }
@@ -215,7 +216,7 @@ namespace bbtk
       mUser(user),
       mFileNameFilter("*.*")
   {
-    std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
+    //    std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
     //    mInterpreter = new bbtk::Interpreter();
     //mInterpreter->SetWxGUITextEditor(this);
     //  mInterpreter->SetCommandLine(true);
@@ -244,7 +245,8 @@ namespace bbtk
                                    | wxNO_BORDER);
     
     sizer->Add(mwxNotebook,1,wxGROW);
-    
+
+
     // BUTTONS
     wxPanel *btnsCtrlPanel = new wxPanel(this,-1);
     wxBoxSizer *btnsSizer  = new wxBoxSizer(wxHORIZONTAL);
@@ -295,6 +297,9 @@ namespace bbtk
     btnsSizer->Add( mwxPosition );
     
     btnsCtrlPanel->SetSizer(btnsSizer);
+    btnsCtrlPanel->SetAutoLayout(true);
+    btnsCtrlPanel->Layout();
+
     sizer->Add ( btnsCtrlPanel, 0, wxLEFT | wxRIGHT | wxBOTTOM  //| wxGROW
                 , 10 );
        
@@ -329,7 +334,8 @@ namespace bbtk
        page->Load(name);
       }
     page->SetPageName(name);
-    mwxNotebook->AddPage(page,std2wx(name),true);
+    std::string fname = Utilities::get_file_name(name);
+    mwxNotebook->AddPage(page,std2wx(fname),true);
     FocusOnCurrentPage();
   }
   //================================================================
@@ -358,7 +364,7 @@ namespace bbtk
   } 
   void WxGUITextEditor::Open()
   {
-    std::cout << "-------------- OPEN ---------------"<<std::endl;
+    //    std::cout << "-------------- OPEN ---------------"<<std::endl;
 
     wxFileDialog* fd = new wxFileDialog(this,_T("Open file"),_T(""),
                                        _T(""),std2wx(mFileNameFilter),
@@ -373,7 +379,7 @@ namespace bbtk
       }
     else 
       {
-       std::cout << "-------------- CANCELLED ---------------"<<std::endl;
+       //      std::cout << "-------------- CANCELLED ---------------"<<std::endl;
       }
   }
   //================================================================  
@@ -396,7 +402,7 @@ namespace bbtk
   //================================================================  
   bool WxGUITextEditor::CloseCurrentPage()
   {
-    std::cout << "-------------- CLOSE ---------------"<<std::endl;
+    //    std::cout << "-------------- CLOSE ---------------"<<std::endl;
     if (mwxNotebook->GetPageCount()==0) return true;
     if (GetCurrentPage()->IsModified()) 
       {
@@ -466,7 +472,7 @@ namespace bbtk
   //================================================================  
   void WxGUITextEditor::OnPageClose(wxAuiNotebookEvent& evt)
   {
-    std::cout << "-------------- CLOSE ---------------"<<std::endl;
+    //    std::cout << "-------------- CLOSE ---------------"<<std::endl;
     if (!CloseCurrentPage()) evt.Veto();
 
     /*
@@ -556,7 +562,7 @@ namespace bbtk
   }
   void WxGUITextEditor::New()
   {
-    std::cout << "-------------- NEW ---------------" << std::endl;
+    ///    std::cout << "-------------- NEW ---------------" << std::endl;
     NewPage("");
     UpdateInfo();
   }
@@ -659,11 +665,11 @@ namespace bbtk
     
     SetSizer(sizer);
 
-    // Creates and sets the parent window of all bbtk windows
-    wxWindow* top = new wxPanel(this,-1);
-    top->Hide();
+    // Creates the parent window of all bbtk windows as a child of this
+    Wx::CreateTopWindow(this);
+    // Add the method OnWxSignal as a Wx::Signal observer 
+    //bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);
     
-    Wx::SetTopWindow(top);
    
     SetAutoLayout(true);
     Layout();