bbtkWidgetBlackBox.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkWidgetBlackBox.h,v $
00004   Language:  C++
00005   Date:      $Date: 2010/01/14 13:17:27 $
00006   Version:   $Revision: 1.7 $
00007 ========================================================================*/
00008 
00009 
00010 /* ---------------------------------------------------------------------
00011 
00012 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00013 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00014 *
00015 *  This software is governed by the CeCILL-B license under French law and 
00016 *  abiding by the rules of distribution of free software. You can  use, 
00017 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00018 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00019 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00020 *  or in the file LICENSE.txt.
00021 *
00022 *  As a counterpart to the access to the source code and  rights to copy,
00023 *  modify and redistribute granted by the license, users are provided only
00024 *  with a limited warranty  and the software's author,  the holder of the
00025 *  economic rights,  and the successive licensors  have only  limited
00026 *  liability. 
00027 *
00028 *  The fact that you are presently reading this means that you have had
00029 *  knowledge of the CeCILL-B license and that you accept its terms.
00030 * ------------------------------------------------------------------------ */                                                                         
00031 
00046 #ifndef __bbtkWidgetBlackBox_h_INCLUDED__
00047 #define __bbtkWidgetBlackBox_h_INCLUDED__
00048 
00049 #include "bbtkAtomicBlackBox.h"
00050 
00051 namespace bbtk
00052 {
00053 
00054 
00055 
00056 
00057   //==================================================================
00062 
00063 //JCP 09JUIN2009 BBTK_EXPORT
00064   template <class W>
00065           
00066   class /*BBTK_EXPORT*/ WidgetBlackBox : public bbtk::AtomicBlackBox  
00067   { 
00068   public:
00069     //    typedef WidgetTraits Traits;
00070     typedef W Widget;
00071     typedef Widget* WidgetPointer;
00072     
00073     
00074     BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
00075     BBTK_DECLARE_INPUT(WinTitle,std::string);
00076     BBTK_DECLARE_INPUT(WinWidth,int);
00077     BBTK_DECLARE_INPUT(WinHeight,int);
00078     BBTK_DECLARE_INPUT(WinDialog,bool);
00079     BBTK_DECLARE_INPUT(WinHide,Void);
00080     BBTK_DECLARE_INPUT(WinClose,Void);
00081     BBTK_DECLARE_OUTPUT(Widget,Widget*);
00082 
00083     //==================================================================
00086     virtual void bbCreateWindow();
00087     virtual bool bbWindowIsCreated() { return false; }
00088     //==================================================================
00089     
00090     //==================================================================
00093     virtual void bbShowWindow() {}
00094     //==================================================================    
00095 
00096  
00098     bool bbIsOutputWidgetConnected();
00099 
00100     //==================================================================    
00101     bool bbIsShown();
00102     //==================================================================    
00103  
00104    
00105     //==================================================================    
00108     virtual void bbUserCreateWidget(Widget* parent) 
00109     {
00110       bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?");
00111     }
00112     //==================================================================    
00113 
00114           
00115   protected:
00116     
00117     void bbSetShown(bool);
00118 
00119     //==================================================================
00124     Widget* bbCreateWidgetOfInput(const std::string& in, 
00125                                   Widget* parent);
00126     //==================================================================
00127 
00128    //==================================================================    
00131     virtual void bbCreateDialogWindow()
00132     {
00133       bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateDialogWindow method is not overloaded ?!?");
00134     }
00135     //==================================================================    
00136 
00137  //==================================================================    
00140     virtual void bbCreateFrameWindow()
00141     {
00142       bbtkError(bbGetTypeName()<<" is a WidgetBlackBox whose bbCreateFrameWindow method is not overloaded ?!?");
00143     }
00144     //==================================================================    
00145     //==================================================================
00147     virtual void bbProcess();
00148     //==================================================================
00149 
00150     //==================================================================
00152     virtual void bbDestroyWindow() {}
00153     //==================================================================
00154 
00155    
00156 
00157   private:
00158    
00161     bool bbmShown;
00167     std::vector<BlackBox::WeakPointer> bbmNestedWidgetBoxes;
00168   };
00169   //=================================================================
00170  
00171 
00172   //======================================================================
00174 #define BBTK_CREATE_WIDGET(CALLBACK)                                    \
00175   public:                                                               \
00176   inline void bbUserCreateWidget(Widget* parent)                        \
00177   {                                                                     \
00178     bbtkBlackBoxDebugMessage("widget",1,"**> Creating widget"           \
00179                              <<std::endl);                              \
00180     CALLBACK(parent);                                                   \
00181   }
00182   
00183   //======================================================================
00184 
00185   //======================================================================
00187 #define BBTK_ON_SHOW_WIDGET(CALLBACK)                                   \
00188   public:                                                               \
00189   inline void bbUserOnShow()                                            \
00190   {                                                                     \
00191     bbtkBlackBoxDebugMessage("widget",1,"**> Showing"                   \
00192                              <<std::endl);                              \
00193     CALLBACK();                                                         \
00194   }
00195   
00196   //======================================================================
00197 
00198   //=================================================================
00199   // WidgetBlackBoxDescriptor declaration
00200   BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(WidgetBlackBox,bbtk::AtomicBlackBox);
00201   BBTK_NAME("WidgetBlackBox_"+HumanTypeName<T>());
00202   // BBTK_DESCRIPTION("Widget box. The inputs marked with (*) are only used if the widget is not inserted in another widget.\n");
00203   BBTK_CATEGORY("widget");
00204   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinTitle,
00205              "Title of the window (*)",
00206              std::string);
00207   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinWidth,
00208              "Width of the window (* : only used if the widget is not connected to a Layout box)",int);
00209   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHeight,
00210              "Height of the window (*)",int);
00211   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinDialog,
00212              "Set to 'true' to create a dialog window, i.e. which blocks the pipeline until it is closed (modal) (*)",bool);
00213   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinHide,
00214              "Any signal received hides the window (*)",Void);
00215   BBTK_TEMPLATE_INPUT(WidgetBlackBox,WinClose,
00216              "Any signal received closes the window (*)",Void);
00217   typedef typename WidgetBlackBox<T>::WidgetPointer WidgetPointer;
00218   BBTK_TEMPLATE_OUTPUT(WidgetBlackBox,Widget,"Output widget",WidgetPointer);
00219   BBTK_END_DESCRIBE_BLACK_BOX(WidgetBlackBox);
00220   //=================================================================
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 } //namespace bbtk
00231 
00232 // template code inclusion
00233 #include "bbtkWidgetBlackBox.txx"
00234 
00235 // WidgetBlackBoxWindow interface + code inclusion
00236 #include "bbtkWidgetBlackBoxWindow.h"
00237 
00238 #endif  //__bbtkWidgetBlackBox_h__

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1