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 | |
---|
11 | GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,GWt_softwarePanel* sPanel) |
---|
12 | :WContainerWidget(), |
---|
13 | firstElement(first), |
---|
14 | lastElement(last), |
---|
15 | software(soft), |
---|
16 | softwarePanel(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 : ")); |
---|
30 | labelAndComboInsideContainerLayout->addWidget(first); |
---|
31 | labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to : ")); |
---|
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 | // resize combo |
---|
88 | firstElement->setMinimumSize(80,12); |
---|
89 | lastElement->setMinimumSize(80,12); |
---|
90 | software->setMinimumSize(80,12); |
---|
91 | |
---|
92 | firstElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
93 | lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
94 | software->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); |
---|
95 | |
---|
96 | manageWarningsAndErrors(); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | void GWt_sectionToExecute::setFirstElementCurrentSelection(Wt::WString txt){ |
---|
101 | for (int a=0; a< firstElement->count(); a++) { |
---|
102 | if (firstElement->itemText(a) == txt) { |
---|
103 | firstElement->setCurrentIndex (a); |
---|
104 | return; |
---|
105 | } |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | void GWt_sectionToExecute::setLastElementCurrentSelection(Wt::WString txt){ |
---|
110 | for (int a=0; a< lastElement->count(); a++) { |
---|
111 | if (lastElement->itemText(a) == txt) { |
---|
112 | lastElement->setCurrentIndex (a); |
---|
113 | return; |
---|
114 | } |
---|
115 | } |
---|
116 | } |
---|
117 | |
---|
118 | void GWt_sectionToExecute::setSoftwareElementCurrentSelection(Wt::WString txt){ |
---|
119 | for (int a=0; a< software->count(); a++) { |
---|
120 | if (software->itemText(a) == txt) { |
---|
121 | software->setCurrentIndex (a); |
---|
122 | return; |
---|
123 | } |
---|
124 | } |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | void GWt_sectionToExecute::manageWarningsAndErrors(){ |
---|
129 | if (warningsLabel_->text() == "") { |
---|
130 | warningsContainer_->hide(); |
---|
131 | } else { |
---|
132 | warningsContainer_->show(); |
---|
133 | } |
---|
134 | if (errorsLabel_->text() == "") { |
---|
135 | errorsContainer_->hide(); |
---|
136 | } else { |
---|
137 | errorsContainer_->show(); |
---|
138 | } |
---|
139 | |
---|
140 | } |
---|