]> Creatis software - bbtk.git/blob - kernel/src/bbtkQt.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkQt.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkQt.h,v $
4   Language:  C++
5   Date:      $Date: 2009/04/08 07:56:11 $
6   Version:   $Revision: 1.1 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /* ---------------------------------------------------------------------
33
34 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
35 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
36 *
37 *  This software is governed by the CeCILL-B license under French law and 
38 *  abiding by the rules of distribution of free software. You can  use, 
39 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
40 *  license as circulated by CEA, CNRS and INRIA at the following URL 
41 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
42 *  or in the file LICENSE.txt.
43 *
44 *  As a counterpart to the access to the source code and  rights to copy,
45 *  modify and redistribute granted by the license, users are provided only
46 *  with a limited warranty  and the software's author,  the holder of the
47 *  economic rights,  and the successive licensors  have only  limited
48 *  liability. 
49 *
50 *  The fact that you are presently reading this means that you have had
51 *  knowledge of the CeCILL-B license and that you accept its terms.
52 * ------------------------------------------------------------------------ */                                                                         
53
54
55 #ifndef __bbtkQt_h_INCLUDED__
56 #define __bbtkQt_h_INCLUDED__
57
58 //===========================================================================
59 // SIGNAL/SLOT MECHANISM 
60 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION 
61 // BBTKWXSIG
62 #include <boost/signal.hpp>
63 #include <boost/bind.hpp>
64 typedef boost::signals::trackable SignalObserver;
65 // \BBTKWXSIG
66 //===========================================================================
67
68
69 //===========================================================================
70 // Qt headers
71 #ifdef USE_QT
72 #include "qwidget.h"
73 // EO Qt headers
74
75 #else //USE_QT
76
77 // define QWidget
78 typedef void QWidget;
79 typedef void QBusyCursor;
80
81 #endif // EO USE_WXWIDGETS
82 //===========================================================================
83
84 //===========================================================================
85 #include "bbtkSystem.h"
86 //===========================================================================
87
88
89 namespace bbtk
90 {
91
92   //==================================================================
93   /// Global qt handlers (cursor...)
94   
95 // BBTKWXSIG
96 #define bbtkAddQtSignalObserver(METHOD)         \
97   Qt::AddSignalObserver(boost::bind(&METHOD, this))
98 // \BBTKWXSIG
99
100 #define BBTK_BUSY_CURSOR bbtk::Qt::BusyCursor __bbtk_dummy_busy_cursor;
101
102   struct BBTK_EXPORT Qt
103   {     
104   public:
105     // BBTKWXSIG
106     // The keyword 'signals' is also a macro in qt
107     //    typedef boost::signals::trackable SignalObserver;
108     typedef boost::signal<void ()>  Signal_type;
109     typedef Signal_type::slot_function_type Slot_function_type;
110     // \BBTKWXSIG
111
112     /*
113     static void ResetCursor();
114     static void BeginBusyCursor(); 
115     static void EndBusyCursor();
116     */
117
118     static void LoopUntilAllWindowsClose();
119
120     class BusyCursor
121     {
122     public:
123       BusyCursor();
124       ~BusyCursor();
125       //wxBusyCursor* mCursor;
126     };
127
128     static void SetTopWindowParent(QWidget*);
129     static void SetAutoDestroyTopWindow(bool);
130
131     /// Returns the creation time parent of all bbtk windows 
132     /// (window can be reparented after creation)
133     static QWidget* GetTopWindow();
134     static bool TopWindowExists();
135     
136     static void IncNbWindowsAlive();
137     static void DecNbWindowsAlive();
138     static int  GetNbWindowsAlive();
139     static bool IsSomeWindowAlive();
140     
141     static void IncNbWindowsShown();
142     static void DecNbWindowsShown();
143     static int  GetNbWindowsShown();
144     static bool IsSomeWindowShown();
145
146     // BBTKWXSIG
147     static void AddSignalObserver(Slot_function_type);
148     // \BBTKWXSIG
149
150
151
152     static void CreateQtAppIfNeeded();
153     static void DestroyQtAppIfNeeded();
154
155   private:
156     static void CreateTopWindowIfNeeded();
157     static void DestroyTopWindowIfNeeded();
158
159     /// Sets the creation time parent of all bbtk windows
160     static void SetTopWindow(QWidget*);
161   }; // struct Qt
162   //==================================================================
163   
164
165
166
167
168   
169 } // namespace bbtk
170   
171
172 #endif // EO __bbtkQt_h_INCLUDED__