本文整理汇总了C++中DomElement::mode方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::mode方法的具体用法?C++ DomElement::mode怎么用?C++ DomElement::mode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::mode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDom
void WTemplate::updateDom(DomElement& element, bool all)
{
if (changed_ || all) {
std::set<WWidget *> previouslyRendered;
std::vector<WWidget *> newlyRendered;
for (WidgetMap::const_iterator i = widgets_.begin(); i != widgets_.end();
++i) {
WWidget *w = i->second;
if (w->isRendered() && w->webWidget()->domCanBeSaved()) {
previouslyRendered.insert(w);
}
}
bool saveWidgets = element.mode() == DomElement::ModeUpdate;
previouslyRendered_ = saveWidgets ? &previouslyRendered : 0;
newlyRendered_ = &newlyRendered;
std::stringstream html;
renderTemplate(html);
previouslyRendered_ = 0;
newlyRendered_ = 0;
for (unsigned i = 0; i < newlyRendered.size(); ++i) {
WWidget *w = newlyRendered[i];
if (previouslyRendered.find(w) != previouslyRendered.end()) {
if (saveWidgets)
element.saveChild(w->id());
previouslyRendered.erase(w);
}
}
element.setProperty(Wt::PropertyInnerHTML, html.str());
changed_ = false;
for (std::set<WWidget *>::const_iterator i = previouslyRendered.begin();
i != previouslyRendered.end(); ++i) {
WWidget *w = *i;
w->webWidget()->setRendered(false);
}
}
WInteractWidget::updateDom(element, all);
}
示例2: updateDomChildren
void WContainerWidget::updateDomChildren(DomElement& parent, WApplication *app)
{
if (!app->session()->renderer().preLearning() && !layout_) {
if (parent.mode() == DomElement::ModeUpdate)
parent.setWasEmpty(wasEmpty());
if (transientImpl_) {
std::vector<int> orderedInserts;
std::vector<WWidget *>& ac = transientImpl_->addedChildren_;
for (unsigned i = 0; i < ac.size(); ++i)
orderedInserts.push_back(Utils::indexOf(*children_, ac[i]));
Utils::sort(orderedInserts);
int addedCount = transientImpl_->addedChildren_.size();
int totalCount = children_->size();
int insertCount = 0;
for (unsigned i = 0; i < orderedInserts.size(); ++i) {
int pos = orderedInserts[i];
DomElement *c = (*children_)[pos]->createSDomElement(app);
if (pos + (addedCount - insertCount) == totalCount)
parent.addChild(c);
else
parent.insertChildAt(c, pos + firstChildIndex());
++insertCount;
}
transientImpl_->addedChildren_.clear();
}
}
#ifndef WT_NO_LAYOUT
if (flags_.test(BIT_LAYOUT_NEEDS_UPDATE)) {
if (layout_)
layoutImpl()->updateDom(parent);
flags_.reset(BIT_LAYOUT_NEEDS_UPDATE);
}
#endif // WT_NO_LAYOUT
}
示例3: updateDom
void WTemplate::updateDom(DomElement& element, bool all)
{
if (changed_ || all) {
std::set<WWidget *> previouslyRendered;
std::vector<WWidget *> newlyRendered;
for (WidgetMap::const_iterator i = widgets_.begin(); i != widgets_.end();
++i) {
WWidget *w = i->second;
if (w->isRendered() && w->webWidget()->domCanBeSaved()) {
previouslyRendered.insert(w);
}
}
bool saveWidgets = element.mode() == DomElement::ModeUpdate;
previouslyRendered_ = saveWidgets ? &previouslyRendered : 0;
newlyRendered_ = &newlyRendered;
std::stringstream html;
renderTemplate(html);
previouslyRendered_ = 0;
newlyRendered_ = 0;
for (unsigned i = 0; i < newlyRendered.size(); ++i) {
WWidget *w = newlyRendered[i];
if (previouslyRendered.find(w) != previouslyRendered.end()) {
if (saveWidgets)
element.saveChild(w->id());
previouslyRendered.erase(w);
}
}
if (encodeTemplateText_)
element.setProperty(Wt::PropertyInnerHTML, html.str());
else
element.setProperty(Wt::PropertyInnerHTML, encode(html.str()));
changed_ = false;
for (std::set<WWidget *>::const_iterator i = previouslyRendered.begin();
i != previouslyRendered.end(); ++i) {
WWidget *w = *i;
// it could be that the widget was removed/deleted in the mean time
// as a side-effect of rendering some of the widgets; thus we check
// that the widget is still a child
for (WidgetMap::const_iterator j = widgets_.begin();
j != widgets_.end(); ++j) {
if (j->second == w) {
w->webWidget()->setRendered(false);
break;
}
}
}
WApplication::instance()->session()->renderer()
.updateFormObjects(this, true);
}
WInteractWidget::updateDom(element, all);
}
示例4: apply
void WBootstrapTheme::apply(WWidget *widget, DomElement& element,
int elementRole) const
{
bool creating = element.mode() == DomElement::Mode::Create;
if (!widget->isThemeStyleEnabled())
return;
{
WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
if (popup) {
WDialog *dialog = dynamic_cast<WDialog *>(widget);
if (!dialog)
element.addPropertyWord(Property::Class, "dropdown-menu");
}
}
switch (element.type()) {
case DomElementType::A: {
if (creating && dynamic_cast<WPushButton *>(widget))
element.addPropertyWord(Property::Class, classBtn(widget));
WPushButton *btn = dynamic_cast<WPushButton *>(widget);
if (creating && btn && btn->isDefault())
element.addPropertyWord(Property::Class, "btn-primary");
if (element.getProperty(Property::Class).find("dropdown-toggle")
!= std::string::npos) {
WMenuItem *item = dynamic_cast<WMenuItem *>(widget->parent());
if (!dynamic_cast<WPopupMenu *>(item->parentMenu())) {
DomElement *b = DomElement::createNew(DomElementType::B);
b->setProperty(Property::Class, "caret");
element.addChild(b);
}
}
break;
}
case DomElementType::BUTTON: {
if (creating && !widget->hasStyleClass("list-group-item"))
element.addPropertyWord(Property::Class, classBtn(widget));
WPushButton *button = dynamic_cast<WPushButton *>(widget);
if (button) {
if (creating && button->isDefault())
element.addPropertyWord(Property::Class, "btn-primary");
if (button->menu() &&
element.properties().find(Property::InnerHTML) !=
element.properties().end()) {
element.addPropertyWord(Property::InnerHTML,
"<span class=\"caret\"></span>");
}
if (creating && !button->text().empty())
element.addPropertyWord(Property::Class, "with-label");
if (!button->link().isNull())
LOG_ERROR("Cannot use WPushButton::setLink() after the button has "
"been rendered with WBootstrapTheme");
}
break;
}
case DomElementType::DIV:
{
WDialog *dialog = dynamic_cast<WDialog *>(widget);
if (dialog) {
if (version_ == BootstrapVersion::v2)
element.addPropertyWord(Property::Class, "modal");
else
element.addPropertyWord(Property::Class, "modal-dialog Wt-dialog");
return;
}
WPanel *panel = dynamic_cast<WPanel *>(widget);
if (panel) {
element.addPropertyWord(Property::Class, classAccordionGroup());
return;
}
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
if (bar) {
switch (elementRole) {
case MainElement:
element.addPropertyWord(Property::Class, "progress");
break;
case ProgressBarBar:
element.addPropertyWord(Property::Class, classBar());
break;
case ProgressBarLabel:
element.addPropertyWord(Property::Class, "bar-label");
}
return;
}
WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
//.........这里部分代码省略.........
示例5: apply
void WCssTheme::apply(WWidget *widget, DomElement& element, int elementRole)
const
{
bool creating = element.mode() == DomElement::ModeCreate;
{
WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
if (popup)
element.addPropertyWord(PropertyClass, "Wt-outset");
}
switch (element.type()) {
case DomElement_BUTTON:
if (creating)
element.addPropertyWord(PropertyClass, "Wt-btn");
break;
case DomElement_UL:
if (dynamic_cast<WPopupMenu *>(widget))
element.addPropertyWord(PropertyClass, "Wt-popupmenu Wt-outset");
else {
WTabWidget *tabs
= dynamic_cast<WTabWidget *>(widget->parent()->parent());
if (tabs)
element.addPropertyWord(PropertyClass, "Wt-tabs");
else {
WSuggestionPopup *suggestions
= dynamic_cast<WSuggestionPopup *>(widget);
if (suggestions)
element.addPropertyWord(PropertyClass, "Wt-suggest");
}
}
break;
case DomElement_LI:
{
WMenuItem *item = dynamic_cast<WMenuItem *>(widget);
if (item) {
if (item->isSeparator())
element.addPropertyWord(PropertyClass, "Wt-separator");
if (item->isSectionHeader())
element.addPropertyWord(PropertyClass, "Wt-sectheader");
if (item->menu())
element.addPropertyWord(PropertyClass, "submenu");
}
}
break;
case DomElement_DIV:
{
WDialog *dialog = dynamic_cast<WDialog *>(widget);
if (dialog) {
element.addPropertyWord(PropertyClass, "Wt-dialog");
return;
}
WPanel *panel = dynamic_cast<WPanel *>(widget);
if (panel) {
element.addPropertyWord(PropertyClass, "Wt-panel Wt-outset");
return;
}
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
if (bar) {
switch (elementRole) {
case MainElementThemeRole:
element.addPropertyWord(PropertyClass, "Wt-progressbar");
break;
case ProgressBarBarRole:
element.addPropertyWord(PropertyClass, "Wt-pgb-bar");
break;
case ProgressBarLabelRole:
element.addPropertyWord(PropertyClass, "Wt-pgb-label");
}
return;
}
}
break;
case DomElement_INPUT:
{
WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget);
if (spinBox) {
element.addPropertyWord(PropertyClass, "Wt-spinbox");
return;
}
WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget);
if (dateEdit) {
element.addPropertyWord(PropertyClass, "Wt-dateedit");
return;
}
}
break;
default:
break;
}
//.........这里部分代码省略.........
示例6: apply
void WBootstrapTheme::apply(WWidget *widget, DomElement& element,
int elementRole) const
{
bool creating = element.mode() == DomElement::ModeCreate;
{
WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget);
if (popup) {
WDialog *dialog = dynamic_cast<WDialog *>(widget);
if (!dialog)
element.addPropertyWord(PropertyClass, "dropdown-menu");
}
}
switch (element.type()) {
case DomElement_A:
if (creating && dynamic_cast<WPushButton *>(widget))
element.addPropertyWord(PropertyClass, "btn");
if (element.getProperty(PropertyClass).find("dropdown-toggle")
!= std::string::npos) {
WMenuItem *item = dynamic_cast<WMenuItem *>(widget->parent());
if (!dynamic_cast<WPopupMenu *>(item->parentMenu())) {
DomElement *b = DomElement::createNew(DomElement_B);
b->setProperty(PropertyClass, "caret");
element.addChild(b);
}
}
break;
case DomElement_BUTTON: {
if (creating)
element.addPropertyWord(PropertyClass, "btn");
WPushButton *button = dynamic_cast<WPushButton *>(widget);
if (button) {
if (creating && button->isDefault())
element.addPropertyWord(PropertyClass, "btn-primary");
if (button->menu() &&
element.properties().find(PropertyInnerHTML) !=
element.properties().end()) {
element.addPropertyWord(PropertyInnerHTML,
"<span class=\"caret\"></span>");
}
}
break;
}
case DomElement_DIV:
{
WDialog *dialog = dynamic_cast<WDialog *>(widget);
if (dialog) {
element.addPropertyWord(PropertyClass, "modal");
return;
}
WPanel *panel = dynamic_cast<WPanel *>(widget);
if (panel) {
element.addPropertyWord(PropertyClass, "accordion-group");
return;
}
WProgressBar *bar = dynamic_cast<WProgressBar *>(widget);
if (bar) {
switch (elementRole) {
case MainElementThemeRole:
element.addPropertyWord(PropertyClass, "progress");
break;
case ProgressBarBarRole:
element.addPropertyWord(PropertyClass, "bar");
break;
case ProgressBarLabelRole:
element.addPropertyWord(PropertyClass, "bar-label");
}
return;
}
WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget);
if (map) {
element.addPropertyWord(PropertyClass, "Wt-googlemap");
return;
}
WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget);
if (itemView) {
element.addPropertyWord(PropertyClass, "form-horizontal");
return;
}
}
break;
case DomElement_LABEL:
{
WCheckBox *cb = dynamic_cast<WCheckBox *>(widget);
if (cb) {
element.addPropertyWord(PropertyClass, "checkbox");
//.........这里部分代码省略.........