Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkWidget
               +----GtkDrawingArea
                     +----AdgGtkArea
                           +----AdgGtkLayout

Implemented Interfaces

AdgGtkArea implements AtkImplementorIface and GtkBuildable.

Properties

  "autozoom"                 gboolean              : Read / Write
  "canvas"                   AdgCanvas*            : Read / Write / Construct
  "factor"                   gdouble               : Read / Write
  "render-map"               CairoMatrix*          : Read / Write

Signals

  "canvas-changed"                                 : No Recursion
  "extents-changed"                                : No Recursion

Description

This is a GtkDrawingArea derived object that provides an easy way to show an ADG based canvas. The associated canvas can be set directly with the adg_gtk_area_new_with_canvas() constructor function or by using adg_gtk_area_set_canvas().

The minimum size of the widget will depend on the canvas content.

The default implementation reacts to some mouse events: if you drag the mouse keeping the wheel pressed, the canvas will be translated (in local space by default and in global space if SHIFT is pressed); if the mouse wheel is rotated the canvas will be scaled up or down according to the wheel direction by the factor specified in the "factor" property (again, in local space by default and in global space if SHIFT is pressed). The adg_gtk_area_get_zoom() method could be used to retrieve the current zoom coefficient.

A new transformation layer is present between the global space and the rendering: the "render-map" matrix. This transformation is applied just before the rendering and it is used to align and/or apply the zoom coefficient to the canvas without affecting the other layers. Local transformations, instead, are directly applied to the local matrix of the canvas.

Details

struct AdgGtkArea

struct AdgGtkArea;

All fields are private and should not be used directly. Use its public methods instead.

Since 1.0


struct AdgGtkAreaClass

struct AdgGtkAreaClass {
    /* Signals */
    void                (*canvas_changed)       (AdgGtkArea     *area,
                                                 AdgCanvas      *old_canvas);
    void                (*extents_changed)      (AdgGtkArea     *area,
                                                 const CpmlExtents
                                                                *old_extents);
};

The default canvas_changed resets the internal initialization flag, so at the first call to the size_allocate() method the zoom factor is set to 1.

The default extents_changed signal does not do anything: it is intended as a hook for derived class for refreshing GUI elements (such as scrollbars) whenever the boundary box changes.

canvas_changed ()

signals that a new AdgCanvas is bound to this widget.

extents_changed ()

signals that the extents on the underling AdgCanvas has been changed.

Since 1.0


adg_gtk_area_new ()

GtkWidget *         adg_gtk_area_new                    (void);

Creates a new empty AdgGtkArea. The widget is useful only after an AdgCanvas has been added either using the "canvas" property or with adg_gtk_area_set_canvas().

Returns :

the newly created widget

Since 1.0


adg_gtk_area_new_with_canvas ()

GtkWidget *         adg_gtk_area_new_with_canvas        (AdgCanvas *canvas);

Creates a new AdgGtkArea and sets the "canvas" property to canvas.

canvas :

the AdgCanvas shown by this widget

Returns :

the newly created widget

Since 1.0


adg_gtk_area_set_canvas ()

void                adg_gtk_area_set_canvas             (AdgGtkArea *area,
                                                         AdgCanvas *canvas);

Sets a new canvas on area. The old canvas, if presents, is unreferenced.

area :

an AdgGtkArea

canvas :

the new AdgCanvas

Since 1.0


adg_gtk_area_get_canvas ()

AdgCanvas *         adg_gtk_area_get_canvas             (AdgGtkArea *area);

Gets the canvas associated to area. The returned canvas is owned by area and should not be modified or freed.

area :

an AdgGtkArea

Returns :

the requested AdgCanvas object or NULL on errors. [transfer none]

Since 1.0


adg_gtk_area_get_extents ()

const CpmlExtents * adg_gtk_area_get_extents            (AdgGtkArea *area);

Gets the extents of the canvas bound to area. The returned struct is owned by area and should not modified or freed.

The extents of an AdgGtkArea instance are the extents of its canvas (as returned by adg_entity_get_extents()) with the margins added to it and the "render-map" transformation applied.

If area does not have any canvas associated to it or the canvas is invalid or empty, an undefined CpmlExtents struct will be returned.

The canvas will be updated, meaning adg_entity_arrange() is called before the extents computation.

area :

an AdgGtkArea

Returns :

the extents of the area canvas or NULL on errors

Since 1.0


adg_gtk_area_get_zoom ()

gdouble             adg_gtk_area_get_zoom               (AdgGtkArea *area);

Gets the last zoom coefficient applied on the canvas of area. If the "autozoom" property is FALSE, the value returned should be always 1.

area :

an AdgGtkArea

Returns :

the current zoom coefficient

Since 1.0


adg_gtk_area_set_factor ()

void                adg_gtk_area_set_factor             (AdgGtkArea *area,
                                                         gdouble factor);

Sets a new zoom factor to area. If the factor is less than 1, it will be clamped to 1.

area :

an AdgGtkArea

factor :

the new zoom factor

Since 1.0


adg_gtk_area_get_factor ()

