1 /*=========================================================================
3 Module: $RCSfile: bbwxRadioButton.cxx,v $
5 Date: $Date: 2009/05/15 14:58:03 $
6 Version: $Revision: 1.9 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
37 #ifdef _USE_WXWIDGETS_
40 #include "bbwxRadioButton.h"
41 #include "bbwxPackage.h"
49 //--------------------------------------------------------------------------
50 // The widget created by the box
51 class RadioButtonWidget : public wxPanel
54 RadioButtonWidget( RadioButton* box, wxWindow *parent,
57 std::vector<wxString> lstIn );
62 void OnRadioButton(wxEvent& event);
67 wxRadioButton *mwxRadioButton[10];
70 //------------------------------------------------------------------------
71 //------------------------------------------------------------------------
72 //------------------------------------------------------------------------
74 //-------------------------------------------------------------------------
75 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
79 std::vector<wxString> lstIn )
81 wxPanel( parent, -1) ,
84 wxPanel *panel = this;
85 MAX_RADIOBUTTON = lstIn.size();
87 long style=wxRB_GROUP;
88 for (i=0;i<MAX_RADIOBUTTON; i++)
90 if ( lstIn[i]!=_T(""))
92 //---------------------------------------------------------------------
93 // 1) Creation of the components of the widget
94 // Any top level sub-widget must have the panel returned by panel
96 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
100 mwxRadioButton[i]->SetValue(true);
104 mwxRadioButton[i]->SetValue(false);
106 Connect( mwxRadioButton[i]->GetId(),
107 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
108 (wxObjectEventFunction)
109 (void (wxPanel::*)(wxEvent&))
110 &RadioButtonWidget::OnRadioButton );
114 mwxRadioButton[i]=NULL;
118 //---------------------------------------------------------------------
119 // 2) Insertion of the components in the window
121 // We use a FlexGridSizer
122 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
125 sizer->Add( new wxStaticText(panel,-1, title ) );
127 for (i=0;i<MAX_RADIOBUTTON; i++)
129 if (mwxRadioButton[i]!=NULL)
131 sizer->Add( mwxRadioButton[i],1,wxGROW );
134 sizer->AddGrowableCol(0);
135 panel->SetSizer(sizer);
137 // panel->SetAutoLayout(true);
141 //-------------------------------------------------------------------------
143 RadioButtonWidget::~RadioButtonWidget()
147 //-------------------------------------------------------------------------
149 int RadioButtonWidget::GetValue()
153 for (i=0;i<MAX_RADIOBUTTON; i++)
155 if ( mwxRadioButton[i]!=NULL)
157 if (mwxRadioButton[i]->GetValue()==true)
166 //--------------------------------------------------------------------------
167 void RadioButtonWidget::OnRadioButton(wxEvent& event)
169 mBox->bbSetOutputOut( GetValue() );
170 mBox->bbSetInputIn( GetValue() );
171 mBox->bbSignalOutputModification("Out");
174 //--------------------------------------------------------------------------
175 //-------------------------------------------------------------------------
176 //--------------------------------------------------------------------------
177 //--------------------------------------------------------------------------
179 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
180 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
183 //-----------------------------------------------------------------
184 void RadioButton::bbUserSetDefaultValues()
187 bbSetOutputOut( bbGetInputIn() );
200 //-----------------------------------------------------------------
201 void RadioButton::bbUserInitializeProcessing()
205 //-----------------------------------------------------------------
206 void RadioButton::bbUserFinalizeProcessing()
210 void RadioButton::Process()
212 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
213 bbtkDebugDecTab("Core",9);
217 * \brief Create wxWidget .
221 void RadioButton::CreateWidget(wxWindow* parent)
224 std::vector<wxString> lstIn;
225 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
226 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
227 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
228 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
229 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
230 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
231 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
232 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
233 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
234 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
236 RadioButtonWidget *w = new RadioButtonWidget(
241 bbtk::std2wx(bbGetInputTitle()),
244 bbSetOutputOut( bbGetInputIn() );
245 bbSetOutputWidget( w );
254 #endif // _USE_WXWIDGETS_