#include #include #include #include #include #include #include "GWt_sectionToExecute.h" #include "GWt_softwarePanel.h" #include "GWt_sector.h" GWt_sectionToExecute::GWt_sectionToExecute(Wt::WComboBox* first,Wt::WComboBox* last,Wt::WComboBox* soft,Wt::WContainerWidget* buttonPanel, sectionToExecute* section,GWt_sector* sector) :WContainerWidget(), firstElement_(first), lastElement_(last), softElement_(soft), section_(section), UIsector_(sector) { Wt::WGridLayout* mainContainerLayout = new Wt::WGridLayout(); mainContainerLayout->setContentsMargins(0,0,0,0); Wt::WContainerWidget* labelAndComboContainer = new Wt::WContainerWidget(); Wt::WVBoxLayout* labelAndComboContainerLayout = new Wt::WVBoxLayout(); labelAndComboContainerLayout->setContentsMargins(0,0,0,0); Wt::WContainerWidget* labelAndComboInsideContainer = new Wt::WContainerWidget(); Wt::WHBoxLayout* labelAndComboInsideContainerLayout = new Wt::WHBoxLayout(); labelAndComboInsideContainerLayout->setContentsMargins(0,0,0,0); labelAndComboInsideContainerLayout->addWidget(new Wt::WText("from : ")); labelAndComboInsideContainerLayout->addWidget(firstElement_); labelAndComboInsideContainerLayout->addWidget(new Wt::WText("to : ")); labelAndComboInsideContainerLayout->addWidget(lastElement_); labelAndComboInsideContainerLayout->addWidget(softElement_); // add buttons labelAndComboInsideContainerLayout->addWidget(buttonPanel); labelAndComboInsideContainer->setLayout(labelAndComboInsideContainerLayout); labelAndComboContainerLayout->addWidget(labelAndComboInsideContainer); labelAndComboContainerLayout->addStretch (10); labelAndComboContainer->setLayout(labelAndComboContainerLayout); // add errors and warning layout warningsContainer_ = new Wt::WContainerWidget(); errorsContainer_ = new Wt::WContainerWidget(); Wt::WContainerWidget* warningsAndErrorsContainer = new Wt::WContainerWidget(); Wt::WVBoxLayout* vWarningsAndErrorsLayoutContainer = new Wt::WVBoxLayout(); Wt::WHBoxLayout* hLayoutContainerWarnings = new Wt::WHBoxLayout(); Wt::WHBoxLayout* hLayoutContainerErrors = new Wt::WHBoxLayout(); warningsLabel_ = new Wt::WText("",XHTMLText); errorsLabel_ = new Wt::WText("",XHTMLText); hLayoutContainerWarnings->addWidget(warningsLabel_); hLayoutContainerErrors->addWidget(errorsLabel_); warningsAndErrorsContainer->addWidget(warningsLabel_); warningsAndErrorsContainer->addWidget(errorsLabel_); // set Layouts warningsContainer_->setLayout(hLayoutContainerWarnings); errorsContainer_->setLayout(hLayoutContainerErrors); vWarningsAndErrorsLayoutContainer->addWidget(errorsContainer_); vWarningsAndErrorsLayoutContainer->addWidget(warningsContainer_); vWarningsAndErrorsLayoutContainer->addStretch (100); warningsAndErrorsContainer->setLayout(vWarningsAndErrorsLayoutContainer); // add label and Combo containers mainContainerLayout->addWidget(labelAndComboContainer,0,0); // add warnings and errors containers mainContainerLayout->addWidget(warningsAndErrorsContainer,1,0); // manage margins vWarningsAndErrorsLayoutContainer->setContentsMargins(20,0,0,0); hLayoutContainerWarnings->setContentsMargins(0,0,0,0); hLayoutContainerErrors->setContentsMargins(0,0,0,0); setLayout(mainContainerLayout); warningsContainer_->setStyleClass("warningsContainer"); errorsContainer_->setStyleClass("errorsContainer"); // resize combo firstElement_->setMinimumSize(80,12); lastElement_->setMinimumSize(80,12); softElement_->setMinimumSize(80,12); firstElement_->activated().connect(this,&GWt_sectionToExecute::changeFirstElement); // lastElement->activated().connect(softwarePanel,&GWt_softwarePanel::updateSections); softElement_->activated().connect(this,&GWt_sectionToExecute::setSoftware); this->redraw_.connect(UIsector_,&GWt_sector::displayWidgetBeamLine); manageWarningsAndErrors(); } void GWt_sectionToExecute::setFirstElementCurrentSelection_deprecated(Wt::WString txt){ for (int a=0; a< firstElement_->count(); a++) { if (firstElement_->itemText(a) == txt) { firstElement_->setCurrentIndex (a); return; } } } void GWt_sectionToExecute::setLastElementCurrentSelection_deprecated(Wt::WString txt){ for (int a=0; a< lastElement_->count(); a++) { if (lastElement_->itemText(a) == txt) { lastElement_->setCurrentIndex (a); return; } } } void GWt_sectionToExecute::setSoftwareElementCurrentSelection_deprecated(Wt::WString txt){ for (int a=0; a< softElement_->count(); a++) { if (softElement_->itemText(a) == txt) { softElement_->setCurrentIndex (a); return; } } } void GWt_sectionToExecute::manageWarningsAndErrors(){ if (warningsLabel_->text() == "") { warningsContainer_->hide(); } else { warningsContainer_->show(); } if (errorsLabel_->text() == "") { errorsContainer_->hide(); } else { errorsContainer_->show(); } } void GWt_sectionToExecute::setSoftware() { section_->setSoftware(softElement_->currentText().toUTF8()); UIsector_->getBeamLineWidget()->buildBeamLineWidget(); } void GWt_sectionToExecute::changeFirstElement() { if (!section_) return; if (!UIsector_) return; section_->setFirstElement(firstElement_->currentIndex()); redraw_.emit(); }