gdouble             adg_gtk_area_get_factor             (AdgGtkArea *area);

Gets the zoom factor associated to area. The zoom factor is directly used to zoom in (that is, the default zoom factor of 1.05 will zoom of 5% every iteration) and it is reversed while zooming out (that is, the default factor will be 1/1.05).

area :

an AdgGtkArea

Returns :

the requested zoom factor or 0 on error

Since 1.0


adg_gtk_area_switch_autozoom ()

void                adg_gtk_area_switch_autozoom        (AdgGtkArea *area,
                                                         gboolean state);

Sets the "autozoom" property of area to state. When the autozoom feature is enabled, area reacts to any size allocation by adjusting its zoom coefficient in global space. This means the drawing will fill the available space (keeping its aspect ratio) when resizing the window.

area :

an AdgGtkArea

state :

the new autozoom state

Since 1.0


adg_gtk_area_has_autozoom ()

gboolean            adg_gtk_area_has_autozoom           (AdgGtkArea *area);

Gets the current state of the "autozoom" property on the area object.

area :

an AdgGtkArea

Returns :

the current autozoom state

Since 1.0


adg_gtk_area_reset ()

void                adg_gtk_area_reset                  (AdgGtkArea *area);

Forcibly resets the zoom ratio and position of the canvas bound to area. This means the canvas will be scaled and centered on the current available space.

area :

an AdgGtkArea

adg_gtk_area_canvas_changed ()

void                adg_gtk_area_canvas_changed         (AdgGtkArea *area,
                                                         AdgCanvas *old_canvas);

Emits the "canvas-changed" signal on area.

area :

an AdgGtkArea

old_canvas :

the old canvas bound to area

Since 1.0


adg_gtk_area_set_render_map ()

void                adg_gtk_area_set_render_map         (AdgGtkArea *area,
                                                         const cairo_matrix_t *map);

Sets the new render transformation of area to map: the old map is discarded. If map is NULL, the render map is left unchanged.

Note

The render map is an implementation detail and this function is expected to be used only by AdgGtkArea derived objects.

area :

an AdgGtkArea object

map :

the new map

Since 1.0


adg_gtk_area_transform_render_map ()

void                adg_gtk_area_transform_render_map   (AdgGtkArea *area,
                                                         const cairo_matrix_t *transformation,
                                                         AdgTransformMode mode);

Convenient function to change the render map of area by applying tranformation using the mode operator. This is logically equivalent to the following:

1
2
3
4
cairo_matrix_t map;
adg_matrix_copy(&map, adg_gtk_area_get_render_map(area));
adg_matrix_transform(&map, transformation, mode);
adg_gtk_area_set_render_map(area, &map);

Note

The render map is an implementation detail and this function is expected to be used only by AdgGtkArea derived objects.

area :

an AdgGtkArea object

transformation :

the transformation to apply

mode :

how transformation should be applied

Since 1.0


adg_gtk_area_get_render_map ()

const cairo_matrix_t * adg_gtk_area_get_render_map      (AdgGtkArea *area);

Gets the render map.

area :

an AdgGtkArea object

Returns :

the requested map or NULL on errors

Since 1.0


adg_gtk_area_extents_changed ()

void                adg_gtk_area_extents_changed        (AdgGtkArea *area,
                                                         const CpmlExtents *old_extents);

Emits the "extents-changed" signal on area.

area :

an AdgGtkArea

old_extents :

the old extents of area

Since 1.0

Property Details

The "autozoom" property

  "autozoom"                 gboolean              : Read / Write

When enabled, automatically adjust the zoom in global space at every size allocation.

Default value: FALSE


The "canvas" property

  "canvas"                   AdgCanvas*            : Read / Write / Construct

The canvas to be shown.


The "factor" property

  "factor"                   gdouble               : Read / Write

The factor to use while zooming in and out (usually with the mouse wheel).

Allowed values: >= 1

Default value: 1.05


The "render-map" property

  "render-map"               CairoMatrix*          : Read / Write

The transformation to be applied on the canvas before rendering it.

Signal Details

The "canvas-changed" signal

void                user_function                      (AdgGtkArea *area,
                                                        AdgCanvas  *old_canvas,
                                                        gpointer    user_data)       : No Recursion

Emitted when the AdgGtkArea has a new canvas. If the new canvas is the same as the old one, the signal is not emitted.

area :

an AdgGtkArea

old_canvas :

the old AdgCanvas object

user_data :

user data set when the signal handler was connected.

Since 1.0


The "extents-changed" signal

void                user_function                      (AdgGtkArea *area,
                                                        gpointer    old_extents,
                                                        gpointer    user_data)        : No Recursion

Emitted when the extents of area have been changed. The old extents are always compared to the new ones, so when the extents are recalculated but the result is the same the signal is not emitted.

The extents of AdgGtkArea are subject to the render map, so changing the "render-map" property will emit this signal too.

area :

an AdgGtkArea

old_extents :

the old CpmlExtents struct

user_data :

user data set when the signal handler was connected.

Since 1.0