1 /*=========================================================================
3 Module: $RCSfile: bbwxRadioButton.cxx,v $
5 Date: $Date: 2008/11/24 15:45:51 $
6 Version: $Revision: 1.7 $
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"
47 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,RadioButton);
49 //-------------------------------------------------------------------------
50 RadioButtonWidget::RadioButtonWidget( RadioButton* box,
54 std::vector<wxString> lstIn )
56 wxPanel( parent, -1) ,
59 wxPanel *panel = this;
60 MAX_RADIOBUTTON = lstIn.size();
62 long style=wxRB_GROUP;
63 for (i=0;i<MAX_RADIOBUTTON; i++)
65 if ( lstIn[i]!=_T(""))
67 //---------------------------------------------------------------------
68 // 1) Creation of the components of the widget
69 // Any top level sub-widget must have the panel returned by panel
71 mwxRadioButton[i] = new wxRadioButton( panel, -1, lstIn[i],wxDefaultPosition, wxDefaultSize, style);
75 mwxRadioButton[i]->SetValue(true);
79 mwxRadioButton[i]->SetValue(false);
81 Connect( mwxRadioButton[i]->GetId(),
82 wxEVT_COMMAND_RADIOBUTTON_SELECTED,
83 (wxObjectEventFunction)
84 (void (wxPanel::*)(wxEvent&))
85 &RadioButtonWidget::OnRadioButton );
89 mwxRadioButton[i]=NULL;
93 //---------------------------------------------------------------------
94 // 2) Insertion of the components in the window
96 // We use a FlexGridSizer
97 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
100 sizer->Add( new wxStaticText(panel,-1, title ) );
102 for (i=0;i<MAX_RADIOBUTTON; i++)
104 if (mwxRadioButton[i]!=NULL)
106 sizer->Add( mwxRadioButton[i],1,wxGROW );
109 sizer->AddGrowableCol(0);
110 panel->SetSizer(sizer);
112 // panel->SetAutoLayout(true);
116 //-------------------------------------------------------------------------
118 RadioButtonWidget::~RadioButtonWidget()
122 //-------------------------------------------------------------------------
124 int RadioButtonWidget::GetValue()
128 for (i=0;i<MAX_RADIOBUTTON; i++)
130 if ( mwxRadioButton[i]!=NULL)
132 if (mwxRadioButton[i]->GetValue()==true)
141 //--------------------------------------------------------------------------
142 void RadioButtonWidget::OnRadioButton(wxEvent& event)
144 mBox->bbSetOutputOut( GetValue() );
145 mBox->bbSetInputIn( GetValue() );
146 mBox->bbSignalOutputModification("Out");
149 //--------------------------------------------------------------------------
150 //-------------------------------------------------------------------------
151 //--------------------------------------------------------------------------
152 //--------------------------------------------------------------------------
155 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
158 void RadioButton::bbUserConstructor()
161 bbSetOutputOut( bbGetInputIn() );
175 void RadioButton::Process()
177 bbtkDebugMessageInc("Core",9,"RadioButton::Process()"<<std::endl);
178 bbtkDebugDecTab("Core",9);
182 * \brief Create wxWidget .
186 void RadioButton::CreateWidget(wxWindow* parent)
189 std::vector<wxString> lstIn;
190 lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) );
191 lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) );
192 lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) );
193 lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) );
194 lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) );
195 lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) );
196 lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) );
197 lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) );
198 lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) );
199 lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) );
201 RadioButtonWidget *w = new RadioButtonWidget(
206 bbtk::std2wx(bbGetInputTitle()),
209 bbSetOutputOut( bbGetInputIn() );
210 bbSetOutputWidget( w );
219 #endif // _USE_WXWIDGETS_