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 MAX_RADIOBUTTON = lstIn.size();
95 wxPanel *panel = this;
97 long style=wxRB_GROUP;
98 for (i=0;i<MAX_RADIOBUTTON; i++)
100 if ( lstIn[i]!=_T(""))
102 //---------------------------------------------------------------------
103 // 1) Creation of the components of the widget
104 // Any top level sub-widget must have the panel returned by panel
106 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
110 mwxRadioButton[i]->SetValue(true);
112 mwxRadioButton[i]->SetValue(false);
114 Connect( mwxRadioButton[i]->GetId(),
115 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
116 (wxObjectEventFunction)
117 (void (wxPanel::*)(wxEvent&))
118 &RadioButtonWidget::OnRadioButton );
120 mwxRadioButton[i]=NULL;
124 //---------------------------------------------------------------------
125 // 2) Insertion of the components in the window
127 // We use a FlexGridSizer
130 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
131 sizer = new wxFlexGridSizer(1);
135 sizer->Add( new wxStaticText(panel,-1, title ) );
137 for (i=0;i<MAX_RADIOBUTTON; i++)
139 if (mwxRadioButton[i]!=NULL)
141 sizer->Add( mwxRadioButton[i],1,wxGROW );
144 sizer->AddGrowableCol(0);
145 panel->SetSizer(sizer);
147 // panel->SetAutoLayout(true);
152 //-------------------------------------------------------------------------
154 RadioButtonWidget::~RadioButtonWidget()
158 //-------------------------------------------------------------------------
160 int RadioButtonWidget::GetValue()
164 for (i=0;i<MAX_RADIOBUTTON; i++)
166 if ( mwxRadioButton[i]!=NULL)
168 if (mwxRadioButton[i]->GetValue()==true)
177 //--------------------------------------------------------------------------
178 void RadioButtonWidget::OnRadioButton(wxEvent& event)
180 mBox->bbSetOutputOut( GetValue() );
181 mBox->bbSetInputIn( GetValue() );
182 mBox->bbSignalOutputModification("Out");
186 //--------------------------------------------------------------------------
187 void RadioButtonWidget::AddElements( std::vector<wxString> lstIn ,int In, wxString title)
191 MAX_RADIOBUTTON = lstIn.size();
192 wxPanel *panel = this;
194 long style=wxRB_GROUP;
195 for (i=0;i<MAX_RADIOBUTTON; i++)
197 if ( lstIn[i]!=_T(""))
199 //---------------------------------------------------------------------
200 // 1) Creation of the components of the widget
201 // Any top level sub-widget must have the panel returned by panel
203 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
207 mwxRadioButton[i]->SetValue(true);
209 mwxRadioButton[i]->SetValue(false);
211 Connect( mwxRadioButton[i]->GetId(),
212 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
213 (wxObjectEventFunction)
214 (void (wxPanel::*)(wxEvent&))
215 &RadioButtonWidget::OnRadioButton );
217 mwxRadioButton[i]=NULL;
221 //---------------------------------------------------------------------
222 // 2) Insertion of the components in the window
224 // We use a FlexGridSizer
227 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
228 sizer = new wxFlexGridSizer(1);
232 sizer->Add( new wxStaticText(panel,-1, title ) );
234 for (i=0;i<MAX_RADIOBUTTON; i++)
236 if (mwxRadioButton[i]!=NULL)
238 sizer->Add( mwxRadioButton[i],1,wxGROW );
241 sizer->AddGrowableCol(0);
242 panel->SetSizer(sizer);
244 // panel->SetAutoLayout(true);
252 //--------------------------------------------------------------------------
253 //-------------------------------------------------------------------------
254 //--------------------------------------------------------------------------
255 //--------------------------------------------------------------------------
257 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
258 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
261 //-----------------------------------------------------------------
262 void RadioButton::bbUserSetDefaultValues()
265 bbSetOutputOut( bbGetInputIn() );
278 //-----------------------------------------------------------------
279 void RadioButton::bbUserInitializeProcessing()
283 //-----------------------------------------------------------------
284 void RadioButton::bbUserFinalizeProcessing()
288 void RadioButton::Process()
290 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
291 bbtkDebugDecTab("Core",9);
294 std::vector<wxString> lstIn;
295 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
296 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
297 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
298 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
299 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
300 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
301 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
302 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
303 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
304 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
307 ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) );
313 * \brief Create wxWidget .
317 void RadioButton::CreateWidget(wxWindow* parent)
320 std::vector<wxString> lstIn;
321 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
322 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
323 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
324 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
325 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
326 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
327 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
328 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
329 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
330 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
332 RadioButtonWidget *w = new RadioButtonWidget(
337 bbtk::std2wx(bbGetInputTitle()),
340 bbSetOutputOut( bbGetInputIn() );
341 bbSetOutputWidget( w );
350 #endif // _USE_WXWIDGETS_