void WCssDecorationStyle::updateDomElement(DomElement& element, bool all) { /* * set cursor */ if (cursorChanged_ || all) { switch (cursor_) { case AutoCursor: if (cursorChanged_) element.setProperty(PropertyStyleCursor, "auto"); break; case ArrowCursor: element.setProperty(PropertyStyleCursor, "default"); break; case CrossCursor: element.setProperty(PropertyStyleCursor, "crosshair"); break; case PointingHandCursor: element.setProperty(PropertyStyleCursor, "pointer"); break; case OpenHandCursor: element.setProperty(PropertyStyleCursor, "move"); break; case WaitCursor: element.setProperty(PropertyStyleCursor, "wait"); break; case IBeamCursor: element.setProperty(PropertyStyleCursor, "text"); break; case WhatsThisCursor: element.setProperty(PropertyStyleCursor, "help"); break; } if (!cursorImage_.empty()) { element.setProperty(PropertyStyleCursor, "url(" + cursorImage_ + ")," + element.getProperty(PropertyStyleCursor)); } cursorChanged_ = false; } /* * set font */ font_.updateDomElement(element, fontChanged_, all); fontChanged_ = false; /* * set border */ Property properties[4] = { PropertyStyleBorderTop, PropertyStyleBorderRight, PropertyStyleBorderBottom, PropertyStyleBorderLeft }; if (borderChanged_ || all) { for (unsigned i = 0; i < 4; ++i) { if (border_[i]) element.setProperty(properties[i], border_[i]->cssText()); else if (borderChanged_) element.setProperty(properties[i], ""); } borderChanged_ = false; } /* * set colors */ if (foregroundColorChanged_ || all) { if ((all && !foregroundColor_.isDefault()) || foregroundColorChanged_) element.setProperty(PropertyStyleColor, foregroundColor_.cssText()); foregroundColorChanged_ = false; } if (backgroundColorChanged_ || all) { if ((all && !backgroundColor_.isDefault()) || backgroundColorChanged_) element.setProperty(PropertyStyleBackgroundColor, backgroundColor_.cssText()); backgroundColorChanged_ = false; } if (backgroundImageChanged_ || all) { if (!backgroundImage_.isNull() || backgroundImageChanged_) { if (backgroundImage_.isNull()) element.setProperty(PropertyStyleBackgroundImage, "none"); else { Wt::WApplication *app = Wt::WApplication::instance(); std::string url = app->encodeUntrustedUrl (app->resolveRelativeUrl(backgroundImage_.url())); element.setProperty(PropertyStyleBackgroundImage, "url(" + WWebWidget::jsStringLiteral(url, '"') + ")"); } if (backgroundImageRepeat_ != RepeatXY || backgroundImageLocation_ != 0) { switch (backgroundImageRepeat_) { case RepeatXY: element.setProperty(PropertyStyleBackgroundRepeat, "repeat"); break; case RepeatX: element.setProperty(PropertyStyleBackgroundRepeat, "repeat-x"); break; case RepeatY: element.setProperty(PropertyStyleBackgroundRepeat, "repeat-y"); break; case NoRepeat: element.setProperty(PropertyStyleBackgroundRepeat, "no-repeat"); break; } if (backgroundImageLocation_) { // www3schools claims this is needed for mozilla -- but not true ? //element.setProperty(PropertyStyleBackgroundAttachment, "fixed"); std::string location; if (backgroundImageLocation_ & CenterY) location += " center"; else if (backgroundImageLocation_ & Bottom) location += " bottom"; else location += " top"; if (backgroundImageLocation_ & CenterX) location += " center"; else if (backgroundImageLocation_ & Right) location += " right"; else location += " left"; element.setProperty(PropertyStyleBackgroundPosition, location); } } } backgroundImageChanged_ = false; } if (textDecorationChanged_ || all) { std::string options; if (textDecoration_ & Underline) options += " underline"; if (textDecoration_ & Overline) options += " overline"; if (textDecoration_ & LineThrough) options += " line-through"; if (textDecoration_ & Blink) options += " blink"; if (!options.empty() || textDecorationChanged_) element.setProperty(PropertyStyleTextDecoration, options); textDecorationChanged_ = false; } }