Wt  4.11.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Wt::WCssTemplateRule Class Reference

A CSS rule based on a template widget. More...

#include <Wt/WCssStyleSheet.h>

Inheritance diagram for Wt::WCssTemplateRule:
[legend]

Public Member Functions

 WCssTemplateRule (const std::string &selector)
 Creates a CSS rule with a given selector.
 
WWidgettemplateWidget ()
 Returns the widget that is used as a template.
 
virtual std::string declarations () override
 Returns the declarations.
 
- Public Member Functions inherited from Wt::WCssRule
virtual ~WCssRule ()
 Destructor.
 
void setSelector (const std::string &selector)
 Sets the selector.
 
virtual std::string selector () const
 Returns the selector.
 
WCssStyleSheetsheet () const
 Returns the style sheet to which this rule belongs.
 
void modified ()
 Indicates that the rule has changed and needs updating.
 
- Public Member Functions inherited from Wt::WObject
void addChild (std::unique_ptr< WObject > child)
 Add a child WObject whose lifetime is determined by this WObject.
 
template<typename Child >
ChildaddChild (std::unique_ptr< Child > child)
 Add a child WObject, returning a raw pointer.
 
std::unique_ptr< WObjectremoveChild (WObject *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
template<typename Child >
std::unique_ptr< ChildremoveChild (Child *child)
 Remove a child WObject, so its lifetime is no longer determined by this WObject.
 
virtual const std::string id () const
 Returns the (unique) identifier for this object.
 
virtual void setObjectName (const std::string &name)
 Sets an object name.
 
virtual std::string objectName () const
 Returns the object name.
 
void resetLearnedSlots ()
 Resets learned stateless slot implementations.
 
template<class T >
void resetLearnedSlot (void(T::*method)())
 Resets a learned stateless slot implementation.
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)())
 Declares a slot to be stateless and learn client-side behaviour on first invocation.
 
template<class T >
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 Declares a slot to be stateless and learn client-side behaviour in advance.
 
void isNotStateless ()
 Marks the current function as not stateless.
 
template<class T >
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 Provides a JavaScript implementation for a method.
 
- Public Member Functions inherited from Wt::Core::observable
 observable () noexcept
 Default constructor.
 
virtual ~observable ()
 Destructor.
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...)) noexcept
 Protects a method call against object destruction.
 
template<typename... Args, typename C >
auto bindSafe (void(C::*method)(Args...) const) const noexcept
 Protects a const method call against object destruction.
 
template<typename Function >
auto bindSafe (const Function &function) noexcept
 Protects a function against object destruction.
 

Additional Inherited Members

- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 Typedef for a WObject method without arguments.
 
- Protected Member Functions inherited from Wt::WCssRule
 WCssRule (const std::string &selector)
 Creates a new CSS rule with given selector.
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 On-demand stateless slot implementation.
 

Detailed Description

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.

Usage example:

Wt::WApplication::instance()->styleSheet().addRule(
std::make_unique<Wt::WCssTemplateRule>("#" + id() + " .item"));
styleRule->templateWidget()->resize(100, WLength::Auto);
static WApplication * instance()
Returns the current application instance.
Definition WApplication.C:1375
A CSS rule based on a template widget.
Definition WCssStyleSheet.h:109
WWidget * templateWidget()
Returns the widget that is used as a template.
Definition WCssStyleSheet.C:142
static WLength Auto
An 'auto' length.
Definition WLength.h:65
virtual WCssDecorationStyle & decorationStyle()=0
Returns the decoration style of this widget.
virtual void resize(const WLength &width, const WLength &height)
Resizes the widget.
Definition WWidget.C:70
@ PointingHand
Pointing hand, CSS 'pointer' cursor.
See also
Wt::WCssStyleSheet

Constructor & Destructor Documentation

◆ WCssTemplateRule()

Wt::WCssTemplateRule::WCssTemplateRule ( const std::string &  selector)

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.

Member Function Documentation

◆ declarations()

std::string Wt::WCssTemplateRule::declarations ( )
overridevirtual

Returns the declarations.

This is a semi-colon separated list of CSS declarations.

Implements Wt::WCssRule.

◆ templateWidget()

WWidget * Wt::WCssTemplateRule::templateWidget ( )

Returns the widget that is used as a template.

Various properties of the widget are reflected in the CSS style:

When modifying one of these properties of the returned widget, the rule will be updated accordingly.