/*========================================================================= Program: bbtk Module: $RCSfile: bbwxRadioButton.cxx,v $ Language: C++ Date: $Date: 2008/04/18 12:59:53 $ Version: $Revision: 1.4 $ 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 "bbwxRadioButton.h" #include "bbwxPackage.h" #include namespace bbwx { BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton); //------------------------------------------------------------------------- RadioButtonWidget::RadioButtonWidget( RadioButton* box, wxWindow *parent, int In, wxString title, std::vector lstIn ) : wxPanel( parent, -1) , mBox(box) { wxPanel *panel = this; MAX_RADIOBUTTON = lstIn.size(); int i; long style=wxRB_GROUP; for (i=0;iSetValue(true); } else { mwxRadioButton[i]->SetValue(false); } Connect( mwxRadioButton[i]->GetId(), wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &RadioButtonWidget::OnRadioButton ); } else { mwxRadioButton[i]=NULL; } } //--------------------------------------------------------------------- // 2) Insertion of the components in the window // We use a FlexGridSizer wxFlexGridSizer *sizer = new wxFlexGridSizer(1); if (title!=_T("")) { sizer->Add( new wxStaticText(panel,-1, title ) ); } for (i=0;iAdd( mwxRadioButton[i],1,wxGROW ); } } sizer->AddGrowableCol(0); panel->SetSizer(sizer); // panel->SetAutoLayout(true); // panel->Layout(); } //------------------------------------------------------------------------- RadioButtonWidget::~RadioButtonWidget() { } //------------------------------------------------------------------------- int RadioButtonWidget::GetValue() { int result=-1; int i; for (i=0;iGetValue()==true) { result=i; } } } return result; } //-------------------------------------------------------------------------- void RadioButtonWidget::OnRadioButton(wxEvent& event) { mBox->bbSetOutputOut( GetValue() ); mBox->bbSetInputIn( GetValue() ); mBox->bbSignalOutputModification("Out"); } //-------------------------------------------------------------------------- //------------------------------------------------------------------------- //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox); void RadioButton::bbUserConstructor() { bbSetInputIn(0); bbSetOutputOut( bbGetInputIn() ); bbSetInputIn0(""); bbSetInputIn1(""); bbSetInputIn2(""); bbSetInputIn3(""); bbSetInputIn4(""); bbSetInputIn5(""); bbSetInputIn6(""); bbSetInputIn7(""); bbSetInputIn8(""); bbSetInputIn9(""); } void RadioButton::Process() { bbtkDebugMessageInc("Core",9,"RadioButton::Process()"< lstIn; lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) ); lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) ); RadioButtonWidget *w = new RadioButtonWidget( this, bbGetWxParent(), bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()), lstIn ); bbSetOutputWidget( w ); } }//namespace bbtk #endif // _USE_WXWIDGETS_