Program: bbtk
Module: $RCSfile: bbtkWidgetBlackBox.h,v $
Language: C++
- Date: $Date: 2009/04/21 14:36:51 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2009/06/10 11:36:51 $
+ Version: $Revision: 1.6 $
========================================================================*/
{
- template <class T> class WidgetBlackBoxWindow;
//==================================================================
/// 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
{
public:
// typedef WidgetTraits Traits;
typedef W Widget;
typedef Widget* WidgetPointer;
- typedef WidgetBlackBoxWindow<W> Window;
BBTK_BLACK_BOX_INTERFACE(WidgetBlackBox,bbtk::AtomicBlackBox);
/// 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
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
//==================================================================
//==================================================================
- /// 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;
-
-
- 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;
};
//=================================================================
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); \
}
//======================================================================
/// 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); \
}
//======================================================================