GooCanvas Reference Manual: GooCanvasWidget

## GooCanvasWidget GooCanvasWidget — an embedded widget item. |

## Synopsis

    struct              GooCanvasWidget;
    GooCanvasItem *     goo_canvas_widget_new               (GooCanvasItem *parent,
                                                             GtkWidget *widget,
                                                             gdouble x,
                                                             gdouble y,
                                                             gdouble width,
                                                             gdouble height,
                                                             ...);

## Object Hierarchy

      GObject
       +----GooCanvasItemSimple
             +----GooCanvasWidget

## Implemented Interfaces

GooCanvasWidget implements GooCanvasItem.

## Properties

      "anchor"                   GooCanvasAnchorType   : Read / Write
      "height"                   gdouble               : Read / Write
      "widget"                   GtkWidget*            : Read / Write
      "width"                    gdouble               : Read / Write
      "x"                        gdouble               : Read / Write
      "y"                        gdouble               : Read / Write

## Description

GooCanvasWidget provides support for placing any GtkWidget in the canvas.

The "width" and "height" properties specify the widget's size. If either of them is -1, then the requested size of the widget is used instead, which is the default for both width and height.

Note that there are a number of limitations in the use of GooCanvasWidget:

- It doesn't support any transformation besides simple translation. This means you can't scale a canvas with a GooCanvasWidget in it.

- It doesn't support layering, so you can't place other items beneath or above the GooCanvasWidget.

- It doesn't support rendering of widgets to a given cairo_t, which means you can't output the widget to a pdf or postscript file.

- It doesn't have a model/view variant like the other standard items, so it can only be used in a simple canvas without a model.

- It can't be made a static item.

## Details

### struct GooCanvasWidget

    struct GooCanvasWidget;

The GooCanvasWidget struct contains private data only.

### goo_canvas_widget_new ()

    GooCanvasItem *     goo_canvas_widget_new               (GooCanvasItem *parent,
                                                             GtkWidget *widget,
                                                             gdouble x,
                                                             gdouble y,
                                                             gdouble width,
                                                             gdouble height,
                                                             ...);

Creates a new widget item.

`parent` : | the parent item, or `NULL`. If a parent is specified, it will assume ownership of the item, and the item will automatically be freed when it is removed from the parent. Otherwise call `g_object_unref()` to free it. [skip]
`widget` : | the widget.
`x` : | the x coordinate of the item.
`y` : | the y coordinate of the item.
`width` : | the width of the item, or -1 to use the widget's requested width.
`height` : | the height of the item, or -1 to use the widget's requested height.
`...` : | optional pairs of property names and values, and a terminating `NULL`.
Returns : | a new widget item. [transfer full]

Here's an example showing how to create an entry widget centered at (100.0, 100.0):

    1
    2
    3
    4
    5
    GtkWidget *entry = gtk_entry_new ();
    GooCanvasItem *witem = goo_canvas_widget_new (mygroup, entry,
                                                  100, 100, -1, -1,
                                                  "anchor", GOO_CANVAS_ANCHOR_CENTER,
                                                  NULL);

## Property Details

### The `"anchor"` property

      "anchor"                   GooCanvasAnchorType   : Read / Write

How to position the widget relative to the item's x and y coordinate settings.

Default value: GOO_CANVAS_ANCHOR_NORTH_WEST

### The `"height"` property

      "height"                   gdouble               : Read / Write

The height of the widget, or -1 to use its requested height.

Default value: -1

### The `"widget"` property

      "widget"                   GtkWidget*            : Read / Write

The widget to place in the canvas.

### The `"width"` property

      "width"                    gdouble               : Read / Write

The width of the widget, or -1 to use its requested width.

Default value: -1

### The `"x"` property

      "x"                        gdouble               : Read / Write

The x coordinate of the widget.

Default value: 0

### The `"y"` property

      "y"                        gdouble               : Read / Write

The y coordinate of the widget.

Default value: 0