]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxBlackBox.cxx
* Major changes on IOStatus update / propagation
[bbtk.git] / kernel / src / bbtkWxBlackBox.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxBlackBox.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/12/08 12:54:27 $
6   Version:   $Revision: 1.33 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 #ifdef _USE_WXWIDGETS_
33
34
35
36 /**
37  *  \file 
38  *  \brief 
39  */
40  
41 #include "bbtkWxBlackBox.h"
42 #include "bbtkBlackBoxOutputConnector.h"
43
44 //#include "bbtkWxContainerBlackBox.h"
45 #include <wx/dialog.h>
46
47 //#include "bbtkData.h"
48 //#include "bbtkFactory.h"
49
50
51
52
53 namespace bbtk
54 {
55
56
57
58
59   //=========================================================================
60   // WxBlackBoxWindow
61   //=========================================================================
62
63
64
65   //=========================================================================
66   WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox::Pointer box)
67     : mBox(box), mShown(false)
68   {
69     bbtkDebugMessage("wx",9,"WxBlackBoxWindow::WxBlackBoxWindow("<<
70                      mBox.lock()->bbGetFullName()<<")"<<std::endl);
71     mBox.lock()->bbSetWindow(this);
72     Wx::IncNbWindowsAlive();
73   }
74   //=========================================================================
75
76   //=========================================================================
77   WxBlackBoxWindow::~WxBlackBoxWindow()
78   {
79     bbtkDebugMessage("wx",9,"WxBlackBoxWindow::~WxBlackBoxWindow() "
80                      <<this<<std::endl);
81     bbHide();
82     Wx::DecNbWindowsAlive();
83     if (!mBox.expired())
84       {
85         mBox.lock()->bbSetWindow(0);
86       }
87   }
88   //========================================================================= 
89
90
91   //=========================================================================
92   void WxBlackBoxWindow::bbShow()
93   {
94     if (bbIsShown()) return;
95     bbtkDebugMessage("wx",9,"WxBlackBoxWindow::bbShow()"<<std::endl);
96     Wx::IncNbWindowsShown();
97     mShown = true;
98   }
99   //=========================================================================
100
101   //=========================================================================
102   void WxBlackBoxWindow::bbHide()
103   {
104     if (!bbIsShown()) return;
105     bbtkDebugMessage("wx",9,"WxBlackBoxWindow::bbHide()"<<std::endl);
106     Wx::DecNbWindowsShown();
107     mShown = false;
108   }
109   //=========================================================================
110
111   //=========================================================================
112   void WxBlackBoxWindow::bbClose()
113   {
114   }
115   //=========================================================================
116
117
118   //=========================================================================
119   // WxBlackBoxDialog
120   //=========================================================================
121
122   //=========================================================================
123   WxBlackBoxDialog::WxBlackBoxDialog(WxBlackBox::Pointer box,
124                                      wxWindow *parent,
125                                      wxString title,
126                                      wxSize size)
127     :
128     wxDialog( parent, 
129                 -1, 
130                 title,
131                 wxDefaultPosition,
132                 size,
133                 wxRESIZE_BORDER | 
134                 wxSYSTEM_MENU  |
135                 wxCLOSE_BOX |
136                 wxMAXIMIZE_BOX | 
137                 wxMINIMIZE_BOX | 
138                 wxCAPTION  
139               ),
140     WxBlackBoxWindow(box)
141   {
142     bbtkDebugMessage("wx",9,"WxBlackBoxDialog::WxBlackBoxDialog("<<
143                      bbGetBlackBox()->bbGetFullName()<<","<<parent<<","
144                      <<title<<",size)"<<std::endl);
145     // Insert the widget into the window
146     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
147           // LG 22/11/08 : new widget pipeline
148           bbGetBlackBox()->bbCreateWidgetAndEventHandler(this);
149     wxWindow* widget = bbGetBlackBox()->bbGetOutputWidget();
150 // old :    widget->Reparent(this);
151     sizer->Add( widget, 1, wxALL|wxEXPAND, 2);
152     //SetAutoLayout(true);
153     SetSizer(sizer);
154     Layout();
155   }
156   //=========================================================================
157   
158   //=========================================================================
159   void WxBlackBoxDialog::bbShow()
160   { 
161     if (bbIsShown()) return;
162     bbtkDebugMessage("wx",5,"WxBlackBoxDialog::bbShow() ["
163                      <<bbGetBlackBox()->bbGetFullName()<<"]"<<std::endl);
164     WxBlackBoxWindow::bbShow();
165     SetReturnCode( wxDialog::ShowModal() ); 
166     bbClose();
167   }
168   //=========================================================================
169
170   //=========================================================================
171   void WxBlackBoxDialog::bbHide()
172   {
173     bbtkDebugMessage("wx",9,"WxBlackBoxDialog::bbHide()"<<std::endl);
174     WxBlackBoxWindow::bbHide();
175     Hide();
176   }
177   //=========================================================================
178
179   //=========================================================================
180   void WxBlackBoxDialog::bbClose()
181   {
182     bbtkDebugMessage("wx",9,"WxBlackBoxDialog::bbClose()"<<std::endl);
183     wxDialog::Destroy();
184   }
185   //=========================================================================
186
187   //=========================================================================
188   WxBlackBoxDialog::~WxBlackBoxDialog()
189   {
190   }
191   //=========================================================================
192
193
194
195
196
197   //=========================================================================
198   // WxBlackBoxFrame
199   //=========================================================================
200
201   //=========================================================================
202   WxBlackBoxFrame::WxBlackBoxFrame(WxBlackBox::Pointer box,
203                                    wxWindow *parent,
204                                    wxString title,
205                                    wxSize size)
206     :  wxFrame( parent, 
207                -1, 
208                title,
209                wxDefaultPosition,
210                size,
211                wxRESIZE_BORDER | 
212                wxSYSTEM_MENU  |
213                wxCLOSE_BOX |
214                wxMAXIMIZE_BOX | 
215                wxMINIMIZE_BOX | 
216                wxCAPTION  
217                 ),
218        WxBlackBoxWindow(box)
219   {
220     bbtkDebugMessage("wx",9,"WxBlackBoxFrame::WxBlackBoxFrame("<<
221                      bbGetBlackBox()->bbGetFullName()<<","<<parent<<","
222                      <<title<<",size)"<<std::endl);
223     // Insert the widget into the window
224     wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
225           // LG 22/11/08 : new widget pipeline
226           bbGetBlackBox()->bbCreateWidgetAndEventHandler(this);
227     wxWindow* widget = bbGetBlackBox()->bbGetOutputWidget();
228     wxFrame* frame = (wxFrame*)this;
229 // old :    widget->Reparent(frame);
230     sizer->Add( widget, 1, wxALL|wxGROW, 2);
231     //  frame->SetAutoLayout(true);
232     frame->SetSizer(sizer);
233     //frame->Fit();
234     frame->Layout();
235   }
236   //=========================================================================
237   
238   //=========================================================================
239   WxBlackBoxFrame::~WxBlackBoxFrame()
240   {
241   }
242   //=========================================================================
243
244   //=========================================================================
245   void WxBlackBoxFrame::bbShow() 
246   { 
247     if (bbIsShown()) return;
248     bbtkDebugMessage("wx",5,"WxBlackBoxFrame::bbShow("
249                      <<bbGetBlackBox()->bbGetFullName()<<")"<<std::endl);
250     WxBlackBoxWindow::bbShow();
251   wxFrame::Show();
252     // This Update is ** MANDATORY ** 
253     // to synchronize wxvtkRenderWindowInteractor objects
254     // (force wx objects creation **NOW**)
255
256
257 #if defined(_WIN32)
258       wxFrame::Refresh();
259 #endif
260
261       wxFrame::Update();
262       wxFrame::SetFocus();
263     if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnShow();
264   }
265   //=========================================================================
266
267   //=========================================================================
268   void WxBlackBoxFrame::bbHide()
269   {
270     bbtkDebugMessage("wx",9,"WxBlackBoxFrame::bbHide()"<<std::endl);
271     WxBlackBoxWindow::bbHide();
272     wxFrame::Hide();
273     if (bbGetBlackBox()) bbGetBlackBox()->bbUserOnHide();
274   }
275   //=========================================================================
276
277   //=========================================================================
278   void WxBlackBoxFrame::bbClose()
279   {
280     bbtkDebugMessage("wx",9,"WxBlackBoxFrame::bbClose()"<<std::endl);
281     wxFrame::Close();
282   }
283   //=========================================================================
284
285
286
287   //=========================================================================
288   // WxBlackBoxWidgetEventHandler
289   //=========================================================================
290
291   //=========================================================================
292   WxBlackBoxWidgetEventHandler::
293   WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, 
294                                 wxWindow *widget )
295     :
296     mBox(box),
297     mWindow(widget)
298   { 
299     bbtkDebugMessage("wx",9,"WxBlackBoxWidgetEventHandler::WxBlackBoxWidgetEventHandler("<<mBox.lock()->bbGetFullName()<<")"<<std::endl);
300
301     mBox.lock()->bbSetWidgetEventHandler(this);
302
303     Connect (  mWindow->GetId(),
304                wxEVT_DESTROY,
305                (wxObjectEventFunction) 
306                (void (wxEvtHandler::*)(wxWindowDestroyEvent& c))
307                 &WxBlackBoxWidgetEventHandler::OnWindowDestroy );
308     
309     mWindow->PushEventHandler(this);
310     
311   }
312   //=========================================================================
313
314   //=========================================================================
315   WxBlackBoxWidgetEventHandler::~WxBlackBoxWidgetEventHandler()
316   {
317     if (mBox.expired()) return;
318     bbtkDebugMessage("wx",9,
319                      "WxBlackBoxWidgetEventHandler::~WxBlackBoxWidgetEventHandler() ["
320                      <<mBox.lock()->bbGetFullName()<<"]"<<std::endl);
321      mBox.lock()->bbSetWidgetEventHandler(0);   
322   }
323   //=========================================================================
324
325   //=========================================================================
326   void WxBlackBoxWidgetEventHandler::OnWindowDestroy(wxWindowDestroyEvent&)
327   {
328     if (mBox.expired()) return;
329     bbtkDebugMessage("wx",9,"WxBlackBoxWidgetEventHandler::OnWindowDestroy() ["
330                      <<mBox.lock()->bbGetFullName()<<"]"<<std::endl);
331     mBox.lock()->bbSetOutputWidget(0);
332     // LGSIGNAL
333     //    mBox.lock()->bbSetModifiedStatus();
334   }
335   //=========================================================================
336
337
338
339
340
341
342
343   //=========================================================================
344   // WxBlackBox
345   //=========================================================================
346
347   //=========================================================================
348   //=========================================================================
349   //=========================================================================
350   //=========================================================================
351   BBTK_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox);
352   //=========================================================================
353   
354   //=========================================================================
355   void WxBlackBox::bbUserConstructor()
356   {
357     bbtkDebugMessage("Kernel",9,"WxBlackBox::bbUserConstructor()"<<std::endl);
358     bbInitAttributes();
359   }
360   //=========================================================================
361
362   //=========================================================================
363   void WxBlackBox::bbUserCopyConstructor(bbtk::BlackBox::Pointer)
364   {
365     bbtkDebugMessage("Kernel",9,"WxBlackBox::bbUserCopyConstructor()"
366                      <<std::endl);
367     bbInitAttributes();
368   }
369   //=========================================================================
370
371
372   //=========================================================================
373   void WxBlackBox::bbUserDestructor()
374   {
375     bbtkDebugMessage("wx",9,"==> WxBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
376     if (bbGetWindow()) {
377       delete bbGetWindow();
378       bbSetWindow(0);
379     }
380     bbtkDebugMessage("wx",9,"<== WxBlackBox::bbUserDestructor() ["<<bbGetFullName()<<"]"<<std::endl);
381   }
382   //=========================================================================
383   
384
385   /*
386   //=========================================================================
387   WxBlackBox::Widget*  WxBlackBox::bbGetWidget()
388   { 
389     if (bbGetOutputWidget() && bbGetOutputWidget()->IsDead()) 
390       {
391         bbtkDebugMessage("wx",9,"WxBlackBox::bbGetWidget() ["<<
392                          bbGetFullName()<<"] : Widget is dead : deleting it"
393                          <<std::endl);
394         delete bbGetOutputWidget();
395         bbSetOutputWidget(0);
396       }
397     return bbGetOutputWidget();
398   }
399   //=========================================================================
400   */
401
402
403   //=========================================================================
404   /**
405    * \brief Initialize the attributes of the class
406    *
407    */
408   void WxBlackBox::bbInitAttributes()
409   {
410     bbmWindow = 0;
411     //    bbmWidget = 0;
412     //    bbSetInputWinParent(0);
413     bbSetInputWinTitle(bbGetName());
414     bbSetInputWinWidth(800);
415     bbSetInputWinHeight(800);
416     bbSetInputWinDialog(false);
417     bbSetOutputWidget(0);
418
419     bbSetWidgetEventHandler(0);
420     //    bbSetUpdateTransferedToParent(false);
421   }
422   //=========================================================================
423
424   //=========================================================================
425   /// Main processing method of the box.
426   void WxBlackBox::bbExecute(bool force)
427   {
428     
429     bbtkDebugMessageInc("process",2,
430                         "=> WxBlackBox::bbExecute("<<(int)force<<") ["
431                         <<bbGetFullName()<<"]"<<std::endl);
432     
433     
434     // If the output 'Widget' is connected then 
435     // we must execute the parent box
436     BlackBox::OutputConnectorMapType::const_iterator i 
437       = bbGetOutputConnectorMap().find("Widget");
438     
439     if ( i->second->GetConnectionVector().size() != 0 ) 
440       {
441         bbtkWarning("Execution called on '"<<bbGetFullName()
442                     <<"' although its Output 'Widget' is connected: "
443                     <<"if the widget is not created yet then it will not be! "
444                     <<"Execute the top level Layout widget to create and "
445                     <<"display the widget.");
446       }
447
448     AtomicBlackBox::bbExecute(force);
449
450     bbtkDebugMessageDec("process",2,
451                         "<= WxBlackBox::bbExecute() ["
452                         <<bbGetFullName()<<"]"<<std::endl);
453   }
454   //=========================================================================
455
456
457   //=========================================================================
458   void WxBlackBox::bbProcess()
459   { 
460 /*
461           if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
462           this->bbUserProcess(); 
463           bbShowWindow();
464           //    this->bbUserOnShow();
465           */
466     // LG 22/11/08 : new widget pipeline
467     // If output widget not connected : 
468     if ( (*bbGetOutputConnectorMap().find("Widget")).second
469          ->GetConnectionVector().size() == 0 ) 
470       {
471         Window* show = 0;
472         // If the window already exists : no need creating it
473         if (bbGetWindow()!=0)
474           {
475             bbtkDebugMessage("wx",2,
476                              "-> Window already exists"
477                              <<std::endl);
478             show = bbGetWindow();
479           }
480         // Else create window 
481         else 
482           {
483             bbtkDebugMessage("wx",2,
484                              "-> Creating the window"
485                              <<std::endl);
486             
487             
488             // Input WinDialog set to true : creating a Dialog
489             if (bbGetInputWinDialog()) 
490               {
491                 bbtkDebugMessage("wx",2,
492                                  "   Input WinDialog set to true : creating a Dialog"
493                                  <<std::endl);
494                 show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
495                                                        // bbGetWxParent(), 
496                                                        // LG 24/11/08 : New widget pipeline
497                                                        Wx::GetTopWindow(),
498                                                        std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
499                                                        wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
500               }
501             // Input WinDialog set to false : creating a Frame
502             else 
503               {
504                 bbtkDebugMessage("process",2,
505                                  "   Input WinDialog set to false : creating a Frame"
506                                  <<std::endl);
507                 show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
508                                                       // bbGetWxParent(), 
509                                                       // LG 24/11/08 : New widget pipeline
510                                                       Wx::GetTopWindow(),
511                                                       std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
512                                                       wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
513               }
514             
515           }
516         
517         // Show the window
518         show->bbShow(); 
519         
520         
521       }           
522     this->bbUserProcess(); 
523     
524   }
525   //=========================================================================
526  
527         
528         
529   // LG 24/11/08 : New widget pipeline
530   void WxBlackBox::bbCreateWidgetAndEventHandler(wxWindow* parent)
531   {
532     if (bbGetOutputWidget()==0)
533       {
534         this->bbUserCreateWidget(parent);
535       }         
536     // If Event Handler for the widget does not exist or is obsolete : create it 
537     if (bbGetOutputWidget()!=0)
538       {
539         if (bbGetWidgetEventHandler()==0)
540           {
541             bbtkDebugMessage("wx",3,
542                              "-> No widget event handler : creating one"
543                              <<std::endl);
544             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
545                                              bbGetOutputWidget());
546           }
547         else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
548                   ( bbGetOutputWidget() ) )
549           {
550             bbtkDebugMessage("wx",3,
551                              "-> Obsolete widget event handler : re-creating one"
552                              <<std::endl);
553             delete bbGetWidgetEventHandler();
554             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
555                                              bbGetOutputWidget());
556           }
557         // Sets the name of the wxWindow to the input WinTitle
558         bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
559       }
560     
561     
562   }
563   
564   
565   
566   wxWindow*  WxBlackBox::bbCreateWidgetOfInput(const std::string& in, wxWindow* parent)
567   {
568     wxWindow* w = 0;
569     // If input is connected 
570     BlackBoxInputConnector* c = bbGetInputConnectorMap().find(in)->second ;
571     if ( c->IsConnected() )                     
572       {
573         // Get black box from 
574         BlackBox::Pointer from = 
575           c->GetConnection()->GetBlackBoxFrom();
576         // Cast it into a WxBlackBox
577         WxBlackBox::Pointer wfrom = boost::dynamic_pointer_cast<WxBlackBox>(from);
578         // Call bbCreateWidgetAndEventHandler
579         wfrom->bbCreateWidgetAndEventHandler(parent);
580         // Get the widget created
581         w = wfrom->bbGetOutputWidget();
582       }
583     return w;
584   }
585   
586   /*
587   //==================================================================
588   /// Specific methods for window creation during pipeline execution
589   /// Shows the window associated to the box 
590   /// (called after bbProcess during bbExecute)
591   void WxBlackBox::bbShowWindow()
592   {
593     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
594                         <<bbGetFullName()<<"]"<<std::endl);
595  
596     // If Event Handler for the widget does not exist or is obsolete : create it 
597     if (bbGetOutputWidget()!=0)
598       {
599         if (bbGetWidgetEventHandler()==0)
600           {
601             bbtkDebugMessage("wx",3,
602                              "-> No widget event handler : creating one"
603                              <<std::endl);
604             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
605                                              bbGetOutputWidget());
606           }
607         else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
608                   ( bbGetOutputWidget() ) )
609           {
610             bbtkDebugMessage("wx",3,
611                              "-> Obsolete widget event handler : re-creating one"
612                              <<std::endl);
613             delete bbGetWidgetEventHandler();
614             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
615                                              bbGetOutputWidget());
616           }
617         // Sets the name of the wxWindow to the input WinTitle
618         bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
619       }
620
621     // If the output 'Widget' is connected then it's gonna 
622     // be captured by its parent window : nothing to do 
623     if ( (*bbGetOutputConnectorMap().find("Widget")).second
624          ->GetConnectionVector().size() != 0 ) 
625       {
626         
627         bbtkDebugMessage("wx",2,
628                          "-> Output 'Widget' connected : nothing to do"
629                          <<std::endl);
630         return;
631       }
632
633
634     Window* show = 0;
635     // If the window already exists : no need creating it
636     if (bbGetWindow()!=0)
637       {
638         bbtkDebugMessage("wx",2,
639                          "-> Window already exists"
640                          <<std::endl);
641         show = bbGetWindow();
642       }
643     // Else if the widget exists : create window 
644     else if (bbGetOutputWidget()!=0) 
645       {
646         bbtkDebugMessage("wx",2,
647                          "-> Widget exists : creating the window"
648                          <<std::endl);
649
650
651         // Input WinDialog set to true : creating a Dialog
652         if (bbGetInputWinDialog()) 
653           {
654             bbtkDebugMessage("wx",2,
655                              "   Input WinDialog set to true : creating a Dialog"
656                              <<std::endl);
657             show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
658                                                   // bbGetWxParent(), 
659                                                                                           // LG 24/11/08 : New widget pipeline
660                                                                                           Wx::GetTopWindow(),
661                                                    std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
662                                                    wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
663           }
664         // Input WinDialog set to false : creating a Frame
665         else 
666           {
667             bbtkDebugMessage("process",2,
668                              "   Input WinDialog set to false : creating a Frame"
669                              <<std::endl);
670             show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
671                                                   // bbGetWxParent(), 
672                                                                                          // LG 24/11/08 : New widget pipeline
673                                                                                          Wx::GetTopWindow(),
674                                                   std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
675                                                   wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
676           }
677
678       }
679     // No window nor widget : error
680     else
681       {
682         bbtkError("WxBlackBox::bbShowWindow() ["
683                   <<bbGetFullName()
684                   <<"] : No widget. Did you set the box output 'Widget' in the processing method of the box ?");
685       }
686  
687     
688     // Show the window
689     if (true) //!show->IsShown())
690       {
691         show->bbShow(); 
692       }
693     else 
694       {
695         bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
696       }
697   
698
699     bbtkDebugMessage("wx",2,"<= WxBlackBox::bbShowWindow() ["
700                         <<bbGetFullName()<<"]"<<std::endl);
701
702   }
703   //==================================================================
704 */
705
706
707
708   //==================================================================
709    void WxBlackBox::bbHideWindow()
710   {
711     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbHideWindow() ["
712                         <<bbGetFullName()<<"]"<<std::endl);
713
714     if (bbGetWindow()!=0) bbGetWindow()->bbHide();
715
716     bbtkDebugMessageDec("wx",2,"<= WxBlackBox::bbHideWindow() ["
717                         <<bbGetFullName()<<"]"<<std::endl);
718   }
719   //==================================================================
720
721
722   //==================================================================
723    void WxBlackBox::bbCloseWindow()
724   {
725     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbCloseWindow() ["
726                         <<bbGetFullName()<<"]"<<std::endl);
727
728     if (bbGetWindow()!=0) bbGetWindow()->bbClose();
729
730     bbtkDebugMessageDec("wx",2,"<= WxBlackBox::bbCloseWindow() ["
731                         <<bbGetFullName()<<"]"<<std::endl);
732   }
733   //==================================================================
734
735   //==================================================================
736   WxBlackBox::Window* WxBlackBox::bbGetContainingWindow()
737   {
738     if (bbGetWindow()!=0) return bbGetWindow();
739     BlackBox::OutputConnectorMapType::const_iterator i 
740       = bbGetOutputConnectorMap().find("Widget");
741     if ( i->second->GetConnectionVector().size() != 0 ) 
742       {
743         return boost::static_pointer_cast<WxBlackBox>
744           (i->second->GetConnectionVector().front() //.lock()
745            ->GetBlackBoxTo())->bbGetContainingWindow();
746       }
747     return 0;
748   }
749   //==================================================================
750
751
752   //==================================================================
753         // LG 24/11/08 : New widget pipeline
754         //  wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
755   //==================================================================
756   
757   
758   //==================================================================
759   bool WxBlackBox::bbIsShown()
760   {
761     if (bbGetContainingWindow()!=0)
762       return bbGetContainingWindow()->bbIsShown();
763     return false;
764   }
765   //==================================================================
766
767
768 }//namespace bbtk
769
770
771 #endif
772