本文整理汇总了C++中DomElement::insertChildAt方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::insertChildAt方法的具体用法?C++ DomElement::insertChildAt怎么用?C++ DomElement::insertChildAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::insertChildAt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateDom
void WPushButton::updateDom(DomElement& element, bool all)
{
if (all && element.type() == DomElement_BUTTON)
element.setAttribute("type", "button");
bool updateInnerHtml = !icon_.isNull() && flags_.test(BIT_TEXT_CHANGED);
if (updateInnerHtml || flags_.test(BIT_ICON_CHANGED)
|| (all && !icon_.isNull())) {
DomElement *image = DomElement::createNew(DomElement_IMG);
image->setProperty(PropertySrc, icon_.resolveUrl(WApplication::instance()));
image->setId("im" + formName());
element.insertChildAt(image, 0);
flags_.set(BIT_ICON_RENDERED);
flags_.reset(BIT_ICON_CHANGED);
}
if (flags_.test(BIT_TEXT_CHANGED) || all) {
element.setProperty(Wt::PropertyInnerHTML, text_.formattedText());
flags_.reset(BIT_TEXT_CHANGED);
}
// bool needsUrlResolution = false;
if (flags_.test(BIT_LINK_CHANGED) || all) {
if (element.type() == DomElement_A) {
/* needsUrlResolution = */ WAnchor::renderHRef(this, linkState_, element);
WAnchor::renderHTarget(linkState_, element, all);
} else
renderHRef(element);
flags_.reset(BIT_LINK_CHANGED);
}
if (isCheckable()) {
if (flags_.test(BIT_CHECKED_CHANGED) || all) {
if (!all || flags_.test(BIT_IS_CHECKED)) {
toggleStyleClass("active", flags_.test(BIT_IS_CHECKED), true);
}
flags_.reset(BIT_CHECKED_CHANGED);
}
}
if (!all)
WApplication::instance()->theme()->apply(this, element,
MainElementThemeRole);
WFormWidget::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: itemAt
DomElement *WTable::createRowDomElement(int row, bool withIds, WApplication *app)
{
DomElement *tr = DomElement::createNew(DomElement_TR);
if (withIds)
tr->setId(rows_[row]->id());
rows_[row]->updateDom(*tr, true);
// because of the mix of addChild() and insertChildAt()
tr->setWasEmpty(false);
int spanCounter = 0;
for (int col = 0; col < columnCount(); ++col) {
WTableRow::TableData& d = itemAt(row, col);
if (!d.overSpanned) {
DomElement *td = d.cell->createSDomElement(app);
/*
* So, IE gets confused when doing appendChild() for TH followed by
* insertCell(-1) for TD. But, we cannot insertChild() for element 0,
* so we do TH with appendChild, and insertCell(col).
*/
if (col < headerColumnCount_ || row < headerRowCount_)
tr->addChild(td);
else
tr->insertChildAt(td, col - spanCounter);
for (int i = 0; i < d.cell->rowSpan(); ++i)
for (int j = 0; j < d.cell->columnSpan(); ++j)
if (i + j > 0) {
itemAt(row + i, col + j).overSpanned = true;
itemAt(row + i, col + j).cell->setRendered(false);
}
} else {
spanCounter++;
}
}
return tr;
}
示例4: updateDom
void FlexLayoutImpl::updateDom(DomElement& parent)
{
WApplication *app = WApplication::instance();
DomElement *div = DomElement::getForUpdate(elId_, DomElementType::DIV);
Orientation orientation = getOrientation();
std::vector<int> orderedInserts;
for (unsigned i = 0; i < addedItems_.size(); ++i)
orderedInserts.push_back(indexOf(addedItems_[i], orientation));
Utils::sort(orderedInserts);
int totalStretch = getTotalStretch(orientation);
for (unsigned i = 0; i < orderedInserts.size(); ++i) {
int pos = orderedInserts[i];
DomElement *el = createElement(orientation, pos, totalStretch, app);
div->insertChildAt(el, pos);
}
addedItems_.clear();
for (unsigned i = 0; i < removedItems_.size(); ++i)
div->callJavaScript(WT_CLASS ".remove('" + removedItems_[i] + "');",
true);
removedItems_.clear();
WStringStream js;
js << "layout.adjust(" << grid_.horizontalSpacing_ << ")";
div->callMethod(js.str());
parent.addChild(div);
}
示例5: updateDom
void WPushButton::updateDom(DomElement& element, bool all)
{
if (all) {
element.setAttribute("type", "button");
element.setProperty(PropertyClass, "Wt-btn");
}
if (flags_.test(BIT_ICON_CHANGED) || (all && !icon_.isNull())) {
DomElement *image = DomElement::createNew(DomElement_IMG);
image->setProperty(PropertySrc, icon_.url());
image->setId("im" + formName());
element.insertChildAt(image, 0);
flags_.set(BIT_ICON_RENDERED);
}
if (flags_.test(BIT_TEXT_CHANGED) || all) {
element
.setProperty(Wt::PropertyInnerHTML,
text_.literal() ? escapeText(text_, true).toUTF8()
: text_.toUTF8());
flags_.reset(BIT_TEXT_CHANGED);
}
if (flags_.test(BIT_LINK_CHANGED) || (all && !link_.isNull())) {
if (!link_.isNull()) {
WApplication *app = WApplication::instance();
if (!redirectJS_) {
redirectJS_ = new JSlot();
clicked().connect(*redirectJS_);
if (!app->environment().ajax())
clicked().connect(this, &WPushButton::doRedirect);
}
if (link_.type() == WLink::InternalPath)
redirectJS_->setJavaScript
("function(){"
WT_CLASS ".history.navigate(" + jsStringLiteral(link_.internalPath())
+ ",true);"
"}");
else
if (linkTarget_ == TargetNewWindow)
redirectJS_->setJavaScript
("function(){"
"window.open(" + jsStringLiteral(link_.url()) + ");"
"}");
else
redirectJS_->setJavaScript
("function(){"
"window.location=" + jsStringLiteral(link_.url()) + ";"
"}");
clicked().senderRepaint(); // XXX only for Java port necessary
} else {
delete redirectJS_;
redirectJS_ = 0;
}
}
WFormWidget::updateDom(element, all);
}