本文整理汇总了C++中DomElement::callMethod方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::callMethod方法的具体用法?C++ DomElement::callMethod怎么用?C++ DomElement::callMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::callMethod方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rootAsJavaScript
void WContainerWidget::rootAsJavaScript(WApplication *app, std::ostream& out,
bool all)
{
std::vector<WWidget *> *toAdd
= all ? children_ : (transientImpl_ ? &transientImpl_->addedChildren_ : 0);
if (toAdd)
for (unsigned i = 0; i < toAdd->size(); ++i) {
DomElement *c = (*toAdd)[i]->createSDomElement(app);
app->streamBeforeLoadJavaScript(out, false);
c->callMethod("omousemove=function(e) {"
"if (!e) e = window.event;"
"return " + app->javaScriptClass()
+ "._p_.dragDrag(event); }");
c->callMethod("mouseup=function(e) {"
"if (!e) e = window.event;"
"return " + app->javaScriptClass()
+ "._p_.dragEnd(event);}");
c->callMethod("dragstart=function(){return false;}");
c->asJavaScript(out);
delete c;
}
if (transientImpl_)
transientImpl_->addedChildren_.clear();
if (!all) {
/* Note: we ignore rendering of deletion of a bound widget... */
}
// FIXME
propagateRenderOk(false);
}
示例2: 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);
}
示例3: updateDom
void WSelectionBox::updateDom(DomElement& element, bool all)
{
if (configChanged_ || all) {
element.setAttribute("size", std::to_string(verticalSize_));
if (!all || (selectionMode_ == SelectionMode::Extended)) {
element.setProperty(Property::Multiple,
selectionMode_ == SelectionMode::Extended
? "true" : "false");
if (!all)
selectionChanged_ = true;
}
configChanged_ = false;
}
if (selectionMode_ == SelectionMode::Extended) {
if (selectionChanged_ && !all) {
for (int i = 0; i < count(); ++i) {
element.callMethod("options[" + std::to_string(i) + "].selected="
+ (isSelected(i) ? "true" : "false"));
}
}
selectionChanged_ = false;
}
WComboBox::updateDom(element, all);
}
示例4: updateContents
void WWidgetVectorPainter::updateContents(std::vector<DomElement *>& result,
WPaintDevice *device)
{
WVectorImage *vectorDevice = dynamic_cast<WVectorImage *>(device);
if (widget_->repaintFlags_ & PaintUpdate) {
DomElement *painter = DomElement::updateGiven
(WT_CLASS ".getElement('p" + widget_->id()+ "').firstChild",
DomElement_DIV);
painter->setProperty(PropertyAddedInnerHTML, vectorDevice->rendered());
WApplication *app = WApplication::instance();
if (app->environment().agentIsOpera())
painter->callMethod("forceRedraw();");
result.push_back(painter);
} else {
DomElement *canvas = DomElement::getForUpdate
('p' + widget_->id(), DomElement_DIV);
/*
* In fact, we should use another property, since we could be using
* document.importNode() instead of myImportNode() since the xml does not
* need to be interpreted as HTML...
*/
canvas->setProperty(PropertyInnerHTML, vectorDevice->rendered());
result.push_back(canvas);
}
widget_->sizeChanged_ = false;
delete device;
}
示例5: 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);
}
示例6: layout
DomElement *FlexLayoutImpl::createDomElement(DomElement *parent,
bool fitWidth, bool fitHeight,
WApplication *app)
{
addedItems_.clear();
removedItems_.clear();
int margin[] = { 0, 0, 0, 0 };
DomElement *result;
if (layout()->parentLayout() == nullptr) {
/*
* If it is a top-level layout (as opposed to a nested layout),
* configure overflow of the container.
*/
if (container() == app->root()) {
/*
* Reset body,html default paddings and so on if we are doing layout
* in the entire document.
*/
app->setBodyClass(app->bodyClass() + " Wt-layout");
app->setHtmlClass(app->htmlClass() + " Wt-layout");
parent->setProperty(Property::StyleBoxSizing, "border-box");
}
#ifndef WT_TARGET_JAVA
layout()->getContentsMargins(margin + 3, margin, margin + 1, margin + 2);
#else // WT_TARGET_JAVA
margin[3] = layout()->getContentsMargin(Side::Left);
margin[0] = layout()->getContentsMargin(Side::Top);
margin[1] = layout()->getContentsMargin(Side::Right);
margin[2] = layout()->getContentsMargin(Side::Bottom);
#endif // WT_TARGET_JAVA
Orientation orientation = getOrientation();
if (orientation == Orientation::Horizontal) {
margin[3] = std::max(0, margin[3] - (grid_.horizontalSpacing_) / 2);
margin[1] = std::max(0, margin[1] - (grid_.horizontalSpacing_ + 1) / 2);
} else {
margin[0] = std::max(0, margin[0] - (grid_.verticalSpacing_) / 2);
margin[2] = std::max(0, margin[2] - (grid_.horizontalSpacing_ + 1) / 2);
}
ResizeSensor::applyIfNeeded(container());
container()->setFlexBox(true);
result = parent;
elId_ = container()->id();
} else {
result = DomElement::createNew(DomElementType::DIV);
elId_ = id();
result->setId(elId_);
}
if (margin[0] != 0 || margin[1] != 0 || margin[2] != 0 || margin[3] != 0) {
WStringStream paddingProperty;
paddingProperty << margin[0] << "px " << margin[1] << "px "
<< margin[2] << "px " << margin[3] << "px";
result->setProperty(Property::StylePadding, paddingProperty.str());
}
// FIXME minsize/maxsize
result->setProperty(Property::StyleDisplay, styleDisplay());
result->setProperty(Property::StyleFlexFlow, styleFlex());
Orientation orientation = getOrientation();
int c = count(orientation);
int totalStretch = getTotalStretch(orientation);
for (int i = 0; i < c; ++i) {
DomElement *el = createElement(orientation, i, totalStretch, app);
result->addChild(el);
}
WStringStream js;
js << "layout=new " WT_CLASS ".FlexLayout("
<< app->javaScriptClass() << ",'" << elId_ << "');";
result->callMethod(js.str());
return result;
}