## GocCanvas GocCanvas — The canvas widget |

## Functions

void | goc_canvas_c2w ()
void | goc_canvas_get_bounds ()
GdkEvent * | goc_canvas_get_cur_event ()
GocDirection | goc_canvas_get_direction ()
GODoc * | goc_canvas_get_document ()
GocItem * | goc_canvas_get_grabbed_item ()
int | goc_canvas_get_height ()
GocItem * | goc_canvas_get_item_at ()
double | goc_canvas_get_pixels_per_unit ()
gboolean | goc_canvas_get_realized ()
GocGroup * | goc_canvas_get_root ()
void | goc_canvas_get_scroll_position ()
int | goc_canvas_get_width ()
void | goc_canvas_grab_item ()
void | goc_canvas_invalidate ()
void | goc_canvas_invalidate_region ()
void | goc_canvas_render ()
void | goc_canvas_scroll_to ()
void | goc_canvas_set_direction ()
void | goc_canvas_set_document ()
void | goc_canvas_set_pixels_per_unit ()
void | goc_canvas_ungrab_item ()
void | goc_canvas_w2c ()

## Types and Values

| GocCanvas
typedef | GocCanvasClass
enum | GocDirection

## Object Hierarchy

        GObject
        ╰── GInitiallyUnowned
            ╰── GtkWidget
                ╰── GtkContainer
                    ╰── GtkLayout
                        ╰── GocCanvas

## Implemented Interfaces

GocCanvas implements AtkImplementorIface, GtkBuildable and GtkScrollable.

## Description

The canvas widget used in gnumeric.

## Functions

### goc_canvas_c2w ()

    void
    goc_canvas_c2w (GocCanvas *canvas,
                    double x,
                    double y,
                    int *x_,
                    int *y_);

Retrieves the position in the widget given the canvas coordinates.

#### Parameters

canvas | GocCanvas |
x | the horizontal position as a canvas coordinate. |
y | the vertical position as a canvas coordinate. |
x_ | where to store the horizontal position as a widget coordinate. |
y_ | where to store the vertical position as a widget coordinate. |

### goc_canvas_get_bounds ()

    void
    goc_canvas_get_bounds (GocCanvas *canvas,
                           double *x0,
                           double *y0,
                           double *x1,
                           double *y1);

