-/*=========================================================================
+/*
+ # ---------------------------------------------------------------------
+ #
+ # 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/05/14 14:43:34 $
- Version: $Revision: 1.3 $
+ 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
*
{
- 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:
-
+ 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;
-
-
-
+
+ /// 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); \
}
//======================================================================