]> 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/12/08 14:02:15 $
6   Version:   $Revision: 1.34 $
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           /*
437     BlackBox::OutputConnectorMapType::const_iterator i 
438       = bbGetOutputConnectorMap().find("Widget");
439     
440     if ( i->second->GetConnectionVector().size() != 0 ) 
441       {
442         bbtkWarning("Execution called on '"<<bbGetFullName()
443                     <<"' although its Output 'Widget' is connected: "
444                     <<"if the widget is not created yet then it will not be! "
445                     <<"Execute the top level Layout widget to create and "
446                     <<"display the widget.");
447       }
448 */
449     AtomicBlackBox::bbExecute(force);
450
451     bbtkDebugMessageDec("process",2,
452                         "<= WxBlackBox::bbExecute() ["
453                         <<bbGetFullName()<<"]"<<std::endl);
454   }
455   //=========================================================================
456
457
458   //=========================================================================
459   void WxBlackBox::bbProcess()
460   { 
461 /*
462           if (bbGetOutputWidget()==0) this->bbUserCreateWidget();
463           this->bbUserProcess(); 
464           bbShowWindow();
465           //    this->bbUserOnShow();
466           */
467     // LG 22/11/08 : new widget pipeline
468     // If output widget not connected : 
469     if ( (*bbGetOutputConnectorMap().find("Widget")).second
470          ->GetConnectionVector().size() == 0 ) 
471       {
472         Window* show = 0;
473         // If the window already exists : no need creating it
474         if (bbGetWindow()!=0)
475           {
476             bbtkDebugMessage("wx",2,
477                              "-> Window already exists"
478                              <<std::endl);
479             show = bbGetWindow();
480           }
481         // Else create window 
482         else 
483           {
484             bbtkDebugMessage("wx",2,
485                              "-> Creating the window"
486                              <<std::endl);
487             
488             
489             // Input WinDialog set to true : creating a Dialog
490             if (bbGetInputWinDialog()) 
491               {
492                 bbtkDebugMessage("wx",2,
493                                  "   Input WinDialog set to true : creating a Dialog"
494                                  <<std::endl);
495                 show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
496                                                        // bbGetWxParent(), 
497                                                        // LG 24/11/08 : New widget pipeline
498                                                        Wx::GetTopWindow(),
499                                                        std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
500                                                        wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
501               }
502             // Input WinDialog set to false : creating a Frame
503             else 
504               {
505                 bbtkDebugMessage("process",2,
506                                  "   Input WinDialog set to false : creating a Frame"
507                                  <<std::endl);
508                 show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
509                                                       // bbGetWxParent(), 
510                                                       // LG 24/11/08 : New widget pipeline
511                                                       Wx::GetTopWindow(),
512                                                       std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
513                                                       wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
514               }
515             
516           }
517         
518         // Show the window
519         show->bbShow(); 
520         
521         
522       }           
523     this->bbUserProcess(); 
524     
525   }
526   //=========================================================================
527  
528         
529         
530   // LG 24/11/08 : New widget pipeline
531   void WxBlackBox::bbCreateWidgetAndEventHandler(wxWindow* parent)
532   {
533     if (bbGetOutputWidget()==0)
534       {
535         this->bbUserCreateWidget(parent);
536       }         
537     // If Event Handler for the widget does not exist or is obsolete : create it 
538     if (bbGetOutputWidget()!=0)
539       {
540         if (bbGetWidgetEventHandler()==0)
541           {
542             bbtkDebugMessage("wx",3,
543                              "-> No widget event handler : creating one"
544                              <<std::endl);
545             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
546                                              bbGetOutputWidget());
547           }
548         else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
549                   ( bbGetOutputWidget() ) )
550           {
551             bbtkDebugMessage("wx",3,
552                              "-> Obsolete widget event handler : re-creating one"
553                              <<std::endl);
554             delete bbGetWidgetEventHandler();
555             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
556                                              bbGetOutputWidget());
557           }
558         // Sets the name of the wxWindow to the input WinTitle
559         bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
560       }
561     
562     
563   }
564   
565   
566   
567   wxWindow*  WxBlackBox::bbCreateWidgetOfInput(const std::string& in, wxWindow* parent)
568   {
569     wxWindow* w = 0;
570     // If input is connected 
571     BlackBoxInputConnector* c = bbGetInputConnectorMap().find(in)->second ;
572     if ( c->IsConnected() )                     
573       {
574         // Get black box from 
575         BlackBox::Pointer from = 
576           c->GetConnection()->GetBlackBoxFrom();
577         // Cast it into a WxBlackBox
578         WxBlackBox::Pointer wfrom = boost::dynamic_pointer_cast<WxBlackBox>(from);
579         // Call bbCreateWidgetAndEventHandler
580         wfrom->bbCreateWidgetAndEventHandler(parent);
581         // Get the widget created
582         w = wfrom->bbGetOutputWidget();
583       }
584     return w;
585   }
586   
587   /*
588   //==================================================================
589   /// Specific methods for window creation during pipeline execution
590   /// Shows the window associated to the box 
591   /// (called after bbProcess during bbExecute)
592   void WxBlackBox::bbShowWindow()
593   {
594     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbShowWindow() ["
595                         <<bbGetFullName()<<"]"<<std::endl);
596  
597     // If Event Handler for the widget does not exist or is obsolete : create it 
598     if (bbGetOutputWidget()!=0)
599       {
600         if (bbGetWidgetEventHandler()==0)
601           {
602             bbtkDebugMessage("wx",3,
603                              "-> No widget event handler : creating one"
604                              <<std::endl);
605             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
606                                              bbGetOutputWidget());
607           }
608         else if ( ! bbGetWidgetEventHandler()->IsHandlerOf 
609                   ( bbGetOutputWidget() ) )
610           {
611             bbtkDebugMessage("wx",3,
612                              "-> Obsolete widget event handler : re-creating one"
613                              <<std::endl);
614             delete bbGetWidgetEventHandler();
615             new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
616                                              bbGetOutputWidget());
617           }
618         // Sets the name of the wxWindow to the input WinTitle
619         bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
620       }
621
622     // If the output 'Widget' is connected then it's gonna 
623     // be captured by its parent window : nothing to do 
624     if ( (*bbGetOutputConnectorMap().find("Widget")).second
625          ->GetConnectionVector().size() != 0 ) 
626       {
627         
628         bbtkDebugMessage("wx",2,
629                          "-> Output 'Widget' connected : nothing to do"
630                          <<std::endl);
631         return;
632       }
633
634
635     Window* show = 0;
636     // If the window already exists : no need creating it
637     if (bbGetWindow()!=0)
638       {
639         bbtkDebugMessage("wx",2,
640                          "-> Window already exists"
641                          <<std::endl);
642         show = bbGetWindow();
643       }
644     // Else if the widget exists : create window 
645     else if (bbGetOutputWidget()!=0) 
646       {
647         bbtkDebugMessage("wx",2,
648                          "-> Widget exists : creating the window"
649                          <<std::endl);
650
651
652         // Input WinDialog set to true : creating a Dialog
653         if (bbGetInputWinDialog()) 
654           {
655             bbtkDebugMessage("wx",2,
656                              "   Input WinDialog set to true : creating a Dialog"
657                              <<std::endl);
658             show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
659                                                   // bbGetWxParent(), 
660                                                                                           // LG 24/11/08 : New widget pipeline
661                                                                                           Wx::GetTopWindow(),
662                                                    std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
663                                                    wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
664           }
665         // Input WinDialog set to false : creating a Frame
666         else 
667           {
668             bbtkDebugMessage("process",2,
669                              "   Input WinDialog set to false : creating a Frame"
670                              <<std::endl);
671             show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
672                                                   // bbGetWxParent(), 
673                                                                                          // LG 24/11/08 : New widget pipeline
674                                                                                          Wx::GetTopWindow(),
675                                                   std2wx( bbGetInputWinTitle()  + " - bbtk (c) CREATIS LRMN"),
676                                                   wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
677           }
678
679       }
680     // No window nor widget : error
681     else
682       {
683         bbtkError("WxBlackBox::bbShowWindow() ["
684                   <<bbGetFullName()
685                   <<"] : No widget. Did you set the box output 'Widget' in the processing method of the box ?");
686       }
687  
688     
689     // Show the window
690     if (true) //!show->IsShown())
691       {
692         show->bbShow(); 
693       }
694     else 
695       {
696         bbtkDebugMessage("wx",2,"-> Already shown : nothing to do"<<std::endl);
697       }
698   
699
700     bbtkDebugMessage("wx",2,"<= WxBlackBox::bbShowWindow() ["
701                         <<bbGetFullName()<<"]"<<std::endl);
702
703   }
704   //==================================================================
705 */
706
707
708
709   //==================================================================
710    void WxBlackBox::bbHideWindow()
711   {
712     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbHideWindow() ["
713                         <<bbGetFullName()<<"]"<<std::endl);
714
715     if (bbGetWindow()!=0) bbGetWindow()->bbHide();
716
717     bbtkDebugMessageDec("wx",2,"<= WxBlackBox::bbHideWindow() ["
718                         <<bbGetFullName()<<"]"<<std::endl);
719   }
720   //==================================================================
721
722
723   //==================================================================
724    void WxBlackBox::bbCloseWindow()
725   {
726     bbtkDebugMessageInc("wx",1,"=> WxBlackBox::bbCloseWindow() ["
727                         <<bbGetFullName()<<"]"<<std::endl);
728
729     if (bbGetWindow()!=0) bbGetWindow()->bbClose();
730
731     bbtkDebugMessageDec("wx",2,"<= WxBlackBox::bbCloseWindow() ["
732                         <<bbGetFullName()<<"]"<<std::endl);
733   }
734   //==================================================================
735
736   //==================================================================
737   WxBlackBox::Window* WxBlackBox::bbGetContainingWindow()
738   {
739     if (bbGetWindow()!=0) return bbGetWindow();
740     BlackBox::OutputConnectorMapType::const_iterator i 
741       = bbGetOutputConnectorMap().find("Widget");
742     if ( i->second->GetConnectionVector().size() != 0 ) 
743       {
744         return boost::static_pointer_cast<WxBlackBox>
745           (i->second->GetConnectionVector().front() //.lock()
746            ->GetBlackBoxTo())->bbGetContainingWindow();
747       }
748     return 0;
749   }
750   //==================================================================
751
752
753   //==================================================================
754         // LG 24/11/08 : New widget pipeline
755         //  wxWindow* WxBlackBox::bbGetWxParent() { return Wx::GetTopWindow(); }
756   //==================================================================
757   
758   
759   //==================================================================
760   bool WxBlackBox::bbIsShown()
761   {
762     if (bbGetContainingWindow()!=0)
763       return bbGetContainingWindow()->bbIsShown();
764     return false;
765   }
766   //==================================================================
767
768
769 }//namespace bbtk
770
771
772 #endif
773