当前位置: 首页>>代码示例>>C++>>正文


C++ WText::setText方法代码示例

本文整理汇总了C++中WText::setText方法的典型用法代码示例。如果您正苦于以下问题:C++ WText::setText方法的具体用法?C++ WText::setText怎么用?C++ WText::setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WText的用法示例。


在下文中一共展示了WText::setText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WPanel

Playlist::Playlist(Session* session, Settings* settings, WContainerWidget* parent)
: WPanel(parent), d(this, session)
{
  setCentralWidget(d->container = new WContainerWidget);
  setTitleBar(true);
  addStyleClass("playlist");
  setHeaderCollapsible(this);
  titleBarWidget()->addStyleClass("playtlist-titlebar");
  setCollapsible(false);

  d->container->hide();
  d->container->setList(true);
  d->container->addStyleClass("nav nav-pills nav-stacked");
  d->container->setMargin(5, Side::Bottom);
  WText *showHideButtonText = WW<WText>();
  
  d->setPlaylistVisible = [=](bool visible) {
    if(!visible) {
      showHideButtonText->setText(wtr("playlist.show"));
      settings->animateHide(Settings::PlaylistAnimation, d->container);
    }
    else {
      showHideButtonText->setText(wtr("playlist.hide"));
      settings->animateShow(Settings::PlaylistAnimation, d->container);
    }
  };
  
  d->playSignal.connect([=](PlaylistItem*,_n5){ d->setPlaylistVisible(false); });

  WContainerWidget *firstGroup = WW<WContainerWidget>().css("btn-group");
  firstGroup->addWidget(WW<WAnchor>().css("btn btn-xs")
    .setImage(WW<WImage>(Settings::staticPath("/icons/actions/playlist.png")).setMargin(5, Side::Right))
    .add(showHideButtonText)
    .onClick([=](WMouseEvent){
      d->setPlaylistVisible(!d->container->isVisible());
    }));
  firstGroup->addWidget(WW<WAnchor>().css("btn btn-xs")
    .setImage(WW<WImage>(Settings::staticPath("/icons/actions/playlist.clear.png")).setMargin(5, Side::Right))
    .setText(wtr("playlist.clear"))
    .onClick([=](WMouseEvent){
    for(auto item: d->internalQueue)
      delete item;
    d->internalQueue.clear();
  }));

  WContainerWidget *secondGroup = WW<WContainerWidget>().css("btn-group");
  WWidget *prev = WW<WAnchor>(secondGroup).css("btn btn-xs")
    .add(new WImage{Settings::staticPath("/icons/actions/previous.png")}).onClick(boost::bind(&Playlist::previous, this));
  WWidget *next = WW<WAnchor>(secondGroup).css("btn btn-xs")
    .add(new WImage{Settings::staticPath("/icons/actions/next.png")}).onClick(boost::bind(&Playlist::next, this));
  WContainerWidget *playlistButtonsContainer = WW<WContainerWidget>(titleBarWidget()).css("btn-toolbar")
  .add(firstGroup).add(secondGroup);
  d->setPlaylistVisible(false);
}
开发者ID:geolffrey,项目名称:Pandorica,代码行数:54,代码来源:playlist.cpp

示例2: plot

void DensityApp::plot() {
    const char *kernelstr[] = { "gaussian", "epanechnikov", "rectangular", "triangular", "cosine" };
    greeting_->setText("Starting R call");
    R_["tfile"]  = tempfile_;
    R_["bw"]     = bw_;
    R_["kernel"] = kernelstr[kernel_]; 			// passes the string to R
    R_["y"]      = Yvec_;
    std::string cmd0 = "png(filename=tfile,width=600,height=400); plot(density(y, bw=bw/100, kernel=kernel), xlim=range(y)+c(-2,2), main=\"Kernel: ";
    std::string cmd1 = "\"); points(y, rep(0, length(y)), pch=16, col=rgb(0,0,0,1/4));  dev.off()";
    std::string cmd = cmd0 + kernelstr[kernel_] + cmd1; // stick the selected kernel in the middle
    R_.parseEvalQ(cmd);				     	// evaluate command -- generates new density plot
    imgfile_->setChanged();				// important: tells consumer that image has changed, forces refresh
    greeting_->setText("Finished request from " + this->environment().clientAddress() + " using " + this->environment().userAgent()) ;
}
开发者ID:JohnRobson,项目名称:Wt-Tests,代码行数:14,代码来源:wtdensityPlain.cpp

