From: Eduardo Davila Date: Tue, 12 Feb 2008 10:31:57 +0000 (+0000) Subject: wxButtonExecBlackBox X-Git-Tag: r0.6.1~238 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=150d84b9895d0948aa71182b8719768a9172cb0e;p=bbtk.git wxButtonExecBlackBox --- diff --git a/packages/wx/bbs/appli/testButtonExecBlackBox.bbs b/packages/wx/bbs/appli/testButtonExecBlackBox.bbs new file mode 100644 index 0000000..c9b1671 --- /dev/null +++ b/packages/wx/bbs/appli/testButtonExecBlackBox.bbs @@ -0,0 +1,12 @@ +description "Simple test of wx::ButtonExecBlackBox widget" +author "eduardo.davila@creatis.insa-lyon.fr" +category "test;widget" + +load wx +new Slider slider +new ButtonExecBlackBox button + set button.In "slider" + set button.Label "Run" + +exec button + diff --git a/packages/wx/src/bbwxButtonExecBlackBox.cxx b/packages/wx/src/bbwxButtonExecBlackBox.cxx new file mode 100644 index 0000000..9951196 --- /dev/null +++ b/packages/wx/src/bbwxButtonExecBlackBox.cxx @@ -0,0 +1,158 @@ +/*========================================================================= + + Program: bbtk + Module: $RCSfile: bbwxButtonExecBlackBox.cxx,v $ + Language: C++ + Date: $Date: 2008/02/12 10:31:58 $ + Version: $Revision: 1.1 $ + + 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. + +=========================================================================*/ +/** + * \file + * \brief + */ + + +#ifdef _USE_WXWIDGETS_ + + +#include "bbwxButtonExecBlackBox.h" +#include "bbwxPackage.h" +#include "bbtkInterpreter.h" + + + +namespace bbwx +{ + BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ButtonExecBlackBox); + + ButtonExecBlackBoxWidget::ButtonExecBlackBoxWidget(ButtonExecBlackBox* box, + wxWindow *parent, + wxString title) + :wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), + mBox(box) + { + + wxPanel *panel = this; + + mwxButton = new wxButton( panel, -1, title); + Connect( mwxButton->GetId(), + wxEVT_COMMAND_BUTTON_CLICKED , + (wxObjectEventFunction) + (void (wxPanel::*)(wxEvent&)) + &ButtonExecBlackBoxWidget::OnButton ); + + wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + sizer->Add( mwxButton,1,wxGROW ); + sizer->AddGrowableCol(0); + + panel->SetSizer(sizer); + panel->SetAutoLayout(true); + panel->Layout(); + + } + + + ButtonExecBlackBoxWidget::~ButtonExecBlackBoxWidget() + { + } + + + void ButtonExecBlackBoxWidget::OnButton( wxEvent& ) + { + std::string + commandstr("exec " + +mBox->bbGetInputIn()); + bool insideComment = false; // for multiline comment + bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr, + insideComment ); + mBox->bbSignalOutputModification(); + } + + + + + void ButtonExecBlackBoxWidget::SetLabel(wxString title) + { + mwxButton->SetLabel(title); + } + + + + void ButtonExecBlackBoxWidget::SetColour(wxColour color) + { + mwxButton->SetBackgroundColour(color); + } + + + + //-------------------------------------------------------------------------- + //------------------------------------------------------------------------- + // WxBlackBox implementation + //-------------------------------------------------------------------------- + //-------------------------------------------------------------------------- + + BBTK_USER_BLACK_BOX_IMPLEMENTATION(ButtonExecBlackBox,bbtk::WxBlackBox); + + void ButtonExecBlackBox::bbUserConstructor() + { + bbSetInputIn("CURRENT"); + bbSetInputLabel(""); + std::vector lstColour; + lstColour.push_back(-1); + lstColour.push_back(-1); + lstColour.push_back(-1); + } + + + void ButtonExecBlackBox::Process() + { + mWidget->SetLabel( wxString( bbGetInputLabel().c_str() , wxConvUTF8 ) ); + + + /* + if ( (bbGetInputColour()[0]==-1) && (bbGetInputColour()[1]==-1) &&(bbGetInputColour()[1]==-1) ) + { + wxwidget->SetColour( wxwidget->GetParent()->GetBeckgroundColor() ); + } else { + int r=(int) (255*bbGetInputColour()[0]); + int g=(int) (255*bbGetInputColour()[1]); + int b=(int) (255*bbGetInputColour()[2]); + wxwidget->SetColour( wxColour(r,g,b) ); + } +*/ +// wxwidget->Update(); +// bbSetOutput###( 0 ); + } + + + /** + * \brief Create wxWidget . + * + * + */ + void ButtonExecBlackBox::CreateWidget() + { + bbtkDebugMessageInc("Core",9,"ButtonExecBlackBox::bbCreateWxWindow("< ); + // BBTK_DECLARE_OUTPUT(Out,int); + BBTK_CREATE_WIDGET(CreateWidget); + BBTK_PROCESS(Process); + void Process(); + void CreateWidget(); + + protected: + virtual void bbUserConstructor(); + + private: + ButtonExecBlackBoxWidget *mWidget; + }; + + //================================================================= + // UserBlackBox description + BBTK_BEGIN_DESCRIBE_BLACK_BOX(ButtonExecBlackBox,bbtk::WxBlackBox); + BBTK_NAME("ButtonExecBlackBox"); + BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr"); + // Already inserted for any WxBlackBox BBTK_CATEGORY("widget"); + BBTK_DESCRIPTION("Button widget (Execute a BlackBox)"); + + typedef std::vector vectorcolour; + + BBTK_INPUT(ButtonExecBlackBox,In,"Name of the Black Box to be executed",std::string); + BBTK_INPUT(ButtonExecBlackBox,Label,"Label of the button",std::string); + BBTK_INPUT(ButtonExecBlackBox,Colour,"Colour of the button (-1 -1 -1 Background)",vectorcolour); + // BBTK_OUTPUT(ButtonExecBlackBox,Out,"..Out..",int); + BBTK_END_DESCRIBE_BLACK_BOX(ButtonExecBlackBox); + //================================================================= + + +}//namespace bbwx + +#endif // __bbwxButtonExecBlackBox_h_INCLUDED_H__ + +#endif //_USE_WXWIDGETS_ diff --git a/packages/wx/src/bbwxSlider.cxx b/packages/wx/src/bbwxSlider.cxx index ca2409a..0efc2c7 100644 --- a/packages/wx/src/bbwxSlider.cxx +++ b/packages/wx/src/bbwxSlider.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbwxSlider.cxx,v $ Language: C++ - Date: $Date: 2008/02/08 14:58:31 $ - Version: $Revision: 1.5 $ + Date: $Date: 2008/02/12 10:31:58 $ + Version: $Revision: 1.6 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -336,12 +336,10 @@ namespace bbwx //-------------------------------------------------------------------------- BBTK_USER_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WxBlackBox); BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Slider); - //-------------------------------------------------------------------------- - + //-------------------------------------------------------------------------- void Slider::bbUserConstructor() { - // bbSetInputWinTitle("Slider"); bbSetInputIn(0); bbSetInputMin(0); bbSetInputMax(500); @@ -351,8 +349,7 @@ namespace bbwx bbSetInputLabel(true); bbSetInputReactiveOnTrack(0); } - //-------------------------------------------------------------------------- - + //-------------------------------------------------------------------------- void Slider::Process() { @@ -382,17 +379,6 @@ namespace bbwx bbSetOutputWidget( w ); } - //-------------------------------------------------------------------------- - /* - //-------------------------------------------------------------------------- - bbtk::WxBlackBoxWidget* Slider::bbUserCreateWidget(wxWindow *parent) - { - - - } - //-------------------------------------------------------------------------- - */ - } //namespace bbwx diff --git a/packages/wx/src/bbwxSlider.h b/packages/wx/src/bbwxSlider.h index 693df80..cac5a73 100644 --- a/packages/wx/src/bbwxSlider.h +++ b/packages/wx/src/bbwxSlider.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbwxSlider.h,v $ Language: C++ - Date: $Date: 2008/02/08 14:58:31 $ - Version: $Revision: 1.7 $ + Date: $Date: 2008/02/12 10:31:58 $ + 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 @@ -52,18 +52,9 @@ namespace bbwx { - - - - - //-------------------------------------------------------------------------- // Forward declaration of the box class Slider; - //-------------------------------------------------------------------------- - - - //-------------------------------------------------------------------------- // The widget created by the box @@ -153,14 +144,10 @@ namespace bbwx BBTK_INPUT(Slider,Min,"Minimum value of the slider (default 0)",int); BBTK_INPUT(Slider,Max,"Maximum value of the slider (default 500)",int); BBTK_INPUT(Slider,Label,"Show slider labels ? (default FALSE) ",bool); - BBTK_INPUT(Slider,Title,"Title shown above the slider (default '') ", - std::string); - BBTK_INPUT(Slider,Orientation, - "Orientation : (default H) 0=H=HORIZONTAL, 1=V=VERTICAL ",std::string); - BBTK_INPUT(Slider,ChangeResolution, - "Can the user change the resolution of the slider ? (default FALSE) ",bool); - BBTK_INPUT(Slider,ReactiveOnTrack, - "Slider sends info when track moves (default 0 = no)",int); + BBTK_INPUT(Slider,Title,"Title shown above the slider (default '') ", std::string); + BBTK_INPUT(Slider,Orientation, "Orientation : (default H) 0=H=HORIZONTAL, 1=V=VERTICAL ",std::string); + BBTK_INPUT(Slider,ChangeResolution, "Can the user change the resolution of the slider ? (default FALSE) ",bool); + BBTK_INPUT(Slider,ReactiveOnTrack, "Slider sends info when track moves (default 0 = no)",int); BBTK_OUTPUT(Slider,Out,"Current position of the slider",int); BBTK_END_DESCRIBE_BLACK_BOX(Slider); //=================================================================