1 /*=========================================================================
4 Module: $RCSfile: bbwxButtonExecBlackBox.cxx,v $
6 Date: $Date: 2008/02/12 10:31:58 $
7 Version: $Revision: 1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
24 #ifdef _USE_WXWIDGETS_
27 #include "bbwxButtonExecBlackBox.h"
28 #include "bbwxPackage.h"
29 #include "bbtkInterpreter.h"
35 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ButtonExecBlackBox);
37 ButtonExecBlackBoxWidget::ButtonExecBlackBoxWidget(ButtonExecBlackBox* box,
40 :wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
44 wxPanel *panel = this;
46 mwxButton = new wxButton( panel, -1, title);
47 Connect( mwxButton->GetId(),
48 wxEVT_COMMAND_BUTTON_CLICKED ,
49 (wxObjectEventFunction)
50 (void (wxPanel::*)(wxEvent&))
51 &ButtonExecBlackBoxWidget::OnButton );
53 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
54 sizer->Add( mwxButton,1,wxGROW );
55 sizer->AddGrowableCol(0);
57 panel->SetSizer(sizer);
58 panel->SetAutoLayout(true);
64 ButtonExecBlackBoxWidget::~ButtonExecBlackBoxWidget()
69 void ButtonExecBlackBoxWidget::OnButton( wxEvent& )
73 +mBox->bbGetInputIn());
74 bool insideComment = false; // for multiline comment
75 bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr,
77 mBox->bbSignalOutputModification();
83 void ButtonExecBlackBoxWidget::SetLabel(wxString title)
85 mwxButton->SetLabel(title);
90 void ButtonExecBlackBoxWidget::SetColour(wxColour color)
92 mwxButton->SetBackgroundColour(color);
97 //--------------------------------------------------------------------------
98 //-------------------------------------------------------------------------
99 // WxBlackBox implementation
100 //--------------------------------------------------------------------------
101 //--------------------------------------------------------------------------
103 BBTK_USER_BLACK_BOX_IMPLEMENTATION(ButtonExecBlackBox,bbtk::WxBlackBox);
105 void ButtonExecBlackBox::bbUserConstructor()
107 bbSetInputIn("CURRENT");
109 std::vector<double> lstColour;
110 lstColour.push_back(-1);
111 lstColour.push_back(-1);
112 lstColour.push_back(-1);
116 void ButtonExecBlackBox::Process()
118 mWidget->SetLabel( wxString( bbGetInputLabel().c_str() , wxConvUTF8 ) );
122 if ( (bbGetInputColour()[0]==-1) && (bbGetInputColour()[1]==-1) &&(bbGetInputColour()[1]==-1) )
124 wxwidget->SetColour( wxwidget->GetParent()->GetBeckgroundColor() );
126 int r=(int) (255*bbGetInputColour()[0]);
127 int g=(int) (255*bbGetInputColour()[1]);
128 int b=(int) (255*bbGetInputColour()[2]);
129 wxwidget->SetColour( wxColour(r,g,b) );
132 // wxwidget->Update();
133 // bbSetOutput###( 0 );
138 * \brief Create wxWidget .
142 void ButtonExecBlackBox::CreateWidget()
144 bbtkDebugMessageInc("Core",9,"ButtonExecBlackBox::bbCreateWxWindow("<<parent<<")"<<std::endl);
145 mWidget = new ButtonExecBlackBoxWidget(this,
147 wxString( bbGetInputLabel().c_str() , wxConvUTF8 )
149 bbtkDebugDecTab("Core",9);
150 bbSetOutputWidget( mWidget );
157 #endif // _USE_WXWIDGETS_