]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtRadioButton.cxx~
#3037 creaWT Bug New Normal - AddMesh update
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtRadioButton.cxx~
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbwtRadioButton.h"
5 #include "bbwtPackage.h"
6 #include <vector>
7
8 namespace bbwt
9 {
10
11  class RadioButtonWidget : public Wt::WContainerWidget
12   {
13   public:
14     RadioButtonWidget( RadioButton* box, Wt::WContainerWidget *parent, 
15                       int In, 
16                       Wt::WString title, 
17                       std::vector<Wt::WString> lstIn );
18
19     ~RadioButtonWidget();
20
21     int GetValue();
22     void OnRadioButton();
23
24   private:
25     RadioButton      *mBox;
26     int              MAX_RADIOBUTTON;
27     Wt::WRadioButton    *mwtRadioButton[10];
28                 Wt::WButtonGroup *group;
29   };
30
31
32
33   //-------------------------------------------------------------------------
34   RadioButtonWidget::RadioButtonWidget( RadioButton* box,
35                Wt::WContainerWidget *parent,
36                int In,
37                Wt::WString title,
38                std::vector<Wt::WString> lstIn )
39     :
40     Wt::WContainerWidget( parent) ,
41     mBox(box)
42   {
43     Wt::WContainerWidget *panel = this;
44     MAX_RADIOBUTTON = lstIn.size();
45     int i;
46     
47
48                 Wt::WGroupBox *cont = new Wt::WGroupBox(title);
49                 group = new Wt::WButtonGroup(panel);
50                 
51
52     for (i=0;i<MAX_RADIOBUTTON; i++)
53     {
54            if ( lstIn[i]!="")
55            {
56     //---------------------------------------------------------------------
57     // 1) Creation of the components of the widget
58     // Any top level sub-widget must have the panel returned by panel
59     // for parent
60               mwtRadioButton[i] = new Wt::WRadioButton( lstIn[i],cont);
61                                 group->addButton(mwtRadioButton[i],i);
62               if (In==i)
63               {
64                       mwtRadioButton[i]->setChecked(true);
65               } 
66               else 
67               {
68                       mwtRadioButton[i]->setChecked(false);
69               }
70               mwtRadioButton[i]->checked().connect(this,&RadioButtonWidget::OnRadioButton);
71            } 
72            else 
73            {
74                mwtRadioButton[i]=NULL;
75            }
76     }
77     
78                 panel->addWidget(cont);
79
80   }
81   //-------------------------------------------------------------------------
82   
83   RadioButtonWidget::~RadioButtonWidget()
84   {
85   }
86
87   //-------------------------------------------------------------------------
88  
89   int RadioButtonWidget::GetValue()
90   { 
91                 
92     return group->checkedId();
93   }
94
95   //--------------------------------------------------------------------------
96   void RadioButtonWidget::OnRadioButton()
97   {
98     mBox->bbSetOutputOut( GetValue() );
99     mBox->bbSetInputIn( GetValue() );
100     mBox->bbSignalOutputModification("Out");
101   }
102
103   //--------------------------------------------------------------------------
104   //-------------------------------------------------------------------------
105   //--------------------------------------------------------------------------
106   //--------------------------------------------------------------------------
107
108 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,RadioButton)
109 BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WtBlackBox);
110 //===== 
111 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
112 //===== 
113 void RadioButton::Process()
114 {
115   
116 }
117 //===== 
118 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
119 //===== 
120 void RadioButton::CreateWidget(Wt::WContainerWidget* parent)
121 {
122
123    
124     std::vector<wxString> lstIn;
125     lstIn.push_back( bbtk::std2wt(bbGetInputIn0()) );
126     lstIn.push_back( bbtk::std2wt(bbGetInputIn1()) );
127     lstIn.push_back( bbtk::std2wt(bbGetInputIn2()) );
128     lstIn.push_back( bbtk::std2wt(bbGetInputIn3()) );
129     lstIn.push_back( bbtk::std2wt(bbGetInputIn4()) );
130     lstIn.push_back( bbtk::std2wt(bbGetInputIn5()) );
131     lstIn.push_back( bbtk::std2wt(bbGetInputIn6()) );
132     lstIn.push_back( bbtk::std2wt(bbGetInputIn7()) );
133     lstIn.push_back( bbtk::std2wt(bbGetInputIn8()) );
134     lstIn.push_back( bbtk::std2wt(bbGetInputIn9()) );
135
136     RadioButtonWidget *w = new RadioButtonWidget(
137                          this,
138 //                         bbGetWxParent(),
139                                                         parent, 
140                          bbGetInputIn() ,
141                          bbtk::std2wt(bbGetInputTitle()),
142                          lstIn );
143
144    bbSetOutputOut( bbGetInputIn() );
145    bbSetOutputWidget( w );
146
147   
148 }
149 //===== 
150 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
151 //===== 
152 void RadioButton::bbUserSetDefaultValues()
153 {
154                 bbSetInputIn(0);
155                 bbSetOutputOut( bbGetInputIn() );
156                 bbSetInputIn0("");
157                 bbSetInputIn1("");
158                 bbSetInputIn2("");
159                 bbSetInputIn3("");
160                 bbSetInputIn4("");
161                 bbSetInputIn5("");
162                 bbSetInputIn6("");
163                 bbSetInputIn7("");
164                 bbSetInputIn8("");
165                 bbSetInputIn9("");      
166 }
167 //===== 
168 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
169 //===== 
170 void RadioButton::bbUserInitializeProcessing()
171 {
172
173 }
174 //===== 
175 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
176 //===== 
177 void RadioButton::bbUserFinalizeProcessing()
178 {
179
180 }
181 }
182 // EO namespace bbwt
183
184