2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbwxRadioButton.cxx,v $
32 Date: $Date: 2012/11/16 08:52:14 $
33 Version: $Revision: 1.10 $
34 =========================================================================*/
42 #ifdef _USE_WXWIDGETS_
45 #include "bbwxRadioButton.h"
46 #include "bbwxPackage.h"
54 //--------------------------------------------------------------------------
55 // The widget created by the box
56 class RadioButtonWidget : public wxPanel
59 RadioButtonWidget( RadioButton* box, wxWindow *parent,
62 std::vector<wxString> lstIn );
67 void OnRadioButton(wxEvent& event);
68 void AddElements(std::vector<wxString> lstIn, int In, wxString title);
73 wxRadioButton *mwxRadioButton[10];
75 wxFlexGridSizer *sizer;
78 //------------------------------------------------------------------------
79 //------------------------------------------------------------------------
80 //------------------------------------------------------------------------
82 //-------------------------------------------------------------------------
83 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
87 std::vector<wxString> lstIn )
89 wxPanel( parent, -1) ,
94 //-------------------------------------------------------------------------
96 RadioButtonWidget::~RadioButtonWidget()
100 //-------------------------------------------------------------------------
102 int RadioButtonWidget::GetValue()
106 for (i=0;i<MAX_RADIOBUTTON; i++)
108 if ( mwxRadioButton[i]!=NULL)
110 if (mwxRadioButton[i]->GetValue()==true)
119 //--------------------------------------------------------------------------
120 void RadioButtonWidget::OnRadioButton(wxEvent& event)
122 mBox->bbSetOutputOut( GetValue() );
123 mBox->bbSetInputIn( GetValue() );
124 mBox->bbSignalOutputModification("Out");
128 //--------------------------------------------------------------------------
129 void RadioButtonWidget::AddElements( std::vector<wxString> lstIn ,int In, wxString title)
133 MAX_RADIOBUTTON = lstIn.size();
134 wxPanel *panel = this;
136 long style=wxRB_GROUP;
137 for (i=0;i<MAX_RADIOBUTTON; i++)
139 if ( lstIn[i]!=_T(""))
141 //---------------------------------------------------------------------
142 // 1) Creation of the components of the widget
143 // Any top level sub-widget must have the panel returned by panel
145 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
149 mwxRadioButton[i]->SetValue(true);
151 mwxRadioButton[i]->SetValue(false);
153 Connect( mwxRadioButton[i]->GetId(),
154 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
155 (wxObjectEventFunction)
156 (void (wxPanel::*)(wxEvent&))
157 &RadioButtonWidget::OnRadioButton );
159 mwxRadioButton[i]=NULL;
163 //---------------------------------------------------------------------
164 // 2) Insertion of the components in the window
166 // We use a FlexGridSizer
169 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
170 sizer = new wxFlexGridSizer(1);
174 sizer->Add( new wxStaticText(panel,-1, title ) );
176 for (i=0;i<MAX_RADIOBUTTON; i++)
178 if (mwxRadioButton[i]!=NULL)
180 sizer->Add( mwxRadioButton[i],1,wxGROW );
183 sizer->AddGrowableCol(0);
184 panel->SetSizer(sizer);
186 panel->SetAutoLayout(true);
192 //--------------------------------------------------------------------------
193 //-------------------------------------------------------------------------
194 //--------------------------------------------------------------------------
195 //--------------------------------------------------------------------------
197 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
198 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
201 //-----------------------------------------------------------------
202 void RadioButton::bbUserSetDefaultValues()
205 bbSetOutputOut( bbGetInputIn() );
218 //-----------------------------------------------------------------
219 void RadioButton::bbUserInitializeProcessing()
223 //-----------------------------------------------------------------
224 void RadioButton::bbUserFinalizeProcessing()
228 void RadioButton::Process()
230 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
231 bbtkDebugDecTab("Core",9);
234 std::vector<wxString> lstIn;
235 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
236 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
237 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
238 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
239 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
240 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
241 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
242 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
243 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
244 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
247 ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) );
253 * \brief Create wxWidget .
257 void RadioButton::CreateWidget(wxWindow* parent)
260 std::vector<wxString> lstIn;
261 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
262 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
263 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
264 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
265 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
266 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
267 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
268 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
269 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
270 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
272 RadioButtonWidget *w = new RadioButtonWidget(
276 bbtk::std2wx(bbGetInputTitle()),
279 bbSetOutputOut( bbGetInputIn() );
280 bbSetOutputWidget( w );
289 #endif // _USE_WXWIDGETS_