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);
72 wxRadioButton *mwxRadioButton[10];
75 //------------------------------------------------------------------------
76 //------------------------------------------------------------------------
77 //------------------------------------------------------------------------
79 //-------------------------------------------------------------------------
80 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
84 std::vector<wxString> lstIn )
86 wxPanel( parent, -1) ,
89 wxPanel *panel = this;
90 MAX_RADIOBUTTON = lstIn.size();
92 long style=wxRB_GROUP;
93 for (i=0;i<MAX_RADIOBUTTON; i++)
95 if ( lstIn[i]!=_T(""))
97 //---------------------------------------------------------------------
98 // 1) Creation of the components of the widget
99 // Any top level sub-widget must have the panel returned by panel
101 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
105 mwxRadioButton[i]->SetValue(true);
109 mwxRadioButton[i]->SetValue(false);
111 Connect( mwxRadioButton[i]->GetId(),
112 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
113 (wxObjectEventFunction)
114 (void (wxPanel::*)(wxEvent&))
115 &RadioButtonWidget::OnRadioButton );
119 mwxRadioButton[i]=NULL;
123 //---------------------------------------------------------------------
124 // 2) Insertion of the components in the window
126 // We use a FlexGridSizer
127 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
130 sizer->Add( new wxStaticText(panel,-1, title ) );
132 for (i=0;i<MAX_RADIOBUTTON; i++)
134 if (mwxRadioButton[i]!=NULL)
136 sizer->Add( mwxRadioButton[i],1,wxGROW );
139 sizer->AddGrowableCol(0);
140 panel->SetSizer(sizer);
142 // panel->SetAutoLayout(true);
146 //-------------------------------------------------------------------------
148 RadioButtonWidget::~RadioButtonWidget()
152 //-------------------------------------------------------------------------
154 int RadioButtonWidget::GetValue()
158 for (i=0;i<MAX_RADIOBUTTON; i++)
160 if ( mwxRadioButton[i]!=NULL)
162 if (mwxRadioButton[i]->GetValue()==true)
171 //--------------------------------------------------------------------------
172 void RadioButtonWidget::OnRadioButton(wxEvent& event)
174 mBox->bbSetOutputOut( GetValue() );
175 mBox->bbSetInputIn( GetValue() );
176 mBox->bbSignalOutputModification("Out");
179 //--------------------------------------------------------------------------
180 //-------------------------------------------------------------------------
181 //--------------------------------------------------------------------------
182 //--------------------------------------------------------------------------
184 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
185 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
188 //-----------------------------------------------------------------
189 void RadioButton::bbUserSetDefaultValues()
192 bbSetOutputOut( bbGetInputIn() );
205 //-----------------------------------------------------------------
206 void RadioButton::bbUserInitializeProcessing()
210 //-----------------------------------------------------------------
211 void RadioButton::bbUserFinalizeProcessing()
215 void RadioButton::Process()
217 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
218 bbtkDebugDecTab("Core",9);
222 * \brief Create wxWidget .
226 void RadioButton::CreateWidget(wxWindow* parent)
229 std::vector<wxString> lstIn;
230 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
231 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
232 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
233 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
234 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
235 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
236 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
237 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
238 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
239 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
241 RadioButtonWidget *w = new RadioButtonWidget(
246 bbtk::std2wx(bbGetInputTitle()),
249 bbSetOutputOut( bbGetInputIn() );
250 bbSetOutputWidget( w );
259 #endif // _USE_WXWIDGETS_