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: bbtkWx.cxx,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.17 $
34 =========================================================================*/
39 #include "bbtkMessageManager.h"
41 #ifdef _USE_WXWIDGETS_
45 //=========================================================================
47 //=========================================================================
49 //=========================================================================
50 static WxApp* mgWxApp = 0;
51 static wxWindow* mgTopWindow = 0;
52 static int mgNbWindowsAlive = 0;
53 //=========================================================================
55 //=========================================================================
57 static Wx::Signal_type mgWxSignal;
59 //=========================================================================
62 //=========================================================================
63 // The wxApp class which is used when no user wxApp was created
64 class WxApp : public wxApp
68 int OnExit() { return true; }
70 //=========================================================================
71 IMPLEMENT_APP_NO_MAIN(WxApp);
72 //=========================================================================
75 std::cout<<"Testing OnINIT Wx ---- JFGA !!!DELETE ME!!! bbtkWx"<<std::endl;
78 //See http://www.wxwindows.org/faqgtk.htm#locale
79 setlocale(LC_NUMERIC, "C");
83 //=========================================================================
85 //=========================================================================
86 void Wx::CreateWxAppIfNeeded()
89 std::cout<<"Testing CreateWxAppIfNeeded --- DELETE ME ----"<<std::endl;
90 if (wxApp::GetInstance()==0)
94 bbtkGlobalError("Wx::CreateWxAppIfNeeded() : INTERNAL ERROR ! (wxApp::GetInstance()==0) && (mgWxApp != 0)");
96 bbtkDebugMessage("wx",1," --> Creating bbtk wxApp"<<std::endl);
98 wxApp::SetInstance(mgWxApp);
102 //=========================================================================
104 //=========================================================================
105 void Wx::DestroyWxAppIfNeeded()
109 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
116 //=========================================================================
119 //=========================================================================
120 void Wx::ProcessPendingEvents()
123 if (Wx::GetTopWindow() != 0)
125 Wx::GetTopWindow()->DestroyChildren();
130 wxApp* a = (wxApp*)wxApp::GetInstance();
133 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
136 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
141 //=========================================================================
142 wxWindow* Wx::GetTopWindow()
146 //=========================================================================
150 //=========================================================================
151 void Wx::AddSignalObserver(Slot_function_type f)
153 mgWxSignal.connect(f);
155 //=========================================================================
159 //=========================================================================
160 void Wx::SetTopWindow(wxWindow* w)
164 bbtkGlobalError("Wx::SetTopWindow : top window already set !");
168 //=========================================================================
171 //=========================================================================
172 void Wx::IncNbWindowsAlive()
175 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
181 //=========================================================================
183 //=========================================================================
184 void Wx::DecNbWindowsAlive()
187 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
194 //=========================================================================
196 //=========================================================================
197 int Wx::GetNbWindowsAlive()
199 return mgNbWindowsAlive;
201 //=========================================================================
203 //=========================================================================
204 bool Wx::IsSomeWindowAlive()
206 return (mgNbWindowsAlive!=0);
208 //=========================================================================
211 //=========================================================================
212 Wx::BusyCursor::BusyCursor()
215 if (wxApp::GetInstance()!=0)
217 bbtkDebugMessage("wx",2,
218 "Wx::BusyCursor::BusyCursor() : creating new cursor"
220 //mCursor = new wxBusyCursor;
223 //=========================================================================
224 //=========================================================================
225 Wx::BusyCursor::~BusyCursor()
230 bbtkDebugMessage("wx",2,
231 "Wx::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
234 //=========================================================================
241 //=======================================================================
243 //=========================================================================
246 //=========================================================================
247 Wx::BusyCursor::BusyCursor()
250 Wx::BusyCursor::~BusyCursor()
253 //=========================================================================