StyleSheet

Since: BlackBerry 10.2.0

#include <bb/platform/geo/StyleSheet>

To link against this class, add the following line to your .pro file: LIBS += -lbbcascadesmaps

A collection of Styles to be used when rendering a set of map content.

DataProvider and MapData use StyleSheet instances to gather and store stylistic information about the Geographic data they contain. This visual information is used by the RenderEngine when drawing the Geographic data. The Styles within a StyleSheet can be applied directly to individual elements, or applied to several elements through a Geographic's style family, or applied to several elements through their class type.

Styles can be registered for a StyleSheet in a number of ways:
  1. Applied directly to a specific Geographic element by association with the Geographic's ID (Geographic::id()).

  2. Applied to several Geographic elements by association with a style family (Geographic::styleFamily()).

  3. Applied to several Geographic elements by association with their class type. That is, associating a Style with a specific class. For example, applying a Style to all instances of GeoLocation.

  4. Base style for StyleSheet.

  5. System-wide defaults.

An individual Style's attributes can be set or "inherited". When an attribute is set to "inherit", the next rule in sequence is used to resolve that value. The sequence of these rules is in the same order listed above.

To help illustrate how these rules resolve inherited values, let's use the following styles:
  • Style for ID "bob"
    • edge style = inherited

    • edge color = inherited

    • fill color = blue

  • Style for style family "smith"
    • edge style = inherited

    • edge color = inherited

    • fill color = red

  • Style for instances of class GeoPolygon
    • edge style = EdgeStyle::Medium

    • edge color = inherited

    • fill color = inherited

  • Style for instances of class GeoPolyline
    • edge style = EdgeStyle::Large

    • edge color = white

    • fill color = inherited

  • Base style for StyleSheet
    • edge style = EdgeStyle::Small

    • edge color = purple

    • fill color = pink

Using the above definitions, the following Geographic elements would have the following Style definitions:
  • GeoPolyline, ID = "alison", style family = "smith"
    • edge style = EdgeStyle::Large (from class GeoPolyline)

    • edge color = white (from class GeoPolyline)

    • fill color = red (from style family "smith")

  • GeoPolygon, ID = "bob", style family = "smith"
    • edge style = EdgeStyle::Medium (from class GeoPolygon)

    • edge color = purple (from base style for StyleSheet)

    • fill color = blue (from ID "bob")

  • GeoPolyline, ID = "carol", style family = "jones"

StyleSheet is an adaption of the Style Sheet Language for the visual representation of Geographic data types within the MapView control. As such, the Style and StyleSheet are analogous to how Cascading Style Sheets are used to render HTML documents. In an HTML document, the <p> element can contain id and class attributes. The accompanying CSS document can designate visual information based on the id attribute, by the class attribute, by the element type (in this case, <p>) or by using a document default. A StyleSheet is analogous to CSS in that its visual information can be stated by ID (id in CSS), by style family (class in CSS), by class name (element type in CSS) or by using a default.

There is a noted difference between the "getter" operations (eg: styleForId, styleForFamily) and the resolveStyle operation. The "getter" operations return the raw Style that was registered, including any attributes set to be "inherited". The resolveStyle operation ensures that all attributes are fully resolved so that there are no "inherited" values.


Overview

Public Functions Index

StyleSheet ()
StyleSheet (const StyleSheet &src)
~StyleSheet ()
voidaddStyleForClass (const QString &className, const Style &style)
voidaddStyleForClass (const Geographic *classType, const Style &style)
voidaddStyleForFamily (const QString &family, const Style &style)
voidaddStyleForId (const QString &id, const Style &style)
StylebaseStyle () const
booloperator!= (const StyleSheet &rhs) const
StyleSheet &operator= (const StyleSheet &src)
booloperator== (const StyleSheet &rhs) const
QStringListregisteredClasses () const
QStringListregisteredFamilies () const
QStringListregisteredIds () const
voidremoveStyleForClass (const QString &classname)
voidremoveStyleForClass (const Geographic *classType)
voidremoveStyleForFamily (const QString &family)
voidremoveStyleForId (const QString &id)
StyleresolveStyle (const Geographic *element) const
voidsetBaseStyle (const Style &style)
StylestyleForClass (const QString &classname) const
StylestyleForClass (const Geographic *classType) const
StylestyleForFamily (const QString &family) const
StylestyleForId (const QString &id) const

