本文整理汇总了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);
}
示例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()) ;
}
示例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());
}
}
示例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");
}
}
示例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("×");
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;
}
}
示例6: greet
void HelloApplication::greet()
{
/*
* Update the text, using text input into the nameEdit_ field.
*/
greeting_->setText("Hello there, " + nameEdit_->text());
}
示例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));
}
}
示例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);
}
示例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");
}
}
示例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;
}
示例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);
}
示例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));
}
}
示例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);
}
示例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();
}
}
示例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;
}
//.........这里部分代码省略.........