]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIScriptingInterface.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUIScriptingInterface.cxx
index 895410e940cf630a76c004f7f1a98f049650fd73..6ae91c60d69d82515e4242e3d43b9556439807d8 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/09/10 07:25:23 $
-  Version:   $Revision: 1.16 $
+  Date:      $Date: 2008/10/02 13:21:11 $
+  Version:   $Revision: 1.20 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -39,6 +39,7 @@
 #include "bbtkWxStreamRedirector.h"
 #include "bbtkUtilities.h"
 
+#include <wx/tipwin.h>
 
 //#include "icons/cc_run.xpm"
 
@@ -65,8 +66,9 @@ namespace bbtk
     
   
   //================================================================
-  WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent, wxString title, wxSize size)
-    : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
+  WxGUIScriptingInterface::WxGUIScriptingInterface( wxWindow *parent )
+    : wxFrame((wxFrame *)parent, -1, _T("bbStudio"), 
+             wxDefaultPosition, wxSize(1200,800) )
   {    
     //    m_mgr = new wxAuiManager(this);
     m_mgr.SetManagedWindow(this);
@@ -81,13 +83,13 @@ namespace bbtk
     wxInitAllImageHandlers();
     
     wxMenu *menuFile = new wxMenu;
+    menuFile->Append( ID_Menu_EditConfig, _T("Open bbtk &Config file") );
     menuFile->Append( ID_Menu_Quit, _T("&Quit") );
     
     wxMenu *menuAbout = new wxMenu;
     menuAbout->Append( ID_Menu_About, _T("&About...") );
 
     wxMenu *menuTools = new wxMenu;
-    menuTools->Append( ID_Menu_EditConfig, _T("&Edit bbtk config") );
     menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
     menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &black box") );
     menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") );
@@ -122,10 +124,13 @@ namespace bbtk
     
     SetMenuBar( menuBar );
     
+    //=== 
+    // Status bar
     CreateStatusBar();
     SetStatusText( _T("Welcome to bbStudio !") );
     
-    //
+    //===
+    // Panes (Files, Messages, Help, Command)
     mWxGUITextEditor = new WxGUITextEditor(this,this);
     mWxGUITextEditor->SetFileNameFilter("*.bbs");
        
@@ -179,7 +184,7 @@ namespace bbtk
                  .Caption(wxT("Files"))
                  .MinimizeButton(true)
                  .MaximizeButton(true)
-                 .Left()
+                 .Center()
                  .MinSize(wxSize(100,100))
                  );   
   
@@ -189,7 +194,8 @@ namespace bbtk
                  .MinimizeButton(true)
                  .MaximizeButton(true)
                  .Right()
-                 .MinSize(wxSize(200,100))
+                 .Layer(2)
+                 .MinSize(wxSize(400,100))
                  );
 
     m_mgr.AddPane(mWxGUIOutputMessages,
@@ -206,7 +212,7 @@ namespace bbtk
                  .MinimizeButton(true)
                  .MaximizeButton(true)
                  .Bottom()
-                 .Position(1)
+                 .Layer(1)
                  .MinSize(wxSize(100,100))
                  );     
 #endif
@@ -216,9 +222,11 @@ namespace bbtk
     // Add the method OnWxSignal as a Wx::Signal observer 
     //bbtkAddWxSignalObserver(WxGUIPackageBrowser2Window::OnWxSignal);
 
-//.PaneBorder(false)); 
+    //.PaneBorder(false)); 
+    // Load the interface appearance saved on last closing
     LoadPerspective();
 
+    // Done in LoadPerspective
     //    m_mgr.Update();
        
     SetAutoLayout(true);
@@ -226,9 +234,14 @@ namespace bbtk
     //    mwxNotebook->SetSelection(1);
     mWxGUIHtmlBrowser->GoHome();
 //    Refresh();
-//    m_mgr.Update();
+    m_mgr.Update();
     //   LoadPerspective();
 
+
+    wxTipWindow* tip = new wxTipWindow(this,
+                                      _T("\n                  Welcome to bbStudio !\n\n   To run a demo or example:\n     1. click on the 'Demos' or 'Examples' link\n     2. select a demo or example\n     3. click on the '[source]' link : the source file is loaded in bbStudio\n     4. click on the 'Run' button (the arrow at the bottom right of the source file)   \n"),1000);
+    tip->CenterOnParent();
+    tip->Show();
   }
   //================================================================
 
@@ -254,7 +267,7 @@ namespace bbtk
     }                                                                  \
   catch (InterpreterError e)                                           \
     {                                                                  \
-      std::cerr << "* IERROR : "<<e.GetMessage()<<std::endl;           \
+      std::cerr << "* IERROR : "<<e.GetErrorMessage()<<std::endl;              \
       if (e.IsInScriptFile())                                          \
        std::cerr << "* FILE   : '"<<e.GetScriptFile()<<"'"<<std::endl; \
       std::cerr << "* LINE   : "<<e.GetScriptLine()<<std::endl;                \
@@ -336,16 +349,9 @@ namespace bbtk
   //================================================================
   void WxGUIScriptingInterface::OnMenuEditConfig(wxCommandEvent& WXUNUSED(event))
   {
-       std::string commandStr;
-    std::string configFile = ConfigurationFile::GetInstance().Get_config_xml_full_path();
-#ifdef WIN32
-       commandStr = "notepad.exe ";
-#else
-       commandStr = "gedit ";
-#endif 
-       commandStr = commandStr + configFile;
-       //      std::cout << "system: " << commandStr << std::endl;
-       system ( commandStr.c_str() );
+    std::string configFile = 
+      ConfigurationFile::GetInstance().Get_config_xml_full_path();
+    Open(configFile);
   }
   //================================================================
 
@@ -433,8 +439,11 @@ namespace bbtk
 
     Interpreter::Pointer I = Interpreter::New();    
 
+    I->InterpretLine( "config");
+    I->InterpretLine( "message echo 2");
     I->InterpretLine( "exec freeze");
     I->InterpretLine( "include *");
+    I->InterpretLine( "help packages");
     I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials");
     I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages");
     I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories");
@@ -540,6 +549,11 @@ namespace bbtk
     f.open(fname.c_str(), std::ios::out );
     f << conf << std::endl;
 
+    //    int x,y;
+    //    GetPosition(&x,&y);
+    //    f << x << "  " << y << std::endl;
+
+
     int w,h;
     GetSize(&w,&h);
 
@@ -563,14 +577,17 @@ namespace bbtk
        std::string conf;
        f >> conf;
 
-       int w,h;
+       //      int x,y;
+       //      f >> x >> y ;
 
+       int w,h;
        f >> w >> h ;
 
        f.close();
        
        //      std::cout << conf << std::endl;
 
+       //      Move(x,y);
        SetSize(w,h);
        m_mgr.LoadPerspective(std2wx(conf));
       }
@@ -585,7 +602,8 @@ namespace bbtk
   void WxGUIScriptingInterface::OnPaneClose(wxAuiManagerEvent& evt)
   {
     std::cout  << "Closing panel '"<<evt.pane->name<<"'"<<std::endl;
-    
+    // TO DO : Uncheck 
+    //    OnMenuWindowsCheck( wxCommandEvent& event, wxWindow* w);
   }
   //================================================================