]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxConsole.cxx
Create Black Box bbs + .bat + Bug interface Windows
[bbtk.git] / kernel / src / bbtkWxConsole.cxx
index a218586269b5ac855af6bd207b1f613982312dca..11b9f56bd12e6bd9643bd7157f9f846315531aac 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/14 14:58:53 $
-  Version:   $Revision: 1.13 $
+  Date:      $Date: 2008/03/17 07:04:08 $
+  Version:   $Revision: 1.14 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -158,6 +158,8 @@ namespace bbtk
   WxConsole::WxConsole( wxWindow *parent, wxString title, wxSize size)
     : wxFrame((wxFrame *)parent, -1, title, wxDefaultPosition, size)
   {    
+//    m_mgr = new wxAuiManager(this);
+       m_mgr.SetManagedWindow(this);
    
     mInterpreter = new bbtk::Interpreter();
     mInterpreter->SetWxConsole(this);
@@ -173,9 +175,11 @@ namespace bbtk
     menuAbout->Append( ID_Menu_About, _T("&About...") );
 
     wxMenu *menuTools = new wxMenu;
-    menuTools->Append( ID_Menu_CreatePackage, _T("&Create package") );
-    menuTools->Append( ID_Menu_CreateBlackBox, _T("&Create blackbox") );
+    menuTools->Append( ID_Menu_EditConfig, _T("&Edit bbtk config") );
+    menuTools->Append( ID_Menu_CreatePackage, _T("Create &package") );
+    menuTools->Append( ID_Menu_CreateBlackBox, _T("Create &blackbox") );
     menuTools->Append( ID_Menu_ShowImageGraph, _T("&Show last image graph") );
+    menuTools->Append( ID_Menu_CreateIndex, _T("&Generate index") );
     
     
     wxMenuBar *menuBar = new wxMenuBar;
@@ -201,18 +205,9 @@ namespace bbtk
                                     wxSize(500,500),
                                     wxAUI_NB_TAB_SPLIT | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER);
     
-    mwxPageCommand = new wxPanel(mwxNotebook,-1);    
-    mwxNotebook->AddPage( mwxPageCommand, _T("Command"));
-    
+    mwxPageCommand = new wxPanel(mwxNotebook,-1);        
     mwxPageHelp = new wxPanel(mwxNotebook,-1);    
-    mwxNotebook->AddPage( mwxPageHelp, _T("Help"));
     
-
-
-//EED    sizer->Add ( mwxNotebook, 1, wxEXPAND /*| wxALIGN_BOTTOM*/ );
-    wxAuiManager *m_mgr = new wxAuiManager(this);
-       m_mgr->AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 
-    m_mgr->Update();
     
     wxBoxSizer *cmdsizer = new wxBoxSizer(wxVERTICAL);
     
