All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Stylish::AttributeBackground Class Reference

Attribute used to define CSSBoxModel background, that includes set of background images, color and clipping mode. More...

#include <Stylish/AttributeBackground.hpp>

Inheritance diagram for Stylish::AttributeBackground:
Valuable::Attribute Valuable::Serializable

Valuable Attributes

QStringList background-clip = QStringList()
 Determine the background painting areas Default value is 'border-box', other choices are 'padding-box' and 'content-box'. More...
 
Radiant::Color background-color = Radiant::Color(1.F, 1.F, 1.F, 1.F)
  More...
 
QStringList background-image = QStringList()
  More...
 
QStringList background-origin = QStringList()
 Determine the background positioning areas Default value is 'padding-box', other choices are 'border-box' and 'content-box'. More...
 
Valuable::StyleValue background-position = Valuable::StyleValue()
 Specifies background images initial position (after any resizing) within their corresponding background positioning area. More...
 
Valuable::StyleValue background-repeat = QByteArray("repeat")
 Specifies how background images are tiled after they have been sized and positioned. More...
 
Valuable::StyleValue background-size = QByteArray("auto")
 Specifies the size of the background images. More...
 

Public Member Functions

STYLISH_API AttributeBackground (Valuable::Node *host, const QByteArray &name)
 
STYLISH_API BackgroundImage::Box backgroundColorClip () const
 
STYLISH_API const std::vector
< BackgroundImage > & 
bgImages () const
 
STYLISH_API QStringList clip () const
 Determine the background painting areas Default value is 'border-box', other choices are 'padding-box' and 'content-box'. More...
 
STYLISH_API Radiant::Color color () const
 
virtual STYLISH_API bool deserialize (const Valuable::ArchiveElement &element)
 Deserializes (reads) this object from serializer element. More...
 
virtual STYLISH_API bool handleShorthand (const Valuable::StyleValue &value, Radiant::ArrayMap< Valuable::Attribute *, Valuable::StyleValue > &expanded)
 If attribute supports shorthand properties, this should be used to parse those. More...
 
STYLISH_API QStringList images () const
 
STYLISH_API QStringList origin () const
 Determine the background positioning areas Default value is 'padding-box', other choices are 'border-box' and 'content-box'. More...
 
STYLISH_API Valuable::StyleValue position () const
 Specifies background images initial position (after any resizing) within their corresponding background positioning area. More...
 
STYLISH_API Valuable::StyleValue repeat () const
 Specifies how background images are tiled after they have been sized and positioned. More...
 
STYLISH_API void setClip (const QStringList &clip)
 Setter for attribute background-clip. More...
 
STYLISH_API void setColor (Radiant::Color color)
 Setter for attribute background-color. More...
 
STYLISH_API void setImages (const QStringList &images)
 Setter for attribute background-image. More...
 
STYLISH_API void setOrigin (const QStringList &origin)
 Setter for attribute background-origin. More...
 
STYLISH_API void setPosition (const Valuable::StyleValue &position)
 Setter for attribute background-position. More...
 
STYLISH_API void setRepeat (const Valuable::StyleValue &repeat)
 Setter for attribute background-repeat. More...
 
STYLISH_API void setSize (const Valuable::StyleValue &size)
 Setter for attribute background-size. More...
 
STYLISH_API Valuable::StyleValue size () const
 Specifies the size of the background images. More...
 
