Wt: Wt::WCssStyleSheet Class Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::WCssStyleSheet Class Reference
Style classes

A CSS style sheet. More...

`#include <Wt/WCssStyleSheet.h>`

## Public Member Functions
| WCssStyleSheet ()
| Creates a new (internal) style sheet.
| ~WCssStyleSheet ()
| Destroys a style sheet, and all rules in it.
WCssTextRule * | addRule (const std::string &selector, const WString &declarations, const std::string &ruleName=std::string())
| Adds a CSS rule.
WCssTemplateRule * | addRule (const std::string &selector, const WCssDecorationStyle &style, const std::string &ruleName=std::string())
| Adds a CSS rule.
WCssRule * | addRule (std::unique_ptr< WCssRule > rule, const std::string &ruleName=std::string())
| Adds a CSS rule.
bool | isDefined (const std::string &ruleName) const
| Returns if a rule was already defined in this style sheet.
std::unique_ptr< WCssRule > | removeRule (WCssRule *rule)
| Removes a rule.

## Detailed Description

A CSS style sheet.

Usage example:

Wt::WApplication::instance()->styleSheet().addRule(".MyWidget .item", "width: 100px; cursor: pointer;");
Wt::WApplication::styleSheet
WCssStyleSheet & styleSheet()
Returns a reference to the inline style sheet.
Definition WApplication.h:318
Wt::WApplication::instance
static WApplication * instance()
Returns the current application instance.
Wt::WCssStyleSheet::addRule
WCssTextRule * addRule(const std::string &selector, const WString &declarations, const std::string &ruleName=std::string())
Adds a CSS rule.

See also
  WApplication::styleSheet()

## Member Function Documentation

## ◆ addRule() [1/3]

WCssTemplateRule * Wt::WCssStyleSheet::addRule | ( | const std::string & | selector,
|  | const WCssDecorationStyle & | style,
|  | const std::string & | ruleName = std::string() )

Adds a CSS rule.

Add a rule using the CSS selector `selector`, with styles specified in `style`.

Optionally, you may give a `ruleName`, which may later be used to check if the rule was already defined.

See also
  isDefined()

## ◆ addRule() [2/3]

WCssTextRule * Wt::WCssStyleSheet::addRule | ( | const std::string & | selector,
|  | const WString & | declarations,
|  | const std::string & | ruleName = std::string() )

Adds a CSS rule.

Add a rule using the CSS selector `selector`, with CSS declarations in `declarations`. These declarations must be a list separated by semi-colons (;).

Optionally, you may give a `ruleName`, which may later be used to check if the rule was already defined.

See also
  isDefined()

## ◆ addRule() [3/3]

WCssRule * Wt::WCssStyleSheet::addRule | ( | std::unique_ptr< WCssRule > | rule,
|  | const std::string & | ruleName = std::string() )

Adds a CSS rule.

Optionally, you may give a `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.

See also
  isDefined()

## ◆ isDefined()

bool Wt::WCssStyleSheet::isDefined | ( | const std::string & | ruleName | ) | const

Returns if a rule was already defined in this style sheet.

Returns whether a rule was added with the given `ruleName`.

See also
  addRule()