]> Creatis software - bbtk.git/blob - kernel/src/bbtkQt.h
143be053c625ad683dc3c19dbb4aa2acca821d2b
[bbtk.git] / kernel / src / bbtkQt.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkQt.h,v $
4   Language:  C++
5   Date:      $Date: 2010/01/14 13:17:27 $
6   Version:   $Revision: 1.2 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
11 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
12 *
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.
19 *
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
24 *  liability. 
25 *
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 * ------------------------------------------------------------------------ */                                                                         
29
30 #ifndef __bbtkQt_h_INCLUDED__
31 #define __bbtkQt_h_INCLUDED__
32
33 //===========================================================================
34 // SIGNAL/SLOT MECHANISM 
35 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION 
36 // BBTKWXSIG
37 #include <boost/signal.hpp>
38 #include <boost/bind.hpp>
39 typedef boost::signals::trackable SignalObserver;
40 // \BBTKWXSIG
41 //===========================================================================
42
43
44 //===========================================================================
45 // Qt headers
46 #ifdef USE_QT
47 #include "qwidget.h"
48 // EO Qt headers
49
50 #else //USE_QT
51
52 // define QWidget
53 typedef void QWidget;
54 typedef void QBusyCursor;
55
56 #endif // EO USE_WXWIDGETS
57 //===========================================================================
58
59 //===========================================================================
60 #include "bbtkSystem.h"
61 //===========================================================================
62
63
64 namespace bbtk
65 {
66
67   //==================================================================
68   /// Global qt handlers (cursor...)
69   
70 // BBTKWXSIG
71 #define bbtkAddQtSignalObserver(METHOD)         \
72   Qt::AddSignalObserver(boost::bind(&METHOD, this))
73 // \BBTKWXSIG
74
75 #define BBTK_BUSY_CURSOR bbtk::Qt::BusyCursor __bbtk_dummy_busy_cursor;
76
77   struct BBTK_EXPORT Qt
78   {     
79   public:
80     // BBTKWXSIG
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;
85     // \BBTKWXSIG
86
87     /*
88     static void ResetCursor();
89     static void BeginBusyCursor(); 
90     static void EndBusyCursor();
91     */
92
93     static void LoopUntilAllWindowsClose();
94
95     class BusyCursor
96     {
97     public:
98       BusyCursor();
99       ~BusyCursor();
100       //wxBusyCursor* mCursor;
101     };
102
103     static void SetTopWindowParent(QWidget*);
104     static void SetAutoDestroyTopWindow(bool);
105
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();
110     
111     static void IncNbWindowsAlive();
112     static void DecNbWindowsAlive();
113     static int  GetNbWindowsAlive();
114     static bool IsSomeWindowAlive();
115     
116     static void IncNbWindowsShown();
117     static void DecNbWindowsShown();
118     static int  GetNbWindowsShown();
119     static bool IsSomeWindowShown();
120
121     // BBTKWXSIG
122     static void AddSignalObserver(Slot_function_type);
123     // \BBTKWXSIG
124
125
126
127     static void CreateQtAppIfNeeded();
128     static void DestroyQtAppIfNeeded();
129
130   private:
131     static void CreateTopWindowIfNeeded();
132     static void DestroyTopWindowIfNeeded();
133
134     /// Sets the creation time parent of all bbtk windows
135     static void SetTopWindow(QWidget*);
136   }; // struct Qt
137   //==================================================================
138   
139
140
141
142
143   
144 } // namespace bbtk
145   
146
147 #endif // EO __bbtkQt_h_INCLUDED__