1 /*=========================================================================
4 Module: $RCSfile: bbwxRadioButton.cxx,v $
6 Date: $Date: 2008/02/14 20:26:54 $
7 Version: $Revision: 1.3 $
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 "bbwxRadioButton.h"
28 #include "bbwxPackage.h"
34 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
36 //-------------------------------------------------------------------------
37 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
41 std::vector<wxString> lstIn )
43 wxPanel( parent, -1) ,
46 wxPanel *panel = this;
47 MAX_RADIOBUTTON = lstIn.size();
49 long style=wxRB_GROUP;
50 for (i=0;i<MAX_RADIOBUTTON; i++)
52 if ( lstIn[i]!=_T(""))
54 //---------------------------------------------------------------------
55 // 1) Creation of the components of the widget
56 // Any top level sub-widget must have the panel returned by panel
58 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
62 mwxRadioButton[i]->SetValue(true);
66 mwxRadioButton[i]->SetValue(false);
68 Connect( mwxRadioButton[i]->GetId(),
69 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
70 (wxObjectEventFunction)
71 (void (wxPanel::*)(wxEvent&))
72 &RadioButtonWidget::OnRadioButton );
76 mwxRadioButton[i]=NULL;
80 //---------------------------------------------------------------------
81 // 2) Insertion of the components in the window
83 // We use a FlexGridSizer
84 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
87 sizer->Add( new wxStaticText(panel,-1, title ) );
89 for (i=0;i<MAX_RADIOBUTTON; i++)
91 if (mwxRadioButton[i]!=NULL)
93 sizer->Add( mwxRadioButton[i],1,wxGROW );
96 sizer->AddGrowableCol(0);
97 panel->SetSizer(sizer);
99 // panel->SetAutoLayout(true);
103 //-------------------------------------------------------------------------
105 RadioButtonWidget::~RadioButtonWidget()
109 //-------------------------------------------------------------------------
111 int RadioButtonWidget::GetValue()
115 for (i=0;i<MAX_RADIOBUTTON; i++)
117 if ( mwxRadioButton[i]!=NULL)
119 if (mwxRadioButton[i]->GetValue()==true)
128 //--------------------------------------------------------------------------
129 void RadioButtonWidget::OnRadioButton(wxEvent& event)
131 mBox->bbSetOutputOut( GetValue() );
132 mBox->bbSetInputIn( GetValue() );
133 mBox->bbSignalOutputModification("Out");
136 //--------------------------------------------------------------------------
137 //-------------------------------------------------------------------------
138 //--------------------------------------------------------------------------
139 //--------------------------------------------------------------------------
142 BBTK_USER_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
145 void RadioButton::bbUserConstructor()
148 bbSetOutputOut( bbGetInputIn() );
162 void RadioButton::Process()
164 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
165 bbtkDebugDecTab("Core",9);
169 * \brief Create wxWidget .
173 void RadioButton::CreateWidget()
176 std::vector<wxString> lstIn;
177 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
178 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
179 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
180 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
181 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
182 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
183 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
184 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
185 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
186 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
188 RadioButtonWidget *w = new RadioButtonWidget(
192 bbtk::std2wx(bbGetInputTitle()),
195 bbSetOutputWidget( w );
204 #endif // _USE_WXWIDGETS_