]> Creatis software - bbtk.git/blobdiff - kernel/src/bbtkWidgetBlackBox.h
Fixed Window deletion mechanism
[bbtk.git] / kernel / src / bbtkWidgetBlackBox.h
index 03601b1db8b76abea4d083c8e928b1f5941f7143..20dc069fae3d79f174516989aea5db71bb3420d3 100644 (file)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbtkWidgetBlackBox.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/14 14:43:34 $
-  Version:   $Revision: 1.3 $
+  Date:      $Date: 2009/05/28 08:12:06 $
+  Version:   $Revision: 1.4 $
 ========================================================================*/
 
 
@@ -51,7 +51,6 @@ namespace bbtk
 {
 
 
-  template <class T> class WidgetBlackBoxWindow;
 
 
   //==================================================================
@@ -66,7 +65,6 @@ namespace bbtk
     //    typedef WidgetTraits Traits;
     typedef W Widget;
     typedef Widget* WidgetPointer;
-    typedef WidgetBlackBoxWindow<W> Window;
     
     
     BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
@@ -82,49 +80,25 @@ 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() {}
+    void bbSetShown(bool);
+    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
@@ -171,38 +145,23 @@ 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();
-    //==================================================================
-
-    
-    //==================================================================
-    //   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; }
+    /// Destroys the WidgetBlackBoxWindow associated to the box (if exists)
+    virtual void bbDestroyWindow() {}
     //==================================================================
 
+   
 
   private:
-    /// friendship
-    friend class WidgetBlackBoxWindow<W>;
-    //    friend class WidgetBlackBoxWidgetEventHandler;
-
-    /// The WidgetBlackBoxWindow associated to the box
-    Window* bbmWindow;
-
-
-
+   
+    /// 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;
   };
   //=================================================================
  
@@ -213,11 +172,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);             \
   }
   
   //======================================================================
@@ -226,13 +183,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);             \
   }
   
   //======================================================================