2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkWxBlackBox.cxx,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.45 $
34 =========================================================================*/
45 #include "bbtkWtBlackBox.h"
46 #include "bbtkBlackBoxOutputConnector.h"
48 #include <Wt/WContainerWidget>
50 //#include "bbtkWxContainerBlackBox.h"
51 //#include <wx/dialog.h>
53 //#include "bbtkData.h"
54 //#include "bbtkFactory.h"
58 //=========================================================================
60 //=========================================================================
62 //==================================================================
63 class WtWContainer : public Wt::WContainerWidget
66 WtWContainer(WtBlackBox::Pointer b,
67 Wt::WContainerWidget *parent,
72 // void OnCloseWindow(wxCloseEvent& event);
75 WtBlackBox::WeakPointer mBox;
76 // DECLARE_EVENT_TABLE();
80 // BEGIN_EVENT_TABLE(WxFrame, wxFrame)
81 // EVT_CLOSE(WxFrame::OnCloseWindow)
83 //==================================================================
85 //==================================================================
87 WtWContainer::WtWContainer(WtBlackBox::Pointer b,
88 Wt::WContainerWidget *parent,
93 Wt::WContainerWidget( parent),
96 bbtkDebugMessage("widget",9,"["<<b->bbGetName()<<"] Wt::Widget()"
98 Wt::WObject::setObjectName(bbtk::wt2std(title));
99 WWt::IncNbWindowsAlive();
100 b->bbSetWindow(this);
101 // Insert the widget into the window
102 //wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
103 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................30%"<<std::endl;
104 std::cout<<"NAME : "<<bbtk::wt2std(title);
106 std::cout<<" CON PADRE "<<parent->objectName()<<std::endl;
108 std::cout<<" SIN PADRE "<<std::endl;
109 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
110 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................55%"<<std::endl;
111 //this->addWidget(new Wt::WContainerWidget());
112 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................58%"<<std::endl;
113 b->bbUserCreateWidget(this);
114 Wt::WContainerWidget* widget = b->bbGetOutputWidget();
115 this->addWidget(widget);
116 /* Wt::WWidget* widget = b->bbGetOutputWidget();
117 sizer->Add( widget, 1, wxALL|wxGROW, 2);
122 //==================================================================
123 //==================================================================
124 WtWContainer::~WtWContainer()
127 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
128 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
131 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
132 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
133 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
134 WWt::DecNbWindowsAlive();
139 //==================================================================
141 //=========================================================================
143 //=========================================================================
145 //==================================================================
146 // Dialog window which is modal
147 /* class BBTK_EXPORT WxDialog : public wxDialog
150 WxDialog(WxBlackBox::Pointer box,
155 void OnCloseWindow(wxCloseEvent& event);
158 WxBlackBox::WeakPointer mBox;
159 DECLARE_EVENT_TABLE();
163 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
164 EVT_CLOSE(WxDialog::OnCloseWindow)
166 //=========================================================================
168 //=========================================================================
169 WxDialog::WxDialog(WxBlackBox::Pointer b,
188 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
190 Wx::IncNbWindowsAlive();
191 b->bbSetWindow(this);
192 // Insert the widget into the window
193 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
194 b->bbUserCreateWidget(this);
195 wxWindow* widget = b->bbGetOutputWidget();
196 sizer->Add( widget, 1, wxALL|wxGROW, 2);
200 //==================================================================
201 //==================================================================
202 WxDialog::~WxDialog()
204 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
205 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
206 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
207 // Wx::DecNbWindowsAlive();
209 //==================================================================
210 //==================================================================
211 void WxDialog::OnCloseWindow(wxCloseEvent& event)
213 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<std::endl);
214 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
215 Wx::DecNbWindowsAlive();
218 //==================================================================
221 //=========================================================================
223 //=========================================================================
225 //=========================================================================
226 //=========================================================================
227 //=========================================================================
228 //=========================================================================
229 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
230 //=========================================================================
232 //=========================================================================
233 void WtBlackBox::bbUserSetDefaultValues()
235 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
238 //=========================================================================
240 //=========================================================================
241 void WtBlackBox::bbUserInitializeProcessing()
243 //TODO delete this commment
244 std::cout<<"Initializing WT BlackBox --- DELETE this message bbtkWtBlackBox.cxx"<<std::endl;
246 //==================================================================
248 //=========================================================================
249 void WtBlackBox::bbUserFinalizeProcessing()
251 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
253 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
255 //==================================================================
257 //==================================================================
258 /// Callback for creating a Dialog window (modal)
259 void WtBlackBox::bbCreateDialogWindow()
261 bbtkBlackBoxDebugMessage("widget",3,
262 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
265 w = new WxDialog( GetThisPointer<WxBlackBox>(),
267 std2wx( bbGetInputWinTitle()
268 + " - bbtk (c) CREATIS"),
269 wxSize( bbGetInputWinWidth() ,
270 bbGetInputWinHeight() ) );
275 //=========================================================================
277 //==================================================================
279 //==================================================================
280 /// Callback for creating a Frame window
281 void WtBlackBox::bbCreateFrameWindow()
284 std::cout<<"Creating Container WT -- DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
285 bbtkBlackBoxDebugMessage("widget",3,
286 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
287 <<WWt::GetTopWindow()
291 w = new WtWContainer( GetThisPointer<WtBlackBox>(),
293 std2wt( bbGetInputWinTitle()
294 + " - bbtk (c) CREATIS")
296 std::cout<<"Container created succesfully -- DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
300 w = new WxFrame( GetThisPointer<WxBlackBox>(),
302 std2wx( bbGetInputWinTitle()
303 + " - bbtk (c) CREATIS"),
304 wxSize( bbGetInputWinWidth() ,
305 bbGetInputWinHeight() ) );
309 WWt::CreateWtAppIfNeeded();
312 //==================================================================
314 //==================================================================
315 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
317 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
318 if ((bbmWindow != 0)&&(w!=0))
320 std::cout << "ERRRRRRRROOOOR"<<std::endl;
324 //==================================================================
326 //==================================================================
327 void WtBlackBox::bbShowWindow()
329 if ((bbmWindow) && (!bbIsShown()))
331 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
333 if (bbGetInputWinDialog())
335 // ((WxDialog*)bbmWindow)->ShowModal();
339 // There is not such a thing like show becouse it is a webapp
340 // bbGetWindow()->Show();
341 WWt::CreateWtAppIfNeeded();
346 //==================================================================
348 //==================================================================
349 void WtBlackBox::bbDestroyWindow()
351 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
352 if (bbGetWindow()!=NULL)
354 // wxWindow* w = bbGetWindow();
356 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
360 delete bbGetWindow();
363 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
366 //==================================================================