Пример #1
0
 // Static Functions
 /// Returns the value of pretty much all widget types
 static WString getValue(WFormWidget* widget) {
     Wt::WComboBox* asComboBox = dynamic_cast<Wt::WComboBox*>(widget);
     if (asComboBox != 0)
         return asComboBox->currentText();
     Wt::WLineEdit* asLineEdit = dynamic_cast<Wt::WLineEdit*>(widget);
     if (asLineEdit != 0)
         return asLineEdit->text();
     Wt::WSlider* asSlider = dynamic_cast<Wt::WSlider*>(widget);
     if (asSlider != 0) {
         std::stringstream out;
         out << asSlider->value();
         return out.str();
     }
     Wt::WTextArea* asTextArea = dynamic_cast<Wt::WTextArea*>(widget);
     if (asTextArea != 0)
         return asTextArea->text();
     throw std::logic_error("I don't know how to get the value of whatever widget you passed me");
 }
Пример #2
0
HeightLines::HeightLines()
{
  museums.set("mapbox://mapbox.2opop9hr");
  contours.set("mapbox://mapbox.mapbox-terrain-v2");

  museumLayer.set(&museums);
  museumLayer.sourceLayer("museum-cusco");
  museumLayer.radius(8);
  museumLayer.color(Wt::WColor(55, 148, 179));

  contourLayer.set(&contours);
  contourLayer.sourceLayer("contour");
  contourLayer.join(MapBox::JOIN::Round);
  contourLayer.cap(MapBox::CAP::Round);
  contourLayer.color(Wt::WColor("#877b59"));
  contourLayer.width(1);

  resize(250, 100);

  Wt::WVBoxLayout * vbox = new Wt::WVBoxLayout();
  setLayout(vbox);

  Wt::WHBoxLayout * hbox = new Wt::WHBoxLayout();
  vbox->addLayout(hbox);

  Wt::WText * t = new Wt::WText("Width: ", this);
  t->setMargin(10);
  hbox->addWidget(t);

  Wt::WSlider * slider = new Wt::WSlider(this);
  slider->resize(200, 12);
  slider->setMinimum(1);
  slider->setMaximum(10);
  slider->setValue(1);
  hbox->addWidget(slider);

  slider->valueChanged().connect(std::bind([=]() {
    contourLayer.width(slider->value());
  }));

  hbox = new Wt::WHBoxLayout();
  vbox->addLayout(hbox);

  t = new Wt::WText("Blur: ", this);
  t->setMargin(10);
  hbox->addWidget(t);

  slider = new Wt::WSlider(this);
  slider->resize(200, 12);
  slider->setMinimum(0);
  slider->setMaximum(10);
  slider->setValue(0);
  hbox->addWidget(slider);

  slider->valueChanged().connect(std::bind([=]() {
    contourLayer.blur(slider->value());
  }));

}