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) ,
92 AddElements( lstIn , In,title);
93 mBox->bbSetOutputOut( GetValue() );
94 mBox->bbSetInputIn( GetValue() );
97 //-------------------------------------------------------------------------
99 RadioButtonWidget::~RadioButtonWidget()
103 //-------------------------------------------------------------------------
105 int RadioButtonWidget::GetValue()
109 for (i=0;i<MAX_RADIOBUTTON; i++)
111 if ( mwxRadioButton[i]!=NULL)
113 if (mwxRadioButton[i]->GetValue()==true)
118 } // if mwxRadioButton
122 //--------------------------------------------------------------------------
123 void RadioButtonWidget::OnRadioButton(wxEvent& event)
125 mBox->bbSetOutputOut( GetValue() );
126 mBox->bbSetInputIn( GetValue() );
127 mBox->bbSignalOutputModification("Out");
131 //--------------------------------------------------------------------------
132 void RadioButtonWidget::AddElements( std::vector<wxString> lstIn ,int In, wxString title)
136 MAX_RADIOBUTTON = lstIn.size();
137 wxPanel *panel = this;
139 long style=wxRB_GROUP;
140 for (i=0;i<MAX_RADIOBUTTON; i++)
142 if ( lstIn[i]!=_T(""))
144 //---------------------------------------------------------------------
145 // 1) Creation of the components of the widget
146 // Any top level sub-widget must have the panel returned by panel
148 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
152 mwxRadioButton[i]->SetValue(true);
154 mwxRadioButton[i]->SetValue(false);
156 Connect( mwxRadioButton[i]->GetId(),
157 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
158 (wxObjectEventFunction)
159 (void (wxPanel::*)(wxEvent&))
160 &RadioButtonWidget::OnRadioButton );
162 mwxRadioButton[i]=NULL;
166 //---------------------------------------------------------------------
167 // 2) Insertion of the components in the window
169 // We use a FlexGridSizer
172 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
173 sizer = new wxFlexGridSizer(1);
177 sizer->Add( new wxStaticText(panel,-1, title ) );
179 for (i=0;i<MAX_RADIOBUTTON; i++)
181 if (mwxRadioButton[i]!=NULL)
183 sizer->Add( mwxRadioButton[i],1,wxGROW );
186 sizer->AddGrowableCol(0);
187 panel->SetSizer(sizer);
189 panel->SetAutoLayout(true);
195 //--------------------------------------------------------------------------
196 //-------------------------------------------------------------------------
197 //--------------------------------------------------------------------------
198 //--------------------------------------------------------------------------
200 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
201 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
204 //-----------------------------------------------------------------
205 void RadioButton::bbUserSetDefaultValues()
208 bbSetOutputOut( bbGetInputIn() );
221 //-----------------------------------------------------------------
222 void RadioButton::bbUserInitializeProcessing()
226 //-----------------------------------------------------------------
227 void RadioButton::bbUserFinalizeProcessing()
231 void RadioButton::Process()
233 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
234 bbtkDebugDecTab("Core",9);
235 std::vector<wxString> lstIn;
236 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
237 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
238 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
239 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
240 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
241 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
242 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
243 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
244 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
245 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
246 if (bbGetOutputWidget()!=NULL)
248 ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) );
249 } // if bbGetOutputWidget
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_