]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkKWBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkKWBlackBox.cxx
index 08679361b1b485a4123fd916b7c12f5ba0e38066..ea7f31f446f5cedac9e5c1973b1502418c9399a0 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkKWBlackBox.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/12/18 11:54:44 $
-  Version:   $Revision: 1.8 $
+  Date:      $Date: 2009/04/08 07:56:11 $
+  Version:   $Revision: 1.9 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -54,172 +54,50 @@ namespace bbtk
   //=========================================================================
   //=========================================================================
   //=========================================================================
-  BBTK_BLACK_BOX_IMPLEMENTATION(KWBlackBox,AtomicBlackBox);
+  BBTK_BLACK_BOX_IMPLEMENTATION(KWBlackBox,WidgetBlackBox<wxWindow>);
   //=========================================================================
   
-  //=========================================================================
-  void KWBlackBox::bbUserConstructor()
-  {
-    bbtkDebugMessage("Kernel",9,"KWBlackBox::bbUserConstructor()"<<std::endl);
-    bbInitAttributes();
-  }
-  //=========================================================================
-
-  //=========================================================================
-  void KWBlackBox::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
+  //==================================================================    
+  /// Callback for creating a Dialog window (modal)
+  void WxBlackBox::bbCreateDialogWindow()
   {
-    bbtkDebugMessage("Kernel",9,"KWBlackBox::bbUserCopyConstructor()"
-                    <<std::endl);
-    bbInitAttributes();
-  }
-  //=========================================================================
-
+    KW::GetApplication();
+    vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New();
+    show = (Window*) win;
+    win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
+    KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
+    win->Create();
+    win->SetResizable(0,0);
+    
+    bbUserCreateWidget(win->GetFrame());
+    /*
+      KW::GetApplication()->Script
+      ("pack %s -expand yes -fill both",
+      bbGetOutputWidget()->GetWidgetName());
+    */
+    
+    KW::GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
+                                bbGetOutputWidget()->GetWidgetName(),
+                                bbGetInputWinWidth(),
+                                bbGetInputWinHeight());
+    
 
