]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIConsole.cxx
Fixed Window deletion mechanism
[bbtk.git] / kernel / src / bbtkWxGUIConsole.cxx
index ae431dc9cb1cd6570949f29e969dc2a6d720e067..8f3c4e80452d361d2f0b6d3d3357184bfd81e029 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/10/17 08:18:15 $
-  Version:   $Revision: 1.15 $
+  Date:      $Date: 2009/05/28 08:12:06 $
+  Version:   $Revision: 1.16 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -169,7 +169,8 @@ namespace bbtk
 
         
     // Set the parent window of all bbtk windows as a child of this
-    bbtk::Wx::SetTopWindowParent(this);
+    //    bbtk::Wx::SetTopWindowParent(this);
+    bbtk::Wx::SetTopWindow(this);
     // Top Window Auto Destroys when no more black box window alive 
     // : this is the default 
     //    bbtk::Wx::SetAutoDestroyTopWindow(true);
@@ -199,12 +200,36 @@ namespace bbtk
   }
   //================================================================
 
+  //================================================================
+  void WxGUIConsole::OnClose(wxCloseEvent& event)
+  {
+    bbtkDebugMessage("widget",9,"bbi::OnClose()"<<std::endl);
+    //Wx::SetWindowsHaveBeenDestroyedByParent();
+    //mInterpreter.reset();
+    wxWindowList& list = GetChildren();
+    wxWindowList::iterator iter;
+    for (iter = list.begin(); iter != list.end(); ++iter)
+      {
+       (*iter)->Close();
+      }
+    this->Destroy();
+  }
+  //================================================================
+
   //================================================================
   void WxGUIConsole::OnWxSignal()
   {
-    if ((!Wx::TopWindowExists())&&(!IsShown())) 
+    if ((!bbtk::Wx::IsSomeWindowAlive())&&(!IsShown())) 
       {
        bbtkDebugMessage("wx",2,"  --> bbtk top window destroyed and WxGUIConsole not shown => destructing"<<std::endl);
+       /*
+       wxWindowList& list = GetChildren();
+       wxWindowList::iterator iter;
+       for (iter = list.begin(); iter != list.end(); ++iter)
+         {
+           (*iter)->Close();
+         }
+       */
        Close();
       }
   }
@@ -428,15 +453,17 @@ namespace bbtk
   
   //================================================================  
   // Overloaded Show method to handle bbtk::Wx::TopWindow auto-destruction
+  // OBSOLETE !!!
   bool WxGUIConsole::Show(bool show)
   {
-    bbtk::Wx::SetAutoDestroyTopWindow(!show);
+    //    bbtk::Wx::SetAutoDestroyTopWindow(!show);
     return wxFrame::Show(show);
   }
   //================================================================  
    
   //================================================================  
   BEGIN_EVENT_TABLE(WxGUIConsole, wxFrame)
+    EVT_CLOSE(  WxGUIConsole::OnClose)
     EVT_MENU(ID_Menu_Quit                      , WxGUIConsole::OnMenuQuit)
     EVT_MENU(ID_Menu_About                     , WxGUIConsole::OnMenuAbout)
     EVT_MENU(ID_Menu_EditConfig                , WxGUIConsole::OnMenuEditConfig)