示例3: loadGitModel

  /*! \brief Change repository and/or revision
   */
  void loadGitModel() {
    sourceView_->setIndex(WModelIndex());
    repositoryError_->setText("");
    revisionError_->setText("");
    try {
      gitModel_->setRepositoryPath(repositoryEdit_->text().toUTF8());
      try {
	gitModel_->loadRevision(revisionEdit_->text().toUTF8());
      } catch (const Git::Exception& e) {
	revisionError_->setText(e.what());
      }
    } catch (const Git::Exception& e) {
      repositoryError_->setText(e.what());
    }
  }
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:17,代码来源:GitView.C

示例4: updateView

void UpdatePasswordWidget::updateView(const std::string& var,
				      RegistrationModel::Field field)
{
  WFormWidget *edit = resolve<WFormWidget *>(var);
  WText *info = resolve<WText *>(var + "-info");
  
  const WValidator::Result& v = model_->validationResult(field);
  info->setText(v.message());

  switch (v.state()) {
  case WValidator::InvalidEmpty:
  case WValidator::Invalid:
    edit->removeStyleClass("Wt-valid");
    if (validated_)
      edit->addStyleClass("Wt-invalid");
    info->addStyleClass("Wt-error");

    break;
  case WValidator::Valid:
    edit->removeStyleClass("Wt-invalid");
    if (validated_)
      edit->addStyleClass("Wt-valid");
    info->removeStyleClass("Wt-error");
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:25,代码来源:UpdatePasswordWidget.C

示例5: apply

void WBootstrapTheme::apply(WWidget *widget, WWidget *child, int widgetRole)
  const
{
  switch (widgetRole) {
  case MenuItemIconRole:
    child->addStyleClass("Wt-icon");
    break;
  case MenuItemCheckBoxRole:
    child->addStyleClass("Wt-chkbox");
    break;
  case DialogCoverRole:
    child->addStyleClass("modal-backdrop");
    break;
  case DialogTitleBarRole:
    child->addStyleClass("modal-header");
    break;
  case DialogBodyRole:
    child->addStyleClass("modal-body");
    break;
  case DialogFooterRole:
    child->addStyleClass("modal-footer");
    break;
  case DialogCloseIconRole:
    {
      child->addStyleClass("close");
      WText *t = dynamic_cast<WText *>(child);
      t->setText("&times;");
      break;
    }

  case TableViewRowContainerRole:
    {
      WAbstractItemView *view = dynamic_cast<WAbstractItemView *>(widget);
      child->toggleStyleClass("Wt-striped", view->alternatingRowColors());
      break;
    }

  case DatePickerPopupRole:
    child->addStyleClass("Wt-datepicker");
    break;

  case PanelTitleBarRole:
    child->addStyleClass("accordion-heading");
    break;

  case PanelCollapseButtonRole:
  case PanelTitleRole:
    child->addStyleClass("accordion-toggle");
    break;

  case PanelBodyRole:
    child->addStyleClass("accordion-inner");
    break;
  case AuthWidgets:
    WApplication *app = WApplication::instance();
    app->builtinLocalizedStrings().useBuiltin
      (skeletons::AuthBootstrapTheme_xml1);
    break;
  }
}
开发者ID:patrickjwhite,项目名称:wt,代码行数:60,代码来源:WBootstrapTheme.C

示例6: greet

void HelloApplication::greet()
{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}
开发者ID:AlexanderKotliar,项目名称:wt,代码行数:7,代码来源:hello.C

示例7: modelDataChanged

void WSuggestionPopup::modelDataChanged(const WModelIndex& topLeft,
					const WModelIndex& bottomRight)
{
  if (topLeft.parent().isValid())
    return;

  if (modelColumn_ < topLeft.column() || modelColumn_ > bottomRight.column())
    return;

  for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
    WContainerWidget *w = dynamic_cast<WContainerWidget *>(impl_->widget(i));
    WAnchor *anchor = dynamic_cast<WAnchor *>(w->widget(0));
    WText *value = dynamic_cast<WText *>(anchor->widget(0));

    WModelIndex index = model_->index(i, modelColumn_);

    boost::any d = index.data();
    value->setText(asString(d));

    TextFormat format = index.flags() & ItemIsXHTMLText ? XHTMLText : PlainText;
    value->setTextFormat(format);

    boost::any d2 = model_->data(i, modelColumn_, UserRole);
    if (d2.empty())
      d2 = d;

    value->setAttributeValue("sug", asString(d2));
  }
}
开发者ID:Unss,项目名称:wt,代码行数:29,代码来源:WSuggestionPopup.C

示例8: get_search

void Example::get_search(MapViewer::GeoNode node) {
    Coordinate& pos = node.first;
    click_search_->setText(
        "You have chosen: " + node.second + " <br />Position: " +
        str(boost::format("%.4f %.4f") % pos.longitude() % pos.latitude()));
    mv_->time_zone(pos).connect(this, &Example::get_time_zone);
}
开发者ID:NCAR,项目名称:wt-classes,代码行数:7,代码来源:map-viewer.cpp

示例9: updateViewField

void WTemplateFormView::updateViewField(WFormModel *model,
					WFormModel::Field field)
{
  const std::string var = field;

  if (model->isVisible(field)) {
    setCondition("if:" + var, true);
    WWidget *edit = resolveWidget(var);
    if (!edit) {
      edit = createFormWidget(field);
      if (!edit) {
	LOG_ERROR("updateViewField: createFormWidget('"
		  << field << "') returned 0");
	return;
      }
      bindWidget(var, edit);
    }

    WFormWidget *fedit = dynamic_cast<WFormWidget *>(edit);
    if (fedit) {
      if (fedit->validator() != model->validator(field) &&
	  model->validator(field))
	fedit->setValidator(model->validator(field));
      updateViewValue(model, field, fedit);
    } else
      updateViewValue(model, field, edit);

    WText *info = resolve<WText *>(var + "-info");
    if (!info) {
      info = new WText();
      bindWidget(var + "-info", info);
    }

    bindString(var + "-label", model->label(field));

    const WValidator::Result& v = model->validation(field);
    info->setText(v.message());
    indicateValidation(field, model->isValidated(field),
		       info, edit, v);
    edit->setDisabled(model->isReadOnly(field));
  } else {
    setCondition("if:" + var, false);
    bindEmpty(var);
    bindEmpty(var + "-info");    
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:46,代码来源:WTemplateFormView.C

示例10: renderCell

WWidget* WCalendar::renderCell(WWidget* widget, const WDate& date)
{
  WText* t = dynamic_cast<WText*>(widget);

  if (!t) {
    t = new WText();
    t->setInline(false);
    t->setTextFormat(PlainText);
  }

#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA
  Utils::itoa(date.day(), buf);
  t->setText(WString::fromUTF8(buf));

  std::string styleClass;

  if (isInvalid(date))
    styleClass += " Wt-cal-oor";
  else if (date.month() != currentMonth())
    styleClass += " Wt-cal-oom";

  if (isSelected(date))
    styleClass += " Wt-cal-sel";

  WDate currentDate = WDate::currentDate();
  if (date.day() == currentDate.day() && date.month() == currentDate.month() &&
      date.year() == currentDate.year()) {
    if (!isSelected(date))
      styleClass += " Wt-cal-now";
    t->setToolTip(WString::tr("Wt.WCalendar.today"));
  } else
    t->setToolTip("");

  t->setStyleClass(styleClass.c_str());

  return t;
}
开发者ID:LifeGo,项目名称:wt,代码行数:41,代码来源:WCalendar.C

示例11: load

void WsTwitterStream::load()
{
  Wt::WApplication::instance()->require("//platform.twitter.com/widgets.js");
  WContainerWidget::load();
  std::string width = Wt::asString(option("width")).toUTF8();
  std::string url = Wt::asString(option("url")).toUTF8();
  std::string widgetId = Wt::asString(option("widgetId")).toUTF8();
  std::string text = Wt::asString(option("text")).toUTF8();
  setId("twitterstream");
  //resize(WLength(25, WLength::Percentage), WLength(25, WLength::Percentage));
  setOverflow(WContainerWidget::OverflowAuto);
  std::string html = "<a class=\"twitter-timeline\"";
  if (width!="")
    html+=" width=\""+width+"\"";
  html+=" data-dnt=\"true\" href=\""+url+"\" data-widget-id=\""+widgetId+"\">"+text+"</a>";
  wApp->log("notice") << "WsModTwitterStream::load() "+html;
  WText* textField = new WText(this);
  textField->setTextFormat(Wt::XHTMLUnsafeText);
  textField->setText(html);
  addWidget(textField);
}
开发者ID:Wittyshare,项目名称:wittyshare,代码行数:21,代码来源:WsModTwitterStream.cpp

示例12: modelDataChanged

void WSuggestionPopup::modelDataChanged(const WModelIndex& topLeft,
					const WModelIndex& bottomRight)
{
  if (topLeft.parent().isValid())
    return;

  if (modelColumn_ < topLeft.column() || modelColumn_ > bottomRight.column())
    return;

  for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
    WContainerWidget *w = dynamic_cast<WContainerWidget *>(content_->widget(i));
    WText *value = dynamic_cast<WText *>(w->widget(0));

    boost::any d = model_->data(i, modelColumn_);
    value->setText(asString(d));

    boost::any d2 = model_->data(i, modelColumn_, UserRole);
    if (d2.empty())
      d2 = d;

    value->setAttributeValue("sug", asString(d2));
  }
}
开发者ID:bvanhauwaert,项目名称:wt,代码行数:23,代码来源:WSuggestionPopup.C

示例13: get_pos

void Example::get_pos(const Coordinate& pos) {
    click_pos_->setText("You clicked near: " +
                        str(boost::format("%.4f %.4f")
                            % pos.longitude() % pos.latitude()));
    mv_->time_zone(pos).connect(this, &Example::get_time_zone);
}
开发者ID:NCAR,项目名称:wt-classes,代码行数:6,代码来源:map-viewer.cpp

示例14: processChatEvent

void SimpleChatWidget::processChatEvent(const ChatEvent& event)
{
  WApplication *app = WApplication::instance();

  /*
   * This is where the "server-push" happens. The chat server posts to this
   * event from other sessions, see SimpleChatServer::postChatEvent()
   */

  /*
   * Format and append the line to the conversation.
   *
   * This is also the step where the automatic XSS filtering will kick in:
   * - if another user tried to pass on some JavaScript, it is filtered away.
   * - if another user did not provide valid XHTML, the text is automatically
   *   interpreted as PlainText
   */

  /*
   * If it is not a plain message, also update the user list.
   */
  if (event.type() != ChatEvent::Message) {
    if (event.type() == ChatEvent::Rename && event.user() == user_)
      user_ = event.data();

    updateUsers();
  }

  /*
   * This is the server call: we (schedule to) propagate the updated UI to
   * the client.
   *
   * This schedules an update and returns immediately
   */
  app->triggerUpdate();

  newMessage();

  /*
   * Anything else doesn't matter if we are not logged in.
   */
  if (!loggedIn())
    return;

  bool display = event.type() != ChatEvent::Message
    || !userList_
    || (users_.find(event.user()) != users_.end() && users_[event.user()]);

  if (display) {
    WText *w = new WText(messages_);

    /*
     * If it fails, it is because the content wasn't valid XHTML
     */
    if (!w->setText(event.formattedHTML(user_, XHTMLText))) {
      w->setText(event.formattedHTML(user_, PlainText));
      w->setTextFormat(XHTMLText);
    }

    w->setInline(false);
    w->setStyleClass("chat-msg");

    /*
     * Leave no more than 100 messages in the back-log
     */
    if (messages_->count() > 100)
      delete messages_->children()[0];

    /*
     * Little javascript trick to make sure we scroll along with new content
     */
    app->doJavaScript(messages_->jsRef() + ".scrollTop += "
		       + messages_->jsRef() + ".scrollHeight;");

    /* If this message belongs to another user, play a received sound */
    if (event.user() != user_ && messageReceived_)
      messageReceived_->play();
  }
}
开发者ID:LifeGo,项目名称:wt,代码行数:79,代码来源:SimpleChatWidget.C

示例15: selectWidget

void WsContent::selectWidget(std::string path)
{
  std::string             sysPath(m_sDocumentRoot + path);
  boost::filesystem::path p(path);
  std::string             strExt (p.extension().string());
  std::string             strName(p.stem().string());
  std::string             strFileName(strName + strExt);
  std::string             fileContent;
  if ( m_bLogContent )
    wApp->log("notice") << "WsContent::selectWidget :  path = " << path << " name = " << strName << " extension = " << strExt << " system path = " << sysPath;
  // This extension is mainly created for allowing text in a image without a link
  if ( strExt == ".nolink" ) {
    addWidget(new WsErrorPage(WsErrorPage::Error, path, 0, "Extension not allowed", true));
    return;
  }
  // .html
  if ( strExt == ".html" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a html file : " << sysPath;
    if ( !m_bAllowHtmlRendering ) {
      addWidget(new WsErrorPage(WsErrorPage::Error, path, 0, "Rendering a html file is not allowed"));
      return;
    }
    clear();
    WsApp->hideImages(false);
    WText* pIFrame = new WText();
    pIFrame->setTextFormat(XHTMLUnsafeText);
    pIFrame->setText("<iframe src='" + m_sRelativeDocumentRoot + path + "' height='98%' width='100%' frameborder='0'></iframe>");
    addWidget(pIFrame);
    return;
  }
  // .form
  if ( strExt == ".form" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a form : " << sysPath;
    clear();
    m_curWForm = new gdWForm(sysPath);
    addWidget(m_curWForm);
    return;
  }
  // .itpl, Inside template : Extension that create a template in the content.
  if ( strExt == ".itpl" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render an inside template : " << sysPath;
    clear();
    WsTemplate* pTemplate = new WsTemplate(strFileName);
    addWidget(pTemplate);
    return;
  }
  // directory
  if ( gdcore_isPathDirectory(sysPath) ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a directory : " << sysPath;
    viewDirectory(path);
    return;
  }
  /*
  Koen : mmm this is a tricky problem. you could do this using an internal path so that you can first let the user authenticate, if necessary, and then you redirect to a static resource with some randomly generated token in the URL so that you can serve the file
  so the permalink is clean, like /cms/folder1/folder2/file.doc
  if your app is deployed at / or /cms, you handle the internal path, authenticate, etc...
  then finally, you create a random ID, and redirect to /resource/folder1/folder2/file.doc?auth=randomid
  and this is handled by a WResource which checks the path and serves the file
  if you prefer I can create a small example ...
  ooops ! must run !
  */
  if ( strExt == ".rss" ) {
    if ( m_bLogContent )
      wApp->log("notice") << "WsContent::selectWidget : render a " << strExt << " file : " << sysPath;
    clear();
    WsApp->hideImages(false);
    addWidget(new WText("Download file : " + path + " ..."));
    return wApp->redirect(m_sRelativeDocumentRoot + path);
  }
  for (int iModule = 0; iModule < WsApp->WsModules().modules().size(); iModule++) {
    WsModule* curModule = WsApp->WsModules().modules()[iModule]->module;
    if ( curModule->isLoaded() ) continue;
    if ( (strExt.size() == 0  && strName == curModule->fileName()) || (strExt.size() > 0 && strExt == curModule->extension(strExt))  ) {
      if ( m_bLogContent )
        if ( strExt == curModule->extension(strExt) )
          wApp->log("notice") << "WsContent::selectWidget : module, render a " << strExt << " file extension : " << sysPath;
        else
          wApp->log("notice") << "WsContent::selectWidget : module, render " << strName << " file name: " << sysPath;
      clear();
      WsApp->hideImages(curModule->hideImages());
      curModule->setSysPath(sysPath);
      curModule->setDiffPath(m_sRelativeDocumentRoot);
      WWidget* w = curModule->createContents();
      if ( w ) {
        if ( asString(curModule->option("useLayout")) == "true" ) {
          WVBoxLayout* vbox = new WVBoxLayout();
          vbox->addWidget(w, 1);
          setLayout(vbox);
        } else {
          addWidget(w);
        }
      } else {
        wApp->log("notice") << "WsContent::selectWidget : module, render " << curModule->moduleName() << " CANNOT call create content: ";
      }
      return;
    }
//.........这里部分代码省略.........
开发者ID:Wittyshare,项目名称:wittyshare,代码行数:101,代码来源:WsContent.cpp


注:本文中的WText::setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。