GOffice.StyledObject

g GObject.GInterface GObject.GInterface GOffice.StyledObject GOffice.StyledObject GObject.GInterface->GOffice.StyledObject

Implementations:

GOffice.CanvasStyledItem, GOffice.GraphStyledObject

Methods

apply_theme (style)

fill (cr, preserve)

get_auto_style ()

get_document ()

get_style ()

set_cairo_line (cr)

set_style (style)

style_changed ()

Virtual Methods

None

Properties

None

Signals

None

Fields

None

Class Details

class GOffice.StyledObject
Bases:

GObject.GInterface

apply_theme(style)
Parameters:

style (GOffice.Style) – a GOffice.Style that will be themed

Apply appropriate theme style if meaningful, i.e. properties with auto flag set to True should be changed to default theme GOffice.value.

fill(cr, preserve)
Parameters:

fills the current path according to the item style and canvas scale.

get_auto_style()
Returns:

a new GOffice.Style

Return type:

GOffice.Style

This function returns a new style that is initialized with the auto values for self. Caller is responsible for the result.

get_document()
Returns:

he GOffice.Doc associated with the object if any.

Return type:

GOffice.Doc

A GOffice.Doc is necessary to store images. If no GOffice.Doc is associated with the object, image filling will not be supported.

get_style()
Returns:

the styled object’s GOffice.Style

Return type:

GOffice.Style

Simply an accessor function that returns self->style, without referencing it.

set_cairo_line(cr)
Parameters:

cr (cairo.Context) – cairo.Context

Returns:

True if the line is not invisible

Return type:

bool

Prepares the cairo context cr to draw a line according to the item style and canvas scale.

set_style(style)
Parameters:

style (GOffice.Style) – a GOffice.Style

Returns:

True if new style may lead to change of object size, which happens when changing GOffice.font size for example.

Return type:

bool

Sets a new style for self, and emits “style-changed” signal. This function does not take ownership of style.

The best way to change the style is to set the “style” property.

This function will fail if the new style and the previous style are the same. In that case, the function will always return false:

style = go_styled_object_get_style (gso);
style->line.width = 2;
size_changed = go_styled_object_set_style (gso, style);

In this sample, the call to GOffice.StyledObject.set_style() is just useless. You need to check yourself if you really change the size, call GOffice.StyledObject.style_changed() to trigger the “style-changed” event. So the following code is much better:

style = go_styled_object_get_style (gso);
if (style->line.width != 2.) {
 style->line.width = 2;
 go_styled_object_style_changed (gso);
 size_changed = true;
} else
 size_changed = FALSE;

or even better:

style = go_style_dup (go_styled_object_get_style (gso));
style->line.width = 2;
size_changed = go_styled_object_set_style (gso, style);
g_object_unref (style);
style_changed()

Called when the style changed. Might emit a signal if meaningful.