Public Functions

StyleSheet ()

Creates a StyleSheet instance.

Since:

BlackBerry 10.2.0

StyleSheet (

Copy constructor.

Parameters
src

The object from which to copy information.

Since:

BlackBerry 10.2.0

~StyleSheet ()

Destructor.

Since:

BlackBerry 10.2.0

void addStyleForClass (

Adds a Style definition for a Geographic class.

This replaces any existing style registered for the given class.

Parameters
className

The class name to register against.

style

The style to register.

Since:

BlackBerry 10.2.0

See also:

addStyleForClass(Geographic*, Style)

void addStyleForClass (

Adds a Style definition for a Geographic class.

This replaces any existing style registered for the given class.

Parameters
classType

The class type derived from Geographic to register against.

style

The style to register.

Since:

BlackBerry 10.2.0

See also:

addStyleForClass(QString, Style)

void addStyleForFamily (

Adds a Style definition for a style family.

This replaces any existing style registered for the given family.

Parameters
family

The style family to register against.

style

The style to register.

Since:

BlackBerry 10.2.0

void addStyleForId (

Adds a Style definition for a Geographic ID.

This replaces any existing style registered for the given ID.

Parameters
id

The ID to register against.

style

The style to register.

Since:

BlackBerry 10.2.0

Style baseStyle ()

Retrieves the base style for this set.

Return:

This set's base style.

Since:

BlackBerry 10.2.0

bool operator!= (

Inequality operator.

Return:

true if any property is different.

Since:

BlackBerry 10.2.0

StyleSheet & operator= (

Assignment operator.

Parameters
src

The object from which to copy information.

Since:

BlackBerry 10.2.0

bool operator== (

Equality operator.

Return:

true if all properties are equal.

Since:

BlackBerry 10.2.0

QStringList registeredClasses ()

Retrieves a list of all registered class names.

Return:

A list of all class names that have been used to register styles.

Since:

BlackBerry 10.2.0

QStringList registeredFamilies ()

Retrieves a list of all registered style families.

Return:

A list of all family styles that have been used to register styles.

Since:

BlackBerry 10.2.0

QStringList registeredIds ()

Retrieves a list of all registered IDs.

Return:

A list of all IDs that have been used to register styles.

Since:

BlackBerry 10.2.0

void removeStyleForClass (

Removes the style for the given class name.

Parameters
classname

The name of the class for which to remove registered styles.

Since:

BlackBerry 10.2.0

See also:

removeStyleForClass(Geographic*)

void removeStyleForClass (

Removes the style for the given class type.

Parameters
classType

The type of the class for which to remove registered styles.

Since:

BlackBerry 10.2.0

See also:

removeStyleForClass(QString)

void removeStyleForFamily (

Removes the style for the given style family.

Parameters
family

The name of the style family to remove.

Since:

BlackBerry 10.2.0

void removeStyleForId (

Removes the style for the given ID.

Parameters
id

The id against which the style to be removed was registered.

Since:

BlackBerry 10.2.0

Style resolveStyle (

Generates a Style applicable for the given element where all unresolved style attributes (inherited attributes) have been resolved.

Parameters
element

The Geographic element to find a complete style for.

Return:

A fully populated Style instance for the given element.

Since:

BlackBerry 10.2.0

void setBaseStyle (

Sets the base style for this set.

Parameters
style

The set's new base style.

Since:

BlackBerry 10.2.0

Style styleForClass (

Retrieves the style for the given ID.

Parameters
classname

The name of the class upon which to retrieve.

Return:

Returns the requested style, or a null Style if it doesn't exist.

Since:

BlackBerry 10.2.0

See also:

styleForClass(Geographic*)

Style styleForClass (

Retrieves the style for the given ID.

Parameters
classType

The class type derived from Geographic upon which to retrieve.

Return:

Returns the requested style, or a null Style if it doesn't exist.

Since:

BlackBerry 10.2.0

See also:

styleForClass(QString)

Style styleForFamily (

Retrieves the style for the given style family.

Parameters
family

The style family name upon which to search.

Return:

Returns the requested style, or a null Style if it doesn't exist.

Since:

BlackBerry 10.2.0

Style styleForId (

Retrieves the style for the given ID.

Parameters
id

The ID upon which to search.

Return:

Returns the requested style, or a null Style if it doesn't exist.

Since:

BlackBerry 10.2.0

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus