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 );
66 void OnRadioButton(wxEvent& event);
67 void AddElements(std::vector<wxString> lstIn, int In, wxString title);
71 wxRadioButton *mwxRadioButton[25];
72 wxFlexGridSizer *sizer;
75 //------------------------------------------------------------------------
76 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
79 //-------------------------------------------------------------------------
80 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
84 std::vector<wxString> lstIn )
86 wxPanel( parent, -1) ,
89 AddElements( lstIn , In,title);
90 mBox->bbSetOutputOut( GetValue() );
91 // mBox->bbSetInputIn( GetValue() );
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)
120 //--------------------------------------------------------------------------
121 void RadioButtonWidget::OnRadioButton(wxEvent& event)
123 mBox->bbSetOutputOut( GetValue() );
124 mBox->bbSetInputIn( GetValue() );
125 mBox->bbSignalOutputModification("Out");
129 //--------------------------------------------------------------------------
130 void RadioButtonWidget::AddElements( std::vector<wxString> lstIn ,int In, wxString title)
134 MAX_RADIOBUTTON = lstIn.size();
135 wxPanel *panel = this;
137 long style=wxRB_GROUP;
138 for (i=0;i<MAX_RADIOBUTTON; i++)
140 if ( lstIn[i]!=_T(""))
142 //---------------------------------------------------------------------
143 // 1) Creation of the components of the widget
144 // Any top level sub-widget must have the panel returned by panel
146 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
150 mwxRadioButton[i]->SetValue(true);
152 mwxRadioButton[i]->SetValue(false);
154 Connect( mwxRadioButton[i]->GetId(),
155 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
156 (wxObjectEventFunction)
157 (void (wxPanel::*)(wxEvent&))
158 &RadioButtonWidget::OnRadioButton );
160 mwxRadioButton[i]=NULL;
164 //---------------------------------------------------------------------
165 // 2) Insertion of the components in the window
167 // We use a FlexGridSizer
170 // wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
171 sizer = new wxFlexGridSizer(1);
175 sizer->Add( new wxStaticText(panel,-1, title ) );
177 for (i=0;i<MAX_RADIOBUTTON; i++)
179 if (mwxRadioButton[i]!=NULL)
181 sizer->Add( mwxRadioButton[i],1,wxGROW );
184 sizer->AddGrowableCol(0);
185 panel->SetSizer(sizer);
187 panel->SetAutoLayout(true);
193 //--------------------------------------------------------------------------
194 //-------------------------------------------------------------------------
195 //--------------------------------------------------------------------------
196 //--------------------------------------------------------------------------
198 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
199 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
202 //-----------------------------------------------------------------
203 void RadioButton::bbUserSetDefaultValues()
206 bbSetOutputOut( bbGetInputIn() );
219 //-----------------------------------------------------------------
220 void RadioButton::bbUserInitializeProcessing()
224 //-----------------------------------------------------------------
225 void RadioButton::bbUserFinalizeProcessing()
229 void RadioButton::Process()
231 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
232 bbtkDebugDecTab("Core",9);
233 std::vector<wxString> lstIn;
234 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
235 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
236 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
237 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
238 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
239 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
240 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
241 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
242 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
243 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
244 if (bbGetOutputWidget()!=NULL)
246 ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) );
247 } // if bbGetOutputWidget
251 * \brief Create wxWidget .
255 void RadioButton::CreateWidget(wxWindow* parent)
258 std::vector<wxString> lstIn;
259 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
260 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
261 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
262 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
263 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
264 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
265 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
266 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
267 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
268 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
270 RadioButtonWidget *w = new RadioButtonWidget(
274 bbtk::std2wx(bbGetInputTitle()),
277 bbSetOutputOut( bbGetInputIn() );
278 bbSetOutputWidget( w );
287 #endif // _USE_WXWIDGETS_