Bonobo API Reference Manual
<<< Previous Page | Home | Up | Next Page >>>

# BonoboCanvasComponent

## Name

BonoboCanvasComponent -- Class for exporting BonoboCanvasItems through BonoboEmbeddables to other applications.

## Synopsis

    typedef     BonoboCanvasComponent;
    typedef     BonoboCanvasComponentClass;
    GnomeCanvas* bonobo_canvas_new              (gboolean is_aa,
                                                 Bonobo_Canvas_ComponentProxy proxy);
    BonoboCanvasComponent* bonobo_canvas_component_construct
                                                (BonoboCanvasComponent *comp,
                                                 GnomeCanvasItem *item);
    BonoboCanvasComponent* bonobo_canvas_component_new
                                                (GnomeCanvasItem *item);
    GnomeCanvasItem* bonobo_canvas_component_get_item
                                                (BonoboCanvasComponent *comp);
    Bonobo_UIContainer bonobo_canvas_component_get_ui_container
                                                (BonoboCanvasComponent *comp);
    void        bonobo_canvas_component_grab    (BonoboCanvasComponent *comp,
                                                 guint mask,
                                                 GdkCursor *cursor,
                                                 guint32 time);
    void        bonobo_canvas_component_ungrab  (BonoboCanvasComponent *comp,
                                                 guint32 time);

## Description

The BonoboCanvasComponent objects are used to wrap GnomeCanvasItems and export them to container applications. Typically the bonobo_component_canvas_new() function will be invoked in a callback from a BonoboEmbeddable object.

Here is an example of how to export Gnome Canvas Items in a simple way.

Example 1. Wrapping a Gnome Canvas Item

    /*
     * Here is where the GnomeCanvasItem (in this case an ellipse)
     * is created and wrapped in a BonoboCanvasComponent.
     *
     * This function is invoked on demand on the embeddable
     * argument.  Embeddables are the document model, and the
     * items returned are the views.
     */
    BonoboCanvasComponent *
    my_item_creator (BonoboEmbeddable *embeddable,
                     GnomeCanvas      *canvas,
                     void             *data)
    {
            GnomeCanvasItem *item = gnome_canvas_item_new (
    		gnome_canvas_root (canvas),
                    gnome_canvas_ellipse_get_type(),
                    "x1", 5.0,  "y1", 5.0,
                    "x2", 95.0, "y2", 95.0,
                    "fill_color", "white",
                    "outline_color", "black",
                    NULL);

            return bonobo_canvas_component_new (item);
    }

    /*
     * This is a routine that creates a BonoboEmbeddable that
     * uses CanvasItems.
     */
    BonoboEmbeddable *make_embeddable (void)
    {
           return bonobo_embeddable_new_canvas_item (my_item_creator, NULL);
    }

Applications that do not use the base BonoboEmbeddable class, but use their own types derived from the BonoboEmbeddable can use the bonobo_embeddable_construct() during their construction phase.

On the client side (the application that will embed this component) an object of the type BonoboCanvasItem is used.

## Details

### BonoboCanvasComponent

    typedef struct {
    	BonoboXObject base;
    	BonoboCanvasComponentPrivate *priv;
    } BonoboCanvasComponent;

### BonoboCanvasComponentClass

    typedef struct {
    	BonoboXObjectClass parent_class;

    	POA_Bonobo_Canvas_Component__epv epv;

    	/* Signals */
    	void (*set_bounds) (BonoboCanvasComponent *component,
    			    Bonobo_Canvas_DRect   *bbox,
    			    CORBA_Environment     *ev);

    	gboolean (*event)  (BonoboCanvasComponent *component,
    			    GdkEvent              *event);
    } BonoboCanvasComponentClass;

### bonobo_canvas_new ()

    GnomeCanvas* bonobo_canvas_new              (gboolean is_aa,
                                                 Bonobo_Canvas_ComponentProxy proxy);

`is_aa` : | Flag indicating is antialiased canvas is desired
`proxy` : | Remote proxy for the component this canvas will support
Returns : | A GnomeCanvas with the root replaced by a forwarding item.

### bonobo_canvas_component_construct ()

    BonoboCanvasComponent* bonobo_canvas_component_construct
                                                (BonoboCanvasComponent *comp,
                                                 GnomeCanvasItem *item);

Creates a CORBA server for the interface Bonobo::Canvas::Item wrapping `item`.

`comp` : | a BonoboCanvasComponent to initialize
`item` : | A GnomeCanvasItem that is being exported
Returns : | The BonoboCanvasComponent.

### bonobo_canvas_component_new ()

    BonoboCanvasComponent* bonobo_canvas_component_new
                                                (GnomeCanvasItem *item);

Creates a CORBA server for the interface Bonobo::Canvas::Item wrapping `item`.

`item` : | A GnomeCanvasItem that is being exported
Returns : | The BonoboCanvasComponent.

### bonobo_canvas_component_get_item ()

    GnomeCanvasItem* bonobo_canvas_component_get_item
                                                (BonoboCanvasComponent *comp);

`comp` : | A BonoboCanvasComponent object
Returns : | The GnomeCanvasItem that this BonoboCanvasComponent proxies

### bonobo_canvas_component_get_ui_container ()

    Bonobo_UIContainer bonobo_canvas_component_get_ui_container
                                                (BonoboCanvasComponent *comp);

`comp` : | A BonoboCanvasComponent object
Returns : | The UI container for the component's remote proxy.

### bonobo_canvas_component_grab ()

    void        bonobo_canvas_component_grab    (BonoboCanvasComponent *comp,
                                                 guint mask,
                                                 GdkCursor *cursor,
                                                 guint32 time);

Grabs the mouse focus via a call to the remote proxy.

`comp` : | A BonoboCanvasComponent object
`mask` : | Mask of events to grab
`cursor` : | GdkCursor to display during grab
`time` : | Time of last event before grab

### bonobo_canvas_component_ungrab ()

    void        bonobo_canvas_component_ungrab  (BonoboCanvasComponent *comp,
                                                 guint32 time);

Grabs the mouse focus via a call to the remote proxy.

`comp` : | A BonoboCanvasComponent object
`time` : | Time of last event before grab

## See Also

BonoboEmbeddable, BonoboCanvasItem

<<< Previous Page | Home | Up | Next Page >>>
BonoboCanvasItem | Printing