]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWidgetBlackBox.h
#3073 BBTK Bug New Normal - message documentation in boxes
[bbtk.git] / kernel / src / bbtkWidgetBlackBox.h
index deed3f707b09d000669ed33e50464ae90ef50729..b0333a6985241a0d1668da493a8067fe469098d1 100644 (file)
@@ -1,33 +1,40 @@
-/*=========================================================================                                                                               
+/*
+ # ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la SantÈ)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
+
+/*=========================================================================
   Program:   bbtk
   Module:    $RCSfile: bbtkWidgetBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/04/08 07:56:11 $
-  Version:   $Revision: 1.1 $
+  Date:      $Date: 2012/11/16 08:49:01 $
+  Version:   $Revision: 1.8 $
 ========================================================================*/
 
 
-/* ---------------------------------------------------------------------
-
-* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
-* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
-*
-*  This software is governed by the CeCILL-B license under French law and 
-*  abiding by the rules of distribution of free software. You can  use, 
-*  modify and/ or redistribute the software under the terms of the CeCILL-B 
-*  license as circulated by CEA, CNRS and INRIA at the following URL 
-*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
-*  or in the file LICENSE.txt.
-*
-*  As a counterpart to the access to the source code and  rights to copy,
-*  modify and redistribute granted by the license, users are provided only
-*  with a limited warranty  and the software's author,  the holder of the
-*  economic rights,  and the successive licensors  have only  limited
-*  liability. 
-*
-*  The fact that you are presently reading this means that you have had
-*  knowledge of the CeCILL-B license and that you accept its terms.
-* ------------------------------------------------------------------------ */                                                                         
+
 /**
  * \brief Short description in one line
  * 
@@ -51,7 +58,6 @@ namespace bbtk
 {
 
 
-  template <class T> class WidgetBlackBoxWindow;
 
 
   //==================================================================
@@ -59,14 +65,16 @@ namespace bbtk
   /// widget black boxes for a specific GUI toolkit inherit with 
   /// apropriate traits.
   /// Declares the common inputs / outputs and interface to all widget boxes
+
+//JCP 09JUIN2009 BBTK_EXPORT
   template <class W>
-  class BBTK_EXPORT WidgetBlackBox : public bbtk::AtomicBlackBox  
+         
+  class /*BBTK_EXPORT*/ WidgetBlackBox : public bbtk::AtomicBlackBox  
   { 
   public:
     //    typedef WidgetTraits Traits;
     typedef W Widget;
     typedef Widget* WidgetPointer;
-    typedef WidgetBlackBoxWindow<W> Window;
     
     
     BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
@@ -82,49 +90,24 @@ namespace bbtk
     /// Overloaded bbCreateWindow method for WidgetBlackBoxes which handles 
     /// the window creation if needed
     virtual void bbCreateWindow();
+    virtual bool bbWindowIsCreated() { return false; }
     //==================================================================
     
     //==================================================================
     /// Overloaded bbShowWindow method for WidgetBlackBoxes which handles 
     /// the window creation if needed
-    virtual void bbShowWindow();
+    virtual void bbShowWindow() {}
     //==================================================================    
 
-    //==================================================================
-    /// Returns the **OWN** window associated to the box
-    /// If 0 returned = no window
-    Window* bbGetWindow() { return bbmWindow; }
-    /// Returns the window containing the widget associated to the box
-    /// Which can be the own window of **ANOTHER** box in case of 
-    /// a hierarchy of widgets (layouts)
-    /// More precisely :
-    /// If bbGetWindow() != 0 then returns bbGetWindow()
-    /// Else if the output 'Widget' is connected 
-    ///  then returns bbGetContainingWindow() of the box connected to 'Widget'
-    /// Else returns 0;
-    Window* bbGetContainingWindow();
-
-
-    /// Returns true iff the 'containing window' exists and is shown 
-    /// (see bbGetContainingWindow).
-    bool bbIsShown();
-
     /// Convenient method which returns true iff the output Widget is connected
     bool bbIsOutputWidgetConnected();
 
     //==================================================================    
-    /// User callback invoked when the containing window is shown
-    virtual void bbUserOnShow() {}
+    bool bbIsShown();
     //==================================================================    
  
-    //==================================================================    
-    /// User callback invoked when the containing window is hidden
-    virtual void bbUserOnHide() {}
-    //==================================================================    
-
-    /// Sets the window
-    inline void bbSetWindow(Window* w) { bbmWindow=w; }
-
+   
     //==================================================================    
     /// User callback for creating the widget associated to the box
     /// ** Must be defined ** in user classes
@@ -137,18 +120,7 @@ namespace bbtk
          
   protected:
     
-  
-    //==================================================================
-    /// User callback called in the box contructor
-    virtual void bbUserConstructor();
-    /// User callback called in the box copy constructor
-    virtual void bbUserCopyConstructor(bbtk::BlackBox::Pointer);
-    /// User callback called in the box destructor
-    virtual void bbUserDestructor();
-    //==================================================================    
-
-
+    void bbSetShown(bool);
 
     //==================================================================
     /// Convenient method for layout widgets which creates and returns
@@ -182,39 +154,27 @@ namespace bbtk
     //==================================================================
 
     //==================================================================
-    /// Hides the WidgetBlackBoxWindow associated to the box (if exists)
-    void bbHideWindow();
-    /// Closes (destroys) the WidgetBlackBoxWindow associated to the box 
-    /// (if exists)
-    void bbCloseWindow();
+    /// Destroys the WidgetBlackBoxWindow associated to the box (if exists)
+    virtual void bbDestroyWindow() {}
     //==================================================================
 
-    
     //==================================================================
-    //   virtual void InitWindowManagerIfNeeded();
-    virtual void IncNbWindowsAlive() {}
-    virtual void DecNbWindowsAlive() {}
-    virtual int  GetNbWindowsAlive() { return 0; }
-    virtual bool IsSomeWindowAlive() { return false; }
-    
-    virtual void IncNbWindowsShown() {}
-    virtual void DecNbWindowsShown() {}
-    virtual int  GetNbWindowsShown() { return 0; }
-    virtual bool IsSomeWindowShown() { return false; }
+       // method to be added in the proces of a window
+       virtual void PutWinTitle() {}
     //==================================================================
-
+   
 
   private:
-    /// friendship
-    friend class WidgetBlackBoxWindow<W>;
-    //    friend class WidgetBlackBoxWidgetEventHandler;
-
-    /// The WidgetBlackBoxWindow associated to the box
-    Window* bbmWindow;
-
-
-    void bbInitAttributes();
-
+   
+    /// Set to true when the 
+    /// window containing the widget is shown
+    bool bbmShown;
+    /// Contains the "nested" WidgetBlackBoxes, 
+    /// i.e. if this WidgetBox is a Layout the ones
+    /// which are inserted into the layout 
+    /// The list is updated by the method bbCreateWidgetOfInput
+    /// It is emptied when ?
+    std::vector<BlackBox::WeakPointer> bbmNestedWidgetBoxes;
   };
   //=================================================================
  
