## GocItem

GocItem

## Synopsis

                        GocItem;
                        GocItemClass;
    GocItem*            goc_item_new                        (GocGroup *parent,
                                                             GType type,
                                                             const gchar *first_arg_name,
                                                             ...);
    void                goc_item_destroy                    (GocItem *item);
    void                goc_item_set                        (GocItem *item,
                                                             const gchar *first_arg_name,
                                                             ...);
    double              goc_item_distance                   (GocItem *item,
                                                             double x,
                                                             double y,
                                                             GocItem **near_item);
    void                goc_item_draw                       (GocItem const *item,
                                                             cairo_t *cr);
    gboolean            goc_item_draw_region                (GocItem const *item,
                                                             cairo_t *cr,
                                                             double x0,
                                                             double y0,
                                                             double x1,
                                                             double y1);
    void                goc_item_invalidate                 (GocItem *item);
    void                goc_item_show                       (GocItem *item);
    void                goc_item_hide                       (GocItem *item);
    gboolean            goc_item_is_visible                 (GocItem *item);
    void                goc_item_get_bounds                 (GocItem const *item,
                                                             double *x0,
                                                             double *y0,
                                                             double *x1,
                                                             double *y1);
    void                goc_item_update_bounds              (GocItem *item);
    void                goc_item_bounds_changed             (GocItem *item);
    void                goc_item_parent_changed             (GocItem *item);
    void                goc_item_grab                       (GocItem *item);
    void                goc_item_ungrab                     (GocItem *item);
    void                goc_item_raise                      (GocItem *item,
                                                             int n);
    void                goc_item_lower                      (GocItem *item,
                                                             int n);
    void                goc_item_lower_to_bottom            (GocItem *item);
    void                goc_item_raise_to_top               (GocItem *item);

## Object Hierarchy

      GObject
       +----GocItem
             +----GocGraph
             +----GocStyledItem
             +----GocWidget
             +----GocGroup

## Properties

      "canvas"                   GocCanvas*            : Read
      "parent"                   GocGroup*             : Read

## Description

## Details

### GocItem

    typedef struct _GocItem GocItem;

The virtual base object for canvas items.

### GocItemClass

    typedef struct {
    	GObjectClass	 base;

    	double			(*distance) (GocItem *item,
    					     double x, double y, GocItem **near_item);
    	void			(*draw) (GocItem const *item, cairo_t *cr);
    	gboolean		(*draw_region) (GocItem const *item, cairo_t *cr,
    						double x0, double y0, double x1, double y1);
    	void			(*update_bounds) (GocItem *item);
    	void			(*parent_changed) (GocItem *item);
    	/* events related functions */
    	gboolean		(*button_pressed) (GocItem *item, int button, double x, double y);
    	gboolean		(*button2_pressed) (GocItem *item, int button, double x, double y);
    	gboolean		(*button_released) (GocItem *item, int button, double x, double y);
    	gboolean		(*motion) (GocItem *item, double x, double y);
    	gboolean		(*enter_notify) (GocItem *item, double x, double y);
    	gboolean		(*leave_notify) (GocItem *item, double x, double y);
    	void			(*realize) (GocItem *item);
    	void			(*unrealize) (GocItem *item);
    	gboolean		(*key_pressed) (GocItem *item, GdkEventKey* ev);
    	gboolean		(*key_released) (GocItem *item, GdkEventKey* ev);
    	void			(*notify_scrolled) (GocItem *item);
    } GocItemClass;

The base class for all canvas items.

