## GocCanvas

GocCanvas — The canvas widget

## Synopsis

    enum                GocDirection;
                        GocCanvas;
    typedef             GocCanvasClass;
    GocGroup*           goc_canvas_get_root                 (GocCanvas *canvas);
    int                 goc_canvas_get_width                (GocCanvas *canvas);
    int                 goc_canvas_get_height               (GocCanvas *canvas);
    void                goc_canvas_scroll_to                (GocCanvas *canvas,
                                                             double x,
                                                             double y);
    void                goc_canvas_get_scroll_position      (GocCanvas *canvas,
                                                             double *x,
                                                             double *y);
    void                goc_canvas_set_pixels_per_unit      (GocCanvas *canvas,
                                                             double pixels_per_unit);
    double              goc_canvas_get_pixels_per_unit      (GocCanvas *canvas);
    void                goc_canvas_invalidate               (GocCanvas *canvas,
                                                             double x0,
                                                             double y0,
                                                             double x1,
                                                             double y1);
    GocItem*            goc_canvas_get_item_at              (GocCanvas *canvas,
                                                             double x,
                                                             double y);
    void                goc_canvas_grab_item                (GocCanvas *canvas,
                                                             GocItem *item);
    void                goc_canvas_ungrab_item              (GocCanvas *canvas);
    GocItem*            goc_canvas_get_grabbed_item         (GocCanvas *canvas);
    void                goc_canvas_set_document             (GocCanvas *canvas,
                                                             GODoc *document);
    GODoc*              goc_canvas_get_document             (GocCanvas *canvas);
    GdkEvent*           goc_canvas_get_cur_event            (GocCanvas *canvas);
    void                goc_canvas_set_direction            (GocCanvas *canvas,
                                                             GocDirection direction);
    GocDirection        goc_canvas_get_direction            (GocCanvas *canvas);
    void                goc_canvas_w2c                      (GocCanvas *canvas,
                                                             int x,
                                                             int y,
                                                             double *x_,
                                                             double *y_);
    void                goc_canvas_c2w                      (GocCanvas *canvas,
                                                             double x,
                                                             double y,
                                                             int *x_,
                                                             int *y_);

## Object Hierarchy

      GObject
       +----GInitiallyUnowned
             +----GtkObject
                   +----GtkWidget
                         +----GtkContainer
                               +----GtkLayout
                                     +----GocCanvas

## Implemented Interfaces

GocCanvas implements AtkImplementorIface and GtkBuildable.

## Description

The canvas widget used in gnumeric.

## Details

### enum GocDirection

    typedef enum {
    	GOC_DIRECTION_LTR,
    	GOC_DIRECTION_RTL,
    	GOC_DIRECTION_MAX
    } GocDirection;

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

### GocCanvas

    typedef struct _GocCanvas GocCanvas;

### GocCanvasClass

    typedef GtkLayoutClass GocCanvasClass;

### goc_canvas_get_root ()

    GocGroup*           goc_canvas_get_root                 (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | the top level item of `canvas`, always a GocGroup.

### goc_canvas_get_width ()

    int                 goc_canvas_get_width                (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | the width of the widget visible region.

### goc_canvas_get_height ()

    int                 goc_canvas_get_height               (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | the height of the widget visible region.

### 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).

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

### 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.

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

### 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.

`canvas` : | GocCanvas
`pixels_per_unit` : | the new scale

### goc_canvas_get_pixels_per_unit ()

    double              goc_canvas_get_pixels_per_unit      (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | how many pixels are used for each unit when displaying the canvas.

### 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.

`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_get_item_at ()

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

`canvas` : | GocCanvas
`x` : | horizontal position
`y` : | vertical position
Returns : | the GocItem displayed at (`x`,`y`) if any.

### 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.

`canvas` : | GocCanvas
`item` : | GocItem

### goc_canvas_ungrab_item ()

    void                goc_canvas_ungrab_item              (GocCanvas *canvas);

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

`canvas` : | GocCanvas

### goc_canvas_get_grabbed_item ()

    GocItem*            goc_canvas_get_grabbed_item         (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | The currently grabbed GocItem.

### 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).

`canvas` : | GocCanvas
`document` : | GODoc

### goc_canvas_get_document ()

    GODoc*              goc_canvas_get_document             (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | The GODoc associated with the GocCanvas.

### goc_canvas_get_cur_event ()

    GdkEvent*           goc_canvas_get_cur_event            (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | The GdkEvent being processed.

### goc_canvas_set_direction ()

    void                goc_canvas_set_direction            (GocCanvas *canvas,
                                                             GocDirection direction);

`canvas` : |
`direction` : |

### goc_canvas_get_direction ()

    GocDirection        goc_canvas_get_direction            (GocCanvas *canvas);

`canvas` : | GocCanvas
Returns : | the current canvas direction.

### 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.

`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.

### 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.

`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.