]> Creatis software - bbtk.git/blob - kernel/src/bbtkWxBlackBox.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkWxBlackBox.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkWxBlackBox.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/10/17 08:18:14 $
6   Version:   $Revision: 1.27 $
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() ["
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     // If the caller's box to is not the box to connected to the 
463     // output 'Widget'
464     if ( ! (( bbGetStatus() == MODIFIED ) ||
465             ( bbBoxProcessModeIsAlways() )) )
466       {
467         bbtkDebugMessage("process",3,"Up-to-date : nothing to do"<<std::endl);
468         bbtkDebugMessage("process",3,
469                          "<= WxBlackBox::bbBackwardUpdate("
470                          <<(caller?caller->GetFullName():"0")<<") ["
471                          <<bbGetFullName()<<"]"<<std::endl);
472         return bbGetStatus();
473       }
474  
475     BlackBox::OutputConnectorMapType::const_iterator i 
476       = bbGetOutputConnectorMap().find("Widget") ;
477     if ( i->second->GetConnectionVector().size() != 0 )
478       
479       {
480         BlackBox::Pointer to = 
481           i->second->GetConnectionVector()[0]->GetBlackBoxTo();
482                 
483         if (caller) 
484           {
485             bbtkDebugMessage("process",3,
486                              "-> Output 'Widget' connected to '"
487                              <<to->bbGetFullName()<<"' - caller->to = '"
488                              <<caller->GetBlackBoxTo()->bbGetFullName()
489                              <<"'"
490                              <<std::endl);
491           }
492         else
493           {
494             bbtkDebugMessage("process",3,
495                              "-> Output 'Widget' connected to '"
496                              <<to->bbGetFullName()<<"'"
497                              <<std::endl);
498           }
499         if ((caller==0) ||
500             ((caller!=0) && 
501              (caller->GetBlackBoxTo() != to))&&
502             (!bbGetUpdateTransferedToParent())&&
503             (to->bbGetStatus()!=UPDATING))
504           {
505             bbtkDebugMessage("process",3,
506                              "   ... Transfering update order to parent"
507                              <<std::endl);
508             
509             bbSetUpdateTransferedToParent(true);
510             i->second->GetConnectionVector().front() //.lock()
511               ->GetBlackBoxTo()->bbExecute(false);
512           }
513         else
514           {
515             bbSetUpdateTransferedToParent(false);
516             bbtkDebugMessage("process",3,
517                              "   ... No need to transfer to parent"
518                              <<std::endl);
519           }
520       }
521     /*    
522
523     // If the caller is not the connection to the output widget
524     // and the output 'Widget' is connected then 
525     // we must execute the parent box 
526     // but only one time 
527     // (this is the role of the flag UpdateTransferedToParent)
528     if ( (caller==0) ||
529          ((caller!=0)&&(caller->GetBlackBoxFromOutput()!="Widget"))
530          )
531       {
532       }
533     */
534     // call 'standard' BlackBox execution method
535     if (!bbGetUpdateTransferedToParent()) 
536       { 
537           AtomicBlackBox::bbBackwardUpdate(caller);
538       }
539     
540     bbtkDebugMessageDec("process",3,
541                         "<= WxBlackBox::bbBackwardUpdate() ["
542                         <<bbGetFullName()<<"]"<<std::endl);
543     
544    return bbGetStatus();
545      
546
547   }
548
549   //=========================================================================
550   void WxBlackBox::bbProcess()
551   { 
552     if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
553     this->bbUserProcess(); 
554     bbShowWindow();
555     //    this->bbUserOnShow();
556   }
557   //=========================================================================
558   
559   //==================================================================
560   /// Specific methods for window creation during pipeline execution
561   /// Shows the window associated to the box 
562   /// (called after bbProcess during bbExecute)
563   void WxBlackBox::bbShowWindow()
564   {
565     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
566                         <<bbGetFullName()<<"]"<<std::endl);
567  
568     // If Event Handler for the widget does not exist or is obsolete : create it 
569     if (bbGetOutputWidget()!=0)
570       {
571         if (bbGetWidgetEventHandler()==0)
572           {
573             bbtkDebugMessage("wx",3,
574                              "-> No widget event handler : creating one"
575                              <<std::endl);
576             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
577                                              bbGetOutputWidget());
578           }
579         else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
580                   ( bbGetOutputWidget() ) )
581           {
582             bbtkDebugMessage("wx",3,
583                              "-> Obsolete widget event handler : re-creating one"
584                              <<std::endl);
585             delete bbGetWidgetEventHandler();
586             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
587                                              bbGetOutputWidget());
588           }
589         // Sets the name of the wxWindow to the input WinTitle
590         bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
591       }
592
593     // If the output 'Widget' is connected then it's gonna 
594     // be captured by its parent window : nothing to do 
595     if ( (*bbGetOutputConnectorMap().find("Widget")).second
596          ->GetConnectionVector().size() != 0 ) 
597       {
598         
599         bbtkDebugMessage("wx",2,
600                          "-> Output 'Widget' connected : nothing to do"
601                          <<std::endl);
602         return;
603       }
604
605
606     Window* show = 0;
607     // If the window already exists : no need creating it
608     if (bbGetWindow()!=0)
609       {
610         bbtkDebugMessage("wx",2,
611                          "-> Window already exists"
612                          <<std::endl);
613         show = bbGetWindow();
614       }
615     // Else if the widget exists : create window 
616     else if (bbGetOutputWidget()!=0) 
617       {
618         bbtkDebugMessage("wx",2,
619                          "-> Widget exists : creating the window"
620                          <<std::endl);
621
622
623         // Input WinDialog set to true : creating a Dialog
624         if (bbGetInputWinDialog()) 
625           {
626             bbtkDebugMessage("wx",2,
627                              "   Input WinDialog set to true : creating a Dialog"
628                              <<std::endl);
629             show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
630                                                    bbGetWxParent(), 
631                                                    std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
632                                                    wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
633           }
634         // Input WinDialog set to false : creating a Frame
635         else 
636           {
637             bbtkDebugMessage("process",2,
638                              "   Input WinDialog set to false : creating a Frame"
639                              <<std::endl);
640             show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
641                                                   bbGetWxParent(), 
642                                                   std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
643                                                   wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
644           }
645
646       }
647     // No window nor widget : error
648     else
649       {
650         bbtkError("WxBlackBox::bbShowWindow() ["
651                   <<bbGetFullName()
652                   <<"] : No widget. Did you set the box output 'Widget' in the processing method of the box ?");
653       }
654  
655     
656     // Show the window
657     if (true) //!show->IsShown())
658       {
659         show->bbShow(); 
660       }
661     else 
662       {
663         bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
664       }
665   
666
667     bbtkDebugMessage("wx",1,"<= WxBlackBox::bbShowWindow() ["
668                         <<bbGetFullName()<<"]"<<std::endl);
669
670   }
671   //==================================================================
672
673
674
675
676   //==================================================================
677    void WxBlackBox::bbHideWindow()
678   {
679     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbHideWindow() ["
680                         <<bbGetFullName()<<"]"<<std::endl);
681
682     if (bbGetWindow()!=0) bbGetWindow()->bbHide();
683
684     bbtkDebugMessageDec("wx",1,"<= WxBlackBox::bbHideWindow() ["
685                         <<bbGetFullName()<<"]"<<std::endl);
686   }
687   //==================================================================
688
689
690   //==================================================================
691    void WxBlackBox::bbCloseWindow()
692   {
693     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbCloseWindow() ["
694                         <<bbGetFullName()<<"]"<<std::endl);
695
696     if (bbGetWindow()!=0) bbGetWindow()->bbClose();
697
698     bbtkDebugMessageDec("wx",1,"<= WxBlackBox::bbCloseWindow() ["
699                         <<bbGetFullName()<<"]"<<std::endl);
700   }
701   //==================================================================
702
703   //==================================================================
704   WxBlackBox::Window* WxBlackBox::bbGetContainingWindow()
705   {
706     if (bbGetWindow()!=0) return bbGetWindow();
707     BlackBox::OutputConnectorMapType::const_iterator i 
708       = bbGetOutputConnectorMap().find("Widget");
709     if ( i->second->GetConnectionVector().size() != 0 ) 
710       {
711         return boost::static_pointer_cast<WxBlackBox>
712           (i->second->GetConnectionVector().front() //.lock()
713            ->GetBlackBoxTo())->bbGetContainingWindow();
714       }
715     return 0;
716   }
717   //==================================================================
718
719
720   //==================================================================
721   wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
722   //==================================================================
723   
724   
725   //==================================================================
726   bool WxBlackBox::bbIsShown()
727   {
728     if (bbGetContainingWindow()!=0)
729       return bbGetContainingWindow()->bbIsShown();
730     return false;
731   }
732   //==================================================================
733
734
735 }//namespace bbtk
736
737
738 #endif
739