## MgCanvas

MgCanvas — Base class for all the GnomeCanvas derived widgets in libmergeant.

## Synopsis

    struct      MgCanvas;
    guint       mg_canvas_get_type              (void);
    MgGraph*    mg_canvas_get_graph             (MgCanvas *canvas);
    GtkWidget*  mg_canvas_set_in_scrolled_window
                                                (MgCanvas *canvas);
    void        mg_canvas_declare_item          (MgCanvas *canvas,
                                                 MgCanvasItem *item);
    MgCanvasItem* mg_canvas_get_item_for_object (MgCanvas *canvas,
                                                 MgBase *ref_obj);
    void        mg_canvas_set_zoom_factor       (MgCanvas *canvas,
                                                 gdouble n);
    gdouble     mg_canvas_get_zoom_factor       (MgCanvas *canvas);
    gdouble     mg_canvas_fit_zoom_factor       (MgCanvas *canvas);

## Object Hierarchy

      GObject
       +----GtkObject
             +----GtkWidget
                   +----GtkContainer
                         +----GtkLayout
                               +----GnomeCanvas
                                     +----MgCanvas
                                           +----MgCanvasDbRelations

## Implemented Interfaces

MgCanvas implements AtkImplementorIface.

## Properties

      "graph"                gpointer             : Read / Write

## Signal Prototypes

    "drag-action"
                void        user_function      (MgCanvas *mgcanvas,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);

## Description

This abstract class adds some basic functionnalities on top of the GnomeCanvas canvas such as:

- synchronisation with a MgGraph object (to be able to save the position of each canvas item) and management of the list of items drawn on the canvas.

- zoom settings

The MgCanvas widget can be used with or without any associated MgGraph object.

## Details

### struct MgCanvas

    struct MgCanvas;

### mg_canvas_get_type ()

    guint       mg_canvas_get_type              (void);

Returns : |

### mg_canvas_get_graph ()

    MgGraph*    mg_canvas_get_graph             (MgCanvas *canvas);

`canvas` : |
Returns : |

### mg_canvas_set_in_scrolled_window ()

    GtkWidget*  mg_canvas_set_in_scrolled_window
                                                (MgCanvas *canvas);

Creates a new GtkScrolledWindow object and put `canvas` in it. `canvas` can be retreived using a "canvas" user property of the new scrolled window.

`canvas` : | a MgCanvas widget
Returns : | the new scrolled window.

### mg_canvas_declare_item ()

    void        mg_canvas_declare_item          (MgCanvas *canvas,
                                                 MgCanvasItem *item);

Declares `item` to be listed by `canvas` as one of its items. This functions should be called after each MgCanvasItem is added to `canvas`.

If it was not called for one item, then that item won't be used in `canvas`'s computations (no drag and drop, cleanup, etc).

`canvas` : | a MgCanvas widget
`item` : | a MgCanvasItem object

### mg_canvas_get_item_for_object ()

    MgCanvasItem* mg_canvas_get_item_for_object (MgCanvas *canvas,
                                                 MgBase *ref_obj);

Get the MgCanvasItem corresponding to `obj`;

`canvas` : | a MgCanvas widget
`ref_obj` : |
Returns : |

### mg_canvas_set_zoom_factor ()

    void        mg_canvas_set_zoom_factor       (MgCanvas *canvas,
                                                 gdouble n);

Sets the zooming factor of a canvas by specifying the number of pixels that correspond to one canvas unit. A zoom factor of 1.0 is the default value; greater than 1.0 makes a zoom in and lower than 1.0 makes a zoom out.

`canvas` : | a MgCanvas widget
`n` : | the zoom factor

### mg_canvas_get_zoom_factor ()

    gdouble     mg_canvas_get_zoom_factor       (MgCanvas *canvas);

Get the current zooming factor of a canvas.

`canvas` : | a MgCanvas widget
Returns : | the zooming factor.

### mg_canvas_fit_zoom_factor ()

    gdouble     mg_canvas_fit_zoom_factor       (MgCanvas *canvas);

Compute and set the correct zoom factor so that all the items on `canvas` can be displayed at once.

`canvas` : | a MgCanvas widget
Returns : | the new zooming factor.

## Properties

"`graph`" (gpointer : Read / Write) |

## Signals

### The "drag-action" signal

    void        user_function                  (MgCanvas *mgcanvas,
                                                gpointer arg1,
                                                gpointer arg2,
                                                gpointer user_data);

`mgcanvas` : | the object which received the signal.
`arg1` : |
`arg2` : |
`user_data` : | user data set when the signal handler was connected.