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()
110 printf("EED Wx::DestroyWxAppIfNeeded \n");
113 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
120 //=========================================================================
123 //=========================================================================
124 void Wx::ProcessPendingEvents()
127 if (Wx::GetTopWindow() != 0)
129 Wx::GetTopWindow()->DestroyChildren();
134 wxApp* a = (wxApp*)wxApp::GetInstance();
137 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
140 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
145 //=========================================================================
146 wxWindow* Wx::GetTopWindow()
150 //=========================================================================
154 //=========================================================================
155 void Wx::AddSignalObserver(Slot_function_type f)
157 mgWxSignal.connect(f);
159 //=========================================================================
163 //=========================================================================
164 void Wx::SetTopWindow(wxWindow* w)
168 bbtkGlobalError("Wx::SetTopWindow : top window already set !");
172 //=========================================================================
175 //=========================================================================
176 void Wx::IncNbWindowsAlive()
179 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
185 //=========================================================================
187 //=========================================================================
188 void Wx::DecNbWindowsAlive()
191 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
198 //=========================================================================
200 //=========================================================================
201 int Wx::GetNbWindowsAlive()
203 return mgNbWindowsAlive;
205 //=========================================================================
207 //=========================================================================
208 bool Wx::IsSomeWindowAlive()
210 return (mgNbWindowsAlive!=0);
212 //=========================================================================
215 //=========================================================================
216 Wx::BusyCursor::BusyCursor()
219 if (wxApp::GetInstance()!=0)
221 bbtkDebugMessage("wx",2,
222 "Wx::BusyCursor::BusyCursor() : creating new cursor"
224 //mCursor = new wxBusyCursor;
227 //=========================================================================
228 //=========================================================================
229 Wx::BusyCursor::~BusyCursor()
234 bbtkDebugMessage("wx",2,
235 "Wx::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
238 //=========================================================================
245 //=======================================================================
247 //=========================================================================
250 //=========================================================================
251 Wx::BusyCursor::BusyCursor()
254 Wx::BusyCursor::~BusyCursor()
257 //=========================================================================