source: PSPA/Interface_Web/trunk/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc @ 407

Last change on this file since 407 was 407, checked in by garnier, 11 years ago

Correction dans les comboBox

File size: 5.0 KB
Line 
1#include <Wt/WText>
2#include <Wt/WVBoxLayout>
3#include <Wt/WHBoxLayout>
4#include <Wt/WGridLayout>
5#include <Wt/WContainerWidget>
6#include <Wt/WImage>
7
8#include "GWt_sectionToExecute.h"
9#include "GWt_softwarePanel.h"
10
11GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,Wt::WContainerWidget* buttonPanel, GWt_softwarePanel* sPanel)
12:WContainerWidget(),
13firstElement(first),
14lastElement(last),
15software(soft),
16softwarePanel(sPanel)
17{
18    Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout();
19    mainContainerLayout->setContentsMargins(0,0,0,0);
20
21    Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget();
22    Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout();
23    labelAndComboContainerLayout->setContentsMargins(0,0,0,0);
24
25    Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget();
26    Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout();
27    labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0);
28   
29    labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from&nbsp;:&nbsp;"));
30    labelAndComboInsideContainerLayout->addWidget(first);
31    labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to&nbsp;:&nbsp;"));
32    labelAndComboInsideContainerLayout->addWidget(last);
33    labelAndComboInsideContainerLayout->addWidget(soft);
34
35    // add buttons
36    labelAndComboInsideContainerLayout->addWidget(buttonPanel);
37
38    labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
39
40    labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
41    labelAndComboContainerLayout->addStretch (10);
42   
43    labelAndComboContainer->setLayout(labelAndComboContainerLayout);
44   
45           
46    // add errors and warning layout
47    warningsContainer_ = new Wt::WContainerWidget();
48    errorsContainer_ = new Wt::WContainerWidget();
49
50    Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
51    Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
52   
53    Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
54    Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
55
56   
57    warningsLabel_ = new Wt::WText("",XHTMLText);
58    errorsLabel_ = new Wt::WText("",XHTMLText);
59    hLayoutContainerWarnings->addWidget(warningsLabel_);
60    hLayoutContainerErrors->addWidget(errorsLabel_);
61
62    warningsAndErrorsContainer->addWidget(warningsLabel_);
63    warningsAndErrorsContainer->addWidget(errorsLabel_);
64   
65   
66    // set Layouts
67    warningsContainer_->setLayout(hLayoutContainerWarnings);
68    errorsContainer_->setLayout(hLayoutContainerErrors);
69   
70    vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
71    vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
72    vWarningsAndErrorsLayoutContainer->addStretch (100);
73
74    warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
75
76    // add label and Combo containers
77    mainContainerLayout->addWidget(labelAndComboContainer,0,0);
78    // add warnings and errors containers
79    mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
80
81    // manage margins
82    vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
83    hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
84    hLayoutContainerErrors->setContentsMargins(0,0,0,0);
85
86    setLayout(mainContainerLayout);
87    warningsContainer_->setStyleClass("warningsContainer");
88    errorsContainer_->setStyleClass("errorsContainer");
89
90    // resize combo
91    firstElement->setMinimumSize(80,12);
92    lastElement->setMinimumSize(80,12);
93    software->setMinimumSize(80,12);
94       
95    firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
96    lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
97    software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
98
99    manageWarningsAndErrors();
100}
101
102
103void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){
104    for (int a=0; a< firstElement->count(); a++) {
105        if (firstElement->itemText(a) == txt) {
106            firstElement->setCurrentIndex (a);
107            return;
108        }
109    }
110}
111
112void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){
113    for (int a=0; a< lastElement->count(); a++) {
114        if (lastElement->itemText(a) == txt) {
115            lastElement->setCurrentIndex (a);
116            return;
117        }
118    }
119}
120
121void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){
122  for (int a=0; a< software->count(); a++) {
123    if (software->itemText(a) == txt) {
124      software->setCurrentIndex (a);
125      return;
126    }
127  }
128}
129
130
131void GWt_sectionToExecute::manageWarningsAndErrors(){
132    if (warningsLabel_->text() == "") {
133        warningsContainer_->hide();
134    } else {
135        warningsContainer_->show();
136    }
137    if (errorsLabel_->text() == "") {
138        errorsContainer_->hide();
139    } else {
140        errorsContainer_->show();
141    }
142
143}
Note: See TracBrowser for help on using the repository browser.