本文整理汇总了C++中DomElement类的典型用法代码示例。如果您正苦于以下问题:C++ DomElement类的具体用法?C++ DomElement怎么用?C++ DomElement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomElement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: named_item_ns
void DomElement::set_child_string_ns(const DomString &namespace_uri, const DomString &qualified_name, const DomString &value)
{
DomString local_name;
DomString::size_type pos = qualified_name.find(L':');
if (pos != DomString::npos)
local_name = qualified_name.substr(pos + 1);
else
local_name = qualified_name;
DomElement element = named_item_ns(namespace_uri, local_name).to_element();
if (element.is_null())
{
element = get_owner_document().create_element_ns(namespace_uri, qualified_name);
append_child(element);
}
DomText dom_text = get_owner_document().create_text_node(value);
if (element.get_first_child().is_text())
{
DomNode temp_domnode = element.get_first_child();
replace_child(dom_text, temp_domnode);
}
else
{
element.append_child(dom_text);
}
}
示例2: createComponent
void WWidgetItemImpl::createComponent(DomElement *parentContainer)
{
DomElement *e = item_->widget()->createSDomElement(WApplication::instance());
e->setProperty(PropertyStyle, e->getProperty(PropertyStyle)
+ "position:absolute;left:-10000px;top:-10000px;"
"visibility:hidden;");
Container *c = dynamic_cast<Container *>(item_->widget());
if (!c) {
std::stringstream js;
js << "var " << var_ << "=new Ext.BoxComponent({id:'"
<< id_ << "',applyTo:'" << item_->widget()->id() << "'";
addConfig(js);
Container::setSizeConfig(js, item_->widget());
js << "});{var s="
<< item_->widget()->jsRef() << ";s.style.position='';"
"s.style.left='';"
"s.style.top='';"
"s.style.visibility='';}";
e->callJavaScript(js.str());
}
parentContainer->addChild(e);
}
示例3: updateDom
void WLineEdit::updateDom(DomElement& element, bool all)
{
if (all || flags_.test(BIT_CONTENT_CHANGED)) {
element.setProperty(Wt::PropertyValue, content_.toUTF8());
flags_.reset(BIT_CONTENT_CHANGED);
}
if (all || flags_.test(BIT_ECHO_MODE_CHANGED)) {
element.setAttribute("type", echoMode_ == Normal ? "text" : "password");
flags_.reset(BIT_ECHO_MODE_CHANGED);
}
if (all || flags_.test(BIT_TEXT_SIZE_CHANGED)) {
element.setAttribute("size",
boost::lexical_cast<std::string>(textSize_));
flags_.reset(BIT_TEXT_SIZE_CHANGED);
}
if (all || flags_.test(BIT_MAX_LENGTH_CHANGED)) {
if (!all || maxLength_ > 0)
element.setAttribute("maxLength",
boost::lexical_cast<std::string>(maxLength_));
flags_.reset(BIT_MAX_LENGTH_CHANGED);
}
WFormWidget::updateDom(element, all);
}
示例4: 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);
}
示例5: save_item
void Project::save_item(DomElement dom_parent, ProjectItem *item)
{
DomElement dom_item;
if (dynamic_cast<ProjectFolderItem*>(item))
{
ProjectFolderItem *folder_item = dynamic_cast<ProjectFolderItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("folder");
dom_item.set_child_string("path", folder_item->path);
}
else if (dynamic_cast<ProjectFilterItem*>(item))
{
ProjectFilterItem *filter_item = dynamic_cast<ProjectFilterItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("filter");
dom_item.set_child_string("name", filter_item->name);
}
else if (dynamic_cast<ProjectFileItem*>(item))
{
ProjectFileItem *file_item = dynamic_cast<ProjectFileItem*>(item);
dom_item = dom_parent.get_owner_document().create_element("file");
dom_item.set_child_string("filename", file_item->filename);
}
else
{
throw Exception("Unknown item type");
}
save_item_children(dom_item, item);
dom_parent.append_child(dom_item);
}
示例6: updateDom
void WPaintedWidget::getDomChanges(std::vector<DomElement *>& result,
WApplication *app)
{
DomElement *e = DomElement::getForUpdate(this, DomElement_DIV);
updateDom(*e, false);
result.push_back(e);
bool createdNew = createPainter();
if (needRepaint_) {
WPaintDevice *device = painter_->getPaintDevice
((repaintFlags_ & PaintUpdate) && !createdNew);
if (renderWidth_ != 0 && renderHeight_ != 0) {
paintEvent(device);
#ifdef WT_TARGET_JAVA
if (device->painter())
device->painter()->end();
#endif // WT_TARGET_JAVA
}
if (createdNew) {
DomElement *canvas = DomElement::getForUpdate('p' + id(), DomElement_DIV);
canvas->removeAllChildren();
painter_->createContents(canvas, device);
result.push_back(canvas);
} else {
painter_->updateContents(result, device);
}
needRepaint_ = false;
repaintFlags_ = 0;
}
}
示例7: updateDom
void WText::updateDom(DomElement& element, bool all)
{
if (flags_.test(BIT_TEXT_CHANGED) || all) {
std::string text = formattedText();
if (flags_.test(BIT_TEXT_CHANGED) || !text.empty())
element.setProperty(Wt::PropertyInnerHTML, text);
flags_.reset(BIT_TEXT_CHANGED);
}
if (flags_.test(BIT_WORD_WRAP_CHANGED) || all) {
if (!all || !flags_.test(BIT_WORD_WRAP))
element.setProperty(Wt::PropertyStyleWhiteSpace,
flags_.test(BIT_WORD_WRAP) ? "normal" : "nowrap");
flags_.reset(BIT_WORD_WRAP_CHANGED);
}
if (flags_.test(BIT_PADDINGS_CHANGED)
|| (all && padding_ &&
!(padding_[0].isAuto() && padding_[1].isAuto()))) {
element.setProperty(PropertyStylePaddingRight, padding_[0].cssText());
element.setProperty(PropertyStylePaddingLeft, padding_[1].cssText());
flags_.reset(BIT_PADDINGS_CHANGED);
}
WInteractWidget::updateDom(element, all);
}
示例8: 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;
}
示例9: 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);
}
示例10: updateDom
void WSlider::updateDom(DomElement& element, bool all)
{
if (paintedSlider_)
paintedSlider_->doUpdateDom(element, all);
else {
if (all || changed_) {
element.setAttribute("type", "range");
element.setProperty(Wt::PropertyValue,
boost::lexical_cast<std::string>(value_));
element.setAttribute("min",
boost::lexical_cast<std::string>(minimum_));
element.setAttribute("max",
boost::lexical_cast<std::string>(maximum_));
if (!changedConnected_
&& (valueChanged_.isConnected() || sliderMoved_.isConnected())) {
changedConnected_ = true;
changed().connect(this, &WSlider::onChange);
}
changed_ = false;
}
}
WFormWidget::updateDom(element, all);
}
示例11:
int LuaDomText2::removeThis(lua_State *L)
{
DomText* obj = DomTextValue::check2( L, 1 );
DomElement* p = obj->getParent();
if( p == 0 || !p->remove( obj ) )
luaL_error( L, "Error removing this node" );
return 0;
}
示例12: webWidget
std::string WWidget::inlineCssStyle()
{
WWebWidget *ww = webWidget();
DomElement *e = DomElement::getForUpdate(ww, ww->domElementType());
ww->updateDom(*e, true);
std::string result = e->cssStyle();
delete e;
return result;
}
示例13: load_item_children
void Project::load_item_children(ProjectItem *item, DomElement dom_items)
{
DomElement cur = dom_items.get_first_child_element();
while (!cur.is_null())
{
item->add(load_item(cur));
cur = cur.get_next_sibling_element();
}
}
示例14: getImpl
DomElement *StdGridLayoutImpl2::createElement(WLayoutItem *item,
WApplication *app)
{
DomElement *c = getImpl(item)->createDomElement(true, true, app);
c->setProperty(PropertyStyleVisibility, "hidden");
return c;
}
示例15: updateDom
void WFormWidget::updateDom(DomElement& element, bool all)
{
const WEnvironment& env = WApplication::instance()->environment();
bool onChangeHandledElsewhere = dynamic_cast<WAbstractToggleButton *>(this);
if (!onChangeHandledElsewhere) {
EventSignal<> *s = voidEventSignal(CHANGE_SIGNAL, false);
if (s)
updateSignalConnection(element, *s, "change", all);
}
if (flags_.test(BIT_ENABLED_CHANGED) || all) {
if (!all || !isEnabled())
element.setProperty(Wt::PropertyDisabled,
isEnabled() ? "false" : "true");
if (!all && isEnabled() && env.agentIsIE()) {
/*
* FIXME: implement a workaround for IE, reenabling a checkbox makes
* the input box loose interactivity.
*/
}
flags_.reset(BIT_ENABLED_CHANGED);
}
if (flags_.test(BIT_READONLY_CHANGED) || all) {
if (!all || isReadOnly())
element.setProperty(Wt::PropertyReadOnly,
isReadOnly() ? "true" : "false");
flags_.reset(BIT_READONLY_CHANGED);
}
if (flags_.test(BIT_TABINDEX_CHANGED) || all) {
if (!all || tabIndex_)
element.setProperty(PropertyTabIndex,
boost::lexical_cast<std::string>(tabIndex_));
flags_.reset(BIT_TABINDEX_CHANGED);
}
if (isEnabled()) {
if (all && flags_.test(BIT_GOT_FOCUS))
flags_.set(BIT_INITIAL_FOCUS);
if (flags_.test(BIT_GOT_FOCUS)
|| (all && flags_.test(BIT_INITIAL_FOCUS))) {
element.callJavaScript("setTimeout(function() {"
"""var f = " + jsRef() + ";"
"""if (f) try { f.focus(); } catch (e) { } }, "
+ (env.agentIsIElt(9) ? "500" : "10") + ");");
flags_.reset(BIT_GOT_FOCUS);
}
}
WInteractWidget::updateDom(element, all);
}