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"
49 //#include "bbtkWxContainerBlackBox.h"
50 //#include <wx/dialog.h>
52 //#include "bbtkData.h"
53 //#include "bbtkFactory.h"
67 std::string jScriptLine;
70 //=========================================================================
72 //=========================================================================
74 // For the very first contruction of the application
77 Wt::WContainerWidget *parent;
78 WtBlackBox::Pointer b;
87 // static bbtk::jScript* js = new bbtk::jScript();
88 static wtData myWtData;
90 //static std::string* jss;
94 //=========================================================================
96 //=========================================================================
97 //Contains all the JS statements needed for the bbwt.
100 //=========================================================================
102 //=========================================================================
103 // Application WT deployed
104 //==================================================================
108 class WtWFrame : public Wt::WApplication
112 const Wt::WEnvironment& env
118 WtBlackBox::WeakPointer mBox;
125 const Wt::WEnvironment& env
128 Wt::WApplication(env)
130 //std::cout<<"Adding JavaScript -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
131 //this->require("/home/gonzalez/Documents/CREATOOLS/wt_library/wt/bbtk_wt_PKG/src/js/xtk.js");
133 //this->require("http://get.goXTK.com/xtk.js");
134 //this->useStyleSheet("css/demo.css");
136 // this->require("http://get.goXTK.com/xtk_edge.js");
137 this->require("http://get.goXTK.com/xtk_xdat.gui.js");
138 this->require("xtk.js");
139 //this->require("xtk_xdat.gui.js");
140 this->useStyleSheet("style.css");
143 std::cout<<"Cargado------------ "<<loadedJS<<std::endl;
148 std::cout<<" SIN PADRE "<<std::endl;
149 if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
150 if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
151 myWtData.parent = new Wt::WContainerWidget();
152 std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
155 Wt::WContainerWidget *myCont = new Wt::WContainerWidget(myWtData.parent);
156 myCont->setMinimumSize(800,500);
157 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
158 myWtData.b->bbUserCreateWidget(myCont);
159 root()->addWidget(myWtData.parent);
160 //bbmWindow = myCont;
162 //jss = WtBlackBox::jScript;
163 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................80%"<<std::endl;
164 std::cout<<"Creando WebWIDGET DELETE ME SCRIPT : ---"<<bbtk::jScript<<".................80%"<<std::endl;
165 //this->doJavaScript(bbtk::jScript);
169 //==================================================================
170 //==================================================================
171 WtWFrame::~WtWFrame()
174 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
175 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
178 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
179 bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
180 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
181 WWt::DecNbWindowsAlive();
187 Wt::WApplication *createApplication(const Wt::WEnvironment& env)
189 return new WtWFrame(env);
193 //=========================================================================
194 // WxDialogWxBlackBox::Pointer box
195 //=========================================================================
197 //==================================================================
198 // Dialog window which is modal
199 /* class BBTK_EXPORT WxDialog : public wxDialog
202 WxDialog(WxBlackBox::Pointer box,
206 ~WxDialog();Wt::GetTopWindow()
207 void OnCloseWindow(wxCloseEvent& event);
210 WxBlackBox::WeakPointer mBox;
211 DECLARE_EVENT_TABLE();
215 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
216 EVT_CLOSE(WxDialog::OnCloseWindow)
218 //=========================================================================
220 //=========================================================================
221 WxDialog::WxDialog(WxBlackBox::Pointer b,
240 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
241 <<std::endl);WxBlackBox::Pointer box
242 Wx::IncNbWindowsAlive();
243 b->bbSetWindow(this);
244 // Insert the widget into the window
245 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
246 b->bbUserCreateWidget(this);
247 wxWindow* widget = b->bbGetOutputWidget();
248 sizer->Add( widget, 1, wxALL|wxGROW, 2);
252 //==================================================================
253 //==================================================================
254 WxDialog::~WxDialog()
256 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
257 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
258 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
259 // Wx::DecNbWindowsAlive();
261 //==================================================================
262 //==================================================================
263 void WxDialog::OnCloseWindow(wxCloseEvent& event)
265 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<wxGUIEditorGraphicBBS:std::endl);
266 if (mBox.lock()) mBox.lock()->bbSetWindow(0); http://doodle.com/qx65tfxismf7d6ku5vxykghs/admin#table
267 Wx::DecNbWindowsAlive();
270 //==================================================================
273 //=========================================================================
275 //=========================================================================
277 //=========================================================================
278 //=========================================================================
279 //=========================================================================
280 //=========================================================================
281 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
285 //=========================================================================
286 //=========================================================================
287 void WtBlackBox::bbUserSetDefaultValues()
289 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
292 //=========================================================================
294 //=========================================================================
295 void WtBlackBox::bbUserInitializeProcessing()
299 //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
301 //=========================================================================
302 void WtBlackBox::bbUserFinalizeProcessing()
304 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
306 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
308 //==================================================================
310 //==================================================================
311 /// Callback for creating a Dialog window (modal)
312 void WtBlackBox::bbCreateDialogWindow()
314 bbtkBlackBoxDebugMessage("widget",3,
315 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
319 //=========================================================================
321 //==================================================================
323 //==================================================================
324 /// Callback for creating a Frame window
325 void WtBlackBox::bbCreateFrameWindow()
328 bbtkBlackBoxDebugMessage("widget",3,
329 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
330 <<WWt::GetTopWindow()
333 //Setting necessary data for Wt server deployment
334 myWtData.parent = WWt::GetTopWindow();
335 myWtData.b = GetThisPointer<WtBlackBox>();
336 myWtData.title = std2wt( bbGetInputWinTitle()
337 + " - bbtk (c) CREATIS");
339 std::cout<<"Creating Container WT -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
340 char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
342 /* if(Wt::WServer::instance()->isRunning())
344 std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
345 Wt::WServer::instance()->stop();
348 std::cout<<"Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
349 Wt::WRun(argc,argv,&createApplication);
352 //==================================================================
354 //==================================================================
355 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
357 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
358 if ((bbmWindow != 0)&&(w!=0))
360 std::cout << "ERRRRRRRROOOOR"<<std::endl;
367 //==================================================================
369 //==================================================================
370 void WtBlackBox::bbShowWindow()
372 if ((bbmWindow) && (!bbIsShown()))
374 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
376 if (bbGetInputWinDialog())
378 // ((WxDialog*)bbmWindow)->ShowModal();
382 // There is not such a thing like show becouse it is a webapp
383 // bbGetWindow()->Show();
384 // WWt::CreateWtAppIfNeeded();
389 //==================================================================
391 //==================================================================
392 void WtBlackBox::bbDestroyWindow()
394 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
395 if (bbGetWindow()!=NULL)
397 // wxWindow* w = bbGetWindow();
399 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
403 delete bbGetWindow();
406 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
409 //==================================================================