]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWidgetBlackBox.txx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWidgetBlackBox.txx
index 39738cf6b3032aaebe8689488fb17d7204ac3a5b..2aeb1783de0d188113b47349f13e75b8da9b3da7 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWidgetBlackBox.txx,v $
   Language:  C++
-  Date:      $Date: 2009/04/21 14:36:51 $
-  Version:   $Revision: 1.2 $
+  Date:      $Date: 2009/05/19 10:19:23 $
+  Version:   $Revision: 1.4 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -54,56 +54,48 @@ namespace bbtk
   
 //=========================================================================
   template <class T>  
-  void WidgetBlackBox<T>::bbUserConstructor()
+  void WidgetBlackBox<T>::bbUserSetDefaultValues()
   {
-    bbtkDebugMessage("widget",9,"WidgetBlackBox::bbUserConstructor()"<<std::endl);
-    bbInitAttributes();
+    bbtkDebugMessage("widget",9,"WidgetBlackBox::bbUserSetDefaultValues()"<<std::endl);
+    bbmWindow = 0;
+    bbSetInputWinTitle(bbGetName());
+    bbSetInputWinWidth(800);
+    bbSetInputWinHeight(800);
+    bbSetInputWinDialog(false);
+    bbSetOutputWidget(0);
   }
   //=========================================================================
 
   //=========================================================================
   template <class T>  
-  void WidgetBlackBox<T>::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
+  void WidgetBlackBox<T>::bbUserInitializeProcessing()
   {
-    bbtkDebugMessage("widget",9,"WidgetBlackBox::bbUserCopyConstructor()"
-                    <<std::endl);
-    bbInitAttributes();
   }
   //=========================================================================
 
-
   //=========================================================================
   template <class T>  
-  void WidgetBlackBox<T>::bbUserDestructor()
+  void WidgetBlackBox<T>::bbUserFinalizeProcessing()
   {
-    bbtkDebugMessage("widget",9,"==> WidgetBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
-    if (bbGetWindow()) {
-      bbGetWindow()->bbClose();
-      bbSetWindow(0);
-    }
-    bbtkDebugMessage("widget",9,"<== WidgetBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
+    bbtkDebugMessage("widget",9,"==> WidgetBlackBox::bbUserFinalizeProcessing() ["<<bbGetFullName()<<"]"<<std::endl);
+    if (bbGetWindow()) 
+      {
+       if (GetUseCount()==0)
+         {
+           if (bbGetWindow()->bbIsShown()) DecNbWindowsShown();
+           DecNbWindowsAlive();
+         }
+       bbGetWindow()->bbDestroy();
+       bbSetWindow(0);
+      }
+    bbtkDebugMessage("widget",9,"<== WidgetBlackBox::bbUserFinalizeProcessing() ["<<bbGetFullName()<<"]"<<std::endl);
   }
   //=========================================================================
   
 
 
-  //=========================================================================
-  /**
-   * \brief Initialize the attributes of the class
-   *
-   */
-  template <class T>  
-  void WidgetBlackBox<T>::bbInitAttributes()
-  {
-    bbmWindow = 0;
-    bbSetInputWinTitle(bbGetName());
-    bbSetInputWinWidth(800);
-    bbSetInputWinHeight(800);
-    bbSetInputWinDialog(false);
-    bbSetOutputWidget(0);
-  }
-  //=========================================================================
-
 
   //=========================================================================
   template <class T>  
@@ -181,7 +173,10 @@ namespace bbtk
        // Cast it into a WidgetBlackBox
        typename WidgetBlackBox<T>::Pointer wfrom 
          = boost::dynamic_pointer_cast<WidgetBlackBox<T> >(from);
-       // Call bbCreateWidget
+       // If the black box from construction is not done yet : do it
+        // If not constructed do it 
+       wfrom->bbInitializeProcessing();
+       // Call bbUserCreateWidget
        wfrom->bbUserCreateWidget(parent);
        // Get the widget created
        w = wfrom->bbGetOutputWidget();
@@ -234,7 +229,7 @@ namespace bbtk
     bbtkDebugMessageInc("widget",1,"=> WidgetBlackBox::bbCloseWindow() ["
                        <<bbGetFullName()<<"]"<<std::endl);
 
-    if (bbGetWindow()!=0) bbGetWindow()->bbClose();
+    if (bbGetWindow()!=0) bbGetWindow()->bbDestroy();
 
     bbtkDebugMessageDec("widget",2,"<= WidgetBlackBox::bbCloseWindow() ["
                        <<bbGetFullName()<<"]"<<std::endl);