]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtComboBox.cxx~
2536 BBTK Feature New Normal wt-version Package
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtComboBox.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 "bbwtComboBox.h"
5 #include "bbwtPackage.h"
6 namespace bbwt
7 {
8
9   class ComboBoxWidget : public Wt::WContainerWidget
10   {
11     public:
12       ComboBoxWidget(ComboBox* box, Wt::WContainerWidget *parent,
13                       int iSelection,
14                       Wt::WString title,
15                       std::vector<std::string> lstIn,
16                       int typeForm);
17       ~ComboBoxWidget();
18       void OnComboBox();
19
20     private:
21       int mTypeForm;
22       ComboBox *mBox;
23       Wt::WComboBox *wtCmbBox;  
24       Wt::WSelectionBox *wtSlctBox;
25       Wt::WComboBox *selection;
26       //TODO choice
27
28   };
29
30   //------------------------------------------------------------------------
31   //------------------------------------------------------------------------
32   //------------------------------------------------------------------------
33
34
35   ComboBoxWidget::ComboBoxWidget(ComboBox* box, Wt::WContainerWidget *parent,
36                       int iSelection,
37                       Wt::WString title,
38                       std::vector<std::string> lstIn,
39                       int typeForm)
40                  :
41                       Wt::WContainerWidget(parent),
42                       mBox(box),
43                       mTypeForm(typeForm)
44   {
45
46     Wt::WContainerWidget *panel = this;
47     Wt::WBorderLayout *layout = new Wt::WBorderLayout();
48     int i;
49     if(title!="")
50     {
51       layout->addWidget(new Wt::WText(title),Wt::WBorderLayout::North);
52     
53     }
54     
55    
56     if(mTypeForm == 1)
57     {
58       wtCmbBox = new Wt::WComboBox();
59       selection = wtCmbBox;
60     }
61     else
62     {
63       wtSlctBox = new Wt::WSelectionBox();
64      // wtSlctBox->setSelectionMode(Wt::ExtendedSelection);
65       selection = wtSlctBox;
66     }
67     for (i=0;i<lstIn.size(); i++)
68     {
69       selection->addItem(bbtk::std2wt(lstIn[i]));
70     }
71
72     selection->activated().connect(this,&ComboBoxWidget::OnComboBox);
73
74     layout->addWidget(selection,Wt::WBorderLayout::Center);
75     panel->setLayout(layout);
76       
77     
78   }
79
80   //-------------------------------------------------------------------------
81   
82   ComboBoxWidget::~ComboBoxWidget()
83   {
84   }
85
86     //--------------------------------------------------------------------------
87   void ComboBoxWidget::OnComboBox()
88   {
89     mBox->bbSetInputSelection( selection->currentIndex() );
90     mBox->bbSetOutputOut( selection->currentIndex() );
91     mBox->bbSetOutputOutString(    bbtk::wt2std( selection->valueText() )     );
92     mBox->bbSignalOutputModification("Out");
93     mBox->bbSignalOutputModification("OutString");
94   }
95
96   
97 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,ComboBox)
98 BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WtBlackBox);
99 //===== 
100 // 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)
101 //===== 
102 void ComboBox::Process()
103 {
104
105
106   
107 }
108 //===== 
109 // 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)
110 //===== 
111 void ComboBox::CreateWidget(Wt::WContainerWidget* parent)
112 {
113
114        ComboBoxWidget *w = new ComboBoxWidget(
115                                 this,
116                                                                         parent,
117                                 bbGetInputSelection() ,
118                                 bbGetInputTitle(),
119                                 bbGetInputIn(),
120                                 bbGetInputForm() );
121
122    bbSetOutputOut( bbGetInputSelection() );
123    bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
124    bbSetOutputWidget( w );
125   
126 }
127 //===== 
128 // 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)
129 //===== 
130 void ComboBox::bbUserSetDefaultValues()
131 {
132         bbSetInputSelection(0);
133         bbSetInputTitle("");
134         bbSetInputForm(0);
135 }
136 //===== 
137 // 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)
138 //===== 
139 void ComboBox::bbUserInitializeProcessing()
140 {
141
142 }
143 //===== 
144 // 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)
145 //===== 
146 void ComboBox::bbUserFinalizeProcessing()
147 {
148
149 }
150 }
151 // EO namespace bbwt
152
153