StDrawingArea: St Reference Manual

## StDrawingArea StDrawingArea — A dynamically-sized Cairo drawing area |

## Functions

void | st_drawing_area_queue_repaint ()
cairo_t * | st_drawing_area_get_context ()
void | st_drawing_area_get_surface_size ()

## Types and Values

#define | ST_TYPE_DRAWING_AREA
struct | StDrawingAreaClass
| StDrawingArea

## Description

StDrawingArea allows drawing via Cairo; the primary difference is that it is dynamically sized. To use, connect to the “repaint” signal, and inside the signal handler, call `st_drawing_area_get_context()` to get the Cairo context to draw to. The “repaint” signal will be emitted by default when the area is resized or the CSS style changes; you can use the `st_drawing_area_queue_repaint()` as well.

## Functions

### st_drawing_area_queue_repaint ()

    void
    st_drawing_area_queue_repaint (StDrawingArea *area);

Will cause the actor to emit a “repaint” signal before it is next drawn to the scene. Useful if some parameters for the area being drawn other than the size or style have changed. Note that `clutter_actor_queue_redraw()` will simply result in the same contents being drawn to the scene again.

#### Parameters

area | the StDrawingArea |

### st_drawing_area_get_context ()

    cairo_t *
    st_drawing_area_get_context (StDrawingArea *area);

Gets the Cairo context to paint to. This function must only be called from a signal handler or virtual function for the “repaint” signal.

JavaScript code must call the special dispose function before returning from the signal handler or virtual function to avoid leaking memory:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    function onRepaint(area) {
        let cr = area.get_context();

        // Draw to the context

        cr.$dispose();
    }

    let area = new St.DrawingArea();
    area.connect('repaint', onRepaint);

#### Parameters

area | the StDrawingArea |

#### Returns

the Cairo context for the paint operation.

[transfer none]

### st_drawing_area_get_surface_size ()

    void
    st_drawing_area_get_surface_size (StDrawingArea *area,
                                      guint *width,
                                      guint *height);

Gets the size of the cairo surface being painted to, which is equal to the size of the content area of the widget. This function must only be called from a signal handler for the “repaint” signal.

#### Parameters

area | the StDrawingArea |
width | location to store the width of the painted area. | [out][optional]
height | location to store the height of the painted area. | [out][optional]

## Types and Values

### ST_TYPE_DRAWING_AREA

    #define ST_TYPE_DRAWING_AREA (st_drawing_area_get_type ())

### struct StDrawingAreaClass

    struct StDrawingAreaClass {
        StWidgetClass parent_class;

        void (*repaint) (StDrawingArea *area);
    };

### StDrawingArea

    typedef struct _StDrawingArea StDrawingArea;