3 # ---------------------------------------------------------------------
5 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
7 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
9 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
11 # This software is governed by the CeCILL-B license under French law and
12 # abiding by the rules of distribution of free software. You can use,
13 # modify and/ or redistribute the software under the terms of the CeCILL-B
14 # license as circulated by CEA, CNRS and INRIA at the following URL
15 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
16 # or in the file LICENSE.txt.
18 # As a counterpart to the access to the source code and rights to copy,
19 # modify and redistribute granted by the license, users are provided only
20 # with a limited warranty and the software's author, the holder of the
21 # economic rights, and the successive licensors have only limited
24 # The fact that you are presently reading this means that you have had
25 # knowledge of the CeCILL-B license and that you accept its terms.
26 # ------------------------------------------------------------------------ */
29 /*=========================================================================
31 Module: $RCSfile: bbtkWxBlackBox.cxx,v $
33 Date: $Date: 2012/11/16 08:49:01 $
34 Version: $Revision: 1.45 $
35 =========================================================================*/
46 #include "bbtkWtBlackBox.h"
47 #include "bbtkBlackBoxOutputConnector.h"
50 //#include "bbtkWxContainerBlackBox.h"
51 //#include <wx/dialog.h>
53 //#include "bbtkData.h"
54 //#include "bbtkFactory.h"
68 std::string jScriptLine;
71 //=========================================================================
73 //=========================================================================
75 // For the very first contruction of the application
76 /* struct wtServerData
86 Wt::WContainerWidget *parent;
87 WtBlackBox::Pointer b;
96 // static bbtk::jScript* js = new bbtk::jScript();
97 static wtData myWtData;
98 // static wtServerData loadedJS;
99 //static std::string* jss;
103 //=========================================================================
105 //=========================================================================
106 //Contains all the JS statements needed for the bbwt.
109 //=========================================================================
111 //=========================================================================
112 // Application WT deployed
113 //==================================================================
117 class WtWFrame : public Wt::WApplication
121 const Wt::WEnvironment& env
127 WtBlackBox::WeakPointer mBox;
134 const Wt::WEnvironment& env
137 Wt::WApplication(env)
139 //std::cout<<"Adding JavaScript -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
140 //this->require("/home/gonzalez/Documents/CREATOOLS/wt_library/wt/bbtk_wt_PKG/src/js/xtk.js");
142 //this->require("http://get.goXTK.com/xtk.js");
143 //this->useStyleSheet("css/demo.css");
145 // this->require("http://get.goXTK.com/xtk_edge.js");
146 this->require("http://get.goXTK.com/xtk_xdat.gui.js");
147 //this->require("http://get.goXTK.com/xtk.js");
148 this->require("xtk.js");
149 //this->require("xtk_xdat.gui.js");
150 this->useStyleSheet("styleWT.css");
153 // std::cout<<"Cargado------------ "<<loadedJS<<std::endl;
158 std::cout<<" SIN PADRE "<<std::endl;
159 if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
160 if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
161 myWtData.parent = new Wt::WContainerWidget();
162 std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
165 Wt::WContainerWidget *myCont = new Wt::WContainerWidget(myWtData.parent);
166 myCont->setMinimumSize(800,500);
167 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
168 myWtData.b->bbUserCreateWidget(myCont);
169 root()->addWidget(myWtData.parent);
170 //bbmWindow = myCont;
172 //jss = WtBlackBox::jScript;
173 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................80%"<<std::endl;
174 std::cout<<"Creando WebWIDGET DELETE ME SCRIPT : ---"<<bbtk::jScript<<".................80%"<<std::endl;
175 //this->doJavaScript(bbtk::jScript);
179 //==================================================================
180 //==================================================================
181 WtWFrame::~WtWFrame()
184 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
185 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
188 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
189 bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
190 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
191 WWt::DecNbWindowsAlive();
197 Wt::WApplication *createApplication(const Wt::WEnvironment& env)
199 return new WtWFrame(env);
203 //=========================================================================
204 // WxDialogWxBlackBox::Pointer box
205 //=========================================================================
207 //==================================================================
208 // Dialog window which is modal
209 /* class BBTK_EXPORT WxDialog : public wxDialog
212 WxDialog(WxBlackBox::Pointer box,
216 ~WxDialog();Wt::GetTopWindow()
217 void OnCloseWindow(wxCloseEvent& event);
220 WxBlackBox::WeakPointer mBox;
221 DECLARE_EVENT_TABLE();
225 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
226 EVT_CLOSE(WxDialog::OnCloseWindow)
228 //=========================================================================
230 //=========================================================================
231 WxDialog::WxDialog(WxBlackBox::Pointer b,
250 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
251 <<std::endl);WxBlackBox::Pointer box
252 Wx::IncNbWindowsAlive();
253 b->bbSetWindow(this);
254 // Insert the widget into the window
255 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
256 b->bbUserCreateWidget(this);
257 wxWindow* widget = b->bbGetOutputWidget();
258 sizer->Add( widget, 1, wxALL|wxGROW, 2);
262 //==================================================================
263 //===========================organise=======================================
264 WxDialog::~WxDialog()
266 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
267 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
268 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
269 // Wx::DecNbWindowsAlive();
271 //==================================================================
272 //==================================================================
273 void WxDialog::OnCloseWindow(wxCloseEvent& event)
275 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<wxGUIEditorGraphicBBS:std::endl);
276 if (mBox.lock()) mBox.lock()->bbSetWindow(0); http://doodle.com/qx65tfxismf7d6ku5vxykghs/admin#table
277 Wx::DecNbWindowsAlive();
280 //==================================================================
283 //=========================================================================
285 //=========================================================================
287 //=========================================================================
288 //=========================================================================
289 //=========================================================================
290 //=========================================================================
291 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
293 //std::string WtBlackBox::wtServerData::docRoot = "/home/gonzalez/Documents/pruebaResources";
294 //std::string WtBlackBox::wtServerData::docRoot = "/usr/local/share/wtResources";
295 //std::string WtBlackBox::wtServerData::port = "8081";
297 std::string WtBlackBox::wtServerData::docRoot = "<void>";
298 std::string WtBlackBox::wtServerData::port = "<void>";
299 std::string WtBlackBox::wtServerData::address = "0.0.0.0";
301 //=========================================================================
302 //=========================================================================
303 void WtBlackBox::bbUserSetDefaultValues()
305 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
307 /* WtBlackBox::serData.docRoot = "/home/gonzalez/Documents/pruebaResources";
308 WtBlackBox::serData.address = "0.0.0.0";
309 WtBlackBox::serData.port = "8080";*/
313 //=========================================================================
315 //=========================================================================
316 void WtBlackBox::bbUserInitializeProcessing()
320 //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
322 //=========================================================================
323 void WtBlackBox::bbUserFinalizeProcessing()
325 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
327 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
329 //==================================================================
331 //==================================================================
332 /// Callback for creating a Dialog window (modal)
333 void WtBlackBox::bbCreateDialogWindow()
335 bbtkBlackBoxDebugMessage("widget",3,
336 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
340 //=========================================================================
342 //==================================================================
344 //==================================================================
345 /// Callback for creating a Frame window
346 void WtBlackBox::bbCreateFrameWindow()
349 bbtkBlackBoxDebugMessage("widget",3,
350 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
351 <<WWt::GetTopWindow()
354 //Setting necessary data for Wt server deployment
355 myWtData.parent = WWt::GetTopWindow();
356 myWtData.b = GetThisPointer<WtBlackBox>();
357 myWtData.title = std2wt( bbGetInputWinTitle()
358 + " - bbtk (c) CREATIS");
365 //char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
369 char *argv[7] = {"./WtTest","--docroot",(char*)WtBlackBox::wtServerData::docRoot.c_str(),"--http-address",(char*)WtBlackBox::wtServerData::address.c_str(),"--http-port",(char*)WtBlackBox::wtServerData::port.c_str()};
372 std::cout<<" --- PUERTO :"<<WtBlackBox::wtServerData::port<<std::endl;
374 /* if(Wt::WServer::instance()->isRunning())
376 std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
377 Wt::WServer::instance()->stop();
380 std::cout<<"Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
381 Wt::WRun(argc,argv,&createApplication);
384 //==================================================================
386 //==================================================================
387 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
389 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
390 if ((bbmWindow != 0)&&(w!=0))
392 std::cout << "ERRRRRRRROOOOR"<<std::endl;
399 //==================================================================
401 //==================================================================
402 void WtBlackBox::bbShowWindow()
404 if ((bbmWindow) && (!bbIsShown()))
406 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
408 if (bbGetInputWinDialog())
410 // ((WxDialog*)bbmWindow)->ShowModal();
414 // There is not such a thing like show becouse it is a webapp
415 // bbGetWindow()->Show();
416 // WWt::CreateWtAppIfNeeded();
421 //==================================================================
423 //==================================================================
424 void WtBlackBox::bbDestroyWindow()
426 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
427 if (bbGetWindow()!=NULL)
429 // wxWindow* w = bbGetWindow();
431 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
435 delete bbGetWindow();
438 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
441 //==================================================================