1 /*=========================================================================
3 Module: $RCSfile: bbtkQt.h,v $
5 Date: $Date: 2010/01/14 13:17:27 $
6 Version: $Revision: 1.2 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
10 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
11 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 * This software is governed by the CeCILL-B license under French law and
14 * abiding by the rules of distribution of free software. You can use,
15 * modify and/ or redistribute the software under the terms of the CeCILL-B
16 * license as circulated by CEA, CNRS and INRIA at the following URL
17 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
18 * or in the file LICENSE.txt.
20 * As a counterpart to the access to the source code and rights to copy,
21 * modify and redistribute granted by the license, users are provided only
22 * with a limited warranty and the software's author, the holder of the
23 * economic rights, and the successive licensors have only limited
26 * The fact that you are presently reading this means that you have had
27 * knowledge of the CeCILL-B license and that you accept its terms.
28 * ------------------------------------------------------------------------ */
30 #ifndef __bbtkQt_h_INCLUDED__
31 #define __bbtkQt_h_INCLUDED__
33 //===========================================================================
34 // SIGNAL/SLOT MECHANISM
35 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
37 #include <boost/signal.hpp>
38 #include <boost/bind.hpp>
39 typedef boost::signals::trackable SignalObserver;
41 //===========================================================================
44 //===========================================================================
54 typedef void QBusyCursor;
56 #endif // EO USE_WXWIDGETS
57 //===========================================================================
59 //===========================================================================
60 #include "bbtkSystem.h"
61 //===========================================================================
67 //==================================================================
68 /// Global qt handlers (cursor...)
71 #define bbtkAddQtSignalObserver(METHOD) \
72 Qt::AddSignalObserver(boost::bind(&METHOD, this))
75 #define BBTK_BUSY_CURSOR bbtk::Qt::BusyCursor __bbtk_dummy_busy_cursor;
81 // The keyword 'signals' is also a macro in qt
82 // typedef boost::signals::trackable SignalObserver;
83 typedef boost::signal<void ()> Signal_type;
84 typedef Signal_type::slot_function_type Slot_function_type;
88 static void ResetCursor();
89 static void BeginBusyCursor();
90 static void EndBusyCursor();
93 static void LoopUntilAllWindowsClose();
100 //wxBusyCursor* mCursor;
103 static void SetTopWindowParent(QWidget*);
104 static void SetAutoDestroyTopWindow(bool);
106 /// Returns the creation time parent of all bbtk windows
107 /// (window can be reparented after creation)
108 static QWidget* GetTopWindow();
109 static bool TopWindowExists();
111 static void IncNbWindowsAlive();
112 static void DecNbWindowsAlive();
113 static int GetNbWindowsAlive();
114 static bool IsSomeWindowAlive();
116 static void IncNbWindowsShown();
117 static void DecNbWindowsShown();
118 static int GetNbWindowsShown();
119 static bool IsSomeWindowShown();
122 static void AddSignalObserver(Slot_function_type);
127 static void CreateQtAppIfNeeded();
128 static void DestroyQtAppIfNeeded();
131 static void CreateTopWindowIfNeeded();
132 static void DestroyTopWindowIfNeeded();
134 /// Sets the creation time parent of all bbtk windows
135 static void SetTopWindow(QWidget*);
137 //==================================================================
147 #endif // EO __bbtkQt_h_INCLUDED__