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: bbtkQt.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.3 $
34 =========================================================================*/
38 #ifndef __bbtkWt_h_INCLUDED__
39 #define __bbtkWt_h_INCLUDED__
41 //===========================================================================
42 // SIGNAL/SLOT MECHANISM
43 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
45 #include <boost/signal.hpp>
46 #include <boost/bind.hpp>
49 //TODO Include libs in the CMake escription
50 #include <Wt/WApplication>
51 #include <Wt/WEnvironment>
52 #include <Wt/WContainerWidget>
54 #include <Wt/WCheckBox>
57 #include <Wt/WPushButton>
59 #include <Wt/WHBoxLayout>
60 #include <Wt/WVBoxLayout>
61 #include <Wt/WBorderLayout>
62 #include <Wt/WLineEdit>
63 #include <Wt/WComboBox>
64 #include <Wt/WSelectionBox>
65 #include <Wt/WGroupBox>
66 #include <Wt/WRadioButton>
67 #include <Wt/WButtonGroup>
69 #include <Wt/WHBoxLayout>
70 #include <Wt/WVBoxLayout>
71 #include <Wt/WRadioButton>
72 #include <Wt/Ext/Splitter>
73 #include <Wt/WTabWidget>
74 //typedef boost::signals::trackable SignalObserver;
76 //===========================================================================
79 //===========================================================================
81 // DEFINIR LOS HEADERS Wt que se necesitan *-*-*-*-*-*-*-*-*-*
91 typedef void QBusyCursor;
93 #endif // EO USE_WXWIDGETS
101 // Definition of some classes used in tehe code
102 typedef Wt::WEnvironment WtWEnvironment;
103 typedef Wt::WWidget WtWWidget;
104 //typedef Wt::WContainerWidget WtWContainerWidget;
105 typedef Wt::WApplication WtWApplication;
106 typedef Wt::WString WtWString;
113 typedef void WtWidget;
114 typedef void WtWContainerWidget;
115 typedef void WtWApplication;
116 typedef void WtBusyCursor;
121 //==========================================================================
123 //===========================================================================
124 #include "bbtkSystem.h"
125 //===========================================================================
134 //==================================================================
135 /// Global wt handlers (cursor...)
138 // BBTKWXSIG BBTK_ADD_BLACK_BOX_TO_PACKAGE(MyProjectWT,Testing)
140 #define bbtkAddWtSignalObserver(METHOD) \
141 WWt::AddSignalObserver(boost::bind(&METHOD, this))
144 #define BBTK_BUSY_CURSOR bbtk::WWt::BusyCursor __bbtk_dummy_busy_cursor;
146 struct BBTK_EXPORT WWt
150 // The keyword 'signals' is also a macro in qt
151 // typedef boost::signals::trackable SignalObserver;
152 typedef boost::signals::trackable SignalObserver;
153 typedef boost::signal<void ()> Signal_type;
154 typedef Signal_type::slot_function_type Slot_function_type;
158 static void ResetCursor();
159 static void BeginBusyCursor();
160 static void EndBusyCursor();
163 static void LoopUntilAllWindowsClose();
170 //wxBusyCursor* mCursor; The wxBusyCursor is only for comunicate to the client/user that the program is busy.
174 static void ProcessPendingEvents();
175 /// Sets the parent of all bbtk windows
176 static void SetTopWindow(Wt::WContainerWidget*);
177 /// Returns the parent of all bbtk windows
178 static Wt::WContainerWidget* GetTopWindow();
181 static void IncNbWindowsAlive();
182 static void DecNbWindowsAlive();
183 static int GetNbWindowsAlive();
184 static bool IsSomeWindowAlive();
188 static void AddSignalObserver(Slot_function_type);
195 static void CreateWtAppIfNeeded();
196 static void DestroyWtAppIfNeeded();
199 //==================================================================
202 //==================================================================
203 /// Conversion std::string to wxString
204 inline Wt::WString std2wt(const std::string& s)
208 const char* my_string=s.c_str();
209 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
210 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
212 // test if conversion works of not. In case it fails convert from Ascii
214 wx=wxString(wxString::FromAscii(s.c_str()));
216 return Wt::WString::fromUTF8(s,false);
217 //return new Wt::WString(s);//wt;
219 //==================================================================
221 //==================================================================
222 /// Conversion wxString to std::string
223 inline std::string wt2std(const Wt::WString& s){
225 if(s.wxString::IsAscii()) {
226 s2=s.wxString::ToAscii();
228 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
229 const char *tmp_str = (const char*) tmp_buf;
230 s2=std::string(tmp_str, strlen(tmp_str));
236 //==================================================================
237 #endif // EO _USE_WXWIDGETS
246 #endif // EO __bbtkWt_h_INCLUDED__