]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUITextEditor.cxx
Feature #1774
[bbtk.git] / kernel / src / bbtkWxGUITextEditor.cxx
index c8baa3759153c030615743deed9a036be936bca1..5f3aea8afe8f077f0ed4ef5a62fda940c58615dd 100644 (file)
@@ -1,20 +1,42 @@
+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
 /*=========================================================================
-                                                                                
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUITextEditor.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/06/26 07:37:05 $
-  Version:   $Revision: 1.13 $
-                                                                                
-  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
-  l'Image). All rights reserved. See Doc/License.txt or
-  http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
-                                                                                
-     This software is distributed WITHOUT ANY WARRANTY; without even
-     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-     PURPOSE.  See the above copyright notices for more information.
-                                                                                
-=========================================================================*//**
+  Date:      $Date: 2012/11/16 08:49:01 $
+  Version:   $Revision: 1.22 $
+=========================================================================*/
+
+
+
+
+/**
  * \brief Short description in one line
  * 
  * Long description which 
 #include "bbtkConfigurationFile.h"
 #include "bbtkUtilities.h"
 
-#include "icons/cc_new.xpm"
-#include "icons/cc_open.xpm"
-#include "icons/cc_stop.xpm"
-#include "icons/cc_save.xpm"
-#include "icons/cc_save_as.xpm"
-#include "icons/cc_run.xpm"
-#include "icons/cc_exit.xpm"
+//#include "icons/cc_new.xpm"
+//#include "icons/cc_open.xpm"
+//#include "icons/cc_stop.xpm"
+//#include "icons/cc_save.xpm"
+//#include "icons/cc_save_as.xpm"
+//#include "icons/cc_run.xpm"
+//#include "icons/cc_exit.xpm"
 
 #include "../data/icons/wxart_new.xpm"
 #include "../data/icons/wxart_fileopen.xpm"
 #include "../data/icons/wxart_filesave.xpm"
 #include "../data/icons/wxart_filesaveas.xpm"
-#include "../data/icons/wxart_exefile.xpm"
-#include "../data/icons/wxart_delete.xpm"
-#include "../data/icons/wxart_down.xpm"
+//#include "../data/icons/wxart_exefile.xpm"
+//#include "../data/icons/wxart_delete.xpm"
+//#include "../data/icons/wxart_down.xpm"
+#include "../data/icons/wxart_run.xpm"
+#include "../data/icons/wxart_runbbi.xpm"
+#include "../data/icons/wxart_graphsimple.xpm"
+#include "../data/icons/wxart_graphdetail.xpm"
 #include "../data/icons/wxart_eldel.xpm"
 
 namespace bbtk
@@ -107,7 +133,6 @@ namespace bbtk
   //================================================================
   
   
-
   //================================================================  
   /*  BEGIN_EVENT_TABLE(WxGUITextEditorPage, wxPanel)
     EVT_CLOSE(WxGUITextEditorPage::OnClose)
@@ -122,9 +147,13 @@ namespace bbtk
       mName(""),
       mAskFilename(true)
   {  
+
+         //      std::cout << "WxGUITextEditorPage::WxGUITextEditorPage("<<mName<<")"<<std::endl;
+
     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
  
     mwxInputText = 
+               
       new WxTextCtrlGettingKeyEvents(this,
                                     -1, //ID_InputText,
                                     _T(""),
@@ -132,20 +161,30 @@ namespace bbtk
                                     wxDefaultSize,
                                     wxTE_MULTILINE 
                                     //    |wxTE_PROCESS_ENTER
-                                    | wxTE_PROCESS_TAB 
+                                    //| wxTE_PROCESS_TAB 
                                     //             | wxWANTS_CHARS 
-                                    |  wxTAB_TRAVERSAL
+                                   // |  wxTAB_TRAVERSAL
                                     );
     mwxInputText->SetWxGUITextEditor(mEditor);
-    
-    wxFont* FixedFont = new wxFont(10,
+    /*
+       new wxTextCtrl(this,-1,_T(""),
+               wxDefaultPosition,
+                                            wxDefaultSize,
+                                            wxTE_MULTILINE 
+                                            //    |wxTE_PROCESS_ENTER
+                                       //       | wxTE_PROCESS_TAB 
+                               //                  | wxWANTS_CHARS 
+                                //    |  wxTAB_TRAVERSAL
+                                    );
+                                        */
+    mFixedFont = new wxFont(10,
                                    wxFONTFAMILY_MODERN,
                                    wxFONTSTYLE_NORMAL,
                                    wxFONTWEIGHT_NORMAL,
                                    false);
     
     mwxInputTextAttr = new wxTextAttr;
