How to apply a WCssStyleSheet
Added by Jonathan Lim over 14 years ago
Hi
I can't seem to locate it in the documentation, but I would like to ask how I can reapply a WCssStyleSheet? Because when I call wApp~~styleSheet().clear(), this clears even the internal stylesheet. So what I tried was to backup the internal stylesheet by calling wApp~~>styleSheet() and storing the return into a WCssStyleSheet variable, but then I'm not sure how I can reload that contents of that variable back to the wApp instance since wApp->useStyleSheet() accepts only a string.
Thanks and regards,
Jonathan
Replies (3)
RE: How to apply a WCssStyleSheet - Added by Koen Deforche about 14 years ago
Hey Jonathan,
Currently an application only has a single internal stylesheet and it's clear method is not supposed to be used (it's not documented). The object does not support copying (should inherit from boost::noncopyable), but we could make it support it. But reapplying the stylesheet would still require something special since it needs to remove the old style rules and add the new ones.
I am doubtful of what you are trying to achieve though, why not just work with external stylesheets? The internal stylesheet is useful only if you want to add rules that relate to a specific element. E.g. it is used to style individual columns in WTableView and WTreeView. Everything else is more convenient in an external stylesheet ?
Regards,
koen
RE: How to apply a WCssStyleSheet - Added by Marcel Tella about 14 years ago
I understand, but,
even better, is possible to control the whole style of the page with a WLayout, without using css styles? It will make us independent from CSS, won't it?
RE: How to apply a WCssStyleSheet - Added by Koen Deforche about 14 years ago
Hey,
WLayout is useful mostly where CSS is lacking. It complements the layout possibilities of CSS, especially for managing things vertically.
WCssDecorationStyle (and WWidget) cover often-used CSS properties, but do not offer all possibilities of CSS. All of the things done here can be accomplished also using external stylesheets.
I'm not sure what you mean with being independent from CSS: in any case, CSS is the corner-stone of layout and markup for a web application. You can avoid external CSS, if that is what you are after, by using the builtin methods of WWidget, WCssDecorationStyle (and WLayout), and use setAttributeValue("style", "...") for those things that are missing from the API.
Regards,
koen