@@ -273,10 +268,11 @@ namespace bbtk
    mwxTextCommand = 
      new wxComboBox(mwxPageCommand,
                    ID_Text_Command,
-                   _T("")
-//                 wxDefaultPosition,
-//                 wxDefaultSize,
-//                 wxTE_PROCESS_ENTER
+                   _T(""),
+                   wxDefaultPosition,
+                   wxDefaultSize,
+                       0, NULL,
+                   wxTE_PROCESS_ENTER
 //                 | wxTE_PROCESS_TAB 
 //                 | wxWANTS_CHARS 
 //                 //|  wxTAB_TRAVERSAL
@@ -310,10 +306,10 @@ namespace bbtk
     // Events connection
     // COMMAND
     // ENTER
-    /*
     Connect( mwxTextCommand->GetId(),
             wxEVT_COMMAND_TEXT_ENTER,
             (wxObjectEventFunction)& WxConsole::OnCommandEnter );
+    /*
     Connect( mwxTextCommand->GetId(),
             wxEVT_CHAR,
             //wxEVT_COMMAND_TEXT_UPDATED,
@@ -343,15 +339,24 @@ namespace bbtk
 
     // Layout
 //EED    SetSizer(sizer);
-    SetAutoLayout(true);
+
+       mwxNotebook->AddPage( mwxPageCommand, _T("Command"));
+    mwxNotebook->AddPage( mwxPageHelp, _T("Help"));
+       m_mgr.AddPane(mwxNotebook, wxAuiPaneInfo().Name(wxT("notebook_content")).CenterPane().PaneBorder(false)); 
+    m_mgr.Update();
+
+       
+       SetAutoLayout(true);
     Layout();
-    Refresh();
+//    Refresh();
+//    m_mgr.Update();
   }
   //================================================================
 
  //================================================================
   WxConsole::~WxConsole()
   {
+       m_mgr.UnInit();
     delete mRedirect_cout;
     delete mRedirect_cerr;
   }
@@ -398,9 +403,7 @@ namespace bbtk
     {
       bool insideComment = false;
 
-printf("WxConsole::CommandString 04 \n");
       mInterpreter->InterpretLine( wx2std(line), insideComment );
-printf("WxConsole::CommandString 05 \n");
     }
     catch (bbtk::QuitException)
     {
@@ -435,21 +438,39 @@ printf("WxConsole::CommandString 05 \n");
   //================================================================
   void WxConsole::OnMenuAbout(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  bbi\nThe Black Box Toolkit interpreter\n(c) CREATIS-LRMN 2007"),
+    m_mgr.Update();
+       Refresh();
+    wxMessageBox(_T("  bbi\nThe Black Box Toolkit interpreter\n(c) CREATIS-LRMN 2008"),
                  _T("About ..."), wxOK | wxICON_INFORMATION,
                  this);
   }
   //================================================================
 
-  
+
+  //================================================================
+  void WxConsole::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() );
+  }
+  //================================================================
+
+
   //================================================================
   void WxConsole::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  Creating Package"),
-                _T("Creating Package ..."), wxOK | wxICON_INFORMATION, 
-                this);
+       std::cout << "bbi: include CreatePackage" << std::endl;
+    Interpreter* I = new Interpreter;    
+       I->InterpretFile("CreatePackage");
+    delete I;
   }
   //================================================================
 
@@ -457,29 +478,55 @@ printf("WxConsole::CommandString 05 \n");
   //================================================================
   void WxConsole::OnMenuCreateBlackBox(wxCommandEvent& WXUNUSED(event))
   {
-    
-    wxMessageBox(_T("  Creating blackbox"),
-                 _T("Creating blackbox ..."), wxOK | wxICON_INFORMATION,
-                 this);
+       std::cout << "bbi: include CreateBlackBox" << std::endl;
+    Interpreter* I = new Interpreter;    
+       I->InterpretFile("CreateBlackBox");
+    delete I;
   }
   //================================================================
   
   //================================================================
   void WxConsole::OnMenuShowImageGraph(wxCommandEvent& WXUNUSED(event))
   {
-    std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
+    std::string default_temp_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
 
 #if defined(WIN32)
     std::string strappli="start ";
 #else
     std::string strappli="gnome-open ";
 #endif
-    std::string strcommand = strappli +default_doc_dir+"/temp_dir/workspace_workspacePrototype.png";
+    std::string strcommand = strappli +default_temp_dir+"/temp_dir/workspace_workspacePrototype.png";
+       std::cout << "system: " << strcommand << std::endl;
     system ( strcommand.c_str() );
+
   }
   //================================================================
 
-  
+
+  //================================================================
+  void WxConsole::OnMenuCreateIndex(wxCommandEvent& WXUNUSED(event))
+  {
+    std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path();
+    std::string filepath = doc_path+"/bbdoc/make-index.bbs";
+    Interpreter* I = new Interpreter;    
+
+//EED  std::cout << "bbi: include "<<filepath<<std::endl;
+//EED  I->InterpretFile( filepath );
+
+    bool insideComment = false; // for multiline comment
+       I->InterpretLine( "exec freeze" ,insideComment );
+       I->InterpretLine( "include *" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-alpha.html Initials" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-package.html Packages" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories" ,insideComment );
+       I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors",insideComment  );
+
+    delete I;
+  }
+  //================================================================
+
+
+
   
   //================================================================
   void WxConsole::OnCommandChar(wxCommandEvent& event)
@@ -544,10 +591,18 @@ printf("WxConsole::CommandString 05 \n");
      wxButton *btnInclude  = new wxButton( btnsCtrlPanel,-1,_T("Include")  );
      wxButton *btnReset    = new wxButton( btnsCtrlPanel,-1,_T("Reset")    );
      wxButton *btnConfig   = new wxButton( btnsCtrlPanel,-1,_T("Config")   );
-     wxButton *btnGraphS   = new wxButton( btnsCtrlPanel,-1,_T("Graph S.") );
-     wxButton *btnGraphD   = new wxButton( btnsCtrlPanel,-1,_T("Graph D.") );
+     wxButton *btnGraphS   = new wxButton( btnsCtrlPanel,-1,_T("Graph simple") );
+     wxButton *btnGraphD   = new wxButton( btnsCtrlPanel,-1,_T("Graph detailed") );
      wxButton *btnHelp     = new wxButton( btnsCtrlPanel,-1,_T("Help")     );
 
+         btnsSizer->Add( btnInclude    );
+         btnsSizer->Add( btnReset              );
+         btnsSizer->Add( btnConfig             );
+         btnsSizer->Add( btnGraphS     );
+         btnsSizer->Add( btnGraphD     );
+         btnsSizer->Add( btnHelp               );
+         btnsCtrlPanel->SetSizer(btnsSizer);
+
          Connect(btnInclude->GetId()   , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnInclude       );
          Connect(btnReset->GetId()             , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnReset         );
          Connect(btnConfig->GetId()    , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxConsole::OnBtnConfig        );
@@ -584,9 +639,7 @@ printf("WxConsole::CommandString 05 \n");
   //================================================================  
   void WxConsole::OnBtnReset(wxCommandEvent& event)
   {
-printf("WxConsole::OnBtnReset 01 \n");
      CommandString(_T("reset"));
-printf("WxConsole::OnBtnReset 02 \n");
   }
   //================================================================  
 
@@ -626,11 +679,13 @@ printf("WxConsole::OnBtnReset 02 \n");
   BEGIN_EVENT_TABLE(WxConsole, wxFrame)
     EVT_MENU(WxConsole::ID_Menu_Quit, WxConsole::OnMenuQuit)
     EVT_MENU(WxConsole::ID_Menu_About, WxConsole::OnMenuAbout)
+    EVT_MENU(WxConsole::ID_Menu_EditConfig, WxConsole::OnMenuEditConfig)
     EVT_MENU(WxConsole::ID_Menu_CreatePackage, WxConsole::OnMenuCreatePackage)
     EVT_MENU(WxConsole::ID_Menu_CreateBlackBox, WxConsole::OnMenuCreateBlackBox)
     EVT_MENU(WxConsole::ID_Menu_ShowImageGraph, WxConsole::OnMenuShowImageGraph)
+    EVT_MENU(WxConsole::ID_Menu_CreateIndex, WxConsole::OnMenuCreateIndex)
     EVT_TEXT_ENTER(WxConsole::ID_Text_Command, WxConsole::OnCommandEnter)
-  //    EVT_CHAR(WxConsole::ID_Text_Command, WxConsole::OnCommandChar)
+//      EVT_CHAR(WxConsole::ID_Text_Command, WxConsole::OnCommandChar)
     END_EVENT_TABLE()
   //================================================================