X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=kernel%2Fsrc%2FbbtkWxBlackBox.h;h=095553d59b3023405e39e47016feb01dd4b704d7;hb=9e2b6d4716a5d12f39d8dde0a2d719fe961bdd2c;hp=c967fd1e31ea0dafcaea601c484c781f495409cf;hpb=f5db17702a2c51a5933f6c556d070167e4db9cfd;p=bbtk.git diff --git a/kernel/src/bbtkWxBlackBox.h b/kernel/src/bbtkWxBlackBox.h index c967fd1..095553d 100644 --- a/kernel/src/bbtkWxBlackBox.h +++ b/kernel/src/bbtkWxBlackBox.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxBlackBox.h,v $ Language: C++ - Date: $Date: 2008/02/07 07:58:54 $ - Version: $Revision: 1.6 $ + Date: $Date: 2008/07/24 14:37:06 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -61,47 +61,54 @@ namespace bbtk //================================================================== /// Widget black boxes class BBTK_EXPORT WxBlackBox : public bbtk::AtomicBlackBox - { - BBTK_USER_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox); + { + BBTK_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_INPUT(WinClose,Void); BBTK_DECLARE_OUTPUT(Widget, wxWindow*);//WxBlackBoxWidget*); public: + /// 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 (as the container window must be created and displayed - this box will be executed by the normal pipeline recursion mechanism) + virtual void bbExecute(bool force = false); + + typedef WxBlackBoxWindow Window; - /// Returns the window associated to the box + /// Returns the **OWN** 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 bbGlobalGetTopWindow(); } - - - /// Returns the global parent of all bbtk windows - static wxWindow* bbGlobalGetTopWindow(); - /// Sets the global parent of all bbtk windows - static void bbGlobalSetTopWindow(wxWindow*); - - static void bbGlobalIncNbWindowsAlive() { WxBlackBox::bbmgNbWindowsAlive++; } - static void bbGlobalDecNbWindowsAlive(); - static int bbGlobalGetNbWindowsAlive() { return WxBlackBox::bbmgNbWindowsAlive; } - static bool bbGlobalIsSomeWindowAlive() { return (WxBlackBox::bbmgNbWindowsAlive>0);} + /// 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. + /// 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(); - static void bbGlobalDecNbWindowsShown(); - static void bbGlobalIncNbWindowsShown() { WxBlackBox::bbmgNbWindowsShown++; } - static int bbGlobalGetNbWindowsShown() { return WxBlackBox::bbmgNbWindowsShown; } - static bool bbGlobalIsSomeWindowShown() { return (WxBlackBox::bbmgNbWindowsShown>0);} + /// Returns the parent wxWindow that must be used to create the widget + wxWindow* bbGetWxParent(); + /// Returns true iff the 'containing window' exists and is shown + /// (see bbGetContainingWindow). + bool bbIsShown(); - private: - static wxWindow* bbmgTopWindow; - static int bbmgNbWindowsAlive; - static int bbmgNbWindowsShown; + //================================================================== + /// User callback invoked when the containing window is shown + virtual void bbUserOnShow() {} + //================================================================== + + //================================================================== + /// User callback invoked when the containing window is hidden + virtual void bbUserOnHide() {} + //================================================================== protected: @@ -120,25 +127,40 @@ namespace bbtk /// ** Must be defined ** virtual void bbUserCreateWidget() { - bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is undefined : cannot work !!"); + bbtkError(bbGetTypeName()<<" is a WxBlackBox whose bbUserCreateWidget methods is not overloaded : is it a feature or a bug ?!?"); } //================================================================== + + + //================================================================== - /// 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(); - } + /// Main processing method of the box. + virtual IOStatus bbBackwardUpdate( Connection::Pointer caller ); + //================================================================== + + + + //================================================================== + /// Overloaded processing method for WxBlackBoxes : + /// 1) if the widget is null then + /// calls the user defined widget creation method : bbUserCreateWidget() + /// 2) calls the user defined processing method : bbUserProcess() + /// 3) displays the window : bbShowWindow(); + virtual void bbProcess(); //================================================================== //================================================================== - /// Specific methods for windows creation during pipeline execution + /// If necessary creates the WxBlackBoxWindow associated to the box + /// and shows it + /// (does nothing if the box output 'Widget' is connected which + /// means that the box does not have its own window but is contained + /// into another window) void bbShowWindow(); + /// Hides the WxBlackBoxWindow associated to the box (if exists) void bbHideWindow(); + /// Closes (destroys) the WxBlackBoxWindow associated to the box (if exists) + void bbCloseWindow(); //================================================================== private: @@ -165,6 +187,18 @@ namespace bbtk void bbInitAttributes(); + protected : + + + /// For Forward update mechanism when execution is called + /// on a contained window + /// Is set to true before transfering update to parent + /// in order to not re-transfer a second time... + bool bbmUpdateTransferedToParent; + + bool bbGetUpdateTransferedToParent() const { return bbmUpdateTransferedToParent; } + void bbSetUpdateTransferedToParent(bool b) + { bbmUpdateTransferedToParent = b; } }; //================================================================= @@ -176,10 +210,10 @@ namespace bbtk public: \ inline void bbUserCreateWidget() \ { \ - bbtkDebugMessageInc("Process",1,"=> "< Creating widget for [" \ <