GooCanvasStyle: GooCanvas Reference Manual

## GooCanvasStyle GooCanvasStyle — support for cascading style properties for canvas items. |

## Functions

GooCanvasStyle * | goo_canvas_style_new ()
GooCanvasStyle * | goo_canvas_style_copy ()
GooCanvasStyle * | goo_canvas_style_get_parent ()
void | goo_canvas_style_set_parent ()
GValue * | goo_canvas_style_get_property ()
void | goo_canvas_style_set_property ()
gboolean | goo_canvas_style_set_fill_options ()
gboolean | goo_canvas_style_set_stroke_options ()

## Types and Values

struct | GooCanvasStyle
struct | GooCanvasStyleProperty
extern GQuark | goo_canvas_style_antialias_id
extern GQuark | goo_canvas_style_fill_pattern_id
extern GQuark | goo_canvas_style_fill_rule_id
extern GQuark | goo_canvas_style_font_desc_id
extern GQuark | goo_canvas_style_hint_metrics_id
extern GQuark | goo_canvas_style_line_cap_id
extern GQuark | goo_canvas_style_line_dash_id
extern GQuark | goo_canvas_style_line_join_id
extern GQuark | goo_canvas_style_line_join_miter_limit_id
extern GQuark | goo_canvas_style_line_width_id
extern GQuark | goo_canvas_style_operator_id
extern GQuark | goo_canvas_style_stroke_pattern_id

## Object Hierarchy

        GObject
        ╰── GooCanvasStyle

## Description

GooCanvasStyle provides support for cascading style properties for canvas items. It is intended to be used when implementing new canvas items.

The cascading styles canvas feature may be removed in a future version of GooCanvas.

Style properties are identified by a unique GQuark, and contain arbitrary data stored in a GValue.

GooCanvasStyle also provides a few convenience functions such as `goo_canvas_style_set_stroke_options()` and `goo_canvas_style_set_fill_options()` which efficiently apply an item's standard style properties to the given cairo_t.

## Functions

### goo_canvas_style_new ()

    GooCanvasStyle *
    goo_canvas_style_new (void);

Creates a new GooCanvasStyle.

#### Returns

a new GooCanvasStyle.

[transfer full]

### goo_canvas_style_copy ()

    GooCanvasStyle *
    goo_canvas_style_copy (GooCanvasStyle *style);

Copies the given GooCanvasStyle, by copying all of its properties. Though the parent of the new style is left unset.

#### Parameters

style | a GooCanvasStyle. |

#### Returns

a copy of the given GooCanvasStyle.

[transfer full]

### goo_canvas_style_get_parent ()

    GooCanvasStyle *
    goo_canvas_style_get_parent (GooCanvasStyle *style);

Gets the parent of the style.

#### Parameters

style | a style. |

#### Returns

the parent of the given style, or `NULL`.

[transfer none]

### goo_canvas_style_set_parent ()

    void
    goo_canvas_style_set_parent (GooCanvasStyle *style,
                                 GooCanvasStyle *parent);

Sets the parent of the style.

#### Parameters

style | a style. |
parent | the new parent. |

### goo_canvas_style_get_property ()

    GValue *
    goo_canvas_style_get_property (GooCanvasStyle *style,
                                   GQuark property_id);

Gets the value of a property.

This searches though all the GooCanvasStyle's own list of property settings and also all ancestor GooCanvasStyle objects.

Note that it returns a pointer to the internal GValue setting, which should not be changed.

#### Parameters

style | a style. |
property_id | the property identifier. |

#### Returns

the property value, or `NULL` if it isn't set.

### goo_canvas_style_set_property ()

    void
    goo_canvas_style_set_property (GooCanvasStyle *style,
                                   GQuark property_id,
                                   const GValue *value);

Sets a property in the style, replacing any current setting.

Note that this will override the property setting in ancestor GooCanvasStyle objects.

#### Parameters

style | a style. |
property_id | the property identifier. |
value | the value of the property. |

### goo_canvas_style_set_fill_options ()

    gboolean
    goo_canvas_style_set_fill_options (GooCanvasStyle *style,
                                       cairo_t *cr);

Sets the standard cairo fill options using the given style.

#### Parameters

style | a style. |
cr | a cairo context. |

#### Returns

`TRUE` if a paint source is set, or `FALSE` if the fill should be skipped.

### goo_canvas_style_set_stroke_options ()

    gboolean
    goo_canvas_style_set_stroke_options (GooCanvasStyle *style,
                                         cairo_t *cr);

Sets the standard cairo stroke options using the given style.

#### Parameters

style | a style. |
cr | a cairo context. |

#### Returns

`TRUE` if a paint source is set, or `FALSE` if the stroke should be skipped.

## Types and Values

### struct GooCanvasStyle

    struct GooCanvasStyle {
      GooCanvasStyle *parent;
      GArray *properties;
    };

GooCanvasStyle holds the style properties of a canvas item, as well as a pointer to the parent style.

#### Members

GooCanvasStyle *`parent`; | the parent style. |
GArray *`properties`; | an array of GooCanvasStyleProperty property settings. |

### struct GooCanvasStyleProperty

    struct GooCanvasStyleProperty {
      GQuark id;
      GValue value;
    };

GooCanvasStyleProperty represents a property setting.

#### Members

GQuark `id`; | the unique property identifier. |
GValue `value`; | the value of the property. |

### goo_canvas_style_antialias_id

    extern GQuark goo_canvas_style_antialias_id;

Unique GQuark identifier used for the standard antialias property.

### goo_canvas_style_fill_pattern_id

    extern GQuark goo_canvas_style_fill_pattern_id;

Unique GQuark identifier used for the standard fill pattern property.

### goo_canvas_style_fill_rule_id

    extern GQuark goo_canvas_style_fill_rule_id;

Unique GQuark identifier used for the standard fill rule property.

### goo_canvas_style_font_desc_id

    extern GQuark goo_canvas_style_font_desc_id;

Unique GQuark identifier used for the standard font description property.

### goo_canvas_style_hint_metrics_id

    extern GQuark goo_canvas_style_hint_metrics_id;

Unique GQuark identifier used for the standard hint metrics property.

### goo_canvas_style_line_cap_id

    extern GQuark goo_canvas_style_line_cap_id;

Unique GQuark identifier used for the standard line cap property.

### goo_canvas_style_line_dash_id

    extern GQuark goo_canvas_style_line_dash_id;

Unique GQuark identifier used for the standard line dash property.

### goo_canvas_style_line_join_id

    extern GQuark goo_canvas_style_line_join_id;

Unique GQuark identifier used for the standard line join property.

### goo_canvas_style_line_join_miter_limit_id

    extern GQuark goo_canvas_style_line_join_miter_limit_id;

Unique GQuark identifier used for the standard miter limit property.

### goo_canvas_style_line_width_id

    extern GQuark goo_canvas_style_line_width_id;

Unique GQuark identifier used for the standard line width property.

### goo_canvas_style_operator_id

    extern GQuark goo_canvas_style_operator_id;

Unique GQuark identifier used for the standard operator property.

### goo_canvas_style_stroke_pattern_id

    extern GQuark goo_canvas_style_stroke_pattern_id;

Unique GQuark identifier used for the standard stroke pattern property.