/*========================================================================= Program: bbtk Module: $RCSfile: bbtkWxBlackBox.h,v $ Language: C++ Date: $Date: 2008/03/06 09:23:43 $ Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*//** * \brief Short description in one line * * Long description which * can span multiple lines */ /** * \file * \brief */ /** * \class bbtk:: * \brief */ #ifdef _USE_WXWIDGETS_ #ifndef __bbtkWxBlackBox_h__ #define __bbtkWxBlackBox_h__ #include "bbtkWx.h" #include "bbtkAtomicBlackBox.h" namespace bbtk { //================================================================== // Forward declaration of the class of window associated to a WxBlackBox class WxBlackBoxWindow; //================================================================== //================================================================== // Forward declaration of the widget event handler class class WxBlackBoxWidgetEventHandler; //================================================================== //================================================================== /// Widget black boxes class BBTK_EXPORT WxBlackBox : public bbtk::AtomicBlackBox { BBTK_USER_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox); // BBTK_DECLARE_INPUT(WinParent,WxParentToChildData*); BBTK_DECLARE_INPUT(WinTitle,std::string); BBTK_DECLARE_INPUT(WinWidth,int); BBTK_DECLARE_INPUT(WinHeight,int); BBTK_DECLARE_INPUT(WinDialog,bool); BBTK_DECLARE_INPUT(WinHide,Void); BBTK_DECLARE_OUTPUT(Widget, wxWindow*);//WxBlackBoxWidget*); public: typedef WxBlackBoxWindow Window; /// Returns the window associated to the box /// If 0 returned = no window Window* bbGetWindow() { return bbmWindow; } /// Returns the Parent Window that must be used to create the widget wxWindow* bbGetWxParent() { return Wx::GetTopWindow(); } protected: //================================================================== /// User callback called in the box contructor virtual void bbUserConstructor(); /// User callback called in the box copy constructor virtual void bbUserCopyConstructor(); /// User callback called in the box destructor virtual void bbUserDestructor(); //================================================================== //================================================================== /// User callback for creating the widget associated to the box /// ** Must be defined ** virtual void bbUserCreateWidget() { bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is undefined : cannot work !!"); } //================================================================== //================================================================== /// Calls the user defined widget creation method /// and the user processing method and then displays the window virtual void bbProcess() { if (bbGetOutputWidget()==0) this->bbUserCreateWidget(); this->bbUserProcess(); bbShowWindow(); } //================================================================== //================================================================== /// Specific methods for windows creation during pipeline execution void bbShowWindow(); void bbHideWindow(); //================================================================== private: /// friendship friend class WxBlackBoxWindow; friend class WxBlackBoxWidgetEventHandler; /// Sets the window inline void bbSetWindow(Window* w) { bbmWindow=w; } /// Sets the Widget Event Handler inline void bbSetWidgetEventHandler(WxBlackBoxWidgetEventHandler* w) { bbmWidgetEventHandler = w; } /// Gets the Widget Event Handler inline WxBlackBoxWidgetEventHandler* bbGetWidgetEventHandler() { return bbmWidgetEventHandler; } /// The WxBlackBoxWindow associated to the box Window* bbmWindow; /// The WxBlackBoxWidgetEventHandler associated to the box WxBlackBoxWidgetEventHandler* bbmWidgetEventHandler; void bbInitAttributes(); protected : /// Main processing method of the box. Overloaded to handle windows inclusion : if the output Widget is connected then the execution is transfered to the box to which it is connected (the container window must be created and displayed - this box will be also executed by the normal pipeline recursion mechanism) virtual void bbExecute(bool force = false); }; //================================================================= //====================================================================== /// Defines the bbUserCreateWidget method #define BBTK_CREATE_WIDGET(CALLBACK) \ public: \ inline void bbUserCreateWidget() \ { \ bbtkDebugMessageInc("Process",1,"=> "<