本文整理汇总了C++中DomElement::addChild方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::addChild方法的具体用法?C++ DomElement::addChild怎么用?C++ DomElement::addChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::addChild方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createPainter
DomElement *WPaintedWidget::createDomElement(WApplication *app)
{
createPainter();
DomElement *result = DomElement::createNew(domElementType());
setId(result, app);
DomElement *wrap = result;
if (width().isAuto() && height().isAuto()) {
result->setProperty(PropertyStylePosition, "relative");
wrap = DomElement::createNew(DomElement_DIV);
wrap->setProperty(PropertyStylePosition, "absolute");
wrap->setProperty(PropertyStyleLeft, "0");
wrap->setProperty(PropertyStyleRight, "0");
}
DomElement *canvas = DomElement::createNew(DomElement_DIV);
if (!app->environment().agentIsSpiderBot())
canvas->setId('p' + id());
WPaintDevice *device = painter_->getPaintDevice(false);
//handle the widget correctly when inline and using VML
if (painter_->renderType() == WWidgetPainter::InlineVml && isInline()) {
result->setProperty(PropertyStyle, "zoom: 1;");
canvas->setProperty(PropertyStyleDisplay, "inline");
canvas->setProperty(PropertyStyle, "zoom: 1;");
}
if (renderWidth_ != 0 && renderHeight_ != 0) {
paintEvent(device);
#ifdef WT_TARGET_JAVA
if (device->painter())
device->painter()->end();
#endif // WT_TARGET_JAVA
}
painter_->createContents(canvas, device);
needRepaint_ = false;
wrap->addChild(canvas);
if (wrap != result)
result->addChild(wrap);
updateDom(*result, true);
return result;
}
示例2: setId
DomElement *WTable::createDomElement(WApplication *app)
{
bool withIds = !app->environment().agentIsSpiderBot();
DomElement *table = DomElement::createNew(domElementType());
setId(table, app);
DomElement *thead = 0;
if (headerRowCount_ != 0) {
thead = DomElement::createNew(DomElement_THEAD);
if (withIds)
thead->setId(id() + "th");
}
DomElement *tbody = DomElement::createNew(DomElement_TBODY);
if (withIds)
tbody->setId(id() + "tb");
for (unsigned col = 0; col < columns_.size(); ++col) {
DomElement *c = DomElement::createNew(DomElement_COL);
if (withIds)
c->setId(columns_[col]->id());
columns_[col]->updateDom(*c, true);
table->addChild(c);
}
flags_.reset(BIT_COLUMNS_CHANGED);
for (unsigned row = 0; row < (unsigned)rowCount(); ++row)
for (unsigned col = 0; col < (unsigned)columnCount(); ++col)
itemAt(row, col).overSpanned = false;
for (unsigned row = 0; row < (unsigned)rowCount(); ++row) {
DomElement *tr = createRow(row, withIds, app);
if (row < static_cast<unsigned>(headerRowCount_))
thead->addChild(tr);
else
tbody->addChild(tr);
}
rowsAdded_ = 0;
if (thead)
table->addChild(thead);
table->addChild(tbody);
updateDom(*table, true);
flags_.reset(BIT_GRID_CHANGED);
delete rowsChanged_;
rowsChanged_ = 0;
return table;
}
示例3: setId
DomElement *WGLWidget::createDomElement(WApplication *app)
{
DomElement *result = 0;
if (app->environment().agentIsIElt(9) ||
app->environment().agent() == WEnvironment::MobileWebKitAndroid) {
// Shortcut: IE misbehaves when it encounters a canvas element
result = DomElement::createNew(DomElement_DIV);
if (alternative_)
result->addChild(alternative_->createSDomElement(app));
} else {
result = DomElement::createNew(DomElement_CANVAS);;
if (alternative_) {
result->addChild(alternative_->createSDomElement(app));
}
}
setId(result, app);
std::stringstream tmp;
tmp <<
"{\n"
"""var o = new " WT_CLASS ".WGLWidget(" << app->javaScriptClass() << "," << jsRef() << ");\n"
"""o.discoverContext(function(){" << webglNotAvailable_.createCall() << "});\n";
js_.str("");
initializeGL();
tmp <<
"""o.initializeGL=function(){\n"
//"""debugger;\n"
"""var obj=" << glObjJsRef() << ";\n"
"""var ctx=obj.ctx; if(!ctx) return;\n" <<
"" << js_.str() <<
"""obj.initialized = true;\n"
// updates are queued until initialization is complete
"""var key;\n"
"""for(key in obj.updates) obj.updates[key]();\n"
"""obj.updates = new Array();\n"
// Similar, resizeGL is not executed until initialized
"""obj.resizeGL();\n"
"};\n"
"}\n";
tmp << delayedJavaScript_.str();
delayedJavaScript_.str("");
result->callJavaScript(tmp.str());
repaintGL(PAINT_GL | RESIZE_GL);
updateDom(*result, true);
return result;
}
示例4: updateDom
void WFileUpload::updateDom(DomElement& element, bool all)
{
bool containsProgress = progressBar_ && progressBar_->parent() == this;
DomElement *inputE = 0;
if (element.type() != DomElement_INPUT
&& flags_.test(BIT_DO_UPLOAD)
&& containsProgress && !progressBar_->isRendered())
element.addChild(progressBar_->createSDomElement(WApplication::instance()));
// upload() + disable() does not work. -- fix after this release,
// change order of javaScript_ and properties rendering in DomElement
if (fileUploadTarget_ && flags_.test(BIT_DO_UPLOAD)) {
element.callMethod("submit()");
flags_.reset(BIT_DO_UPLOAD);
if (containsProgress) {
inputE = DomElement::getForUpdate("in" + id(), DomElement_INPUT);
inputE->setProperty(PropertyStyleDisplay, "none");
}
}
if (flags_.test(BIT_ENABLED_CHANGED)) {
if (!inputE)
inputE = DomElement::getForUpdate("in" + id(), DomElement_INPUT);
if (isDisabled())
inputE->callMethod("disabled=true");
else
inputE->callMethod("disabled=false");
flags_.reset(BIT_ENABLED_CHANGED);
}
EventSignal<> *change = voidEventSignal(CHANGE_SIGNAL, false);
if (change && change->needsUpdate(all)) {
if (!inputE)
inputE = DomElement::getForUpdate("in" + id(), DomElement_INPUT);
updateSignalConnection(*inputE, *change, "change", all);
}
if (inputE)
element.addChild(inputE);
WWebWidget::updateDom(element, all);
}
示例5: getDomChanges
void WAbstractMedia::getDomChanges(std::vector<DomElement *>& result,
WApplication *app)
{
if (!mediaId_.empty()) {
DomElement *media = DomElement::getForUpdate(mediaId_, DomElement_DIV);
updateMediaDom(*media, false);
if (sourcesChanged_) {
// Updating source elements seems to be ill-supported in at least FF,
// so we delete them all and reinsert them.
// Delete source elements that are no longer required
for (std::size_t i = 0; i < sourcesRendered_; ++i)
media->callJavaScript
(WT_CLASS ".remove('" + mediaId_ + "s"
+ boost::lexical_cast<std::string>(i) + "');",
true);
sourcesRendered_ = 0;
for (std::size_t i = 0; i < sources_.size(); ++i) {
DomElement *src = DomElement::createNew(DomElement_SOURCE);
src->setId(mediaId_ + "s" + boost::lexical_cast<std::string>(i));
renderSource(src, *sources_[i], i + 1 >= sources_.size());
media->addChild(src);
}
sourcesRendered_ = sources_.size();
sourcesChanged_ = false;
// Explicitly request rerun of media selection algorithm
// 4.8.9.2 says it should happen automatically, but FF doesn't
media->callJavaScript(jsMediaRef() + ".load();");
}
result.push_back(media);
}
WInteractWidget::getDomChanges(result, app);
}
示例6: updateDom
void WComboBox::updateDom(DomElement& element, bool all)
{
if (itemsChanged_ || all) {
if (!all)
element.removeAllChildren();
for (unsigned i = 0; i < items_.size(); ++i) {
DomElement *item = DomElement::createNew(DomElement::OPTION);
item->setAttribute("value", boost::lexical_cast<std::string>(i));
item->setProperty(Wt::PropertyInnerHTML, items_[i]);
if ((int)i == currentIndex_)
item->setProperty(Wt::PropertySelected, "true");
element.addChild(item);
}
itemsChanged_ = false;
}
if (selectionChanged_) {
element.setProperty(Wt::PropertySelectedIndex,
boost::lexical_cast<std::string>(currentIndex_));
selectionChanged_ = false;
}
const WSignalInstance_ *s1 = getSignal(SIGNAL(activated(int)));
const WSignalInstance_ *s2 = getSignal(SIGNAL(activated(const std::string)));
if (isConnected(s1) || isConnected(s2))
connect(this, SIGNAL(changed()), this, SLOT(propagateChanged()));
WFormWidget::updateDom(element, all);
renderOk();
}
示例7: doUpdateDom
void PaintedSlider::doUpdateDom(DomElement& element, bool all)
{
if (all) {
WApplication *app = WApplication::instance();
element.addChild(createSDomElement(app));
element.addChild(((WWebWidget *)handle_)->createSDomElement(app));
DomElement *west = DomElement::createNew(DomElement_DIV);
west->setProperty(PropertyClass, "Wt-w");
element.addChild(west);
DomElement *east = DomElement::createNew(DomElement_DIV);
east->setProperty(PropertyClass, "Wt-e");
element.addChild(east);
}
}
示例8: updateDom
void WPaintedWidget::updateDom(DomElement& element, bool all)
{
if ((all && areaImage_) || areaImageAdded_) {
element.addChild(areaImage_->createSDomElement(WApplication::instance()));
areaImageAdded_ = false;
}
WInteractWidget::updateDom(element, all);
}
示例9: updateDom
void WProgressBar::updateDom(DomElement& element, bool all)
{
DomElement *bar = 0, *label = 0;
if (all) {
WApplication *app = WApplication::instance();
bar = DomElement::createNew(DomElement_DIV);
bar->setId("bar" + id());
bar->setProperty(PropertyClass, valueStyleClass_);
app->theme()->apply(this, *bar, ProgressBarBarRole);
label = DomElement::createNew(DomElement_DIV);
label->setId("lbl" + id());
app->theme()->apply(this, *label, ProgressBarLabelRole);
}
if (changed_ || all) {
if (!bar)
bar = DomElement::getForUpdate("bar" + id(), DomElement_DIV);
if (!label)
label = DomElement::getForUpdate("lbl" + id(), DomElement_DIV);
bar->setProperty(PropertyStyleWidth,
boost::lexical_cast<std::string>(percentage()) + "%");
WString s = text();
removeScript(s);
label->setProperty(PropertyInnerHTML, s.toUTF8());
changed_ = false;
}
if (bar)
element.addChild(bar);
if (label)
element.addChild(label);
WInteractWidget::updateDom(element, all);
}
示例10: updateDom
void WImage::updateDom(DomElement& element, bool all)
{
DomElement *img = &element;
if (all && element.type() == DomElement_SPAN) {
DomElement *map = map_->createSDomElement(WApplication::instance());
element.addChild(map);
img = DomElement::createNew(DomElement_IMG);
img->setId("i" + id());
}
if (flags_.test(BIT_IMAGE_LINK_CHANGED) || all) {
if (!imageLink_.isNull()) {
std::string url = resolveRelativeUrl(imageLink_.url());
WApplication *app = WApplication::instance();
url = app->encodeUntrustedUrl(url);
img->setProperty(Wt::PropertySrc, url);
} else
img->setProperty(Wt::PropertySrc, "#");
flags_.reset(BIT_IMAGE_LINK_CHANGED);
}
if (flags_.test(BIT_ALT_TEXT_CHANGED) || all) {
img->setAttribute("alt", altText_.toUTF8());
flags_.reset(BIT_ALT_TEXT_CHANGED);
}
if (flags_.test(BIT_MAP_CREATED) || (all && map_)) {
img->setAttribute("usemap", '#' + map_->id());
flags_.reset(BIT_MAP_CREATED);
}
WInteractWidget::updateDom(*img, all);
if (&element != img)
element.addChild(img);
}
示例11: updateMediaDom
void WAbstractMedia::updateMediaDom(DomElement& element, bool all)
{
// Only if not IE
if (all && alternative_) {
element.setAttribute("onerror",
"""if(event.target.error && event.target.error.code=="
"" "event.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED){"
"" "while (this.hasChildNodes())"
"" "if (" WT_CLASS ".hasTag(this.firstChild,'SOURCE')){"
"" "this.removeChild(this.firstChild);"
"" "}else{"
"" "this.parentNode.insertBefore(this.firstChild, this);"
"" "}"
"" "this.style.display= 'none';"
"""}"
);
}
if (all || flagsChanged_) {
if ((!all) || flags_.test(PlayerOption::Controls))
element.setAttribute("controls",
flags_.test(PlayerOption::Controls) ? "controls" : "");
if ((!all) || flags_.test(PlayerOption::Autoplay))
element.setAttribute("autoplay",
flags_.test(PlayerOption::Autoplay) ? "autoplay" : "");
if ((!all) || flags_.test(PlayerOption::Loop))
element.setAttribute("loop",
flags_.test(PlayerOption::Loop) ? "loop" : "");
}
if (all || preloadChanged_) {
switch (preloadMode_) {
case MediaPreloadMode::None:
element.setAttribute("preload", "none");
break;
default:
case MediaPreloadMode::Auto:
element.setAttribute("preload", "auto");
break;
case MediaPreloadMode::Metadata:
element.setAttribute("preload", "metadata");
break;
}
}
updateEventSignals(element, all);
if (all)
if (alternative_) {
element.addChild(alternative_->createSDomElement(wApp));
}
flagsChanged_ = preloadChanged_ = false;
}
示例12: getDomChanges
void WTable::getDomChanges(std::vector<DomElement *>& result,
WApplication *app)
{
DomElement *e = DomElement::getForUpdate(this, domElementType());
if (!isStubbed() && flags_.test(BIT_GRID_CHANGED)) {
DomElement *newE = createDomElement(app);
e->replaceWith(newE);
} else {
if (rowsChanged_) {
for (std::set<WTableRow *>::iterator i = rowsChanged_->begin();
i != rowsChanged_->end(); ++i) {
DomElement *e2 = DomElement::getForUpdate(*i, DomElement_TR);
(*i)->updateDom(*e2, false);
result.push_back(e2);
}
delete rowsChanged_;
rowsChanged_ = 0;
}
if (rowsAdded_) {
DomElement *etb = DomElement::getForUpdate(id() + "tb",
DomElement_TBODY);
for (unsigned i = 0; i < static_cast<unsigned>(rowsAdded_); ++i) {
DomElement *tr = createRowDomElement(rowCount() - rowsAdded_ + i, true, app);
etb->addChild(tr);
}
result.push_back(etb);
rowsAdded_ = 0;
}
if (flags_.test(BIT_COLUMNS_CHANGED)) {
for (unsigned i = 0; i < columns_.size(); ++i) {
DomElement *e2
= DomElement::getForUpdate(columns_[i], DomElement_COL);
columns_[i]->updateDom(*e2, false);
result.push_back(e2);
}
flags_.reset(BIT_COLUMNS_CHANGED);
}
updateDom(*e, false);
}
result.push_back(e);
}
示例13: updateDom
void WGroupBox::updateDom(DomElement& element, bool all)
{
if (all || titleChanged_) {
DomElement *legend;
if (all) {
legend = DomElement::createNew(DomElement_LEGEND);
legend->setId(id() + "l");
} else
legend = DomElement::getForUpdate(id() + "l", DomElement_LEGEND);
legend->setProperty(Wt::PropertyInnerHTML, escapeText(title_).toUTF8());
element.addChild(legend);
titleChanged_ = false;
}
WContainerWidget::updateDom(element, all);
}
示例14: repaintGL
DomElement *WGLWidget::createDomElement(WApplication *app)
{
DomElement *result = nullptr;
if (!pImpl_) { // no GL support whatsoever
result = DomElement::createNew(DomElementType::DIV);
result->addChild(alternative_->createSDomElement(app));
webGlNotAvailable_ = true;
} else {
result = DomElement::createNew(domElementType());
repaintGL(GLClientSideRenderer::PAINT_GL | GLClientSideRenderer::RESIZE_GL);
}
setId(result, app);
updateDom(*result, true);
return result;
}
示例15: 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
}