]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
Updated Version with the moving of the objects updated and the background doesn't...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.cxx
index 3d761d467899bdc55cdef30204d2a9fedbe8ea3b..12708e34400425a58447bfa5a7e9e2f95dca78a3 100644 (file)
@@ -64,11 +64,15 @@ namespace bbtk
 
                initMenu();
                initToolbar();
-               initPackageBrowser();
                initTabPanelsManager();
+               initPackageBrowser();
+               initHelpHTMLBrowser();
+               initPropertiesPanel();
 
                CreateStatusBar();
                _frameAUIMgr->Update();
+               _actualPkgBrowserBoxName="";
+               _actualPkgBrowserPkgName="";
        }
 
 
@@ -89,16 +93,6 @@ namespace bbtk
                //Adds a tool btn to the toolbar
                _toolbar->AddTool(wxID_NEW,_T("New"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New tab"), _T("Create a new panel tab"));
 
-
-               ////////////////////
-               // TEMP to avoid drag and drop
-                       
-               _toolbar->AddTool(wxID_NEW+1,_T("New Box"),bmp_new, wxNullBitmap, wxITEM_NORMAL,_T("New Box"), _T("Create a new Box"));
-
-
-               //
-               ////////////////////
-
                _toolbar->SetMargins( 2, 2 );
                _toolbar->Realize();
                SetToolBar(_toolbar);
@@ -107,6 +101,14 @@ namespace bbtk
                Connect(wxID_NEW,wxEVT_COMMAND_TOOL_CLICKED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnToolLeftClick));
 
        }
+       //=========================================================================
+       void wxGUIEditorGraphicBBS::initHelpHTMLBrowser()
+       {
+               //TO FIX THE PATH OF BBTK BIN  IN ORDER TO USE REGENERATE EXECUTABLES
+               //RegenerateAll();
+               _helpHtmlBrowser = new WxGUIHtmlBrowser(this,wxSize(200,0));
+               _frameAUIMgr->AddPane(_helpHtmlBrowser,wxAuiPaneInfo().Right().MinSize(200,200));       
+       }
 
        //=========================================================================
        void wxGUIEditorGraphicBBS::initMenu()
@@ -119,6 +121,8 @@ namespace bbtk
                helpMenu->Append(wxID_ABOUT, _T("&About..."), _T("About"));
                fileMenu->Append(wxID_EXIT, _T("E&xit"), _T("Exit"));
 
+               Connect(wxID_EXIT,wxEVT_COMMAND_MENU_SELECTED,wxCommandEventHandler(wxGUIEditorGraphicBBS::OnExit));
+
                // now append the freshly created menu to the menu bar...
                wxMenuBar *menuBar = new wxMenuBar();
                menuBar->Append(fileMenu, _T("&File"));
@@ -131,9 +135,9 @@ namespace bbtk
        //=========================================================================
        void wxGUIEditorGraphicBBS::initTabPanelsManager()
        {
-               wxAuiNotebook *notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
-               _tabsMgr = new wxTabPanelsManager(notebook);
-               _frameAUIMgr->AddPane(notebook,wxAuiPaneInfo().CenterPane());   
+               _notebook = new wxAuiNotebook(this,wxID_ANY,wxDefaultPosition,wxDefaultSize,wxAUI_NB_TOP|wxAUI_NB_TAB_MOVE|wxAUI_NB_CLOSE_ON_ACTIVE_TAB|wxAUI_NB_TAB_FIXED_WIDTH|wxAUI_NB_WINDOWLIST_BUTTON);
+               _tabsMgr = new wxTabPanelsManager(this);
+               _frameAUIMgr->AddPane(_notebook,wxAuiPaneInfo().CenterPane());  
 
        }
        
