]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtComboBox.cxx
#3037 creaWT Bug New Normal - AddMesh update
[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                       int typeForm);
16       ~ComboBoxWidget();
17       void OnComboBox();
18           void SetItems( std::vector<std::string> lstIn );      
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                       int typeForm)
39                  :
40                       Wt::WContainerWidget(parent),
41                       mBox(box),
42                       mTypeForm(typeForm)
43   {
44
45     Wt::WContainerWidget *panel = this;
46     Wt::WBorderLayout *layout = new Wt::WBorderLayout();
47     int i;
48     if(title!="")
49     {
50       layout->addWidget(new Wt::WText(title),Wt::WBorderLayout::North);    
51     }
52     
53     if(mTypeForm == 0)
54     {
55       wtCmbBox  = new Wt::WComboBox();
56       selection = wtCmbBox;
57     } else {
58       wtSlctBox = new Wt::WSelectionBox();
59      // wtSlctBox->setSelectionMode(Wt::ExtendedSelection);
60       selection = wtSlctBox;
61     }
62
63     selection->activated().connect(this,&ComboBoxWidget::OnComboBox);
64
65     layout->addWidget(selection,Wt::WBorderLayout::Center);
66     panel->setLayout(layout);
67   }
68
69 //-------------------------------------------------------------------------  
70   ComboBoxWidget::~ComboBoxWidget()
71   {
72   }
73
74 //--------------------------------------------------------------------------
75   void ComboBoxWidget::OnComboBox()
76   {
77     mBox->bbSetInputSelection( selection->currentIndex() );
78     mBox->bbSetOutputOut( selection->currentIndex() );
79     mBox->bbSetOutputOutString(    bbtk::wt2std( selection->valueText() )     );
80     mBox->bbSignalOutputModification("Out");
81     mBox->bbSignalOutputModification("OutString");
82   }
83
84 //--------------------------------------------------------------------------
85   void ComboBoxWidget::SetItems( std::vector<std::string> lstIn )
86   {
87         int i;
88
89     selection->clear();
90
91     for (i=0;i<lstIn.size(); i++)
92     {
93       selection->addItem(bbtk::std2wt(lstIn[i]));
94     }  // for i
95   }
96
97
98   
99 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,ComboBox)
100 BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WtBlackBox);
101 //===== 
102 // 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)
103 //===== 
104 void ComboBox::Process()
105 {
106
107         ComboBoxWidget *widget = (ComboBoxWidget *)bbGetOutputWidget(); 
108         widget->SetItems( bbGetInputIn() );
109     bbSetOutputOut( 0 );
110         if (bbGetInputIn().size()>0)
111         {
112         bbSetOutputOutString( bbGetInputIn()[0] );
113         } else {
114         bbSetOutputOutString( "" );
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 ComboBox::CreateWidget(Wt::WContainerWidget* parent)
121 {
122
123        ComboBoxWidget *w = new ComboBoxWidget(
124                                 this,
125                                                         parent,
126                                 bbGetInputSelection() ,
127                                 bbGetInputTitle(),
128 //                              bbGetInputIn(),
129                                 bbGetInputForm() );
130
131    bbSetOutputOut( bbGetInputSelection() );
132    bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
133    bbSetOutputWidget( w );
134   
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::bbUserSetDefaultValues()
140 {
141         bbSetInputSelection(0);
142         bbSetInputTitle("");
143         bbSetInputForm(0);
144 }
145 //===== 
146 // 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)
147 //===== 
148 void ComboBox::bbUserInitializeProcessing()
149 {
150
151 }
152 //===== 
153 // 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)
154 //===== 
155 void ComboBox::bbUserFinalizeProcessing()
156 {
157
158 }
159 }
160 // EO namespace bbwt
161
162