本文整理汇总了C++中DomElement::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ DomElement::setAttribute方法的具体用法?C++ DomElement::setAttribute怎么用?C++ DomElement::setAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomElement
的用法示例。
在下文中一共展示了DomElement::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: createContents
void WWidgetCanvasPainter::createContents(DomElement *result,
WPaintDevice *device)
{
std::string wstr = boost::lexical_cast<std::string>(widget_->renderWidth_);
std::string hstr = boost::lexical_cast<std::string>(widget_->renderHeight_);
result->setProperty(PropertyStylePosition, "relative");
result->setProperty(PropertyStyleOverflowX, "hidden");
DomElement *canvas = DomElement::createNew(DomElement_CANVAS);
canvas->setId('c' + widget_->id());
canvas->setProperty(PropertyStyleDisplay, "block");
canvas->setAttribute("width", wstr);
canvas->setAttribute("height", hstr);
result->addChild(canvas);
WCanvasPaintDevice *canvasDevice = dynamic_cast<WCanvasPaintDevice *>(device);
DomElement *text = 0;
if (canvasDevice->textMethod() == WCanvasPaintDevice::DomText) {
text = DomElement::createNew(DomElement_DIV);
text->setId('t' + widget_->id());
text->setProperty(PropertyStylePosition, "absolute");
text->setProperty(PropertyStyleZIndex, "1");
text->setProperty(PropertyStyleTop, "0px");
text->setProperty(PropertyStyleLeft, "0px");
}
canvasDevice->render("c" + widget_->id(), text ? text : result);
if (text)
result->addChild(text);
delete device;
}
示例4: updateContents
void WWidgetCanvasPainter::updateContents(std::vector<DomElement *>& result,
WPaintDevice *device)
{
WCanvasPaintDevice *canvasDevice = dynamic_cast<WCanvasPaintDevice *>(device);
if (widget_->sizeChanged_) {
DomElement *canvas = DomElement::getForUpdate('c' + widget_->id(),
DomElement_CANVAS);
canvas->setAttribute("width",
boost::lexical_cast<std::string>(widget_->renderWidth_));
canvas->setAttribute("height",
boost::lexical_cast<std::string>(widget_->renderHeight_));
result.push_back(canvas);
widget_->sizeChanged_ = false;
}
bool domText = canvasDevice->textMethod() == WCanvasPaintDevice::DomText;
DomElement *el
= DomElement::getForUpdate(domText ? 't' + widget_->id() : widget_->id(),
DomElement_DIV);
if (domText)
el->removeAllChildren();
canvasDevice->render('c' + widget_->id(), el);
result.push_back(el);
delete device;
}
示例5: createContents
void WWidgetCanvasPainter::createContents(DomElement *result,
WPaintDevice *device)
{
std::string wstr = boost::lexical_cast<std::string>(widget_->renderWidth_);
std::string hstr = boost::lexical_cast<std::string>(widget_->renderHeight_);
result->setProperty(PropertyStylePosition, "relative");
result->setProperty(PropertyStyleOverflowX, "hidden");
result->setProperty(PropertyStyleOverflowY, "hidden");
DomElement *canvas = DomElement::createNew(DomElement_CANVAS);
canvas->setId('c' + widget_->id());
canvas->setProperty(PropertyStyleDisplay, "block");
canvas->setAttribute("width", wstr);
canvas->setAttribute("height", hstr);
result->addChild(canvas);
widget_->sizeChanged_ = false;
WCanvasPaintDevice *canvasDevice = dynamic_cast<WCanvasPaintDevice *>(device);
DomElement *text = 0;
if (canvasDevice->textMethod() == WCanvasPaintDevice::DomText) {
text = DomElement::createNew(DomElement_DIV);
text->setId('t' + widget_->id());
text->setProperty(PropertyStylePosition, "absolute");
text->setProperty(PropertyStyleZIndex, "1");
text->setProperty(PropertyStyleTop, "0px");
text->setProperty(PropertyStyleLeft, "0px");
}
DomElement *el = text ? text : result;
bool hasJsObjects = widget_->jsObjects_.size() > 0;
if (hasJsObjects) {
WStringStream ss;
WApplication *app = WApplication::instance();
ss << "new " WT_CLASS ".WPaintedWidget("
<< app->javaScriptClass() << "," << widget_->jsRef() << ");";
widget_->jsObjects_.updateJs(ss);
el->callJavaScript(ss.str());
}
canvasDevice->render('c' + widget_->id(), el);
if (hasJsObjects) {
WStringStream ss;
ss << widget_->objJsRef() << ".repaint=function(){";
ss << canvasDevice->recordedJs_.str();
ss << "};";
el->callJavaScript(ss.str());
}
if (text)
result->addChild(text);
delete device;
}
示例6: updateDom
bool WCircleArea::updateDom(DomElement& element, bool all)
{
element.setAttribute("shape", "circle");
std::stringstream coords;
coords << static_cast<int>(x_) << ','
<< static_cast<int>(y_) << ','
<< static_cast<int>(r_);
element.setAttribute("coords", coords.str());
return WAbstractArea::updateDom(element, all);
}
示例7: updateDom
bool WRectArea::updateDom(DomElement& element, bool all)
{
element.setAttribute("shape", "rect");
std::stringstream coords;
if (x_ == 0 && y_ == 0 && width_ == 0 && height_ == 0)
coords << "0%,0%,100%,100%";
else
coords << x_ << ',' << y_ << ',' << (x_ + width_) << ',' << (y_ + height_);
element.setAttribute("coords", coords.str());
return WAbstractArea::updateDom(element, all);
}
示例8: updateDom
bool WPolygonArea::updateDom(DomElement& element, bool all)
{
element.setAttribute("shape", "poly");
std::stringstream coords;
for (unsigned i = 0; i < points_.size(); ++i) {
if (i != 0)
coords << ',';
coords << static_cast<int>(points_[i].x()) << ','
<< static_cast<int>(points_[i].y());
}
element.setAttribute("coords", coords.str());
return WAbstractArea::updateDom(element, all);
}
示例9: updateDom
void WSpinBox::updateDom(DomElement& element, bool all)
{
if (all || changed_) {
if (nativeControl()) {
element.setAttribute("min", boost::lexical_cast<std::string>(min_));
element.setAttribute("max", boost::lexical_cast<std::string>(max_));
element.setAttribute("step", boost::lexical_cast<std::string>(step_));
} else {
/* Make sure the JavaScript validator is loaded */
WIntValidator v;
v.javaScriptValidate();
}
}
WAbstractSpinBox::updateDom(element, all);
}
示例10: updateDom
virtual void updateDom(DomElement& element, bool all)
{
if (all)
element.setAttribute("name", id());
WContainerWidget::updateDom(element, all);
}
示例11: 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);
}
示例12: 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();
}
示例13: updateContents
void WWidgetCanvasPainter::updateContents(std::vector<DomElement *>& result,
WPaintDevice *device)
{
WCanvasPaintDevice *canvasDevice = dynamic_cast<WCanvasPaintDevice *>(device);
if (widget_->sizeChanged_) {
DomElement *canvas = DomElement::getForUpdate('c' + widget_->id(),
DomElement_CANVAS);
canvas->setAttribute("width",
boost::lexical_cast<std::string>(widget_->renderWidth_));
canvas->setAttribute("height",
boost::lexical_cast<std::string>(widget_->renderHeight_));
result.push_back(canvas);
widget_->sizeChanged_ = false;
}
bool domText = canvasDevice->textMethod() == WCanvasPaintDevice::DomText;
DomElement *el
= DomElement::getForUpdate(domText ? 't' + widget_->id() : widget_->id(),
DomElement_DIV);
if (domText)
el->removeAllChildren();
bool hasJsObjects = widget_->jsObjects_.size() > 0;
if (hasJsObjects) {
WStringStream ss;
widget_->jsObjects_.updateJs(ss);
el->callJavaScript(ss.str());
}
canvasDevice->render('c' + widget_->id(), el);
if (hasJsObjects) {
WStringStream ss;
ss << widget_->objJsRef() << ".repaint=function(){";
ss << canvasDevice->recordedJs_.str();
ss << "};";
el->callJavaScript(ss.str());
}
result.push_back(el);
delete device;
}
示例14: updateMediaDom
void WVideo::updateMediaDom(DomElement& element, bool all)
{
WAbstractMedia::updateMediaDom(element, all);
// Video has a few extra attributes...
if (all || sizeChanged_) {
if ((!all) || !width().isAuto())
element.setAttribute("width",
width().isAuto() ? "" : std::to_string((int)width().toPixels()));
if ((!all) || !height().isAuto())
element.setAttribute("height",
height().isAuto() ? "" : std::to_string((int)height().toPixels()));
}
if (all || posterChanged_) {
if ((!all) || posterUrl_ != "") {
element.setAttribute("poster", resolveRelativeUrl(posterUrl_));
}
}
sizeChanged_ = posterChanged_ = false;
}
示例15: updateDom
void WTextArea::updateDom(DomElement& element, bool all)
{
if (element.type() == DomElement_TEXTAREA)
if (contentChanged_ || all) {
element.setProperty(Wt::PropertyValue, content_.toUTF8());
contentChanged_ = false;
}
if (attributesChanged_ || all) {
element.setAttribute("cols",
boost::lexical_cast<std::string>(cols_));
element.setAttribute("rows",
boost::lexical_cast<std::string>(rows_));
attributesChanged_ = false;
}
WFormWidget::updateDom(element, all);
}