/usr/include/Wt/WCssStyleSheet is in libwt-dev 3.3.4+dfsg-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | // This may look like C code, but it's really -*- C++ -*-
/*
* Copyright (C) 2008 Emweb bvba, Kessel-Lo, Belgium.
*
* See the LICENSE file for terms of use.
*/
#ifndef WCSS_STYLE_SHEET_H_
#define WCSS_STYLE_SHEET_H_
#include <vector>
#include <set>
#include <string>
#include <Wt/WBreak>
#include <Wt/WCssDecorationStyle>
namespace Wt {
class WApplication;
class WCssStyleSheet;
class WCssTemplateWidget;
/*! \class WCssRule Wt/WCssStyleSheet Wt/WCssStyleSheet
* \brief Abstract rule in a CSS style sheet.
*
* A rule presents CSS style properties that are applied to a selected
* set of elements.
*
* Use WCssTemplateRule if you would like to use a widget as a
* template for specifying (<i>and</i> updating) a style rule, using
* the widgets style properties, or WCssTextRule if you wish to
* directly specify the CSS declarations.
*
* \sa WCssStyleSheet
*
* \ingroup style
*/
class WT_API WCssRule : public WObject
{
public:
/*! \brief Destructor.
*/
virtual ~WCssRule();
/*! \brief Sets the selector.
*
* \note The selector can only be changed as long as the rule hasn't
* been rendered.
*/
void setSelector(const std::string& selector) { selector_ = selector; }
/*! \brief Returns the selector.
*/
virtual std::string selector() const { return selector_; }
/*! \brief Returns the style sheet to which this rule belongs.
*/
WCssStyleSheet *sheet() const { return sheet_; }
/*! \brief Indicates that the rule has changed and needs updating
*/
void modified();
/*! \brief Returns the declarations.
*
* This is a semi-colon separated list of CSS declarations.
*/
virtual std::string declarations() = 0;
virtual bool updateDomElement(DomElement& cssRuleElement, bool all);
protected:
/*! \brief Creates a new CSS rule with given selector.
*/
WCssRule(const std::string& selector, WObject* parent = 0);
private:
std::string selector_;
WCssStyleSheet *sheet_;
friend class WCssStyleSheet;
};
/*! \class WCssTemplateRule Wt/WCssStyleSheet Wt/WCssStyleSheet
* \brief A CSS rule based on a template widget.
*
* This is a CSS rule whose CSS style properties are defined based on
* properties of a template widget. When modifying the template
* widget, these changes are reflected on the CSS rule and thus all
* widgets that have this CSS rule.
*
* \if cpp
* Usage example:
* \code
* Wt::WCssTemplateRule *styleRule = new Wt::WCssTemplateRule("#" + id() + " .item");
* Wt::WApplication::instance()->styleSheet().addRule(styleRule);
*
* styleRule->templateWidget()->resize(100, WLength::Auto);
* styleRule->templateWidget()->decorationStyle().setCursor(PointingHandCursor);
* \endcode
* \endif
*
* \sa Wt::WCssStyleSheet
*
* \ingroup style
*/
class WT_API WCssTemplateRule : public WCssRule
{
public:
/*! \brief Creates a CSS rule with a given selector.
*
* The selector should be a valid CSS selector.
*
* \note If you want to update the rule, then the selector should be
* unique and not contain commas, since this is not supported by
* Microsoft Internet Explorer.
*/
WCssTemplateRule(const std::string& selector, WObject* parent = 0);
~WCssTemplateRule();
/*! \brief Returns the widget that is used as a template.
*
* Various properties of the widget are reflected in the CSS style:
* - size and dimensions: WWidget::resize(), WWidget::setMinimumSize(),
* and WWidget::setMaximumSize()
* - its position: WWidget::setPositionScheme(), WWidget::setOffsets(),
* WWidget::setFloatSide(), WWidget::setClearSides()
* - visibility: WWidget::hide(), WWidget::show() and WWidget::setHidden()
* - margins: WWidget::setMargin()
* - line height: WWidget::setLineHeight()
* - all decoration style properties: WWidget::decorationStyle()
*
* When modifying one of these properties of the returned widget, the
* rule will be updated accordingly.
*/
WWidget *templateWidget();
std::string declarations();
bool updateDomElement(DomElement& cssRuleElement, bool all);
private:
WCssTemplateWidget *widget_;
};
/*! \class WCssTextRule Wt/WCssStyleSheet Wt/WCssStyleSheet
* \brief A CSS rule specified directly using CSS declarations
*
* \if cpp
* Usage example:
* \code
* Wt::WCssTextRule *styleRule = new Wt::WCssTextRule(".MyWidget .item", "width: 100px; cursor: pointer;");
* Wt::WApplication::instance()->styleSheet().addRule(styleRule);
* \endcode
* \endif
*
* \sa WCssStyleSheet
*
* \ingroup style
*/
class WT_API WCssTextRule : public WCssRule
{
public:
/*! \brief Creates a CSS rule with a given selector and declarations.
*/
WCssTextRule(const std::string& selector,
const WT_USTRING& declarations,
WObject* parent = 0);
std::string declarations();
private:
WT_USTRING declarations_;
};
/*! \class WCssStyleSheet Wt/WCssStyleSheet Wt/WCssStyleSheet
* \brief A CSS style sheet.
*
* \if cpp
* Usage example:
* \code
* Wt::WApplication::instance()->styleSheet().addRule(".MyWidget .item", "width: 100px; cursor: pointer;");
* \endcode
* \endif
*
* \sa WApplication::styleSheet()
*
* \ingroup style
*/
class WT_API WCssStyleSheet
{
public:
/*! \brief Creates a new (internal) style sheet.
*/
WCssStyleSheet();
/*! \brief Creates a new (external) style sheet reference.
*/
WCssStyleSheet(const WLink& link, const std::string& media = "all");
/*! \brief Destroys a style sheet, and all rules in it.
*/
~WCssStyleSheet();
const WLink& link() const { return link_; }
const std::string& media() const { return media_; }
/*! \brief Adds a CSS rule.
*
* Add a rule using the CSS selector \p selector, with CSS
* declarations in \p declarations. These declarations must be a
* list separated by semi-colons (;).
*
* Optionally, you may give a \p ruleName, which may later be
* used to check if the rule was already defined.
*
* \sa isDefined()
*/
WCssTextRule *addRule(const std::string& selector,
const WT_USTRING& declarations,
const std::string& ruleName = std::string());
#ifndef WT_TARGET_JAVA
/* Interprets as UTF-8 */
WCssTextRule *addRule(const std::string& selector,
const std::string& declarations,
const std::string& ruleName = std::string());
/* Interprets as UTF-8 */
WCssTextRule *addRule(const std::string& selector,
const char *declarations,
const std::string& ruleName = std::string());
#endif
/*! \brief Adds a CSS rule.
*
* Add a rule using the CSS selector \p selector, with styles specified
* in \p style.
*
* Optionally, you may give a \p ruleName, which may later be
* used to check if the rule was already defined.
*
* \sa isDefined()
*/
WCssTemplateRule *addRule(const std::string& selector,
const WCssDecorationStyle& style,
const std::string& ruleName = std::string());
/*! \brief Adds a CSS rule.
*
* Optionally, you may give a \p ruleName, which may later be
* used to check if the rule was already defined.
* Note: you may not pass the same rule to 2 diffrent applications.
*
* \sa isDefined()
*/
WCssRule *addRule(WCssRule *rule,
const std::string& ruleName = std::string());
/*! \brief Returns if a rule was already defined in this style sheet.
*
* Returns whether a rule was added with the given \p ruleName.
*
* \sa addRule()
*/
bool isDefined(const std::string& ruleName) const;
/*! \brief Removes a rule.
*/
void removeRule(WCssRule *rule);
void ruleModified(WCssRule *rule);
void cssText(WStringStream& out, bool all);
void javaScriptUpdate(WApplication *app, WStringStream& js, bool all);
void clear();
private:
typedef std::vector<WCssRule *> RuleList;
typedef std::set<WCssRule *> RuleSet;
WLink link_;
std::string media_;
RuleList rules_;
RuleList rulesAdded_;
RuleSet rulesModified_;
std::vector<std::string> rulesRemoved_;
std::set<std::string> defined_;
bool isDirty();
friend class WebRenderer;
};
}
#endif // WCSS_STYLE_SHEET_H_
|