-    mwxInputTextAttr->SetFont(*FixedFont);
+    mwxInputTextAttr->SetFont(*mFixedFont);
    
     sizer->Add(mwxInputText,1,wxGROW);
     SetSizer(sizer);
@@ -157,6 +196,8 @@ namespace bbtk
   //================================================================
   WxGUITextEditorPage::~WxGUITextEditorPage()
   {
+         delete mwxInputTextAttr;
+         delete mFixedFont;
   }
   //================================================================
 
@@ -207,22 +248,21 @@ namespace bbtk
          } 
       }
     //    std::cout << "file [" << mName << "]" <<std::endl;
-    mwxInputText->SaveFile(std2wx(mName));
+//    mwxInputText->SaveFile(std2wx(mName));
+       SaveFile(mName);
     mwxInputText->SetModified(false);
   }
   //================================================================
   
 
-
-
-
-
-
-
-
-
-
-
+       //================================================================
+       void WxGUITextEditorPage::SaveFile(const std::string& filename)
+       {
+               mwxInputText->SaveFile( std2wx(filename) );
+       }
+       //================================================================
+       
+       
 
 
 
@@ -245,11 +285,25 @@ namespace bbtk
       mUser(user),
       mFileNameFilter("*.*")
   {
-    m_mgr.SetManagedWindow(this);
-    
-    //    wxInitAllImageHandlers();
-      
-    mwxNotebook = new wxAuiNotebook(this,  
+  //  m_mgr.SetManagedWindow(this);
+                   //    wxInitAllImageHandlers();
+     
+       //  std::cout << "WxGUITextEditor::WxGUITextEditor"<<std::endl;
+
+      wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+
+    mwxNotebook = new wxNotebook(this,-1,
+               wxDefaultPosition, wxDefaultSize, 
+               wxNB_TOP 
+
+               
+               );
+               
+   sizer->Add(mwxNotebook,1,wxGROW);
+
+               
+               /*
+   mwxNotebook =               new wxAuiNotebook(this,  
                                    -1,
                                    wxPoint(0, 0),
                                    wxSize(500,500),
@@ -274,7 +328,7 @@ namespace bbtk
                  .Center()
                  .MinSize(wxSize(100,50))
                  );   
-
+*/
  
     /*   
     wxBitmap bmp_new(cc_new_xpm);
@@ -289,7 +343,10 @@ namespace bbtk
     wxBitmap bmp_close(eldel_xpm);
     wxBitmap bmp_save(filesave_xpm);
     wxBitmap bmp_saveas(filesaveas_xpm);
-    wxBitmap bmp_run(down_xpm);
+    wxBitmap bmp_run(wxart_run_xpm);
+    wxBitmap bmp_runbbi(wxart_runbbi_xpm);
+    wxBitmap bmp_graphsimple(wxart_graphsimple_xpm);
+       wxBitmap bmp_graphdetail(wxart_graphdetail_xpm);
 
     mwxToolBar = new wxToolBar(this, wxID_ANY, 
                               wxDefaultPosition, wxDefaultSize,
@@ -313,12 +370,30 @@ namespace bbtk
     mwxToolBar->AddTool(ID_ButtonRun, _T("Run"),
                      bmp_run, wxNullBitmap, wxITEM_NORMAL,
                      _T("Run file"), _T("Run current file"));
+
+         
+       mwxToolBar->AddTool(ID_ButtonGraphSimple, _T("Graph (simple)"),
+                                                 bmp_graphsimple, wxNullBitmap, wxITEM_NORMAL,
+                                                 _T("Graph simple"), _T("Simple graph of actual script"));
+
+       mwxToolBar->AddTool(ID_ButtonGraphDetail, _T("Graph (detail)"),
+                                                 bmp_graphdetail, wxNullBitmap, wxITEM_NORMAL,
+                                                 _T("Graph (detail)"), _T("Detail graph of actual script"));
+         
+       mwxToolBar->AddTool(ID_ButtonRunBBI, _T("Run external bbi "),
+                                                 bmp_runbbi, wxNullBitmap, wxITEM_NORMAL,
+                                                 _T("Run external bbi"), _T("Run external bbi"));
+         
+         
+         
     mwxToolBar->AddSeparator();
     mwxPosition = new wxStaticText ( mwxToolBar, -1, _T(""));
     mwxToolBar->AddControl(mwxPosition);
     mwxToolBar->Realize();
 
+         sizer->Add(mwxToolBar,0,wxGROW);
+
+       /*
     m_mgr.AddPane(mwxToolBar, 
                  wxAuiPaneInfo().Name(wxT("toolBar"))
                  .Caption(wxT(""))
@@ -327,20 +402,24 @@ namespace bbtk
                  .MinSize(wxSize(100,50))
                  .LeftDockable(false).RightDockable(false)
                  );   
-
-    NewPage("");
-    UpdateInfo();
+*/
+  SetSizer(sizer);
+  
     
-    m_mgr.Update();
+//    m_mgr.Update();
     SetAutoLayout(true);
     Layout();
+
+    NewPage("");
+    UpdateInfo();
+
   }
   //================================================================
   
   //================================================================
   WxGUITextEditor::~WxGUITextEditor()
   {
-    m_mgr.UnInit();
+  //  m_mgr.UnInit();
 
     //    delete mInterpreter;
   }
@@ -405,10 +484,29 @@ namespace bbtk
        SaveCurrentPage();
        break;
       case ID_ButtonRun :
-       if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
+       if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
          mUser->WxGUITextEditorRun();
        FocusOnCurrentPage();
        break;
+                         
+                 case ID_ButtonGraphSimple :
+                         if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
+                                 mUser->WxGUITextEditorGraphSimple();
+                         FocusOnCurrentPage();
+                         break;
+
+                 case ID_ButtonGraphDetail :
+                         if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
+                                 mUser->WxGUITextEditorGraphDetail();
+                         FocusOnCurrentPage();
+                         break;
+                         
+                 case ID_ButtonRunBBI :
+                         if ((mUser!=0) && (mwxNotebook->GetPageCount()>0)) 
+                                 mUser->WxGUITextEditorRunBBI();
+                         FocusOnCurrentPage();
+                         break;
+                         
       }
   }
   //================================================================  