@@ -142,12 +146,136 @@ namespace bbtk
        {
                _pkgBrowser = new WxGUIPackageBrowser2(this);
                _pkgBrowser->IncludeAll();
-               _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));  
+               _frameAUIMgr->AddPane(_pkgBrowser,wxAuiPaneInfo().Left().MinSize(200,200).CloseButton(false));          
+       }
+
+       //================================================================
+
+       void wxGUIEditorGraphicBBS::initPropertiesPanel()
+       {
+               _propertiesPanel = new wxPropertiesPanel(this);
+               _frameAUIMgr->AddPane(_propertiesPanel,wxAuiPaneInfo().Right().MinSize(200,200).CloseButton(false).Floatable(false));
+       }
+
+       //================================================================
+
+       void wxGUIEditorGraphicBBS::DoRegeneratePackageDoc( const std::string& pack )
+       {
+               std::string mess("Regenerating doc for package '");
+               if (pack!="-a"){
+                       mess += pack + "'";
+               }
+               else
+               {
+                       mess = "Regenerating doc for all packages";
+               }
                
-               //FIXME - Just the first tab with drop target event
-               //_pkgBrowser->SetBoxListDropTarget((wxDropTarget*)_tabsMgr->getActualTabPanel());
+               mess += " ... please wait";             
+
+               SetStatusText( std2wx(mess) );
+
+               //BBTK_BUSY_CURSOR;
+
+               std::string command;
+               #if defined(WIN32)
+                       command = "\"";
+               #endif
+                       command += ConfigurationFile::GetInstance().Get_bin_path();
+                       command += ConfigurationFile::GetInstance().Get_file_separator();
+                       command += "bbRegeneratePackageDoc";
+               #if defined(WIN32)
+                       command += "\"";
+               #endif
+
+               command += " " + pack + " -q";
+           bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
+
+               if ( ! system ( command.c_str() ) )
+               {
+                       SetStatusText( _T("Done !"));
+                       /*
+                       wxMessageBox(_T("Done !"),_T("Regenerate package '")
+                                        +std2wx(pack)+_T("' doc"),
+                                        wxOK | wxICON_INFORMATION);
+                       */
+               }
+               else 
+               {
+                       SetStatusText( _T("Done !"));
+                       wxString err(_T("An error occured while running '"));
+                       err +=  bbtk::std2wx(command) + _T("'");
+                       wxMessageBox(err,_T("Regenerate package doc"),wxOK | wxICON_ERROR);      
+           }
        }
 
+       //================================================================
+       void wxGUIEditorGraphicBBS::DoRegenerateBoxesLists()
+       {
+               SetStatusText( _T("Regenerating boxes lists ... please wait") );
+               //BBTK_BUSY_CURSOR ;
+
+               std::string command;
+               #if defined(WIN32)
+                       command = "\"";
+               #endif
+                       command += ConfigurationFile::GetInstance().Get_bin_path();
+                       command += ConfigurationFile::GetInstance().Get_file_separator();
+                       command += "bbRegenerateBoxesLists";
+
+               #if defined(WIN32)
+                       command += "\"";
+               #endif
+                       command += " -q";
+
+               bbtkMessage("debug",1,"Executing system command '"<<command<<"'"<<std::endl);
+
+               if ( ! system ( command.c_str() ) )
+               {
+                       SetStatusText( _T("Done !"));
+                       /*
+                       wxMessageBox(_T("Done !"),_T("Regenerate boxes lists"),
+                                        wxOK | wxICON_INFORMATION);
+                       */
+               }
+               else 
+               {
+                       SetStatusText( _T("Done !"));
+                       wxString err(_T("An error occured while running '"));
+                       err +=  bbtk::std2wx(command) + _T("'");
+                       wxMessageBox(err,_T("Regenerate boxes lists"),wxOK | wxICON_ERROR);      
+               }
+       }
+       
+  //================================================================
+       void wxGUIEditorGraphicBBS::RegenerateAll()
+       {
+               DoRegeneratePackageDoc("-a");   
+               DoRegenerateBoxesLists();
+       }
+
+       //================================================================
+
+       wxAuiNotebook* wxGUIEditorGraphicBBS::getAuiNotebook()
+       {
+               return _notebook;
+       }
+
+       //================================================================
+
+       void wxGUIEditorGraphicBBS::displayBlackBoxInfo(std::string packageName, std::string boxName)
+       {
+               if(_actualPkgBrowserPkgName != packageName || _actualPkgBrowserBoxName != boxName )
+               {
+                       _actualPkgBrowserPkgName = packageName;
+                       _actualPkgBrowserBoxName = boxName;
+
+                       BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
+                       _pkgBrowser->WxGUIBlackBoxListUserOnSelected(descriptor.get());
+               }
+       }
+
+       //=========================================================================
+
        /*****************************************************
        /* HANDLERS 
        /*****************************************************/
@@ -157,15 +285,16 @@ namespace bbtk
                switch (event.GetId())
                {
                case wxID_NEW :
-                       std::cout<<"RaC New"<<std::endl;
                        _tabsMgr->addNewTab();
-                       break;
-               case wxID_NEW+1 :
-                       //BlackBoxDescriptor* desc = _pkgBrowser->GetActualSelected();
-                       //cout<<"RaC GetActualSelected desc:"<<desc->GetAuthor()<<endl;
+                       break;                  
                }
        }
 
+       void wxGUIEditorGraphicBBS::OnExit(wxCommandEvent& event)
+       {
+               Close(true);
+       }
+
 
 }  // EO namespace bbtk