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
26 # ------------------------------------------------------------------------ */
29 /*=========================================================================
31 Module: $RCSfile: bbtkQt.cxx,v $
33 Date: $Date: 2012/11/16 08:49:01 $
34 Version: $Revision: 1.4 $
35 =========================================================================*/
39 #include "bbtkMessageManager.h"
48 //=========================================================================
50 Wt::WApplication *createApplication(const Wt::WEnvironment& env);
51 //=========================================================================
53 //=========================================================================
54 static WtApp* mgWtApp = 0;
55 static Wt::WContainerWidget* mgTopWindow = 0;
56 static int mgNbWindowsAlive = 0;
57 //=========================================================================
59 //=========================================================================
61 static WWt::Signal_type mgWtSignal;
63 //=========================================================================
66 //=========================================================================
67 // The wxApp class which is used when no user wxApp was created
68 // The application creates itself completly empty.
69 // The default values for the port and address are port:8080 address 0.0.0.0
70 class WtApp : public Wt::WApplication
73 WtApp(const Wt::WEnvironment& env);
76 //WtWApplication *createApplication(const WtWEnvironment& env);
80 WtApp::WtApp(const Wt::WEnvironment& env):
83 //root()->addWidget(WWt::GetTopWindow());
84 // There is not additional configuration. The new WtApp must have the same behavior that one Wt::WApplication.
95 char *argv[7] = {"./WtTest","--docroot",".","--http-address","0.0.0.0","--http-port","8080"};
97 return Wt::WRun(argc,argv,&createApplication);
101 Wt::WApplication *createApplication(const Wt::WEnvironment& env)
103 return new WtApp(env);
109 //=========================================================================
111 //=========================================================================
112 void WWt::CreateWtAppIfNeeded()
114 std::cout<<"CREATING APP IF NEEDED --------- DELETE ME ------- bbtkWt.cxx"<<std::endl;
115 if(Wt::WApplication::instance()==0)
119 bbtkGlobalError("Wt::CreateWtAppIfNeeded() : INTERNAL ERROR ! (Wt::WApplication::instance()==0) && (mgWtApp != 0)");
121 bbtkDebugMessage("wt",1," --> Creating bbtk WtApp"<<std::endl);
124 bbtkDebugMessage("process",2,"Create WtApp If needed debuging");
126 //=========================================================================
128 //=========================================================================
129 void WWt::DestroyWtAppIfNeeded()
133 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
140 //=========================================================================
143 //=========================================================================
144 void WWt::ProcessPendingEvents()
147 if (Wx::GetTopWindow() != 0)
149 Wx::GetTopWindow()->DestroyChildren();
154 wxApp* a = (wxApp*)wxApp::GetInstance();
157 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
160 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
165 //=========================================================================
166 Wt::WContainerWidget* WWt::GetTopWindow()
170 //=========================================================================
174 //=========================================================================
175 void WWt::AddSignalObserver(Slot_function_type f)
177 mgWtSignal.connect(f);
179 //=========================================================================
183 //=========================================================================
184 void WWt::SetTopWindow(Wt::WContainerWidget* w)
188 bbtkGlobalError("Wt::SetTopWindow : top window already set !");
192 //=========================================================================
195 //=========================================================================
196 void WWt::IncNbWindowsAlive()
199 bbtkDebugMessage("wt",2,"* Number of windows alive = "<<mgNbWindowsAlive
205 //=========================================================================
207 //=========================================================================
208 void WWt::DecNbWindowsAlive()
211 bbtkDebugMessage("wt",2,"* Number of windows alive = "<<mgNbWindowsAlive
218 //=========================================================================
220 //=========================================================================
221 int WWt::GetNbWindowsAlive()
223 return mgNbWindowsAlive;
225 //=========================================================================
227 //=========================================================================
228 bool WWt::IsSomeWindowAlive()
230 return (mgNbWindowsAlive!=0);
232 //=========================================================================
235 //=========================================================================
236 WWt::BusyCursor::BusyCursor()
239 if (Wt::WApplication::instance()!=0)
241 bbtkDebugMessage("wt",2,
242 "Wt::BusyCursor::BusyCursor() : creating new cursor"
244 //mCursor = new wxBusyCursor;
247 //=========================================================================
248 //=========================================================================
249 WWt::BusyCursor::~BusyCursor()
254 //bbtkDebugMessage("wt",2,
255 // "Wt::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
258 //=========================================================================
265 //=======================================================================
267 //=========================================================================
270 //=========================================================================
271 WWt::BusyCursor::BusyCursor()
274 WWt::BusyCursor::~BusyCursor()
277 //=========================================================================