]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWxGUIConsole.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxGUIConsole.cxx
index e70ca40295ec3f4c36c90a5a01408c2ebed0d9dd..69a17d61087e0392b3cb1091f96c9cec839845ec 100644 (file)
@@ -3,8 +3,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWxGUIConsole.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/04/23 14:49:28 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2008/04/24 10:11:28 $
+  Version:   $Revision: 1.9 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -151,13 +151,11 @@ namespace bbtk
     cmdsizer->Add (mWxGUICommand, 0, wxALL | wxGROW, 5);
 
         
-    // Creates and sets the parent window of all bbtk windows
-    /*
-    wxWindow* top = new wxPanel(this,-1);//,_T("top"));
-    top->Hide();
-    Wx::SetTopWindow(top);
-    */
-    Wx::CreateInvisibleTopWindow(this);
+    // Creates the parent window of all bbtk windows as a child of this
+    Wx::CreateTopWindow(this,true);
+    // Add the method OnWxSignal as a Wx::Signal observer 
+    bbtkAddWxSignalObserver(WxGUIConsole::OnWxSignal);
+
 
     // Layout
 //EED    SetSizer(sizer);
@@ -181,6 +179,16 @@ namespace bbtk
   }
   //================================================================
 
+  //================================================================
+  void WxGUIConsole::OnWxSignal()
+  {
+    if ((!Wx::TopWindowExists())&&(!IsShown())) 
+      {
+       bbtkDebugMessage("wx",2,"  --> bbtk top window destroyed and WxGUIConsole not shown => destructing"<<std::endl);
+       Close();
+      }
+  }
+  //================================================================
 
   //================================================================
   void WxGUIConsole::WxGUICommandEnter(const std::string& command)
@@ -376,7 +384,15 @@ namespace bbtk
   } 
   //================================================================  
   
-    
+  //================================================================  
+  // Overloaded Show method to handle bbtk::Wx::TopWindow auto-destruction
+  bool WxGUIConsole::Show(bool show)
+  {
+    Wx::AutoDestroyTopWindow(!show);
+    wxFrame::Show(show);
+  }
+  //================================================================  
+   
   //================================================================  
   BEGIN_EVENT_TABLE(WxGUIConsole, wxFrame)
     EVT_MENU(ID_Menu_Quit, WxGUIConsole::OnMenuQuit)