@@ -225,11 +185,9 @@ namespace bbtk
   public:                                                              \
   inline void bbUserCreateWidget(Widget* parent)                       \
   {                                                                    \
-    bbtkDebugMessageInc("kw",1,"**> Creating widget for ["             \
-                       <<bbGetFullName()<<"]"<<std::endl);             \
+    bbtkBlackBoxDebugMessage("widget",1,"**> Creating widget"          \
+                            <<std::endl);                              \
     CALLBACK(parent);                                                  \
-    bbtkDebugMessageInc("kw",1,"<** Creating widget for ["             \
-                       <<bbGetFullName()<<"]"<<std::endl);             \
   }
   
   //======================================================================
@@ -238,13 +196,11 @@ namespace bbtk
   /// Defines the bbUserOnShow method
 #define BBTK_ON_SHOW_WIDGET(CALLBACK)                                  \
   public:                                                              \
-  inline void bbUserOnShow()                                   \
+  inline void bbUserOnShow()                                           \
   {                                                                    \
-    bbtkDebugMessageInc("wx",1,"**> Showing ["         \
-                       <<bbGetFullName()<<"]"<<std::endl);             \
+    bbtkBlackBoxDebugMessage("widget",1,"**> Showing"                  \
+                            <<std::endl);                              \
     CALLBACK();                                                                \
-    bbtkDebugMessageInc("wx",1,"<** Showing ["         \
-                       <<bbGetFullName()<<"]"<<std::endl);             \
   }
   
   //======================================================================