-  //=========================================================================
-  void KWBlackBox::bbUserDestructor()
-  {
-    bbtkDebugMessage("kw",9,"==> KWBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
-    if (bbGetWindow()) {
-      bbGetWindow()->bbClose();
-      bbSetWindow(0);
-    }
-    bbtkDebugMessage("kw",9,"<== KWBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
   }
-  //=========================================================================
-  
+  //==================================================================    
 
-
-  //=========================================================================
-  /**
-   * \brief Initialize the attributes of the class
-   *
-   */
-  void KWBlackBox::bbInitAttributes()
+  //==================================================================    
+  /// Callback for creating a Frame window 
+  void WxBlackBox::bbCreateFrameWindow()
   {
-    bbmWindow = 0;
-    //    bbmWidget = 0;
-    //    bbSetInputWinParent(0);
-    bbSetInputWinTitle(bbGetName());
-    bbSetInputWinWidth(800);
-    bbSetInputWinHeight(800);
-    bbSetInputWinDialog(false);
-    bbSetOutputWidget(0);
-
-    //    bbSetWidgetEventHandler(0);
-    //  bbSetUpdateTransferedToParent(false);
+    bbtkWarning("KW: Frame windows not supported: creating a Dialog!");
+    bbCreateDialogWindow();
   }
-  //=========================================================================
-
-
-  //=========================================================================
-  void KWBlackBox::bbProcess()
-  { 
-
-    this->bbUserProcess(); 
-
-    // If output widget not connected create the window 
-    if ( (*bbGetOutputConnectorMap().find("Widget")).second
-        ->GetConnectionVector().size() == 0 ) 
-      {
-       Window* show = 0;
-       // If the window already exists : no need creating it
-       if (bbGetWindow()!=0)
-         {
-           bbtkDebugMessage("kw",2,
-                            "-> Window already exists"
-                            <<std::endl);
-           show = bbGetWindow();
-         }
-       // Else create window 
-       else 
-         {
-           bbtkDebugMessage("kw",2,
-                            "-> Creating the window"
-                            <<std::endl);
-           KW::GetApplication();
-           
-           // Input WinDialog set to true : creating a Dialog
-           /*
-           if (bbGetInputWinDialog()) 
-             {
-               bbtkDebugMessage("kw",2,
-                                "   Input WinDialog set to true : creating a Dialog"
-                                <<std::endl);
-           */
-               vtkKWBlackBoxDialog* win = vtkKWBlackBoxDialog::New();
-               show = (Window*) win;
-               win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
-               KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
-               win->Create();
-               win->SetResizable(0,0);
-
-               bbUserCreateWidget(win->GetFrame());
-               /*
-               KW::GetApplication()->Script
-                 ("pack %s -expand yes -fill both",
-                  bbGetOutputWidget()->GetWidgetName());
-               */
-               
-               KW::GetApplication()->Script("place %s -x 0 -y 0 -width %d -height %d",
-                                            bbGetOutputWidget()->GetWidgetName(),
-                                            bbGetInputWinWidth(),
-                                            bbGetInputWinHeight());
-               
-               
-
+  //==================================================================    
 
 
-               /*
-               bbGetOutputWidget()->SetParent(win);
-               bbGetOutputWidget()->Create();
-               KW::GetApplication()->Script("pack %s -side left -anchor c -expand y",
-                       
-                                    //"pack %s -side top -anchor nw -expand y -fill none -padx 2 -pady 2", 
-                                            bbGetOutputWidget()->GetWidgetName());
-               */                           
-               /*      
-                 }
-       
-           // Input WinDialog set to false : creating a Frame
-           else 
-             {
-               bbtkDebugMessage("process",2,
-                                "   Input WinDialog set to false : creating a Frame"
-                                <<std::endl);
-               vtkKWBlackBoxFrame* win = vtkKWBlackBoxFrame::New();
-               show = (Window*) win;
-               win->bbSetBlackBox( GetThisPointer<KWBlackBox>());
-               //              win->SetName( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN" );
-               //              win->SetWidth( bbGetInputWinWidth() );
-               //              win->SetHeight( bbGetInputWinHeight() );
-               KW::GetApplication()->AddWindow((vtkKWWindowBase*)win);
-               win->Create();
-               
-               bbGetOutputWidget()->SetParent(win);
-               bbGetOutputWidget()->Create();
-               KW::GetApplication()->Script("pack %s -side top -anchor nw -expand y -fill none -padx 2 -pady 2", 
-                                            bbGetOutputWidget()->GetWidgetName());           }
-       */
-       
-               //      win->Invoke();
-         }
-       
-       // Show the window
-
-       show->bbShow(); 
-       //      std::cout << "KW::GetApplication()->Start();"<<std::endl;
-       //      KW::GetApplication()->Start();
-       //      std::cout << "AFTER KW::GetApplication()->Start();"<<std::endl;
-       
-      }                  
-    //   
-    
-  }
-  //=========================================================================
-  
-
   //==================================================================
-  vtkKWWidget*  KWBlackBox::bbCreateWidgetOfInput(const std::string& in, vtkKWFrame* parent)
+  vtkKWWidget*  KWBlackBox::bbCreateWidgetOfInput(const std::string& in, 
+                                                 vtkKWFrame* parent)
   {
     vtkKWWidget* w = 0;
     // If input is connected 
@@ -242,59 +120,18 @@ namespace bbtk
 
 
   //==================================================================
-   void KWBlackBox::bbHideWindow()
-  {
-    bbtkDebugMessageInc("kw",1,"=> KWBlackBox::bbHideWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-
-    if (bbGetWindow()!=0) bbGetWindow()->bbHide();
-
-    bbtkDebugMessageDec("kw",2,"<= KWBlackBox::bbHideWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  }
-  //==================================================================
-
-
-  //==================================================================
-   void KWBlackBox::bbCloseWindow()
-  {
-    bbtkDebugMessageInc("kw",1,"=> KWBlackBox::bbCloseWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-
-    if (bbGetWindow()!=0) bbGetWindow()->bbClose();
-
-    bbtkDebugMessageDec("kw",2,"<= KWBlackBox::bbCloseWindow() ["
-                       <<bbGetFullName()<<"]"<<std::endl);
-  }
-  //==================================================================
-
-  //==================================================================
-  KWBlackBox::Window* KWBlackBox::bbGetContainingWindow()
-  {
-    if (bbGetWindow()!=0) return bbGetWindow();
-    BlackBox::OutputConnectorMapType::const_iterator i 
-      = bbGetOutputConnectorMap().find("Widget");
-    if ( i->second->GetConnectionVector().size() != 0 ) 
-      {
-       return boost::static_pointer_cast<KWBlackBox>
-         (i->second->GetConnectionVector().front() //.lock()
-          ->GetBlackBoxTo())->bbGetContainingWindow();
-      }
-    return 0;
-  }
-  //==================================================================
-
-
-  //==================================================================
-  bool KWBlackBox::bbIsShown()
-  {
-    if (bbGetContainingWindow()!=0)
-      return bbGetContainingWindow()->bbIsShown();
-    return false;
-  }
+  //  void KWBlackBox::InitWindowManagerIfNeeded() { KW::
+  void KWBlackBox::IncNbWindowsAlive() { KW::IncNbWindowsAlive(); }
+  void KWBlackBox::DecNbWindowsAlive() { KW::DecNbWindowsAlive(); }
+  int  KWBlackBox::GetNbWindowsAlive() { return KW::GetNbWindowsAlive(); }
+  bool KWBlackBox::IsSomeWindowAlive() { return KW::IsSomeWindowAlive(); }
+  
+  void KWBlackBox::IncNbWindowsShown() { KW::IncNbWindowsShown(); }
+  void KWBlackBox::DecNbWindowsShown() { KW::DecNbWindowsShown(); }
+  int  KWBlackBox::GetNbWindowsShown() { return KW::GetNbWindowsShown(); }
+  bool KWBlackBox::IsSomeWindowShown() { return KW::GetNbWindowsShown(); }
   //==================================================================
-
-
+  
 }//namespace bbtk