/*========================================================================= 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("<