### goc_canvas_get_cur_event ()

    GdkEvent *
    goc_canvas_get_cur_event (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

The GdkEvent being processed.

[transfer none]

### goc_canvas_get_direction ()

    GocDirection
    goc_canvas_get_direction (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

the current canvas direction.

### goc_canvas_get_document ()

    GODoc *
    goc_canvas_get_document (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

The GODoc associated with the GocCanvas.

[transfer none]

### goc_canvas_get_grabbed_item ()

    GocItem *
    goc_canvas_get_grabbed_item (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

The currently grabbed GocItem.

[transfer none]

### goc_canvas_get_height ()

    int
    goc_canvas_get_height (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

the height of the widget visible region.

### goc_canvas_get_item_at ()

    GocItem *
    goc_canvas_get_item_at (GocCanvas *canvas,
                            double x,
                            double y);

#### Parameters

canvas | GocCanvas |
x | horizontal position |
y | vertical position |

#### Returns

the GocItem displayed at (`x` ,`y` ) if any.

[transfer none]

### goc_canvas_get_pixels_per_unit ()

    double
    goc_canvas_get_pixels_per_unit (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

how many pixels are used for each unit when displaying the canvas.

### goc_canvas_get_realized ()

    gboolean
    goc_canvas_get_realized (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

`TRUE` if the canvas has been realized as a GtkWidget.

### goc_canvas_get_root ()

    GocGroup *
    goc_canvas_get_root (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

the top level item of `canvas` , always a GocGroup.

[transfer none]

### goc_canvas_get_scroll_position ()

    void
    goc_canvas_get_scroll_position (GocCanvas *canvas,
                                    double *x,
                                    double *y);

Retrieves the origin of the visible region of the canvas.

#### Parameters

canvas | GocCanvas |
x | where to store the horizontal position |
y | where to store the vertical position |

### goc_canvas_get_width ()

    int
    goc_canvas_get_width (GocCanvas *canvas);

#### Parameters

canvas | GocCanvas |

#### Returns

the width of the widget visible region.

[transfer none]

### goc_canvas_grab_item ()

    void
    goc_canvas_grab_item (GocCanvas *canvas,
                          GocItem *item);

Grabs GocItem. All subsequent events will be passed to GocItem. This function fails if an item is already grabbed.

#### Parameters

canvas | GocCanvas |
item | GocItem |

### goc_canvas_invalidate ()

    void
    goc_canvas_invalidate (GocCanvas *canvas,
                           double x0,
                           double y0,
                           double x1,
                           double y1);

Invalidates a region of the canvas. The canvas will be redrawn only if the invalidated region intersects the visible area.

#### Parameters

canvas | GocCanvas |
x0 | minimum x coordinate of the invalidated region in canvas coordinates |
y0 | minimum y coordinate of the invalidated region in canvas coordinates |
x1 | maximum x coordinate of the invalidated region in canvas coordinates |
y1 | maximum y coordinate of the invalidated region in canvas coordinates |

### goc_canvas_invalidate_region ()

    void
    goc_canvas_invalidate_region (GocCanvas *canvas,
                                  GocItem *item,
                                  cairo_region_t *region);

Invalidates a region of the canvas. Only `item` will be redrawn if the next draw event is called with a cairo contest clipped to `region` . Used in gnumeric for the walking ants cursor.

#### Parameters

canvas | GocCanvas |
item | the item to redraw |
region | the region to redraw |

### goc_canvas_render ()

    void
    goc_canvas_render (GocCanvas *canvas,
                       cairo_t *cr,
                       double x0,
                       double y0,
                       double x1,
                       double y1);

### goc_canvas_scroll_to ()

    void
    goc_canvas_scroll_to (GocCanvas *canvas,
                          double x,
                          double y);

Scrolls the canvas so that the origin of the visible region is at (`x` ,`y` ). The origin position depends on the canvas direction (see GocDirection).

#### Parameters

canvas | GocCanvas |
x | the horizontal position |
y | the vertical position |

### goc_canvas_set_direction ()

    void
    goc_canvas_set_direction (GocCanvas *canvas,
                              GocDirection direction);

Sets the direction used by the canvas.

#### Parameters

canvas | GocCanvas |
direction | GocDirection |

### goc_canvas_set_document ()

    void
    goc_canvas_set_document (GocCanvas *canvas,
                             GODoc *document);

Associates the GODoc with the GocCanvas. This is needed to use images when filling styled items (see GocStyledItem).

#### Parameters

canvas | GocCanvas |
document | GODoc |

### goc_canvas_set_pixels_per_unit ()

    void
    goc_canvas_set_pixels_per_unit (GocCanvas *canvas,
                                    double pixels_per_unit);

Sets the scale as the number of pixels used for each unit when displaying the canvas.

#### Parameters

canvas | GocCanvas |
pixels_per_unit | the new scale |

### goc_canvas_ungrab_item ()

    void
    goc_canvas_ungrab_item (GocCanvas *canvas);

Ungrabs the currently grabbed GocItem. This function fails if no item is grabbed.

#### Parameters

canvas | GocCanvas |

### goc_canvas_w2c ()

    void
    goc_canvas_w2c (GocCanvas *canvas,
                    int x,
                    int y,
                    double *x_,
                    double *y_);

Retrieves the canvas coordinates given the position in the widget.

#### Parameters

canvas | GocCanvas |
x | the horizontal position as a widget coordinate. |
y | the vertical position as a widget coordinate. |
x_ | where to store the horizontal position as a canvas coordinate. |
y_ | where to store the vertical position as a canvas coordinate. |

## Types and Values

### GocCanvas

    typedef struct _GocCanvas GocCanvas;

### GocCanvasClass

    typedef GtkLayoutClass GocCanvasClass;

### enum GocDirection

#### Members

GOC_DIRECTION_LTR | Left to right direction |
GOC_DIRECTION_RTL | Right to left direction |
GOC_DIRECTION_MAX | First invalid value |