GObjectClass `base`; | the parent class
`distance` () | returns the distance between the item and the point defined by `x` and `y`. When the distance is larger than a few pixels, the result is not relevant, so an approximate value or even G_MAXDOUBLE might be returned.
`draw` () | draws the item to the cairo context.
`draw_region` () | draws the item in the region defined by `x0`, `y0`, `x1` and `y1`. Should return TRUE when successfull. If FALSE is returned, `draw` will be called. There is no need to implement both methods for an item. Large items should implement `draw_region`.
`update_bounds` () | updates the bounds stored in GocItem as fields x0, y0, x1,and y1.
`parent_changed` () | callback for a parent changed event.
`button_pressed` () | callback for a button press event.
`button2_pressed` () | callback for a double click event.
`button_released` () | callback for a button release event.
`motion` () | callback for a motion event.
`enter_notify` () | callback for an enter notify event.
`leave_notify` () | callback for a leave notify event.
`realize` () | callback for a realizes event.
`unrealize` () | callback for an unrealize event.
`key_pressed` () | callback for a key press event.
`key_released` () | callback for a key release event.
`notify_scrolled` () | callback for a notify scrolled event. This is useful to reposition children of the GtkLayout parent of the canvas to their new position.

### goc_item_new ()

    GocItem*            goc_item_new                        (GocGroup *parent,
                                                             GType type,
                                                             const gchar *first_arg_name,
                                                             ...);

`parent` : |
`type` : |
`first_arg_name` : |
`...` : |
Returns : |

### goc_item_destroy ()

    void                goc_item_destroy                    (GocItem *item);

`item` : |

### goc_item_set ()

    void                goc_item_set                        (GocItem *item,
                                                             const gchar *first_arg_name,
                                                             ...);

`item` : |
`first_arg_name` : |
`...` : |

### goc_item_distance ()

    double              goc_item_distance                   (GocItem *item,
                                                             double x,
                                                             double y,
                                                             GocItem **near_item);

`item` : |
`x` : |
`y` : |
`near_item` : |
Returns : |

### goc_item_draw ()

    void                goc_item_draw                       (GocItem const *item,
                                                             cairo_t *cr);

`item` : |
`cr` : |

### goc_item_draw_region ()

    gboolean            goc_item_draw_region                (GocItem const *item,
                                                             cairo_t *cr,
                                                             double x0,
                                                             double y0,
                                                             double x1,
                                                             double y1);

`item` : |
`cr` : |
`x0` : |
`y0` : |
`x1` : |
`y1` : |
Returns : |

### goc_item_invalidate ()

    void                goc_item_invalidate                 (GocItem *item);

`item` : |

### goc_item_show ()

    void                goc_item_show                       (GocItem *item);

`item` : |

### goc_item_hide ()

    void                goc_item_hide                       (GocItem *item);

`item` : |

### goc_item_is_visible ()

    gboolean            goc_item_is_visible                 (GocItem *item);

`item` : |
Returns : |

### goc_item_get_bounds ()

    void                goc_item_get_bounds                 (GocItem const *item,
                                                             double *x0,
                                                             double *y0,
                                                             double *x1,
                                                             double *y1);

`item` : |
`x0` : |
`y0` : |
`x1` : |
`y1` : |

### goc_item_update_bounds ()

    void                goc_item_update_bounds              (GocItem *item);

`item` : |

### goc_item_bounds_changed ()

    void                goc_item_bounds_changed             (GocItem *item);

`item` : |

### goc_item_parent_changed ()

    void                goc_item_parent_changed             (GocItem *item);

`item` : |

### goc_item_grab ()

    void                goc_item_grab                       (GocItem *item);

`item` : |

### goc_item_ungrab ()

    void                goc_item_ungrab                     (GocItem *item);

`item` : |

### goc_item_raise ()

    void                goc_item_raise                      (GocItem *item,
                                                             int n);

`item` : |
`n` : |

### goc_item_lower ()

    void                goc_item_lower                      (GocItem *item,
                                                             int n);

`item` : |
`n` : |

### goc_item_lower_to_bottom ()

    void                goc_item_lower_to_bottom            (GocItem *item);

`item` : |

### goc_item_raise_to_top ()

    void                goc_item_raise_to_top               (GocItem *item);

`item` : |

## Property Details

### The `"canvas"` property

      "canvas"                   GocCanvas*            : Read

The canvas object on which the item resides.

### The `"parent"` property

      "parent"                   GocGroup*             : Read

The group in which the item resides.