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 //=========================================================================
77 //See http://www.wxwindows.org/faqgtk.htm#locale
78 setlocale(LC_NUMERIC, "C");
82 //=========================================================================
84 //=========================================================================
85 void Wx::CreateWxAppIfNeeded()
87 if (wxApp::GetInstance()==0)
91 bbtkGlobalError("Wx::CreateWxAppIfNeeded() : INTERNAL ERROR ! (wxApp::GetInstance()==0) && (mgWxApp != 0)");
93 bbtkDebugMessage("wx",1," --> Creating bbtk wxApp"<<std::endl);
95 wxApp::SetInstance(mgWxApp);
99 //=========================================================================
101 //=========================================================================
102 void Wx::DestroyWxAppIfNeeded()
106 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
113 //=========================================================================
116 //=========================================================================
117 void Wx::ProcessPendingEvents()
120 if (Wx::GetTopWindow() != 0)
122 Wx::GetTopWindow()->DestroyChildren();
127 wxApp* a = (wxApp*)wxApp::GetInstance();
130 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
133 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
138 //=========================================================================
139 wxWindow* Wx::GetTopWindow()
143 //=========================================================================
147 //=========================================================================
148 void Wx::AddSignalObserver(Slot_function_type f)
150 mgWxSignal.connect(f);
152 //=========================================================================
156 //=========================================================================
157 void Wx::SetTopWindow(wxWindow* w)
161 bbtkGlobalError("Wx::SetTopWindow : top window already set !");
165 //=========================================================================
168 //=========================================================================
169 void Wx::IncNbWindowsAlive()
172 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
178 //=========================================================================
180 //=========================================================================
181 void Wx::DecNbWindowsAlive()
184 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
191 //=========================================================================
193 //=========================================================================
194 int Wx::GetNbWindowsAlive()
196 return mgNbWindowsAlive;
198 //=========================================================================
200 //=========================================================================
201 bool Wx::IsSomeWindowAlive()
203 return (mgNbWindowsAlive!=0);
205 //=========================================================================
208 //=========================================================================
209 Wx::BusyCursor::BusyCursor()
212 if (wxApp::GetInstance()!=0)
214 bbtkDebugMessage("wx",2,
215 "Wx::BusyCursor::BusyCursor() : creating new cursor"
217 //mCursor = new wxBusyCursor;
220 //=========================================================================
221 //=========================================================================
222 Wx::BusyCursor::~BusyCursor()
227 bbtkDebugMessage("wx",2,
228 "Wx::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
231 //=========================================================================
238 //=======================================================================
240 //=========================================================================
243 //=========================================================================
244 Wx::BusyCursor::BusyCursor()
247 Wx::BusyCursor::~BusyCursor()
250 //=========================================================================