]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxTabPanelsManager.cxx
Bug #1355 The complete tab is not erased from memory. Only the objects are deleted...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxTabPanelsManager.cxx
index 32173e91c291423383f4302615c7f84e8202677e..14f85311b1bacc5f87e8e57b0a6c52b23827bb79 100644 (file)
@@ -48,6 +48,8 @@ namespace bbtk
                _notebook       = _parent->getAuiNotebook();
                addNewTab();
                _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabChanged),0,this);
+               _notebook->Connect(wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,wxAuiNotebookEventHandler(wxTabPanelsManager::OnTabClose),0,this);
+
        }
 
        //=========================================================================
@@ -65,10 +67,16 @@ printf("EED wxTabPanelsManager::addNewTab 0\n");
                newPanel->setPanelsManager(this);
                _panels[_lastId]                    = newPanel;
                _actual                             = newPanel;
+
                _notebook->AddPage(newPanel, tabName  ,true);
+
 printf("EED wxTabPanelsManager::addNewTab 1\n");
        }
 
+
+
+
+
        //=========================================================================
        wxAuiNotebook* wxTabPanelsManager::getAuiNotebook()
        {
@@ -234,6 +242,37 @@ printf("wxTabPanelsManager::VerifyActualTabPanel  %d \n", this->_notebook->GetPa
        }
 
        //=========================================================================
+
+       void wxTabPanelsManager::OnTabClose(wxAuiNotebookEvent& event)
+       {
+
+               std::cout<<"RaC wxTabPanelsManager::OnTabClose Start... "<<_panels.size()<<std::endl;
+               int index = event.GetSelection();
+
+               if(_panels.size()>0)
+               {
+                       wxGEditorTabPanel* tab      = (wxGEditorTabPanel*)_notebook->GetPage(index);
+                       int id                      = tab->getPanelId();
+                       tab->deleteAllBoxes();
+                       _panels.erase(id);
+
+                       _notebook->RemovePage(index);
+
+                       std::cout<<"RaC wxTabPanelsManager::OnTabClose  IMPORTANT. The complete tab is not erased from memory... "<<std::endl;
+                       //////////////////////////////
+                       // TO FIX . RaC May 2012 - IMPORTANT. The complete tab is not erased from memory.
+                       // Only the objects are deleted and the tab is hidden
+                       // Execution problems when a tab is deleted using delete or DeletePage
+                       // delete tab;
+
+                       map<int, wxGEditorTabPanel*>::iterator it = _panels.begin() ;
+                       _actual=(*it).second;
+
+                       std::cout<<"RaC wxTabPanelsManager::OnTabClose End..."<< std::endl;
+               }
+       }
+
+       //=========================================================================
     std::string wxTabPanelsManager::GetCbName()
        {
            return _actual->GetCbName();