00001 /*========================================================================= 00002 Program: bbtk 00003 Module: $RCSfile: bbtkQt.h,v $ 00004 Language: C++ 00005 Date: $Date: 2010/01/14 13:17:27 $ 00006 Version: $Revision: 1.2 $ 00007 =========================================================================*/ 00008 00009 /* --------------------------------------------------------------------- 00010 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) 00011 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux 00012 * 00013 * This software is governed by the CeCILL-B license under French law and 00014 * abiding by the rules of distribution of free software. You can use, 00015 * modify and/ or redistribute the software under the terms of the CeCILL-B 00016 * license as circulated by CEA, CNRS and INRIA at the following URL 00017 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 00018 * or in the file LICENSE.txt. 00019 * 00020 * As a counterpart to the access to the source code and rights to copy, 00021 * modify and redistribute granted by the license, users are provided only 00022 * with a limited warranty and the software's author, the holder of the 00023 * economic rights, and the successive licensors have only limited 00024 * liability. 00025 * 00026 * The fact that you are presently reading this means that you have had 00027 * knowledge of the CeCILL-B license and that you accept its terms. 00028 * ------------------------------------------------------------------------ */ 00029 00030 #ifndef __bbtkQt_h_INCLUDED__ 00031 #define __bbtkQt_h_INCLUDED__ 00032 00033 //=========================================================================== 00034 // SIGNAL/SLOT MECHANISM 00035 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION 00036 // BBTKWXSIG 00037 #include <boost/signal.hpp> 00038 #include <boost/bind.hpp> 00039 typedef boost::signals::trackable SignalObserver; 00040 // \BBTKWXSIG 00041 //=========================================================================== 00042 00043 00044 //=========================================================================== 00045 // Qt headers 00046 #ifdef USE_QT 00047 #include "qwidget.h" 00048 // EO Qt headers 00049 00050 #else //USE_QT 00051 00052 // define QWidget 00053 typedef void QWidget; 00054 typedef void QBusyCursor; 00055 00056 #endif // EO USE_WXWIDGETS 00057 //=========================================================================== 00058 00059 //=========================================================================== 00060 #include "bbtkSystem.h" 00061 //=========================================================================== 00062 00063 00064 namespace bbtk 00065 { 00066 00067 //================================================================== 00069 00070 // BBTKWXSIG 00071 #define bbtkAddQtSignalObserver(METHOD) \ 00072 Qt::AddSignalObserver(boost::bind(&METHOD, this)) 00073 // \BBTKWXSIG 00074 00075 #define BBTK_BUSY_CURSOR bbtk::Qt::BusyCursor __bbtk_dummy_busy_cursor; 00076 00077 struct BBTK_EXPORT Qt 00078 { 00079 public: 00080 // BBTKWXSIG 00081 // The keyword 'signals' is also a macro in qt 00082 // typedef boost::signals::trackable SignalObserver; 00083 typedef boost::signal<void ()> Signal_type; 00084 typedef Signal_type::slot_function_type Slot_function_type; 00085 // \BBTKWXSIG 00086 00087 /* 00088 static void ResetCursor(); 00089 static void BeginBusyCursor(); 00090 static void EndBusyCursor(); 00091 */ 00092 00093 static void LoopUntilAllWindowsClose(); 00094 00095 class BusyCursor 00096 { 00097 public: 00098 BusyCursor(); 00099 ~BusyCursor(); 00100 //wxBusyCursor* mCursor; 00101 }; 00102 00103 static void SetTopWindowParent(QWidget*); 00104 static void SetAutoDestroyTopWindow(bool); 00105 00108 static QWidget* GetTopWindow(); 00109 static bool TopWindowExists(); 00110 00111 static void IncNbWindowsAlive(); 00112 static void DecNbWindowsAlive(); 00113 static int GetNbWindowsAlive(); 00114 static bool IsSomeWindowAlive(); 00115 00116 static void IncNbWindowsShown(); 00117 static void DecNbWindowsShown(); 00118 static int GetNbWindowsShown(); 00119 static bool IsSomeWindowShown(); 00120 00121 // BBTKWXSIG 00122 static void AddSignalObserver(Slot_function_type); 00123 // \BBTKWXSIG 00124 00125 00126 00127 static void CreateQtAppIfNeeded(); 00128 static void DestroyQtAppIfNeeded(); 00129 00130 private: 00131 static void CreateTopWindowIfNeeded(); 00132 static void DestroyTopWindowIfNeeded(); 00133 00135 static void SetTopWindow(QWidget*); 00136 }; // struct Qt 00137 //================================================================== 00138 00139 00140 00141 00142 00143 00144 } // namespace bbtk 00145 00146 00147 #endif // EO __bbtkQt_h_INCLUDED__