Esempio n. 1
0
  void Popup::render(Wt::WFlags<Wt::RenderFlag> flags) {
    Wt::WApplication * app = Wt::WApplication::instance();
    Wt::WString initFunction = app->javaScriptClass() + ".init_popup_" + id();

    Wt::WStringStream stream;
    stream
      << "{" << initFunction.toUTF8() << " = function() {"
      << "  var self = " << jsRef() << ";"
      << "  if (!self) {"
      << "    setTimeout(" << initFunction.toUTF8() << ", 0);"
      << "  }";

    stream
      << "  self.popup = new mapboxgl.Popup( {"
      << "    closeButton: " << ToScript(closeButton_).toUTF8() << ", "
      << "    closeOnClick: " << ToScript(closeOnClick_).toUTF8() << ", "
      << "    anchor: " << ToScript(anchor_).toUTF8()
      << "  });";

    for (unsigned int i = 0; i < additions_.size(); i++) {
      stream << additions_[i].toUTF8();
    }
    additions_.clear();

    stream
      << "  setTimeout(function(){ delete " << initFunction.toUTF8() << ";}, 0)};\n"
      << "}\n"
      << initFunction.toUTF8() << "();\n";

    app->doJavaScript(stream.str());
  }
Esempio n. 2
0
std::string TopicTemplate::escape(const std::string &name)
{
  Wt::WStringStream ss;

  for (unsigned i = 0; i < name.size(); ++i) {
    if (name[i] != ':')
      ss << name[i];
    else
      ss << "_1";
  }

  return ss.str();
}
Esempio n. 3
0
std::string TopicTemplate::docUrl(const std::string& className)
{
  Wt::WStringStream ss;

#if !defined(WT_TARGET_JAVA)
  ss << getString("doc-url") << "class" << escape("Wt::" + className)
     << ".html";
#else
  boost::replace_all(className, ".", "/");
  ss << getString("doc-url") << className << ".html";
#endif

  return ss.str();
}
Esempio n. 4
0
File: Reply.C Progetto: bend/wt
std::string Reply::httpDate(time_t t)
{
  Wt::WStringStream s;
  httpDateBuf(t, s);
  return s.str();
}
Esempio n. 5
0
void WTimePicker::init(const WTime &time)
{
    Wt::WStringStream text;
    text << "<table>"
            """<tr>"
            ""  "<th>${incrementHour}</th>"
            ""  "<th></th>"
            ""  "<th>${incrementMinute}</th>"
            ""  "<th></th>"
            ""  "<th>${incrementSecond}</th>"
            """</tr>"
            """<tr>"
            ""  "<td valign=\"middle\" align=\"center\">${hourText}</td>"
            ""  "<td valign=\"middle\" align=\"center\">:</td>"
            ""  "<td valign=\"middle\" align=\"center\">${minuteText}</td>"
            ""  "<td valign=\"middle\" align=\"center\">:</td>"
            ""  "<td valign=\"middle\" align=\"center\">${secondText}</td>"
            """</tr>"
            """<tr>"
            ""  "<th>${decrementHour}</th>"
            ""  "<th></th>"
            ""  "<th>${decrementMinute}</th>"
            ""  "<th></th>"
            ""  "<th>${decrementSecond}</th>"
            """</tr>"
            "</table>";

    WTemplate *impl = new WTemplate();
    setImplementation(impl);
    impl->setTemplateText(WString::fromUTF8(text.str(), XHTMLUnsafeText));

    WIcon::loadIconFont();
    WPushButton *incHourButton = new WPushButton();
    incHourButton->addStyleClass("fa fa-arrow-up");

    WPushButton *decHourButton = new WPushButton();
    decHourButton->addStyleClass("fa fa-arrow-down");

    WPushButton *incMinuteButton = new WPushButton();
    incMinuteButton->addStyleClass("fa fa-arrow-up");

    WPushButton *decMinuteButton = new WPushButton();
    decMinuteButton->addStyleClass("fa fa-arrow-down");
    
	WPushButton *incSecondButton = new WPushButton();
    incSecondButton->addStyleClass("fa fa-arrow-up");

    WPushButton *decSecondButton = new WPushButton();
    decSecondButton->addStyleClass("fa fa-arrow-down");

    hourText_ = new WText("0");
    hourText_->setInline(false);
    hourText_->setTextAlignment(AlignCenter);

    minuteText_ = new WText("00");
    minuteText_->setInline(false);
    minuteText_->setTextAlignment(AlignCenter);
    
	secondText_ = new WText("00");
    secondText_->setInline(false);
    secondText_->setTextAlignment(AlignCenter);

    impl->bindWidget("incrementHour", incHourButton);
    impl->bindWidget("decrementHour", decHourButton);

    impl->bindWidget("hourText", hourText_);
    impl->bindWidget("minuteText", minuteText_);
    impl->bindWidget("secondText", secondText_);

    impl->bindWidget("incrementMinute", incMinuteButton);
    impl->bindWidget("decrementMinute", decMinuteButton);
    
	impl->bindWidget("incrementSecond", incSecondButton);
    impl->bindWidget("decrementSecond", decSecondButton);

    incHourButton->clicked().connect(this, &WTimePicker::incrementHours);
    decHourButton->clicked().connect(this, &WTimePicker::decrementHours);

    incMinuteButton->clicked().connect(this, &WTimePicker::incrementMinutes);
    decMinuteButton->clicked().connect(this, &WTimePicker::decrementMinutes);
    
	incSecondButton->clicked().connect(this, &WTimePicker::incrementSeconds);
    decSecondButton->clicked().connect(this, &WTimePicker::decrementSeconds);

}