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
75 /* struct wtServerData
85 Wt::WContainerWidget *parent;
86 WtBlackBox::Pointer b;
95 // static bbtk::jScript* js = new bbtk::jScript();
96 static wtData myWtData;
97 // static wtServerData loadedJS;
98 //static std::string* jss;
102 //=========================================================================
104 //=========================================================================
105 //Contains all the JS statements needed for the bbwt.
108 //=========================================================================
110 //=========================================================================
111 // Application WT deployed
112 //==================================================================
116 class WtWFrame : public Wt::WApplication
120 const Wt::WEnvironment& env
126 WtBlackBox::WeakPointer mBox;
133 const Wt::WEnvironment& env
136 Wt::WApplication(env)
138 //std::cout<<"Adding JavaScript -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
139 //this->require("/home/gonzalez/Documents/CREATOOLS/wt_library/wt/bbtk_wt_PKG/src/js/xtk.js");
141 //this->require("http://get.goXTK.com/xtk.js");
142 //this->useStyleSheet("css/demo.css");
144 // this->require("http://get.goXTK.com/xtk_edge.js");
145 this->require("http://get.goXTK.com/xtk_xdat.gui.js");
146 this->require("xtk.js");
147 //this->require("xtk_xdat.gui.js");
148 this->useStyleSheet("style.css");
151 // std::cout<<"Cargado------------ "<<loadedJS<<std::endl;
156 std::cout<<" SIN PADRE "<<std::endl;
157 if(myWtData.parent == 0){std::cout<<" PARENT 0 "<<std::endl;}
158 if(myWtData.parent == NULL){std::cout<<" PARENT NULL "<<std::endl;}
159 myWtData.parent = new Wt::WContainerWidget();
160 std::cout<<"Parent created -- DELETE ME -- bbtkWtBlackBox.cxx"<<std::endl;
163 Wt::WContainerWidget *myCont = new Wt::WContainerWidget(myWtData.parent);
164 myCont->setMinimumSize(800,500);
165 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................50%"<<std::endl;
166 myWtData.b->bbUserCreateWidget(myCont);
167 root()->addWidget(myWtData.parent);
168 //bbmWindow = myCont;
170 //jss = WtBlackBox::jScript;
171 std::cout<<"Creando WebWIDGET DELETE ME ---- bbtkWtBlackBox.cxx.................80%"<<std::endl;
172 std::cout<<"Creando WebWIDGET DELETE ME SCRIPT : ---"<<bbtk::jScript<<".................80%"<<std::endl;
173 //this->doJavaScript(bbtk::jScript);
177 //==================================================================
178 //==================================================================
179 WtWFrame::~WtWFrame()
182 bbtkDebugMessage("widget",9,"["<<mBox.lock()->bbGetName()
183 <<"] $$$$$$$$$$$$$$$$$$$ ~W()"
186 bbtkDebugMessage("widget",9,"[DEAD] $$$$$$$$$$$$$$$$$$$$$ ~WtContainer()"<<std::endl);
187 bbtkDebugMessage("widget",9,"WtWFrame::~WtWFrame()"<<std::endl);
188 if (mBox.lock()) mBox.lock()->bbSetWindow(0);
189 WWt::DecNbWindowsAlive();
195 Wt::WApplication *createApplication(const Wt::WEnvironment& env)
197 return new WtWFrame(env);
201 //=========================================================================
202 // WxDialogWxBlackBox::Pointer box
203 //=========================================================================
205 //==================================================================
206 // Dialog window which is modal
207 /* class BBTK_EXPORT WxDialog : public wxDialog
210 WxDialog(WxBlackBox::Pointer box,
214 ~WxDialog();Wt::GetTopWindow()
215 void OnCloseWindow(wxCloseEvent& event);
218 WxBlackBox::WeakPointer mBox;
219 DECLARE_EVENT_TABLE();
223 BEGIN_EVENT_TABLE(WxDialog, wxDialog)
224 EVT_CLOSE(WxDialog::OnCloseWindow)
226 //=========================================================================
228 //=========================================================================
229 WxDialog::WxDialog(WxBlackBox::Pointer b,
248 bbtkDebugMessage("widget",9,"WxDialog::WxDialog ["<<b->bbGetName()<<"]"
249 <<std::endl);WxBlackBox::Pointer box
250 Wx::IncNbWindowsAlive();
251 b->bbSetWindow(this);
252 // Insert the widget into the window
253 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
254 b->bbUserCreateWidget(this);
255 wxWindow* widget = b->bbGetOutputWidget();
256 sizer->Add( widget, 1, wxALL|wxGROW, 2);
260 //==================================================================
261 //===========================organise=======================================
262 WxDialog::~WxDialog()
264 bbtkDebugMessage("widget",9,"WxDialog::~WxDialog()"<<std::endl);
265 //bbtkDebugMessage("widget",9,"WxFrame::~WxFrame()"<<std::endl);
266 // if (mBox.lock()) mBox.lock()->bbSetWindow(0);
267 // Wx::DecNbWindowsAlive();
269 //==================================================================
270 //==================================================================
271 void WxDialog::OnCloseWindow(wxCloseEvent& event)
273 bbtkDebugMessage("widget",9,"WxDialog::OnCloseWindow()"<<wxGUIEditorGraphicBBS:std::endl);
274 if (mBox.lock()) mBox.lock()->bbSetWindow(0); http://doodle.com/qx65tfxismf7d6ku5vxykghs/admin#table
275 Wx::DecNbWindowsAlive();
278 //==================================================================
281 //=========================================================================
283 //=========================================================================
285 //=========================================================================
286 //=========================================================================
287 //=========================================================================
288 //=========================================================================
289 BBTK_BLACK_BOX_IMPLEMENTATION(WtBlackBox,WidgetBlackBox<Wt::WContainerWidget>);
291 //std::string WtBlackBox::wtServerData::docRoot = "/home/gonzalez/Documents/pruebaResources";
292 //std::string WtBlackBox::wtServerData::docRoot = "/usr/local/share/wtResources";
293 //std::string WtBlackBox::wtServerData::port = "8081";
295 std::string WtBlackBox::wtServerData::docRoot = "<void>";
296 std::string WtBlackBox::wtServerData::port = "<void>";
297 std::string WtBlackBox::wtServerData::address = "0.0.0.0";
299 //=========================================================================
300 //=========================================================================
301 void WtBlackBox::bbUserSetDefaultValues()
303 bbtkBlackBoxDebugMessage("widget",5,"WtBlackBox::bbUserSetDefaultValues()"<<std::endl);
305 /* WtBlackBox::serData.docRoot = "/home/gonzalez/Documents/pruebaResources";
306 WtBlackBox::serData.address = "0.0.0.0";
307 WtBlackBox::serData.port = "8080";*/
311 //=========================================================================
313 //=========================================================================
314 void WtBlackBox::bbUserInitializeProcessing()
318 //================================================================http://intranet-if.insa-lyon.fr/temps/5IF39.html==
320 //=========================================================================
321 void WtBlackBox::bbUserFinalizeProcessing()
323 bbtkBlackBoxDebugMessage("widget",5,"==> WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
325 bbtkBlackBoxDebugMessage("widget",5,"<== WtBlackBox::bbUserFinalizeProcessing()"<<std::endl);
327 //==================================================================
329 //==================================================================
330 /// Callback for creating a Dialog window (modal)
331 void WtBlackBox::bbCreateDialogWindow()
333 bbtkBlackBoxDebugMessage("widget",3,
334 "==> WtBlackBox::bbCreateDialogWindow() - No Dialog must be created, it is a web app"
338 //=========================================================================
340 //==================================================================
342 //==================================================================
343 /// Callback for creating a Frame window
344 void WtBlackBox::bbCreateFrameWindow()
347 bbtkBlackBoxDebugMessage("widget",3,
348 "==> WtBlackBox::bbCreateFrameWindow() - parent = "
349 <<WWt::GetTopWindow()
352 //Setting necessary data for Wt server deployment
353 myWtData.parent = WWt::GetTopWindow();
354 myWtData.b = GetThisPointer<WtBlackBox>();
355 myWtData.title = std2wt( bbGetInputWinTitle()
356 + " - bbtk (c) CREATIS");
363 //char *argv[7] = {"./WtTest","--docroot","/home/gonzalez/Documents/pruebaResources","--http-address","0.0.0.0","--http-port","8080"};
367 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()};
370 std::cout<<" --- PUERTO :"<<WtBlackBox::wtServerData::port<<std::endl;
372 /* if(Wt::WServer::instance()->isRunning())
374 std::cout<<"Checking the existence of a Server deployed -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
375 Wt::WServer::instance()->stop();
378 std::cout<<"Deploying Server -- Definition of server parameters by default -DELETE THIS MESSAGE bbtkWTBlackBox.cxx"<<std::endl;
379 Wt::WRun(argc,argv,&createApplication);
382 //==================================================================
384 //==================================================================
385 void WtBlackBox::bbSetWindow(Wt::WContainerWidget* w)
387 bbtkBlackBoxDebugMessage("widget",9,"==> WtBlackBox::bbSetWindow("<<w<<")"<<std::endl);
388 if ((bbmWindow != 0)&&(w!=0))
390 std::cout << "ERRRRRRRROOOOR"<<std::endl;
397 //==================================================================
399 //==================================================================
400 void WtBlackBox::bbShowWindow()
402 if ((bbmWindow) && (!bbIsShown()))
404 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbShowWindow()"
406 if (bbGetInputWinDialog())
408 // ((WxDialog*)bbmWindow)->ShowModal();
412 // There is not such a thing like show becouse it is a webapp
413 // bbGetWindow()->Show();
414 // WWt::CreateWtAppIfNeeded();
419 //==================================================================
421 //==================================================================
422 void WtBlackBox::bbDestroyWindow()
424 bbtkBlackBoxDebugMessage("widget",3,"==> WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
425 if (bbGetWindow()!=NULL)
427 // wxWindow* w = bbGetWindow();
429 // WE SHOULD DESTROY THE WINDOW WITH THE Close METHOD
433 delete bbGetWindow();
436 bbtkBlackBoxDebugMessage("widget",3,"<== WtBlackBox::bbDestroyWindow("<<bbmWindow<<")"<<std::endl);
439 //==================================================================