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

AttributeBorder represents a stylable border The border frame consists of four borders (top, right, bottom, left) each containing a separate property for color, width and style. More...

#include <Stylish/AttributeBorder.hpp>

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

Public Types

enum  BorderMask {
  TOP = (1 << 0), RIGHT = (1 << 1), BOTTOM = (1 << 2), LEFT = (1 << 3),
  ALL = TOP | RIGHT | BOTTOM | LEFT
}
 Used for when setting properties for one or more borders.
 
- 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...
 

Public Member Functions

STYLISH_API AttributeBorder (Valuable::Node *host, const QByteArray &name, bool transit=false)
 
STYLISH_API std::array
< Stylish::Border, 4 > 
borders () const
 Returns all borders.
 
STYLISH_API const Stylish::Borderbottom () const
 Returns the bottom border.
 
virtual STYLISH_API bool deserialize (const Valuable::ArchiveElement &element)
 Deserializes (reads) this object from serializer element. More...
 
STYLISH_API Nimble::Frame4f frame () const
 Returns width of the four borders.
 
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 bool isUniform () const
 Checks if all borders are identical (same style, color and width) More...
 
STYLISH_API const Stylish::Borderleft () const
 Returns the left border.
 
STYLISH_API const Stylish::Borderright () const
 Returns the right border.
 
STYLISH_API bool set (const QString &value, Layer layer=USER, ValueUnit unit=VU_UNKNOWN)
 Sets the shorthand value for the border. More...
 
STYLISH_API bool set (const Valuable::StyleValue &value, Layer layer=USER)
 Sets the shorthand value for the border. More...
 
STYLISH_API void setColor (Radiant::Color color, Radiant::FlagsT< BorderMask > mask=ALL)
 Sets the color for the border frame or individual borders. More...
 
STYLISH_API void setStyle (Border::Style style, Radiant::FlagsT< BorderMask > mask=ALL)
 Sets the style of one or more borders Default value for all borders is 'none'. More...
 
STYLISH_API void setWidth (const Nimble::Frame4f &width)
 Sets the frame width Default value for all borders is 'medium'. More...
 
STYLISH_API void setWidth (float width, Radiant::FlagsT< BorderMask > mask=ALL)
 Sets the frame width Default value for all borders is 'medium'. More...
 
STYLISH_API const Stylish::Bordertop () const
 Returns the top border.
 
- 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 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 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

- Protected Member Functions inherited from Valuable::Attribute
virtual void emitDelete ()
 Invokes the change valueDeleted function of all listeners.
 

Detailed Description

AttributeBorder represents a stylable border The border frame consists of four borders (top, right, bottom, left) each containing a separate property for color, width and style.

See Also
http://www.w3.org/TR/css3-background/#borders

Constructor & Destructor Documentation

STYLISH_API Stylish::AttributeBorder::AttributeBorder ( Valuable::Node host,
const QByteArray &  name,
bool  transit = false 
)
Parameters
hosthost object
nameattribute name, this will used as a base for other attributes and shorthands, for example with name "border" there will be attributes "border-left", "border-left-width", "border-left-style", "border-left-color" etc
transitShould value changes be transmitted forward

Member Function Documentation

virtual STYLISH_API bool Stylish::AttributeBorder::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::AttributeBorder::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.

STYLISH_API bool Stylish::AttributeBorder::isUniform ( ) const

Checks if all borders are identical (same style, color and width)

Returns
true if all borders are identical, false otherwise
STYLISH_API bool Stylish::AttributeBorder::set ( const QString &  value,
Layer  layer = USER,
ValueUnit  unit = VU_UNKNOWN 
)
virtual

Sets the shorthand value for the border.

Parameters
valueshorthand value
layerattribute layer to use
unitalways VU_UNKNOWN
Returns
true if value was parsed successfully
See Also
http://www.w3.org/TR/css3-background/#the-border-shorthands

Reimplemented from Valuable::Attribute.

STYLISH_API bool Stylish::AttributeBorder::set ( const Valuable::StyleValue value,
Layer  layer = USER 
)
virtual

Sets the shorthand value for the border.

Parameters
valueshorthand value
layerattribute layer to use
Returns
true if value was parsed successfully
See Also
http://www.w3.org/TR/css3-background/#the-border-shorthands

Reimplemented from Valuable::Attribute.

STYLISH_API void Stylish::AttributeBorder::setColor ( Radiant::Color  color,
Radiant::FlagsT< BorderMask mask = ALL 
)

Sets the color for the border frame or individual borders.

Parameters
colornew border color
maskspecify which borders to change
See Also
http://www.w3.org/TR/css3-background/#border-color
STYLISH_API void Stylish::AttributeBorder::setStyle ( Border::Style  style,
Radiant::FlagsT< BorderMask mask = ALL 
)

Sets the style of one or more borders Default value for all borders is 'none'.

Parameters
stylenew style
maskspecify which borders to change
See Also
http://www.w3.org/TR/css3-background/#border-style
STYLISH_API void Stylish::AttributeBorder::setWidth ( const Nimble::Frame4f width)

Sets the frame width Default value for all borders is 'medium'.

Parameters
widthnew frame width
See Also
http://www.w3.org/TR/css3-background/#border-width
STYLISH_API void Stylish::AttributeBorder::setWidth ( float  width,
Radiant::FlagsT< BorderMask mask = ALL 
)

Sets the frame width Default value for all borders is 'medium'.

Parameters
widthnew frame width
maskspecify which borders to change
See Also
http://www.w3.org/TR/css3-background/#border-width