@@ -489,7 +587,7 @@ namespace bbtk
       } 
     mwxNotebook->DeletePage(mwxNotebook->GetSelection());
     FocusOnCurrentPage();
-    return false;
+    return true;
   }
   //================================================================  
 
@@ -614,7 +712,7 @@ namespace bbtk
   //================================================================
   void WxGUITextEditor::OnKeyUp(wxKeyEvent& event)
   {
-    //  std::cout << "U" << std::endl;
+  //    std::cout << "U" << std::endl;
     UpdateInfo();
   }
   //================================================================
@@ -622,7 +720,7 @@ namespace bbtk
   //================================================================
   void WxGUITextEditor::OnKeyDown(wxKeyEvent& event)
   {
-    //    std::cout << "D" << std::endl;
+     //   std::cout << "D" << std::endl;
     // std::cout << "Key="<<event.GetKeyCode()<<std::endl;
     if ( event.ControlDown() )
       {
@@ -668,8 +766,9 @@ namespace bbtk
     
     SetSizer(sizer);
 
-    // Creates the parent window of all bbtk windows as a child of this
-    Wx::CreateTopWindow(this);
+    // parent window of all bbtk windows will be a child of this
+    //    Wx::SetTopWindowParent(this);
+    Wx::SetTopWindow(this);
     // Add the method OnWxSignal as a Wx::Signal observer 
     //bbtkAddWxSignalObserver(WxGUITextEditorWindow::OnWxSignal);