From: Pablo Garzon Date: Tue, 2 May 2023 14:16:03 +0000 (+0200) Subject: #3500 CheckBox Tool X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0c423b9c5dc4cd92f46c871cc6c023f225eb58c9;p=bbtk.git #3500 CheckBox Tool --- diff --git a/packages/wx/src/bbwxCheckBox.cxx b/packages/wx/src/bbwxCheckBox.cxx index e681ab8..48d2091 100644 --- a/packages/wx/src/bbwxCheckBox.cxx +++ b/packages/wx/src/bbwxCheckBox.cxx @@ -71,41 +71,7 @@ #include "bbtkUtilities.h" namespace bbwx -{ - //-------------------------------------------------------------------------- - // The widget created by the box - class CheckBoxWidget : public wxPanel - { - public: - /// Ctor with the two first params the parent window and the creator box - /// which must be passed to the WxBlackBoxWidget constructor. - /// The other params initialize the widget - CheckBoxWidget(CheckBox* box, wxWindow *parent, - wxString title, - bool value, int reactiveOnKeyStroke - ); - /// Dtor - ~CheckBoxWidget(); - /// Events callbacks - /// Called when the box is clicked - void OnCheckBoxClick(wxCommandEvent& event); - - // Accessors - bool GetValue() { return mwxCheckBox->GetValue(); } - void SetValue(bool val); - // Update the texts which display the min/max/current values of the slider - - private: - CheckBox* mBox; - wxCheckBox *mwxCheckBox; - int _reactiveOnKeyStroke; - bool val; - }; - //------------------------------------------------------------------------ - //------------------------------------------------------------------------ - //------------------------------------------------------------------------ - - +{ //------------------------------------------------------------------------- CheckBoxWidget::CheckBoxWidget(CheckBox* box, wxWindow *parent, @@ -173,7 +139,12 @@ namespace bbwx //------------------------------------------------------------------------- void CheckBoxWidget::OnCheckBoxClick(wxCommandEvent& event) { - // When user clicks the box + OnCheckBoxClick_(); + } + //------------------------------------------------------------------------- + void CheckBoxWidget::OnCheckBoxClick_() + { + // When user clicks the box // we update the output of the box mBox->bbSetOutputOut( mwxCheckBox->GetValue() ); mBox->bbSetInputIn( mwxCheckBox->GetValue() ); @@ -183,8 +154,6 @@ namespace bbwx //} } //------------------------------------------------------------------------- - - //------------------------------------------------------------------------- //------------------------------------------------------------------------- @@ -242,7 +211,6 @@ namespace bbwx bbGetInputReactiveOnKeystroke() ); bbSetOutputWidget( w ); - } diff --git a/packages/wx/src/bbwxCheckBox.h b/packages/wx/src/bbwxCheckBox.h index e600f89..5e8f963 100644 --- a/packages/wx/src/bbwxCheckBox.h +++ b/packages/wx/src/bbwxCheckBox.h @@ -109,6 +109,40 @@ namespace bbwx protected: }; + + //-------------------------------------------------------------------------- + // The widget created by the box + class CheckBoxWidget : public wxPanel + { + public: + /// Ctor with the two first params the parent window and the creator box + /// which must be passed to the WxBlackBoxWidget constructor. + /// The other params initialize the widget + CheckBoxWidget(CheckBox* box, wxWindow *parent, + wxString title, + bool value, int reactiveOnKeyStroke + ); + /// Dtor + ~CheckBoxWidget(); + /// Events callbacks + /// Called when the box is clicked + void OnCheckBoxClick(wxCommandEvent& event); + void OnCheckBoxClick_(); + + // Accessors + bool GetValue() { return mwxCheckBox->GetValue(); } + void SetValue(bool val); + // Update the texts which display the min/max/current values of the slider + + private: + CheckBox* mBox; + wxCheckBox *mwxCheckBox; + int _reactiveOnKeyStroke; + bool val; + }; + //------------------------------------------------------------------------ + //------------------------------------------------------------------------ + //------------------------------------------------------------------------ //================================================================= //================================================================= diff --git a/packages/wx/src/bbwxCheckBox_tool.cxx b/packages/wx/src/bbwxCheckBox_tool.cxx new file mode 100644 index 0000000..e85c934 --- /dev/null +++ b/packages/wx/src/bbwxCheckBox_tool.cxx @@ -0,0 +1,75 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#include "bbwxCheckBox_tool.h" +#include "bbwxPackage.h" +namespace bbwx +{ + +BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,CheckBox_tool) +BBTK_BLACK_BOX_IMPLEMENTATION(CheckBox_tool,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void CheckBox_tool::Process() +{ + +// THE MAIN PROCESSING METHOD BODY +// Here we simply set the input 'In' value to the output 'Out' +// And print out the output value +// INPUT/OUTPUT ACCESSORS ARE OF THE FORM : +// void bbSet{Input|Output}NAME(const TYPE&) +// const TYPE& bbGet{Input|Output}NAME() const +// Where : +// * NAME is the name of the input/output +// (the one provided in the attribute 'name' of the tag 'input') +// * TYPE is the C++ type of the input/output +// (the one provided in the attribute 'type' of the tag 'input') + + if(bbGetInputCheckBoxWidget() != NULL){ + CheckBoxWidget* checkboxWidget = dynamic_cast(bbGetInputCheckBoxWidget()); + checkboxWidget->SetValue(bbGetInputIn()); + checkboxWidget->OnCheckBoxClick_(); + } + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void CheckBox_tool::bbUserSetDefaultValues() +{ + +// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX +// Here we initialize the input 'In' to 0 + bbSetInputIn(false); + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void CheckBox_tool::bbUserInitializeProcessing() +{ + +// THE INITIALIZATION METHOD BODY : +// Here does nothing +// but this is where you should allocate the internal/output pointers +// if any + + +} +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +void CheckBox_tool::bbUserFinalizeProcessing() +{ + +// THE FINALIZATION METHOD BODY : +// Here does nothing +// but this is where you should desallocate the internal/output pointers +// if any + +} +} +// EO namespace bbwx + + diff --git a/packages/wx/src/bbwxCheckBox_tool.h b/packages/wx/src/bbwxCheckBox_tool.h new file mode 100644 index 0000000..ea3f9d0 --- /dev/null +++ b/packages/wx/src/bbwxCheckBox_tool.h @@ -0,0 +1,48 @@ +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +#ifndef __bbwxCheckBox_tool_h_INCLUDED__ +#define __bbwxCheckBox_tool_h_INCLUDED__ + +#include "bbwx_EXPORT.h" +#include "bbtkAtomicBlackBox.h" +#include "iostream" + +#include "bbwxCheckBox.h" + +namespace bbwx +{ + +class bbwx_EXPORT CheckBox_tool + : + public bbtk::AtomicBlackBox +{ + BBTK_BLACK_BOX_INTERFACE(CheckBox_tool,bbtk::AtomicBlackBox); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== + BBTK_DECLARE_INPUT(In,bool); + BBTK_DECLARE_INPUT(CheckBoxWidget, wxWindow*); + BBTK_PROCESS(Process); + void Process(); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +}; + +BBTK_BEGIN_DESCRIBE_BLACK_BOX(CheckBox_tool,bbtk::AtomicBlackBox); +BBTK_NAME("CheckBox_tool"); +BBTK_AUTHOR("InfoDev"); +BBTK_DESCRIPTION("No Description."); +BBTK_CATEGORY("empty"); +BBTK_INPUT(CheckBox_tool,In,"new value",bool,""); +BBTK_INPUT(CheckBox_tool,CheckBoxWidget,"Checkbox box to use",wxWindow*,""); +BBTK_END_DESCRIBE_BLACK_BOX(CheckBox_tool); +//===== +// Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost) +//===== +} +// EO namespace bbwx + +#endif // __bbwxCheckBox_tool_h_INCLUDED__ +