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