source: PSPA/Interface_Web/branches/12_03_12-managerComboBox/pspaWT/sources/userInterface/src/GWt_sectionToExecute.cc @ 399

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

Mise en place des comboBox et changement de l'aspect visuel

File size: 4.7 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,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    labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout);
36
37    labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer);
38    labelAndComboContainerLayout->addStretch (10);
39   
40    labelAndComboContainer->setLayout(labelAndComboContainerLayout);
41   
42           
43    // add errors and warning layout
44    warningsContainer_ = new Wt::WContainerWidget();
45    errorsContainer_ = new Wt::WContainerWidget();
46
47    Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget();
48    Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout();
49   
50    Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout();
51    Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout();
52
53   
54    warningsLabel_ = new Wt::WText("",XHTMLText);
55    errorsLabel_ = new Wt::WText("",XHTMLText);
56    hLayoutContainerWarnings->addWidget(warningsLabel_);
57    hLayoutContainerErrors->addWidget(errorsLabel_);
58
59    warningsAndErrorsContainer->addWidget(warningsLabel_);
60    warningsAndErrorsContainer->addWidget(errorsLabel_);
61   
62   
63    // set Layouts
64    warningsContainer_->setLayout(hLayoutContainerWarnings);
65    errorsContainer_->setLayout(hLayoutContainerErrors);
66   
67    vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_);
68    vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_);
69    vWarningsAndErrorsLayoutContainer->addStretch (100);
70
71    warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer);
72
73    // add label and Combo containers
74    mainContainerLayout->addWidget(labelAndComboContainer,0,0);
75    // add warnings and errors containers
76    mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0);
77
78    // manage margins
79    vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0);
80    hLayoutContainerWarnings->setContentsMargins(0,0,0,0);
81    hLayoutContainerErrors->setContentsMargins(0,0,0,0);
82
83    setLayout(mainContainerLayout);
84    warningsContainer_->setStyleClass("warningsContainer");
85    errorsContainer_->setStyleClass("errorsContainer");
86
87   
88    firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
89    lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
90    software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections);
91
92    manageWarningsAndErrors();
93}
94
95
96void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){
97    for (int a=0; a< firstElement->count(); a++) {
98        if (firstElement->itemText(a) == txt) {
99            firstElement->setCurrentIndex (a);
100            return;
101        }
102    }
103}
104
105void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){
106    for (int a=0; a< lastElement->count(); a++) {
107        if (lastElement->itemText(a) == txt) {
108            lastElement->setCurrentIndex (a);
109            return;
110        }
111    }
112}
113
114void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){
115  for (int a=0; a< software->count(); a++) {
116    if (software->itemText(a) == txt) {
117      software->setCurrentIndex (a);
118      return;
119    }
120  }
121}
122
123
124void GWt_sectionToExecute::manageWarningsAndErrors(){
125    if (warningsLabel_->text() == "") {
126        warningsContainer_->hide();
127    } else {
128        warningsContainer_->show();
129    }
130    if (errorsLabel_->text() == "") {
131        errorsContainer_->hide();
132    } else {
133        errorsContainer_->show();
134    }
135
136}
Note: See TracBrowser for help on using the repository browser.