- Public Member Functions inherited from Valuable::Attribute
long addListener (ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (Node *listener, ListenerFunc func, int role=CHANGE_ROLE)
 Adds a listener that is invoked whenever the value is changed. More...
 
long addListener (v8::Persistent< v8::Function > func, int role=CHANGE_ROLE)
 Adds a JavaScript listener that is invoked whenever the value is changed. More...
 
virtual float asFloat (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in a floating point number. More...
 
virtual int asInt (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object in an integer. More...
 
virtual QString asString (bool *const ok=0, Layer layer=LAYER_CURRENT) const
 Converts the value object to a string. More...
 
 Attribute (const Attribute &o)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
 Attribute (Node *host, const QByteArray &name, bool transit=false)
 Constructs a new value object and attaches it to its host. More...
 
virtual Attributeattribute (const QByteArray &name) const
 Gets an Attribute with the given name. More...
 
virtual void clearValue (Layer layer)
 Unsets the value from a specific layer. More...
 
virtual void emitChange ()
 Invokes the change valueChanged function of all listeners.
 
virtual void eventProcess (const QByteArray &id, Radiant::BinaryData &data)
 Process a message. More...
 
void eventProcessFloat (const char *id, float v)
 Utility function for sending a float message to the object.
 
void eventProcessInt (const char *id, int v)
 Utility function for sending an int message to the object.
 
void eventProcessString (const char *id, const QString &str)
 Utility function for sending string message to the object.
 
void eventProcessString (const char *id, const char *str)
 Utility function for sending string message to the object.
 
void eventProcessVector2 (const char *id, Nimble::Vector2)
 Utility function for sending a Nimble::Vector2f message to the object.
 
void eventProcessVector3 (const char *id, Nimble::Vector3)
 Utility function for sending a Vector3 message to the object.
 
void eventProcessVector4 (const char *id, Nimble::Vector4)
 Utility function for sending a Vector4 message to the object.
 
Nodehost () const
 The host object of the value object (is any). More...
 
virtual bool isChanged () const
 
virtual bool isValueDefinedOnLayer (Layer layer) const
 Check if the given layer defines a value. More...
 
bool layerForSerialization (SerializationOptions flags, Layer &layer) const
 
const QByteArray & name () const
 Returns the name of the object.
 
const Attributeoperator= (const Attribute &)
 Create a copy of the given Attribute WITHOUT the link to host, listeners, or the attribute name. More...
 
AttributeownerShorthand () const
 
QByteArray path () const
 Returns the path (separated by '/'s) from the root.
 
void removeHost ()
 Sets the host pointer to zero and removes this object from the host. More...
 
bool removeListener (Node *listener, int role=ALL_ROLES)
 Removes a listener from the listener list. More...
 
bool removeListener (long id)
 Removes a listener from the listener list. More...
 
void removeListeners (int role=ALL_ROLES)
 Removes listeners from the listener list.
 
virtual ArchiveElement serialize (Archive &archive) const
 The object is serialized using its name as a tag name. More...
 
virtual bool set (float v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (int v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const QString &v, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector2f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector3f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const Nimble::Vector4f &v, Layer layer=USER, QList< ValueUnit > units=QList< ValueUnit >())
 Sets the value of the object.
 
virtual bool set (const StyleValue &value, Layer layer=USER)
 Sets the value of the object.
 
virtual void setAsDefaults ()
 Sets the current USER attribute value as the default value and clears the USER value. More...
 
void setName (const QByteArray &s)
 Sets the name of the object.
 
void setOwnerShorthand (Attribute *owner)
 
virtual QByteArray type () const
 Get the type id of the attribute. More...
 
- Public Member Functions inherited from Valuable::Serializable
virtual bool deserializeXML (const DOMElement &element)
 Deserializes (reads) this object from an XML element. More...
 
bool isSerializable () const
 
void setSerializable (bool v)
 

Additional Inherited Members

- Public Types inherited from Valuable::Attribute
enum  Layer {
  DEFAULT = 0, STYLE, USER, STYLE_IMPORTANT,
  LAYER_COUNT, LAYER_CURRENT
}
 Attribute has multiple independent attribute values on LAYER_COUNT different layers. More...
 
typedef std::function< void()> ListenerFunc
 Callback function type in the listener API.
 
enum  ListenerRole { DELETE_ROLE = 1 << 0, CHANGE_ROLE = 1 << 1, ALL_ROLES = (CHANGE_ROLE << 1) -1 }
 Different listener roles, used when adding a new listener.
 
enum  ValueUnit {
  VU_UNKNOWN, VU_PXS, VU_PERCENTAGE, VU_EMS,
  VU_EXS
}
 Units of a value. More...
 
- Protected Member Functions inherited from Valuable::Attribute
virtual void emitDelete ()
 Invokes the change valueDeleted function of all listeners.
 

Detailed Description

Attribute used to define CSSBoxModel background, that includes set of background images, color and clipping mode.

Implements CSS Backgrounds Module Level 3 specification: http://www.w3.org/TR/css3-background

Constructor & Destructor Documentation

STYLISH_API Stylish::AttributeBackground::AttributeBackground ( Valuable::Node host,
const QByteArray &  name 
)
Parameters
hosthost object
nameattribute name

Member Function Documentation

STYLISH_API BackgroundImage::Box Stylish::AttributeBackground::backgroundColorClip ( ) const
Returns
the clip area used in the background color
STYLISH_API const std::vector<BackgroundImage>& Stylish::AttributeBackground::bgImages ( ) const
Returns
generated images
QStringList Stylish::AttributeBackground::clip ( ) const

Determine the background painting areas Default value is 'border-box', other choices are 'padding-box' and 'content-box'.

Returns
list of clip areas, one item per image
See Also
backgroundColorClip()
http://www.w3.org/TR/css3-background/#the-background-clip
Returns
Current value of the background-clip attribute
Radiant::Color Stylish::AttributeBackground::color ( ) const
Returns
background color for this box
See Also
http://www.w3.org/TR/css3-background/#the-background-color
Returns
Current value of the background-color attribute
virtual STYLISH_API bool Stylish::AttributeBackground::deserialize ( const Valuable::ArchiveElement element)
virtual

Deserializes (reads) this object from serializer element.

Parameters
elementSerialized element that holds the data that should be deserialized.
Returns
Returns true if the read process worked correctly, and false otherwise.

Implements Valuable::Serializable.

virtual STYLISH_API bool Stylish::AttributeBackground::handleShorthand ( const Valuable::StyleValue value,
Radiant::ArrayMap< Valuable::Attribute *, Valuable::StyleValue > &  expanded 
)
virtual

If attribute supports shorthand properties, this should be used to parse those.

For example "background: url('image.png') repeat" is a shorhand for setting background-image to "url('image.png')" and background-repeat to "repeat".

Parameters
[in]valueshorthand value
[out]expandedshorthand property split to parts. With the previous background-example map should have two values.
Returns
true if shorthand was successfully handled
See Also
http://www.w3.org/TR/CSS21/about.html#shorthand

Reimplemented from Valuable::Attribute.

QStringList Stylish::AttributeBackground::images ( ) const
Returns
list of background image names
See Also
http://www.w3.org/TR/css3-background/#background-image
Returns
Current value of the background-image attribute
QStringList Stylish::AttributeBackground::origin ( ) const

Determine the background positioning areas Default value is 'padding-box', other choices are 'border-box' and 'content-box'.

Returns
list of origin areas, one item per image
See Also
http://www.w3.org/TR/css3-background/#background-origin
Returns
Current value of the background-origin attribute
Valuable::StyleValue Stylish::AttributeBackground::position ( ) const

Specifies background images initial position (after any resizing) within their corresponding background positioning area.

Returns
comma-separated list of image positions, one item per image
See Also
http://www.w3.org/TR/css3-background/#the-background-position
Returns
Current value of the background-position attribute
Valuable::StyleValue Stylish::AttributeBackground::repeat ( ) const

Specifies how background images are tiled after they have been sized and positioned.

Returns
comma-separated list of repeat-modes, one item per image
See Also
http://www.w3.org/TR/css3-background/#background-repeat
Returns
Current value of the background-repeat attribute
void Stylish::AttributeBackground::setClip ( const QStringList &  clip)

Setter for attribute background-clip.

Parameters
clipnew background painting areas, one item per image
See Also
clip
Parameters
clipnew attribute value
void Stylish::AttributeBackground::setColor ( Radiant::Color  color)

Setter for attribute background-color.

See Also
color
Parameters
colornew background color
colornew attribute value
void Stylish::AttributeBackground::setImages ( const QStringList &  images)

Setter for attribute background-image.

See Also
images
Parameters
imageslist of background image names
imagesnew attribute value
void Stylish::AttributeBackground::setOrigin ( const QStringList &  origin)

Setter for attribute background-origin.

Parameters
originnew background positioning areas, one item per image
See Also
origin
Parameters
originnew attribute value
void Stylish::AttributeBackground::setPosition ( const Valuable::StyleValue position)

Setter for attribute background-position.

See Also
position
Parameters
positioncomma-separated list of background image positions, one per image
positionnew attribute value
void Stylish::AttributeBackground::setRepeat ( const Valuable::StyleValue repeat)

Setter for attribute background-repeat.

See Also
repeat
Parameters
repeatcomma-separated list of repeat-modes, one per image
repeatnew attribute value
void Stylish::AttributeBackground::setSize ( const Valuable::StyleValue size)

Setter for attribute background-size.

See Also
size
Parameters
sizecomma-separated list of background sizes, one per image
sizenew attribute value
Valuable::StyleValue Stylish::AttributeBackground::size ( ) const

Specifies the size of the background images.

Returns
list of background size definitions, one item per image
See Also
http://www.w3.org/TR/css3-background/#background-size
Returns
Current value of the background-size attribute