1 /*=========================================================================
3 Module: $RCSfile: bbtkWx.cxx,v $
5 Date: $Date: 2009/05/28 08:12:06 $
6 Version: $Revision: 1.15 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
31 #include "bbtkMessageManager.h"
33 #ifdef _USE_WXWIDGETS_
37 //=========================================================================
39 //=========================================================================
41 //=========================================================================
42 static WxApp* mgWxApp = 0;
43 static wxWindow* mgTopWindow = 0;
44 static int mgNbWindowsAlive = 0;
45 //=========================================================================
47 //=========================================================================
49 static Wx::Signal_type mgWxSignal;
51 //=========================================================================
54 //=========================================================================
55 // The wxApp class which is used when no user wxApp was created
56 class WxApp : public wxApp
60 int OnExit() { return true; }
62 //=========================================================================
63 IMPLEMENT_APP_NO_MAIN(WxApp);
64 //=========================================================================
69 //See http://www.wxwindows.org/faqgtk.htm#locale
70 setlocale(LC_NUMERIC, "C");
74 //=========================================================================
76 //=========================================================================
77 void Wx::CreateWxAppIfNeeded()
79 if (wxApp::GetInstance()==0)
83 bbtkGlobalError("Wx::CreateWxAppIfNeeded() : INTERNAL ERROR ! (wxApp::GetInstance()==0) && (mgWxApp != 0)");
85 bbtkDebugMessage("wx",1," --> Creating bbtk wxApp"<<std::endl);
87 wxApp::SetInstance(mgWxApp);
91 //=========================================================================
93 //=========================================================================
94 void Wx::DestroyWxAppIfNeeded()
98 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
105 //=========================================================================
108 //=========================================================================
109 void Wx::ProcessPendingEvents()
112 if (Wx::GetTopWindow() != 0)
114 Wx::GetTopWindow()->DestroyChildren();
119 wxApp* a = (wxApp*)wxApp::GetInstance();
122 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
125 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
130 //=========================================================================
131 wxWindow* Wx::GetTopWindow()
135 //=========================================================================
139 //=========================================================================
140 void Wx::AddSignalObserver(Slot_function_type f)
142 mgWxSignal.connect(f);
144 //=========================================================================
148 //=========================================================================
149 void Wx::SetTopWindow(wxWindow* w)
153 bbtkGlobalError("Wx::SetTopWindow : top window already set !");
157 //=========================================================================
160 //=========================================================================
161 void Wx::IncNbWindowsAlive()
164 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
170 //=========================================================================
172 //=========================================================================
173 void Wx::DecNbWindowsAlive()
176 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
183 //=========================================================================
185 //=========================================================================
186 int Wx::GetNbWindowsAlive()
188 return mgNbWindowsAlive;
190 //=========================================================================
192 //=========================================================================
193 bool Wx::IsSomeWindowAlive()
195 return (mgNbWindowsAlive!=0);
197 //=========================================================================
200 //=========================================================================
201 Wx::BusyCursor::BusyCursor()
204 if (wxApp::GetInstance()!=0)
206 bbtkDebugMessage("wx",2,
207 "Wx::BusyCursor::BusyCursor() : creating new cursor"
209 //mCursor = new wxBusyCursor;
212 //=========================================================================
213 //=========================================================================
214 Wx::BusyCursor::~BusyCursor()
219 bbtkDebugMessage("wx",2,
220 "Wx::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
223 //=========================================================================
230 //=======================================================================
232 //=========================================================================
235 //=========================================================================
236 Wx::BusyCursor::BusyCursor()
239 Wx::BusyCursor::~BusyCursor()
242 //=========================================================================