1 /*=========================================================================
3 Module: $RCSfile: bbtkWx.cxx,v $
5 Date: $Date: 2010/01/14 13:17:27 $
6 Version: $Revision: 1.16 $
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 * ------------------------------------------------------------------------ */
32 #include "bbtkMessageManager.h"
34 #ifdef _USE_WXWIDGETS_
38 //=========================================================================
40 //=========================================================================
42 //=========================================================================
43 static WxApp* mgWxApp = 0;
44 static wxWindow* mgTopWindow = 0;
45 static int mgNbWindowsAlive = 0;
46 //=========================================================================
48 //=========================================================================
50 static Wx::Signal_type mgWxSignal;
52 //=========================================================================
55 //=========================================================================
56 // The wxApp class which is used when no user wxApp was created
57 class WxApp : public wxApp
61 int OnExit() { return true; }
63 //=========================================================================
64 IMPLEMENT_APP_NO_MAIN(WxApp);
65 //=========================================================================
70 //See http://www.wxwindows.org/faqgtk.htm#locale
71 setlocale(LC_NUMERIC, "C");
75 //=========================================================================
77 //=========================================================================
78 void Wx::CreateWxAppIfNeeded()
80 if (wxApp::GetInstance()==0)
84 bbtkGlobalError("Wx::CreateWxAppIfNeeded() : INTERNAL ERROR ! (wxApp::GetInstance()==0) && (mgWxApp != 0)");
86 bbtkDebugMessage("wx",1," --> Creating bbtk wxApp"<<std::endl);
88 wxApp::SetInstance(mgWxApp);
92 //=========================================================================
94 //=========================================================================
95 void Wx::DestroyWxAppIfNeeded()
99 // bbtkDebugMessage("wx",1," --> Destructing bbtk WxApp"<<std::endl);
106 //=========================================================================
109 //=========================================================================
110 void Wx::ProcessPendingEvents()
113 if (Wx::GetTopWindow() != 0)
115 Wx::GetTopWindow()->DestroyChildren();
120 wxApp* a = (wxApp*)wxApp::GetInstance();
123 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING "<<std::endl;
126 std::cout << "$$$$$$$$$$$$$$ PROCESS PENDING DONE"<<std::endl;
131 //=========================================================================
132 wxWindow* Wx::GetTopWindow()
136 //=========================================================================
140 //=========================================================================
141 void Wx::AddSignalObserver(Slot_function_type f)
143 mgWxSignal.connect(f);
145 //=========================================================================
149 //=========================================================================
150 void Wx::SetTopWindow(wxWindow* w)
154 bbtkGlobalError("Wx::SetTopWindow : top window already set !");
158 //=========================================================================
161 //=========================================================================
162 void Wx::IncNbWindowsAlive()
165 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
171 //=========================================================================
173 //=========================================================================
174 void Wx::DecNbWindowsAlive()
177 bbtkDebugMessage("wx",2,"* Number of windows alive = "<<mgNbWindowsAlive
184 //=========================================================================
186 //=========================================================================
187 int Wx::GetNbWindowsAlive()
189 return mgNbWindowsAlive;
191 //=========================================================================
193 //=========================================================================
194 bool Wx::IsSomeWindowAlive()
196 return (mgNbWindowsAlive!=0);
198 //=========================================================================
201 //=========================================================================
202 Wx::BusyCursor::BusyCursor()
205 if (wxApp::GetInstance()!=0)
207 bbtkDebugMessage("wx",2,
208 "Wx::BusyCursor::BusyCursor() : creating new cursor"
210 //mCursor = new wxBusyCursor;
213 //=========================================================================
214 //=========================================================================
215 Wx::BusyCursor::~BusyCursor()
220 bbtkDebugMessage("wx",2,
221 "Wx::BusyCursor::~BusyCursor() : deleting cursor"<<std::endl);
224 //=========================================================================
231 //=======================================================================
233 //=========================================================================
236 //=========================================================================
237 Wx::BusyCursor::BusyCursor()
240 Wx::BusyCursor::~BusyCursor()
243 //=========================================================================