Gtkada.Canvas_View

Entities

Simple Types

Array Types

Record Types

Interface Types

Tagged Types

Access Types

Subtypes

Constants

Subprograms

Generic Instantiations

Description

This package is a rewrite of Gtkada.Canvas, with hopefully more capabilities and a cleaner API.

It provides a drawing area (canvas) on which items can be displayed and linked together. It also supports interactive manipulation of those items.

This package is organized around the concept of Model-View-Controller:

A view does not draw any background (image, grid,...). This is because there are simply too many ways application want to take advantage of the background. Instead, you should override the Draw_Internal primitive and take advantage (optionally) of some of the helps in Gtkada.Canvas_View.Views, which among other things provide ways to draw grids.

Likewise, a view does not handle events by default (except for scrolling when it is put in a Gtk_Scrolled_Window). This is also because applications want to do widely different things (for some, clicking in the background should open a menu, whereas others will want to let the user scroll by dragging the mouse in the background -- likewise when clicking on items for instance).

Differences with Gtkada.Canvas ==============================

This package is organized around the concept of Model-View-Controller, which provides a much more flexible approach. There is for instance no need to duplicate the items in memory if you already have them available somewhere else in your application.

Various settings that were set on an Interactive_Canvas (like the font for annotations, arrow sizes,...) are now configured on each item or link separately, which provides much more flexibility in what this canvas can display.

The support for items is much richer: via a number of new primitive operations, it is possible to control with more details the behavior of items and where links should be attached to them. More importantly, this package provides a ready-to-use set of predefined items (rectangles, circles, text, polygons,...) which can be composited and have automatic size computation. This makes it easier than before to have an item that contains, for instance, a list of text fields, since there is no need any more to compute the size of the text explicitly.

This package systematically use a Gdouble for coordinates (in any of the coordinate systems), instead of the mix of Gint, Gdouble and Gfloat that the Gtkada.Canvas is using. In fact, most of the time applications will only have to deal with the item coordinate system (see below), and never with the view coordinate system.

The behavior of snap-to-grid is different: whereas in Gtkada.Canvas it forces items to always be aligned with the grid (with no way to have items not aligned), the Canvas_View's effect is more subtle: basically, when an item is moved closed enough to the grid, it will be aligned to the grid. But if it is far from any grid line, you can drop it anywhere. Snapping also takes into account all four edges of items, not just their topleft corner.

User interaction ================

By default, limited user interaction is supported: * When a view is added to a Gtk_Scrolled_Window, scrolling is automatically supported (it is handled by the scrolled window). Users can use the mouse wheel to scroll vertically, shift and the mouse wheel to scroll horizontally, or use the touchpad to navigate (in general with multiple fingers).

But of course it supports much more advanced interactions, like clicking on items, moving them with the mouse or keyboard,...

For this, you need to connect to the "item_event" signal, and either directly handle the signal (a simple click for instance), or set some data in the details parameters, to enable dragging items or the background of the canvas (for scrolling). The package Gtkada.Canvas_View.Views provides a number of precoded behaviors.

When dragging items, the view will scroll automatically if the mouse is going outside of the visible area. Scrolling will continue while the mouse stays there, even if the user does not move the mouse.

The following has not been backported yet: ==========================================

Items are selected automatically when they are clicked. If Control is pressed at the same time, multiple items can be selected. If the background is clicked (and control is not pressed), then all items are unselected. Pressing and dragging the mouse in the backgroudn draws a virtual box on the screen. All the items fully included in this box when it is released will be selected (this will replace the current selection if Control was not pressed).

<group>Drawing</group> <testgtk>create_canvas_view.adb</testgtk>

Abstract_Item

type Abstract_Item is access all Abstract_Item_Record'Class;

These are all the elements that can be displayed on a canvas, including the boxes, the links between the boxes, any annotations on those links, and so on. Items can be grouped, so that toplevel items contain one or more other items. The toplevel items are the ones that are moved interactively by the user, and their contained items will be moved along. All primitive operations on items, except its position, are done in the Item's own coordinate systems so that it is easy to create new types of items without paying attention to any of its parents rotation or scaling, or the rotation and scaling of the view itself).

This interface is meant for use when you already have ways to store coordinates and sizes in your own data types, at which point you can implement a simpler wrapper for your data type that implements this interface. In general, though, it is better to extend the type Abstract_Item_Record which provides its own non-abstract handling for a number of subprograms below.

Abstract_Item_Record

type Abstract_Item_Record is interface;

These are all the elements that can be displayed on a canvas, including the boxes, the links between the boxes, any annotations on those links, and so on. Items can be grouped, so that toplevel items contain one or more other items. The toplevel items are the ones that are moved interactively by the user, and their contained items will be moved along. All primitive operations on items, except its position, are done in the Item's own coordinate systems so that it is easy to create new types of items without paying attention to any of its parents rotation or scaling, or the rotation and scaling of the view itself).

This interface is meant for use when you already have ways to store coordinates and sizes in your own data types, at which point you can implement a simpler wrapper for your data type that implements this interface. In general, though, it is better to extend the type Abstract_Item_Record which provides its own non-abstract handling for a number of subprograms below.

Add

procedure Add
  (Self : not null access List_Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Add a new item to the model.

Parameters
Self
Item

Add_Child

procedure Add_Child
  (Self     : not null access Container_Item_Record'Class;
   Child    : not null access Container_Item_Record'Class;
   Align    : Alignment_Style := Align_Start;
   Pack_End : Boolean := False;
   Margin   : Margins := No_Margins;
   Float    : Boolean := False;
   Overflow : Overflow_Style := Overflow_Prevent)

Add a new child to the container. If the child's position is set, it is then interpreted as relative to Self. If the position is not specified, it will be computed automatically based on the container's policy (either below the previous child, or to its right).

When Pack_End is true, the child will be added at the end of the parent's area (right or bottom depending on orientation). If the parent's size is larger than that needed by all its children, there will thus be an empty space between children with Pack_End=>False and children with Pack_End => True.

When Pack_End is True, the children are put in reverse order starting from the end of Self: for a vertical layout, for instance, the first pack_end child will appear at the bottom of Self.

Margin are added to each size of the child. The child's width, as set via Set_Size, does not include the margins.

A floating child does not participate in the stacking: it will still be displayed below or to the right of the previous child, but the next item will then be displayed at the same coordinate as the floating child.

Parameters
Self
Child
Align
Pack_End
Margin
Float
Overflow

Add_To_Selection

procedure Add_To_Selection
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Handling of selection. Depending on the selection mode, some of these operations might have no effect, or might unselect the current selection before selecting a new item. The selection might contain child items (i.e. not just toplevel items).

Whenever the selection is changed, the signal "selection_changed" is emitted.

Parameters
Self
Item

Alignment_Style

type Alignment_Style is (Align_Start, Align_Center, Align_End);

How an item should be aligned within its parent. When the parent stacks its children vertically, alignment is taken into account horizontally; and similarly when the parent organizes its children horizontally, the alignment is vertical.

When an item does not request a specific size along the alignment axis, it always uses the full width or height of its parent, so the alignment does not play a role.

However, when the item requests a size smaller than its parent's along the alignment axis, extra margin needs to be added, and they are added either to its left/top (when Align_Start), to both sides (when Align_Center), or to its right/bottom (when Align_End)..

Alignment does not apply to floating children, nor to children with a specific position given along a specific axis (in which case the Anchor_X or Anchor_Y might be used for a slightly similar effect).

Enumeration Literal
Align_Start
Align_Center
Align_End

Anchor_Attachment

type Anchor_Attachment is record
   X, Y          : Glib.Gdouble := 0.5;
   Toplevel_Side : Side_Attachment := Auto;
   Distance      : Model_Coordinate := 0.0;
end record;

Where in the item the link is attached (0.5 means the middle, 0.0 means left or top, and 1.0 means right or bottom).

For the target side of a link, if X or Y are negative, Gtkada will try to draw a strictly orthogonal or vertical segment next on that end by adjusting the location of the end point along the border of the item. If it cannot, then GtkAda will use the absolute value of X and Y to specify the attachment.

You can therefore force a link to always emerge from the right side of an item by setting X to 1.0 and Y to any value, for instance. See the description of Side_Attachment for an example on how to use Toplevel_Side. Distance indicates at which distance from the border of the item the link should stop. By default, it reaches the border.

Record fields
X
Y
Toplevel_Side
Distance

Auto_Size

Auto_Size : constant Size := (Unit => Unit_Auto);

See the descriptions for Size_Unit.

Auto_Size_As_Double

Auto_Size_As_Double : constant Model_Coordinate := -2.0;

See the description of Fit_Size and Auto_Size. These are used for parameters that take a Double instead of a Size for backward compatibility (consider using Set_Size instead).

Avoid_Overlap

procedure Avoid_Overlap
  (Self     : not null access Canvas_View_Record'Class;
   Avoid    : Boolean;
   Duration : Standard.Duration := 0.2)

Sets whether items should avoid overlap when possible. When the user is moving items interactively and dropping them in a new position, items that would be overlapped are moved aside to make space for the new item. If Duration is not 0, the other items are animated to the new position.

This setting has no effect when you set the position of items explicitly via a call to Set_Position. In such cases, you can force the behavior manually by calling Gtkada.Canvas_View.Views.Reserve_Space.

Parameters
Self
Avoid
Duration

Bounding_Box

function Bounding_Box
  (Self : not null access Abstract_Item_Record)
   return Item_Rectangle

Returns the area occupied by the item. Any drawing for the item, including shadows for instance, must be within this area. This bounding box is always returned in the item's own coordinate system, so that it is not necessary to pay attention to the current scaling factor or rotation for the item, its parents or the canvas view.

Parameters
Self
Return Value

Bounding_Box

function Bounding_Box
  (Self : not null access Canvas_Link_Record)
   return Item_Rectangle
Parameters
Self
Return Value

Bounding_Box

function Bounding_Box
  (Self   : not null access Canvas_Model_Record;
   Margin : Model_Coordinate := 0.0)
   return Model_Rectangle

Returns the rectangle that encompasses all the items in the model. This is used by views to compute the maximum area that should be made visible. An extra margin is added to each side of the box. The default implementation is not efficient, since it will iterate all items one by one to compute the rectangle. No caching is done.

Parameters
Self
Margin
Return Value

Bounding_Box

function Bounding_Box
  (Self : not null access Container_Item_Record)
   return Item_Rectangle
Parameters
Self
Return Value

Build_Context

function Build_Context
  (Self : not null access Canvas_View_Record'Class)
   return Draw_Context

Returns a draw context for the view. This context is suitable for computing sizes (in Refresh_Layout), but not for actual drawing.

Parameters
Self
Return Value

Canvas_Event_Details

type Canvas_Event_Details is record
   Event_Type     : Canvas_Event_Type;
   Button         : Guint;
   State          : Gdk.Types.Gdk_Modifier_Type;
   Key            : Gdk.Types.Gdk_Key_Type;
   Root_Point     : Gtkada.Style.Point;
   M_Point        : Model_Point;
   Item           : Abstract_Item;
   Toplevel_Item  : Abstract_Item;
   T_Point        : Item_Point;
   I_Point        : Item_Point;
   Allowed_Drag_Area : Model_Rectangle := No_Drag_Allowed;
   Allow_Snapping    : Boolean := True;
end record;

This record describes high-level aspects of user interaction with the canvas.

Record fields
Event_Type
Button
State

The modifier keys (shift, alt, control). It can be used to activate different behavior in such cases.

Key

The key that was pressed (for key events)

Root_Point

Coordinates in root window. Attributes of the low-level event. This is an implementation detail for proper handling of dragging.

M_Point

Where in the model the user clicked. This is independent of the zoom level or current scrolling.

Item

The actual item that was clicked. Set to null when the user clicked in the background.

Toplevel_Item

The toplevel item that contains Item (might be Item itself). Set to null when the user clicked in the background.

T_Point

The corodinates of the click in toplevel_item

I_Point

The coordinates of the click in Item

Allowed_Drag_Area

Allowed_Drag_Area should be modified by the callback when the event is a button_press event. It should be set to the area within which the item (and all currently selected items) can be moved. If you leave it to No_Drag_Allowed, the item cannot be moved.

This field is ignored for events other than button_press, since it makes no sense for instance to start a drag on a button release.

Allow_Snapping

If set to False, this temporary overrides the settings from Set_Snap, and prevents any snapping on the grid or smart guides. It should be set at the same time that Allowed_Drag_Area is set.

Canvas_Event_Type

type Canvas_Event_Type is
  (Button_Press, Button_Release, Double_Click,
   Start_Drag, In_Drag, End_Drag, Key_Press, Scroll, Custom);

The event types that are emitted for the Item_Event signal:

Enumeration Literal
Button_Press
Button_Release
Double_Click
Start_Drag
In_Drag
End_Drag
Key_Press
Scroll
Custom

Canvas_Item

type Canvas_Item is access all Canvas_Item_Record'Class;

An implementation of the Abstract_Item interface, which handles a number of the operations automatically. For instance, it will store the position of the item and its bounding box. It is easier to derive from this type when you want to create your own items, unless you want complete control of the data storage.

Canvas_Item_Record

type Canvas_Item_Record is abstract new Abstract_Item_Record with private;

An implementation of the Abstract_Item interface, which handles a number of the operations automatically. For instance, it will store the position of the item and its bounding box. It is easier to derive from this type when you want to create your own items, unless you want complete control of the data storage.

Canvas_Link

type Canvas_Link is access all Canvas_Link_Record'Class;

Special support is provided for links. These are a special kind of item, which provides automatic routing algorithms. They always join two items (including possibly two lines)

Canvas_Link_Record

type Canvas_Link_Record is new Abstract_Item_Record with private;

Special support is provided for links. These are a special kind of item, which provides automatic routing algorithms. They always join two items (including possibly two lines)

Canvas_Model

type Canvas_Model is access all Canvas_Model_Record'Class;

A model is a common interface to query the list of items that should be displayed in the canvas. It does not assume anything regarding the actual storage of the items, so it is possible to create your own model implementation that simply query the rest of your application (or a database, or some other source of data) as needed, without duplicating the items.

This type is not an Ada interface because it needs to inherit from GObject so that it can send signals.

The interface does not provide support for adding items to the model: instead, this is expected to be done by the concrete implementations of the model, which must then send the signal "layout_changed".

Canvas_Model_Record

type Canvas_Model_Record
   is abstract new Glib.Object.GObject_Record with private;

A model is a common interface to query the list of items that should be displayed in the canvas. It does not assume anything regarding the actual storage of the items, so it is possible to create your own model implementation that simply query the rest of your application (or a database, or some other source of data) as needed, without duplicating the items.

This type is not an Ada interface because it needs to inherit from GObject so that it can send signals.

The interface does not provide support for adding items to the model: instead, this is expected to be done by the concrete implementations of the model, which must then send the signal "layout_changed".

Canvas_View

type Canvas_View is access all Canvas_View_Record'Class;

A view is a display of one particular part of the model, or a subset of it. Multiple views can be associated with a specific model, and will monitor changes to it view signals. The view automatically refreshes its display when its model changes.

Canvas_View_Record

type Canvas_View_Record is new Gtk.Widget.Gtk_Widget_Record with private;

A view is a display of one particular part of the model, or a subset of it. Multiple views can be associated with a specific model, and will monitor changes to it view signals. The view automatically refreshes its display when its model changes.

Center_On

procedure Center_On
  (Self         : not null access Canvas_View_Record;
   Center_On    : Model_Point;
   X_Pos, Y_Pos : Gdouble := 0.5;
   Duration     : Standard.Duration := 0.0)

Scroll the canvas so that Center_On appears at the given position within the view (center when using 0.5, or left when using 0.0, and so on). If the duration is not 0, animation is used.

Parameters
Self
Center_On
X_Pos
Y_Pos
Duration

Child_Layout_Strategy

type Child_Layout_Strategy is (Horizontal_Stack, Vertical_Stack);

How should the children of a container be organized: either one on top of another, or one next to another.

Enumeration Literal
Horizontal_Stack
Vertical_Stack

Clear

procedure Clear
   (Self     : not null access Container_Item_Record;
    In_Model : not null access Canvas_Model_Record'Class)

Remove all children of Self

Parameters
Self
In_Model

Clear

procedure Clear
  (Self : not null access List_Canvas_Model_Record)

Remove all items from the model, and destroy them.

Parameters
Self

Clear_Selection

procedure Clear_Selection (Self : not null access Canvas_Model_Record)

Handling of selection. Depending on the selection mode, some of these operations might have no effect, or might unselect the current selection before selecting a new item. The selection might contain child items (i.e. not just toplevel items).

Whenever the selection is changed, the signal "selection_changed" is emitted.

Parameters
Self

Clip_Line

function Clip_Line
  (Self   : not null access Abstract_Item_Record;
   P1, P2 : Item_Point) return Item_Point

Returns the intersection of the line from P1 to P2 with the border of the item. Drawing a line from this intersection point to P2 will not intersect the item.

Parameters
Self
P1
P2
Return Value

Clip_Line

function Clip_Line
  (Self   : not null access Canvas_Item_Record;
   P1, P2 : Item_Point) return Item_Point
Parameters
Self
P1
P2
Return Value

Clip_Line

function Clip_Line
  (Self   : not null access Canvas_Link_Record;
   P1, P2 : Item_Point) return Item_Point
Parameters
Self
P1
P2
Return Value

Clip_Line

function Clip_Line
  (Self   : not null access Polyline_Item_Record;
   P1, P2 : Item_Point) return Item_Point
Parameters
Self
P1
P2
Return Value

Container_Item

type Container_Item is access all Container_Item_Record'Class;

Container_Item_Record

type Container_Item_Record is abstract new Canvas_Item_Record with private;

Contains

function Contains
  (Self    : not null access Abstract_Item_Record;
   Point   : Item_Point;
   Context : Draw_Context) return Boolean

Should test whether Point is within the painted region for Self (i.e. whether Self should be selected when the user clicks on the point). For an item with holes, this function should return False when the point is inside one of the holes, for instance.

Parameters
Self
Point
Context
Return Value

Contains

function Contains
  (Self    : not null access Canvas_Item_Record;
   Point   : Item_Point;
   Context : Draw_Context) return Boolean
Parameters
Self
Point
Context
Return Value

Contains

function Contains
  (Self    : not null access Canvas_Link_Record;
   Point   : Item_Point;
   Context : Draw_Context) return Boolean
Parameters
Self
Point
Context
Return Value

Contains

function Contains
  (Self    : not null access Ellipse_Item_Record;
   Point   : Item_Point;
   Context : Draw_Context) return Boolean
Parameters
Self
Point
Context
Return Value

Contains

function Contains
  (Self    : not null access Polyline_Item_Record;
   Point   : Item_Point;
   Context : Draw_Context) return Boolean
Parameters
Self
Point
Context
Return Value

Copy_Selected_To_Dragged_Items

procedure Copy_Selected_To_Dragged_Items
  (Self  : not null access Canvas_View_Record'Class;
   Force : access Abstract_Item_Record'Class)

Setup the 'dragged_items" field from the contents of the selection, and forces a specific item to be there (in addition)

Parameters
Self
Force

Default_Guide_Style

Default_Guide_Style : constant Gtkada.Style.Drawing_Style :=
  Gtkada.Style.Gtk_New (Stroke => (0.957, 0.363, 0.913, 1.0));

Destroy

procedure Destroy
  (Self     : not null access Abstract_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)

Called when Self is no longer needed. Do not call directly.

Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Canvas_Link_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Container_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Hr_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Image_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Polyline_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Destroy

procedure Destroy
  (Self     : not null access Text_Item_Record;
   In_Model : not null access Canvas_Model_Record'Class)
Parameters
Self
In_Model

Drag_Anywhere

Drag_Anywhere   : constant Model_Rectangle :=
  (Gdouble'First, Gdouble'First, Gdouble'Last, Gdouble'Last);

Values for the Event_Details.Allowed_Drag_Area field

Draw

procedure Draw
  (Self    : not null access Abstract_Item_Record;
   Context : Draw_Context)

Draw the item on the given cairo context. A transformation matrix has already been applied to Cr, so that all drawing should be done in item-coordinates for Self, so that (0,0) is the top-left corner of Self's bounding box. Do not call this procedure directly. Instead, call Translate_And_Draw_Item below.

Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Canvas_Link_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Ellipse_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Hr_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Image_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Polyline_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Rect_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw

procedure Draw
  (Self    : not null access Text_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw_As_Selected

procedure Draw_As_Selected
  (Self    : not null access Abstract_Item_Record;
   Context : Draw_Context)

Draw the item when it is selected. The default is to draw both the item and its outline. Do not call this procedure directly, use Translate_And_Draw_Item instead, unless called directly from an overriding of Draw.

Parameters
Self
Context

Draw_As_Selected

procedure Draw_As_Selected
  (Self    : not null access Canvas_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw_As_Selected

procedure Draw_As_Selected
  (Self    : not null access Canvas_Link_Record;
   Context : Draw_Context)
Parameters
Self
Context

Draw_Children

procedure Draw_Children
  (Self    : not null access Container_Item_Record'Class;
   Context : Draw_Context)

Display all the children of Self

Parameters
Self
Context

Draw_Context

type Draw_Context is record
   Cr     : Cairo.Cairo_Context := Cairo.Null_Context;
   Layout : Pango.Layout.Pango_Layout := null;
   View   : Canvas_View := null;
end record;

Context to perform the actual drawing

Record fields
Cr
Layout
View

Draw_Internal

procedure Draw_Internal
  (Self    : not null access Canvas_View_Record;
   Context : Draw_Context;
   Area    : Model_Rectangle)

Redraw either the whole view, or a specific part of it only. The transformation matrix has already been set on the context. This procedure can be overridden if you need to perform special operations, like drawing a grid for instance. See the various helper subprograms in Gtkada.Canvas_View.Views to do so.

Parameters
Self
Context
Area

Draw_Outline

procedure Draw_Outline
  (Self    : not null access Abstract_Item_Record;
   Style   : Gtkada.Style.Drawing_Style;
   Context : Draw_Context)

Draw an outline for Self (which is used for the selection for instance). Do not call this procedure directly, use Translate_And_Draw_Item instead, unless called directly from an overriding of Draw.

Parameters
Self
Style
Context

Draw_Outline

procedure Draw_Outline
  (Self    : not null access Canvas_Item_Record;
   Style   : Gtkada.Style.Drawing_Style;
   Context : Draw_Context)
Parameters
Self
Style
Context

Draw_Outline

procedure Draw_Outline
  (Self    : not null access Rect_Item_Record;
   Style   : Gtkada.Style.Drawing_Style;
   Context : Draw_Context)
Parameters
Self
Style
Context

Edit_Widget

function Edit_Widget
  (Self  : not null access Abstract_Item_Record;
   View  : not null access Canvas_View_Record'Class)
   return Gtk.Widget.Gtk_Widget

Return the widget to use for in-place editing of the item. null should be returned when the item is not editable in place. It is the responsibility of the returned widget to monitor events and validate the editing, update Self, and then call model's layout_changed signal.

Parameters
Self
View
Return Value

Edit_Widget

function Edit_Widget
  (Self  : not null access Canvas_Item_Record;
   View  : not null access Canvas_View_Record'Class)
   return Gtk.Widget.Gtk_Widget
Parameters
Self
View
Return Value

Edit_Widget

function Edit_Widget
  (Self       : not null access Canvas_Link_Record;
   Dummy_View : not null access Canvas_View_Record'Class)
   return Gtk.Widget.Gtk_Widget
Parameters
Self
Dummy_View
Return Value

Edit_Widget

function Edit_Widget
  (Self  : not null access Editable_Text_Item_Record;
   View  : not null access Canvas_View_Record'Class)
   return Gtk.Widget.Gtk_Widget
Parameters
Self
View
Return Value

Editable_Text_Item

type Editable_Text_Item is access all Editable_Text_Item_Record'Class;

A special text item that can be double-clicked on to be editing in place (provided the Gtkada.Canvas_View.Views.On_Item_Event_Edit callback was added to the view).

Editable_Text_Item_Record

type Editable_Text_Item_Record is new Text_Item_Record with private;

A special text item that can be double-clicked on to be editing in place (provided the Gtkada.Canvas_View.Views.On_Item_Event_Edit callback was added to the view).

Ellipse_Item

type Ellipse_Item is access all Ellipse_Item_Record'Class;

A predefined object that displays itself as a circle or an ellipse inscribed in a given rectangle.

Ellipse_Item_Record

type Ellipse_Item_Record is new Container_Item_Record with private;

A predefined object that displays itself as a circle or an ellipse inscribed in a given rectangle.

Event_Details_Access

type Event_Details_Access is not null access all Canvas_Event_Details;

This record describes high-level aspects of user interaction with the canvas.

Export

function Export
  (Self              : not null access Canvas_View_Record;
   Filename          : String;
   Page              : Page_Format;
   Format            : Export_Format := Export_PDF;
   Visible_Area_Only : Boolean := True)
  return Boolean

Create a file with the contents of the view (or the whole model if Visible_Area_Only is False). True is returned if the file was created successfully, False otherwise

Parameters
Self
Filename
Page
Format
Visible_Area_Only
Return Value

Export_Format

type Export_Format is (Export_PDF, Export_SVG, Export_PNG);
Enumeration Literal
Export_PDF
Export_SVG
Export_PNG

Fit_Size

Fit_Size : constant Size := (Unit => Unit_Fit);

See the descriptions for Size_Unit.

Fit_Size_As_Double

Fit_Size_As_Double  : constant Model_Coordinate := -1.0;

See the description of Fit_Size and Auto_Size. These are used for parameters that take a Double instead of a Size for backward compatibility (consider using Set_Size instead).

For_Each_Child

procedure For_Each_Child
  (Self     : not null access Container_Item_Record'Class;
   Callback : not null access procedure
     (Child : not null access Container_Item_Record'Class);
   Recursive : Boolean := False)

Traverse all children of Self, and calls Callback for each.

Parameters
Self
Callback
Recursive

For_Each_Item

procedure For_Each_Item
  (Self     : not null access Canvas_Model_Record;
   Callback : not null access procedure
     (Item : not null access Abstract_Item_Record'Class);
   Selected_Only : Boolean := False;
   Filter        : Item_Kind_Filter := Kind_Any;
   In_Area       : Model_Rectangle := No_Rectangle)

Calls Callback for each item in the model, including links. Only the items that intersect In_Area should be returned for efficiency, although it is valid to return all items.

If Selected_Only is true, then only selected items are returned

Items are returned in z-layer order: lowest items first, highest items last.

You should not remove items while iterating, since removing items might end up removing other items (links to or from the original item for instance). Instead, create a temporary structure via Include_Related_Items and use Remove to remove them all at once.

Parameters
Self
Callback
Selected_Only
Filter
In_Area

For_Each_Item

procedure For_Each_Item
  (Self     : not null access List_Canvas_Model_Record;
   Callback : not null access procedure
     (Item : not null access Abstract_Item_Record'Class);
   Selected_Only : Boolean := False;
   Filter        : Item_Kind_Filter := Kind_Any;
   In_Area       : Model_Rectangle := No_Rectangle)
Parameters
Self
Callback
Selected_Only
Filter
In_Area

For_Each_Link

procedure For_Each_Link
  (Self       : not null access Canvas_Model_Record;
   Callback   : not null access procedure
     (Item : not null access Abstract_Item_Record'Class);
   From_Or_To : Item_Sets.Set)

This iterator should return all the links in the model. If possible, it should restrict itself to the links with at least one end on an item in From_Or_To (or on a link to such an item). This function is important for performance when dragging items in a large model (tens of thousands of items). The default implementation simply calls For_Each_Item. From_Or_To is never empty.

Parameters
Self
Callback
From_Or_To

From

procedure From
  (Self : not null access Canvas_Model_Record'Class;
   Item : not null access Abstract_Item_Record'Class;
   Set  : in out Item_Sets.Set)

Append all the items with a link coming from Item

Parameters
Self
Item
Set

Gdouble_Elementary_Functions

package Gdouble_Elementary_Functions is new
  Ada.Numerics.Generic_Elementary_Functions (Gdouble);

Get_From

function Get_From
  (Self : not null access Canvas_Link_Record) return Abstract_Item

Return both ends of the link

Parameters
Self
Return Value

Get_Label

function Get_Label
  (Self : not null access Canvas_Link_Record) return Container_Item

Retrieve the various label items

Parameters
Self
Return Value

Get_Label_From

function Get_Label_From
  (Self : not null access Canvas_Link_Record) return Container_Item

Retrieve the various label items

Parameters
Self
Return Value

Get_Label_To

function Get_Label_To
  (Self : not null access Canvas_Link_Record) return Container_Item

Retrieve the various label items

Parameters
Self
Return Value

Get_Points

function Get_Points
  (Self : not null access Canvas_Link_Record)
   return Item_Point_Array_Access

Return the computed points for the link. Do not free or store the result

Parameters
Self
Return Value

Get_Scale

function Get_Scale
  (Self : not null access Canvas_View_Record) return Gdouble

Return the current scale

Parameters
Self
Return Value

Get_Selected_Items

function Get_Selected_Items
  (Self : not null access Canvas_Model_Record) return Item_Sets.Set

Return the currently selected items. If no item is selected, an empty set is returned.

Parameters
Self
Return Value

Get_Selection_Style

function Get_Selection_Style
  (Self  : not null access Canvas_View_Record)
   return Gtkada.Style.Drawing_Style

The style used to highlight selected items

Parameters
Self
Return Value

Get_Style

function Get_Style
  (Self : not null access Canvas_Link_Record) return Drawing_Style

Return the style used for the drawingo of this link. When changing the style, you must force a refresh of the canvas.

Parameters
Self
Return Value

Get_Style

function Get_Style
  (Self : not null access Container_Item_Record) return Drawing_Style

Return the style used for the drawingo of this item. When changing the style, you must force a refresh of the canvas.

Parameters
Self
Return Value

Get_Text

function Get_Text
  (Self : not null access Text_Item_Record) return String

Change the text displayed in the item. This does not force a refresh of the item, and it is likely that you will need to call the Model's Refresh_Layout method to properly recompute sizes of items and link paths.

Parameters
Self
Return Value

Get_To

function Get_To
  (Self : not null access Canvas_Link_Record) return Abstract_Item

Return both ends of the link

Parameters
Self
Return Value

Get_Toplevel_Item

function Get_Toplevel_Item
  (Self : not null access Abstract_Item_Record'Class)
   return Abstract_Item

Return the toplevel item that contains Self (or self itself)

Parameters
Self
Return Value

Get_Visibility_Threshold

function Get_Visibility_Threshold
  (Self : not null access Abstract_Item_Record) return Gdouble

When the items bounding box (on the screen) width or height are less than Threshold pixels, the item is automatically hidden. Making the item invisibile does not impact the visibility of links from or to that item (but you could use Include_Related_Items to find these related items. You need to refresh the view afterwards

Parameters
Self
Return Value

Get_Visibility_Threshold

function Get_Visibility_Threshold
  (Self : not null access Canvas_Item_Record) return Gdouble
Parameters
Self
Return Value

Get_Visibility_Threshold

function Get_Visibility_Threshold
  (Self : not null access Canvas_Link_Record) return Gdouble
Parameters
Self
Return Value

Get_Visible_Area

function Get_Visible_Area
  (Self : not null access Canvas_View_Record)
   return Model_Rectangle

Return the area of the model that is currently displayed in the view. This is in model coordinates (since the canvas coordinates are always from (0,0) to (Self.Get_Allocation_Width, Self.Get_Allocation_Height).

Parameters
Self
Return Value

Gtk_New

function Gtk_New
  (From, To    : not null access Abstract_Item_Record'Class;
   Style       : Gtkada.Style.Drawing_Style;
   Routing     : Route_Style := Straight;
   Label       : access Container_Item_Record'Class := null;
   Anchor_From : Anchor_Attachment := Middle_Attachment;
   Label_From  : access Container_Item_Record'Class := null;
   Anchor_To   : Anchor_Attachment := Middle_Attachment;
   Label_To    : access Container_Item_Record'Class := null)
  return Canvas_Link

Create a new link between the two items. This link is not automatically added to the model. Both items must belong to the same model.

The label is displayed approximately in the middle of the link. The Label_From is displayed next to the origin of the link, whereas Label_To is displayed next to the target of the link. These labels will generally be some Text_Item, but it might make sense to use more complex labels, for instance to draw something with a polyline item, or using an image.

If the Label is directed, the direction of the arrow will be changed automatically to match the layout of the link.

Parameters
From
To
Style
Routing
Label
Anchor_From
Label_From
Anchor_To
Label_To
Return Value

Gtk_New

procedure Gtk_New
  (Self  : out Canvas_View;
   Model : access Canvas_Model_Record'Class := null)

Create a new view which displays the model. A new reference to the model is created (and released when the view is destroyed), so that in general the code will look like:

Model := new ....;
Initialize (Model);
Gtk_New (View, Model);
Unref (Model);  --  unless you need to keep a handle on it too
Parameters
Self
Model

Gtk_New

procedure Gtk_New (Self : out List_Canvas_Model)

Create a new model

Parameters
Self

Gtk_New_Editable_Text

function Gtk_New_Editable_Text
  (Style    : Gtkada.Style.Drawing_Style;
   Text     : Glib.UTF8_String;
   Directed : Text_Arrow_Direction := No_Text_Arrow)
   return Editable_Text_Item

Create a new text item

Parameters
Style
Text
Directed
Return Value

Gtk_New_Ellipse

function Gtk_New_Ellipse
  (Style         : Gtkada.Style.Drawing_Style;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)
   return Ellipse_Item

Create a new ellipse item. If either Width or Height are negative, they will be computed based on the children's requested size (if there are no children, a default size is used). The ellipse is inscribed in the rectangle given by the item's position and the size passed in argument to this function.

Parameters
Style
Width
Height
Return Value

Gtk_New_Hr

function Gtk_New_Hr
  (Style   : Gtkada.Style.Drawing_Style;
   Text    : String := "")
   return Hr_Item

Create a new horizontal rule

Parameters
Style
Text
Return Value

Gtk_New_Image

function Gtk_New_Image
  (Style  : Gtkada.Style.Drawing_Style;
   Image  : not null access Gdk.Pixbuf.Gdk_Pixbuf_Record'Class;
   Allow_Rescale : Boolean := True;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)
   return Image_Item

Create a new image item. By default, the size is computed from the image, but if self is actually allocated a different size, the image will be rescaled as appropriate. You can disable this behavior by setting Allow_Rescale to False.

Parameters
Style
Image
Allow_Rescale
Width
Height
Return Value

Gtk_New_Image

function Gtk_New_Image
  (Style  : Gtkada.Style.Drawing_Style;
   Icon_Name : String;
   Allow_Rescale : Boolean := True;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)
   return Image_Item

Same as buffer, but the image is created from one of the files given by the Gtk.Icon_Theme. This will often result in better (more sharp) rendering. You should in general specify the size you want to use, since the icon_name itself does not provide this information.

Parameters
Style
Icon_Name
Allow_Rescale
Width
Height
Return Value

Gtk_New_Polyline

function Gtk_New_Polyline
  (Style    : Gtkada.Style.Drawing_Style;
   Points   : Item_Point_Array;
   Close    : Boolean := False;
   Relative : Boolean := False)
   return Polyline_Item

Create a new polyline item. If Relative is true, then each point is relative to the previous one (i.e. its coordinates are the previous points's coordinate plus the offset given in points). The first point is of course in item coordinates.

Parameters
Style
Points
Close
Relative
Return Value

Gtk_New_Rect

function Gtk_New_Rect
  (Style         : Gtkada.Style.Drawing_Style;
   Width, Height : Model_Coordinate := Fit_Size_As_Double;
   Radius        : Model_Coordinate := 0.0)
   return Rect_Item

Create a new rectangle item. Specifying the size should rather be done with a call to Set_Size, which provides more flexibility with regards to the units used to describe the size.

Parameters
Style
Width
Height
Radius
Return Value

Gtk_New_Text

function Gtk_New_Text
  (Style    : Gtkada.Style.Drawing_Style;
   Text     : Glib.UTF8_String;
   Directed : Text_Arrow_Direction := No_Text_Arrow;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)
   return Text_Item

Create a new text item

Directed indicates whether the text should be followed (or preceded) by a directional arrow. This is used when displaying text along links, to help users read the meaning of the label.

Parameters
Style
Text
Directed
Width
Height
Return Value

Hash

function Hash (Key : Abstract_Item) return Ada.Containers.Hash_Type
Parameters
Key
Return Value

Hide

procedure Hide (Self : not null access Abstract_Item_Record'Class)

Hide or show the item unconditionally. This overrides the settings done by Set_Visibility_Threshold.

Parameters
Self

Hr_Item

type Hr_Item is access all Hr_Item_Record'Class;

A predefined object that displays itself as a horizontal line with optional text in the middle. This thus looks like: ---- text ----

Hr_Item_Record

type Hr_Item_Record is new Container_Item_Record with private;

A predefined object that displays itself as a horizontal line with optional text in the middle. This thus looks like: ---- text ----

Image_Item

type Image_Item is access all Image_Item_Record'Class;

An item that shows an image. The style is used to draw a rectangle around the image

Image_Item_Record

type Image_Item_Record is new Container_Item_Record with private;

An item that shows an image. The style is used to draw a rectangle around the image

Include_Related_Items

procedure Include_Related_Items
  (Self : not null access Canvas_Model_Record'Class;
   Item : not null access Abstract_Item_Record'Class;
   Set  : in out Item_Sets.Set)

Append Item and all items and links related to Item (i.e. the links for which one of the ends is Item, and then the links to these links, and so on).

Parameters
Self
Item
Set

Initialize

procedure Initialize
  (Link        : not null access Canvas_Link_Record'Class;
   From, To    : not null access Abstract_Item_Record'Class;
   Style       : Gtkada.Style.Drawing_Style;
   Routing     : Route_Style := Straight;
   Label       : access Container_Item_Record'Class := null;
   Anchor_From : Anchor_Attachment := Middle_Attachment;
   Label_From  : access Container_Item_Record'Class := null;
   Anchor_To   : Anchor_Attachment := Middle_Attachment;
   Label_To    : access Container_Item_Record'Class := null)

Create a new link between the two items. This link is not automatically added to the model. Both items must belong to the same model.

The label is displayed approximately in the middle of the link. The Label_From is displayed next to the origin of the link, whereas Label_To is displayed next to the target of the link. These labels will generally be some Text_Item, but it might make sense to use more complex labels, for instance to draw something with a polyline item, or using an image.

If the Label is directed, the direction of the arrow will be changed automatically to match the layout of the link.

Parameters
Link
From
To
Style
Routing
Label
Anchor_From
Label_From
Anchor_To
Label_To

Initialize

procedure Initialize
  (Self : not null access Canvas_Model_Record'Class)

Initialize the internal data so that signals can be sent. This procedure must always be called when you create a new model.

Parameters
Self

Initialize

procedure Initialize
  (Self  : not null access Canvas_View_Record'Class;
   Model : access Canvas_Model_Record'Class := null)

Create a new view which displays the model. A new reference to the model is created (and released when the view is destroyed), so that in general the code will look like:

Model := new ....;
Initialize (Model);
Gtk_New (View, Model);
Unref (Model);  --  unless you need to keep a handle on it too
Parameters
Self
Model

Initialize_Details

procedure Initialize_Details
  (Self    : not null access Canvas_View_Record'Class;
   Details : out Canvas_Event_Details)

Initialize Details for a Custom event type. When you have a real Gtk event, better to use Set_Details below.

Parameters
Self
Details

Initialize_Editable_Text

procedure Initialize_Editable_Text
  (Self     : not null access Editable_Text_Item_Record'Class;
   Style    : Gtkada.Style.Drawing_Style;
   Text     : Glib.UTF8_String;
   Directed : Text_Arrow_Direction := No_Text_Arrow)

Create a new text item

Parameters
Self
Style
Text
Directed

Initialize_Ellipse

procedure Initialize_Ellipse
  (Self          : not null access Ellipse_Item_Record'Class;
   Style         : Gtkada.Style.Drawing_Style;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)

Create a new ellipse item. If either Width or Height are negative, they will be computed based on the children's requested size (if there are no children, a default size is used). The ellipse is inscribed in the rectangle given by the item's position and the size passed in argument to this function.

Parameters
Self
Style
Width
Height

Initialize_Hr

procedure Initialize_Hr
  (Self    : not null access Hr_Item_Record'Class;
   Style   : Gtkada.Style.Drawing_Style;
   Text    : String := "")

Create a new horizontal rule

Parameters
Self
Style
Text

Initialize_Image

procedure Initialize_Image
  (Self   : not null access Image_Item_Record'Class;
   Style  : Gtkada.Style.Drawing_Style;
   Image  : not null access Gdk.Pixbuf.Gdk_Pixbuf_Record'Class;
   Allow_Rescale : Boolean := True;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)

Create a new image item. By default, the size is computed from the image, but if self is actually allocated a different size, the image will be rescaled as appropriate. You can disable this behavior by setting Allow_Rescale to False.

Parameters
Self
Style
Image
Allow_Rescale
Width
Height

Initialize_Image

procedure Initialize_Image
  (Self   : not null access Image_Item_Record'Class;
   Style  : Gtkada.Style.Drawing_Style;
   Icon_Name : String;
   Allow_Rescale : Boolean := True;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)

Same as buffer, but the image is created from one of the files given by the Gtk.Icon_Theme. This will often result in better (more sharp) rendering. You should in general specify the size you want to use, since the icon_name itself does not provide this information.

Parameters
Self
Style
Icon_Name
Allow_Rescale
Width
Height

Initialize_Polyline

procedure Initialize_Polyline
  (Self     : not null access Polyline_Item_Record'Class;
   Style    : Gtkada.Style.Drawing_Style;
   Points   : Item_Point_Array;
   Close    : Boolean := False;
   Relative : Boolean := False)

Create a new polyline item. If Relative is true, then each point is relative to the previous one (i.e. its coordinates are the previous points's coordinate plus the offset given in points). The first point is of course in item coordinates.

Parameters
Self
Style
Points
Close
Relative

Initialize_Rect

procedure Initialize_Rect
  (Self          : not null access Rect_Item_Record'Class;
   Style         : Gtkada.Style.Drawing_Style;
   Width, Height : Model_Coordinate := Fit_Size_As_Double;
   Radius        : Model_Coordinate := 0.0)

Create a new rectangle item. Specifying the size should rather be done with a call to Set_Size, which provides more flexibility with regards to the units used to describe the size.

Parameters
Self
Style
Width
Height
Radius

Initialize_Text

procedure Initialize_Text
  (Self     : not null access Text_Item_Record'Class;
   Style    : Gtkada.Style.Drawing_Style;
   Text     : Glib.UTF8_String;
   Directed : Text_Arrow_Direction := No_Text_Arrow;
   Width, Height : Model_Coordinate := Fit_Size_As_Double)

Create a new text item

Directed indicates whether the text should be followed (or preceded) by a directional arrow. This is used when displaying text along links, to help users read the meaning of the label.

Parameters
Self
Style
Text
Directed
Width
Height

Inline_Editing_Finished

procedure Inline_Editing_Finished
  (Self : not null access Canvas_View_Record'Class;
   Item : not null access Abstract_Item_Record'Class)

Called when the user finishes (cancels ot validates) inline editing of items.

Parameters
Self
Item

Inline_Editing_Started

procedure Inline_Editing_Started
  (Self : not null access Canvas_View_Record'Class;
   Item : not null access Abstract_Item_Record'Class)

Called when the user starts inline editing of items.

Parameters
Self
Item

Inner_Most_Item

function Inner_Most_Item
  (Self     : not null access Abstract_Item_Record;
   At_Point : Model_Point;
   Context  : Draw_Context)
   return Abstract_Item

Return the inner-most item at the specific coordinates in Self (or Self itself).

Parameters
Self
At_Point
Context
Return Value

Inner_Most_Item

function Inner_Most_Item
  (Self           : not null access Canvas_Item_Record;
   Dummy_At_Point : Model_Point;
   Dummy_Context  : Draw_Context)
   return Abstract_Item
Parameters
Self
Dummy_At_Point
Dummy_Context
Return Value

Inner_Most_Item

function Inner_Most_Item
  (Self           : not null access Canvas_Link_Record;
   Dummy_At_Point : Model_Point;
   Dummy_Context  : Draw_Context)
   return Abstract_Item
Parameters
Self
Dummy_At_Point
Dummy_Context
Return Value

Inner_Most_Item

function Inner_Most_Item
  (Self     : not null access Container_Item_Record;
   At_Point : Model_Point;
   Context  : Draw_Context) return Abstract_Item
Parameters
Self
At_Point
Context
Return Value

Intersects

function Intersects (Rect1, Rect2 : Item_Rectangle) return Boolean

Whether the two rectangles intersect.

Parameters
Rect1
Rect2
Return Value

Intersects

function Intersects (Rect1, Rect2 : Model_Rectangle) return Boolean

Whether the two rectangles intersect.

Parameters
Rect1
Rect2
Return Value

Is_Editable

function Is_Editable
   (Self   : not null access Editable_Text_Item_Record'Class)
   return Boolean

Sets whether Self can be edited interactively by double-clicking on it. You should also call Gtkada.Canvas_View.Views.Cancel_Inline_Editing in case some editing was taking place.

Parameters
Self
Return Value

Is_Invisible

function Is_Invisible
  (Self : not null access Abstract_Item_Record)
  return Boolean

True if Self has no filling or stroke information (and therefore is invisible even when displayed, although some of its children might be visible). This function is independent of Set_Visibility_Threshold, Show or Hide.

Parameters
Self
Return Value

Is_Invisible

function Is_Invisible
  (Self : not null access Canvas_Item_Record)
  return Boolean
Parameters
Self
Return Value

Is_Invisible

function Is_Invisible
  (Self : not null access Canvas_Link_Record)
  return Boolean
Parameters
Self
Return Value

Is_Invisible

function Is_Invisible
  (Self : not null access Container_Item_Record)
   return Boolean
Parameters
Self
Return Value

Is_Link

function Is_Link
  (Self : not null access Abstract_Item_Record) return Boolean

Whether this item should be considered as a link between two other items. Such links have a few specific behavior: for instance, they cannot be dragged by the user to a new position (their layout is provided by the items they are linked to). They also do not contribute to the smart guides that are used while items are moved around.

Parameters
Self
Return Value

Is_Link

function Is_Link
  (Self : not null access Canvas_Item_Record) return Boolean
Parameters
Self
Return Value

Is_Link

function Is_Link
  (Self : not null access Canvas_Link_Record)
   return Boolean
Parameters
Self
Return Value

Is_Selectable

function Is_Selectable
  (Self       : not null access Canvas_Model_Record;
   Dummy_Item : not null access Abstract_Item_Record'Class)
   return Boolean

Whether the given item is selectable. By default, all items are selectable.

Parameters
Self
Dummy_Item
Return Value

Is_Selected

function Is_Selected
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)
   return Boolean

Handling of selection. Depending on the selection mode, some of these operations might have no effect, or might unselect the current selection before selecting a new item. The selection might contain child items (i.e. not just toplevel items).

Whenever the selection is changed, the signal "selection_changed" is emitted.

Parameters
Self
Item
Return Value

Item_Contents_Changed

procedure Item_Contents_Changed
  (Self : not null access Canvas_Model_Record'Class;
   Item : not null access Abstract_Item_Record'Class)

This signal should be emitted instead of layout_changed when only the contents of an item (but not its size) has changed). This will only trigger the refresh of that specific item.

Parameters
Self
Item

Item_Coordinate

subtype Item_Coordinate   is Gdouble;

We use subtypes for convenience in your applications to avoid casts.

Item_Event

function Item_Event
  (Self    : not null access Canvas_View_Record'Class;
   Details : Event_Details_Access) return Boolean

This signal is emitted whenever the user interacts with an item (button press or release, key events,...). It is recommended to connect to this signal rather than the lower-level Button_Press_Event, Button_Release_Event,... since most information is provided here in the form of the details parameter.

The callback should return True if the event was processed, or False if the default handling should be performed.

The package Gtkada.Canvas_View.Views contains a number of examples of compatible callbacks which enable behaviors such as a moving items, scrolling the canvas by dragging the background,...

Parameters
Self
Details
Return Value

Item_Kind_Filter

type Item_Kind_Filter is (Kind_Item, Kind_Link, Kind_Any);

Calls Callback for each item in the model, including links. Only the items that intersect In_Area should be returned for efficiency, although it is valid to return all items.

If Selected_Only is true, then only selected items are returned

Items are returned in z-layer order: lowest items first, highest items last.

You should not remove items while iterating, since removing items might end up removing other items (links to or from the original item for instance). Instead, create a temporary structure via Include_Related_Items and use Remove to remove them all at once.

Enumeration Literal
Kind_Item
Kind_Link
Kind_Any

Item_Point

subtype Item_Point  is Gtkada.Style.Point;

A point in various coordinates

Item_Point_Array

subtype Item_Point_Array is Gtkada.Style.Point_Array;

Item_Point_Array_Access

subtype Item_Point_Array_Access is Gtkada.Style.Point_Array_Access;

Item_Rectangle

type Item_Rectangle   is record
   X, Y, Width, Height : Item_Coordinate;
end record;

A rectangle in various coordinates

Record fields
X
Y
Width
Height

Item_Sets

package Item_Sets is new Ada.Containers.Hashed_Sets
  (Element_Type        => Abstract_Item,
   Hash                => Hash,
   Equivalent_Elements => "=",
   "="                 => "=");

Item_To_Model

function Item_To_Model
  (Item   : not null access Abstract_Item_Record'Class;
   P      : Item_Point) return Model_Point

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Item
P
Return Value

Item_To_Model

function Item_To_Model
  (Item   : not null access Abstract_Item_Record'Class;
   Rect   : Item_Rectangle) return Model_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Item
Rect
Return Value

Items_Lists

package Items_Lists is new Ada.Containers.Doubly_Linked_Lists
  (Abstract_Item);

Layout_Changed

procedure Layout_Changed (Self : not null access Canvas_Model_Record'Class)

Emits or handles the "layout_changed" signal. This signal must be emitted by models whenever new items are added, existing items are resized or removed, or any other event that impacts coordinates of any item in the model. It is recommended to emit this signal only once per batch of changes,

Parameters
Self

Link_Anchor_Point

function Link_Anchor_Point
  (Self   : not null access Abstract_Item_Record;
   Anchor : Anchor_Attachment)
   return Item_Point

Return the anchor point for links to or from this item. In general, this anchor point is in the middle of the item or depends on the Anchor parameter, and the link will automatically be clipped to one of the borders. The coordinates are absolute. This anchor point can be in the middle of an item, the link itself will be clipped with a call to Clip_Line_On_Top_Level

Parameters
Self
Anchor
Return Value

Link_Anchor_Point

function Link_Anchor_Point
  (Self   : not null access Canvas_Item_Record;
   Anchor : Anchor_Attachment)
   return Item_Point
Parameters
Self
Anchor
Return Value

Link_Anchor_Point

function Link_Anchor_Point
  (Self   : not null access Canvas_Link_Record;
   Anchor : Anchor_Attachment)
   return Item_Point
Parameters
Self
Anchor
Return Value

List_Canvas_Model

type List_Canvas_Model is access all List_Canvas_Model_Record'Class;

A very simple-minded concrete implementation for a model. This model is suitable for most cases where only a few thousands items are displayed. If you have tens of thousands, you should consider wrapping this model with a Gtkada.Canvas_View.Models.Rtree_Model to speed things up.

List_Canvas_Model_Record

type List_Canvas_Model_Record is new Canvas_Model_Record with private;

A very simple-minded concrete implementation for a model. This model is suitable for most cases where only a few thousands items are displayed. If you have tens of thousands, you should consider wrapping this model with a Gtkada.Canvas_View.Models.Rtree_Model to speed things up.

Lower_Item

procedure Lower_Item
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Change the z-order of the item. This emits the layout_changed signal

Parameters
Self
Item

Lower_Item

procedure Lower_Item
  (Self : not null access List_Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)
Parameters
Self
Item

Margins

type Margins is record
   Top, Right, Bottom, Left : Model_Coordinate;
end record;
Record fields
Top
Right
Bottom
Left

Middle_Attachment

Middle_Attachment : constant Anchor_Attachment := (0.5, 0.5, Auto, 0.0);

Where in the item the link is attached (0.5 means the middle, 0.0 means left or top, and 1.0 means right or bottom).

For the target side of a link, if X or Y are negative, Gtkada will try to draw a strictly orthogonal or vertical segment next on that end by adjusting the location of the end point along the border of the item. If it cannot, then GtkAda will use the absolute value of X and Y to specify the attachment.

You can therefore force a link to always emerge from the right side of an item by setting X to 1.0 and Y to any value, for instance. See the description of Side_Attachment for an example on how to use Toplevel_Side. Distance indicates at which distance from the border of the item the link should stop. By default, it reaches the border.

Model

function Model
  (Self  : not null access Canvas_View_Record'Class)
   return Canvas_Model

Return the model

Parameters
Self
Return Value

Model_Bounding_Box

function Model_Bounding_Box
  (Self     : not null access Abstract_Item_Record'Class)
   return Model_Rectangle

Return the bounding box of Self always in model coordinates. As opposed to Bounding_Box, model coordinates are also returned for nested items.

Parameters
Self
Return Value

Model_Coordinate

subtype Model_Coordinate  is Gdouble;

We use subtypes for convenience in your applications to avoid casts.

Model_Get_Type

function Model_Get_Type return Glib.GType

Return the internal type

Return Value

Model_Point

type Model_Point is record
   X, Y : Model_Coordinate;
end record;

A point in various coordinates

Record fields
X
Y

Model_Point_Array

type Model_Point_Array is array (Natural range <>) of Model_Point;

Model_Point_Array_Access

type Model_Point_Array_Access is access Model_Point_Array;

Model_Rectangle

type Model_Rectangle  is record
  X, Y, Width, Height : Model_Coordinate;
end record;

A rectangle in various coordinates

Record fields
X
Y
Width
Height

Model_To_Item

function Model_To_Item
  (Item   : not null access Abstract_Item_Record'Class;
   P      : Model_Point) return Item_Point

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Item
P
Return Value

Model_To_Item

function Model_To_Item
  (Item   : not null access Abstract_Item_Record'Class;
   P      : Model_Rectangle) return Item_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Item
P
Return Value

Model_To_View

function Model_To_View
  (Self   : not null access Canvas_View_Record;
   P      : Model_Point) return View_Point

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
P
Return Value

Model_To_View

function Model_To_View
  (Self   : not null access Canvas_View_Record;
   Rect   : Model_Rectangle) return View_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
Rect
Return Value

Model_To_Window

function Model_To_Window
  (Self   : not null access Canvas_View_Record;
   Rect   : Model_Rectangle) return Window_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
Rect
Return Value

No_Drag_Allowed

No_Drag_Allowed : constant Model_Rectangle := (0.0, 0.0, 0.0, 0.0);

Values for the Event_Details.Allowed_Drag_Area field

No_Item_Point

No_Item_Point : constant Item_Point := (Gdouble'First, Gdouble'First);

No_Margins

No_Margins : constant Margins := (0.0, 0.0, 0.0, 0.0);

No_Point

No_Point      : constant Model_Point := (Gdouble'First, Gdouble'First);

No_Position

No_Position : constant Gtkada.Style.Point := (Gdouble'First, Gdouble'First);

Indicates that the item did not get assigned a proper position

No_Rectangle

No_Rectangle  : constant Model_Rectangle := (0.0, 0.0, 0.0, 0.0);

Null_Canvas_Event_Details

Null_Canvas_Event_Details : constant Canvas_Event_Details :=
  Canvas_Event_Details'
    (Event_Type        => Custom,
     Button            => 0,
     State             => 0,
     Key               => 0,
     Root_Point        => (0.0, 0.0),
     M_Point           => (0.0, 0.0),
     Item              => null,
     Toplevel_Item     => null,
     T_Point           => (0.0, 0.0),
     I_Point           => (0.0, 0.0),
     Allowed_Drag_Area => (0.0, 0.0, 0.0, 0.0),
     Allow_Snapping    => False);

On_Edited

procedure On_Edited
  (Self     : not null access Editable_Text_Item_Record;
   Old_Text : String)

Called after the text has been edited

Parameters
Self
Old_Text

On_Inline_Editing_Finished

function On_Inline_Editing_Finished
  (Self : not null access Canvas_View_Record'Class;
   Call : not null access procedure
     (Self : access GObject_Record'Class; Item : Abstract_Item);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

Called when the user finishes (cancels ot validates) inline editing of items.

Parameters
Self
Call
Slot
Return Value

On_Inline_Editing_Started

function On_Inline_Editing_Started
  (Self : not null access Canvas_View_Record'Class;
   Call : not null access procedure
     (Self : access GObject_Record'Class; Item : Abstract_Item);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

Called when the user starts inline editing of items.

Parameters
Self
Call
Slot
Return Value

On_Item_Contents_Changed

function On_Item_Contents_Changed
  (Self : not null access Canvas_Model_Record'Class;
   Call : not null access procedure
     (Self : access GObject_Record'Class; Item : Abstract_Item);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

This signal should be emitted instead of layout_changed when only the contents of an item (but not its size) has changed). This will only trigger the refresh of that specific item.

Parameters
Self
Call
Slot
Return Value

On_Item_Destroyed

function On_Item_Destroyed
  (Self : not null access Canvas_Model_Record'Class;
   Call : not null access procedure
     (Self : access GObject_Record'Class;
      Item : Abstract_Item);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

This signal is emitted just before an item is destroyed.

Parameters
Self
Call
Slot
Return Value

On_Item_Event

procedure On_Item_Event
  (Self : not null access Canvas_View_Record'Class;
   Call : not null access function
     (Self    : not null access GObject_Record'Class;
      Details : Event_Details_Access)
   return Boolean;
   Slot : access GObject_Record'Class := null)

This signal is emitted whenever the user interacts with an item (button press or release, key events,...). It is recommended to connect to this signal rather than the lower-level Button_Press_Event, Button_Release_Event,... since most information is provided here in the form of the details parameter.

The callback should return True if the event was processed, or False if the default handling should be performed.

The package Gtkada.Canvas_View.Views contains a number of examples of compatible callbacks which enable behaviors such as a moving items, scrolling the canvas by dragging the background,...

Parameters
Self
Call
Slot

On_Layout_Changed

function On_Layout_Changed
  (Self : not null access Canvas_Model_Record'Class;
   Call : not null access procedure
     (Self : not null access GObject_Record'Class);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

Emits or handles the "layout_changed" signal. This signal must be emitted by models whenever new items are added, existing items are resized or removed, or any other event that impacts coordinates of any item in the model. It is recommended to emit this signal only once per batch of changes,

Parameters
Self
Call
Slot
Return Value

On_Selection_Changed

function On_Selection_Changed
  (Self : not null access Canvas_Model_Record'Class;
   Call : not null access procedure
     (Self : not null access GObject_Record'Class;
      Item : Abstract_Item);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

Item is set to null when the selection was cleared, otherwise it is set to the element that was just added or removed from the selection.

Parameters
Self
Call
Slot
Return Value

On_Viewport_Changed

function On_Viewport_Changed
  (Self : not null access Canvas_View_Record'Class;
   Call : not null access procedure
     (Self : not null access GObject_Record'Class);
   Slot : access GObject_Record'Class := null)
   return Gtk.Handlers.Handler_Id

This signal is emitted whenever the view is zoomed or scrolled. This can be used for instance to synchronize multiple views, or display a "mini-map" of the whole view.

Parameters
Self
Call
Slot
Return Value

Overflow_Style

type Overflow_Style is (Overflow_Prevent, Overflow_Hide);

An overflow situation occurs when an item's contents is larger than its contents. If Overflow_Prevent is true, an item will always request enough size to fit all its contents. There might still be cases where the parent item was set to a small size, though, and the overflow is hidden nonetheless. If Overflow_Hide is true, an item will request a minimal size, and simply hide the part of its contents that does not fit.

Enumeration Literal
Overflow_Prevent
Overflow_Hide

Page_Format

type Page_Format is record
   Width_In_Inches, Height_In_Inches : Gdouble;
end record;
Record fields
Width_In_Inches
Height_In_Inches

Parent

function Parent
  (Self : not null access Abstract_Item_Record)
   return Abstract_Item

Return the item inside which Self is contained. null is returned for toplevel items, in which case the coordinates of the bounding box are model coordinats. Otherwise, the coordinates are relative to the returned item.

Parameters
Self
Return Value

Parent

function Parent
  (Self : not null access Canvas_Item_Record)
   return Abstract_Item
Parameters
Self
Return Value

Parent

function Parent
  (Self : not null access Canvas_Link_Record)
   return Abstract_Item
Parameters
Self
Return Value

Parent

function Parent
  (Self : not null access Container_Item_Record)
   return Abstract_Item
Parameters
Self
Return Value

Point_In_Rect

function Point_In_Rect
  (Rect : Item_Rectangle; P : Item_Point) return Boolean

Whether the point is in the rectangle

Parameters
Rect
P
Return Value

Point_In_Rect

function Point_In_Rect
  (Rect : Model_Rectangle; P : Model_Point) return Boolean

Whether the point is in the rectangle

Parameters
Rect
P
Return Value

Polyline_Item

type Polyline_Item is access all Polyline_Item_Record'Class;

A predefine object that displays itself as a set of joined lines. This object can optionally contain children, and the polyline can thus be used to draw a polygon around those items

Polyline_Item_Record

type Polyline_Item_Record is new Container_Item_Record with private;

A predefine object that displays itself as a set of joined lines. This object can optionally contain children, and the polyline can thus be used to draw a polygon around those items

Position

function Position
  (Self : not null access Abstract_Item_Record)
   return Gtkada.Style.Point

The coordinates of the item within its parent. If the item has no parent, the coordinates should be returned in model coordinates. These coordinates describe the origin (0,0) point of the item's coordinate system (even if Set_Position was specified to point to another location in the item).

Parameters
Self
Return Value

Position

function Position
  (Self : not null access Canvas_Item_Record) return Gtkada.Style.Point
Parameters
Self
Return Value

Position

function Position
  (Self : not null access Canvas_Link_Record)
   return Gtkada.Style.Point
Parameters
Self
Return Value

Position

function Position
  (Self : not null access Container_Item_Record) return Gtkada.Style.Point
Parameters
Self
Return Value

Predefined_Page_Format_Type

type Predefined_Page_Format_Type is
  (A3_Portrait,
   A3_Landscape,
   A4_Portrait,
   A4_Landscape,
   Letter_Portrait,
   Letter_Landscape);
Enumeration Literal
A3_Portrait
A3_Landscape
A4_Portrait
A4_Landscape
Letter_Portrait
Letter_Landscape

Raise_Item

procedure Raise_Item
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Change the z-order of the item. This emits the layout_changed signal

Parameters
Self
Item

Raise_Item

procedure Raise_Item
  (Self : not null access List_Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)
Parameters
Self
Item

Rect_Item

type Rect_Item is access all Rect_Item_Record'Class;

A predefined type object which displays itself as a rectangle or a rectangle with rounded corners.

Rect_Item_Record

type Rect_Item_Record is new Container_Item_Record with private;

A predefined type object which displays itself as a rectangle or a rectangle with rounded corners.

Refresh_Layout

procedure Refresh_Layout
  (Self    : not null access Abstract_Item_Record;
   Context : Draw_Context)

Called when Refresh_Layout is called on the model. This is an opportunity for the item to update its size for instance, or do other computation that might impact the result of Bounding_Box.

Parameters
Self
Context

Refresh_Layout

procedure Refresh_Layout
  (Self    : not null access Canvas_Link_Record;
   Context : Draw_Context)

Recompute the layout/routing for the link. This procedure should be called whenever any of the end objects changes side or position. The view will do this automatically the first time, but will not update links later on.

Parameters
Self
Context

Refresh_Layout

procedure Refresh_Layout
  (Self        : not null access Canvas_Model_Record;
   Send_Signal : Boolean := True)

Refresh the layout of Self. This procedure should be called every time items are moved (because this impacts links to or from these items), or when they are added or removed (it could also impact the layout of links if they displays to avoid going underneath items). This procedure is also used to compute the size of items (see Container_Item below). The default implementation will simply iterate over all items, but it could be implemented more efficiently.

This procedure will in general send a Layout_Changed signal if Send_Signal is true. This should in general always be left to True unless you are writting your own model.

WARNING: this procedure must be called only once at least one view has been created for the model. This ensures that the necessary information for the layout of text has been retrieved from the view layer. If you do not have at least one view, all text will be hidden or displayed as ellipsis. In fact, this procedure is called automatically on the model the first time it is associated with a view.

Parameters
Self
Send_Signal

Refresh_Layout

procedure Refresh_Layout
  (Self    : not null access Container_Item_Record;
   Context : Draw_Context)

Anchor_X and Anchor_Y indicate which part of the item is at the given coordinates. For instance, (0, 0) indicates that Pos is the location of the top-left corner of the item, but (0.5, 0.5) indicates that Pos is the position of the center of the item.

Parameters
Self
Context

Refresh_Link_Layout

procedure Refresh_Link_Layout
  (Model : not null access Canvas_Model_Record'Class;
   Items : Item_Drag_Infos.Map := Item_Drag_Infos.Empty_Map)

Refresh the layout for all links (or only the ones linked to Item, or indirectly to a link to Item).

Parameters
Model
Items

Remove

procedure Remove
  (Self : not null access Canvas_Model_Record;
   Set  : Item_Sets.Set)

Remove all elements in the set from the model. It is expected that the set already contains related items (see Include_Related_Items) The default implementation is to call Remove for each of the element in the set, so you will need to override this procedure if your implementation of Remove calls this one.

Parameters
Self
Set

Remove

procedure Remove
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Remove an item from the model, and destroy it. This also removes all links to and from the element, and links to these links (and so on).

Parameters
Self
Item

Remove

procedure Remove
  (Self : not null access List_Canvas_Model_Record;
   Set  : Item_Sets.Set)
Parameters
Self
Set

Remove

procedure Remove
  (Self : not null access List_Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)
Parameters
Self
Item

Remove_From_Selection

procedure Remove_From_Selection
  (Self : not null access Canvas_Model_Record;
   Item : not null access Abstract_Item_Record'Class)

Handling of selection. Depending on the selection mode, some of these operations might have no effect, or might unselect the current selection before selecting a new item. The selection might contain child items (i.e. not just toplevel items).

Whenever the selection is changed, the signal "selection_changed" is emitted.

Parameters
Self
Item

Route_Style

type Route_Style is (Orthogonal, Straight, Arc, Curve);

This defines how a link is routed between its two ends. Curve is similar to orthogonal (links restricted to horizontal and vertical lines), but using a bezier curve.

Enumeration Literal
Orthogonal
Straight
Arc
Curve

Scale_To_Fit

procedure Scale_To_Fit
  (Self      : not null access Canvas_View_Record;
   Rect      : Model_Rectangle := No_Rectangle;
   Min_Scale : Gdouble := 1.0 / 4.0;
   Max_Scale : Gdouble := 4.0;
   Duration  : Standard.Duration := 0.0)

Chose the scale and scroll position so that the whole model (or the specified rectangle) is visible. This procedure leaves a small margin on each sides of the model, since that looks nicer. This function can be called even before Self has got a size assigned by window manager, but the computation of the scale will be delayed until an actual size is known. If a duration is specified, the scaling and scrolling will be animated

Parameters
Self
Rect
Min_Scale
Max_Scale
Duration

Scroll_Into_View

procedure Scroll_Into_View
  (Self     : not null access Canvas_View_Record;
   Rect     : Model_Rectangle;
   Duration : Standard.Duration := 0.0)

Do the minimal amount of scrolling to make the item or rectangle visible. If the duration is not 0, animation is used.

Parameters
Self
Rect
Duration

Scroll_Into_View

procedure Scroll_Into_View
  (Self     : not null access Canvas_View_Record;
   Item     : not null access Abstract_Item_Record'Class;
   Duration : Standard.Duration := 0.0)

Do the minimal amount of scrolling to make the item or rectangle visible. If the duration is not 0, animation is used.

Parameters
Self
Item
Duration

Selection_Changed

procedure Selection_Changed
  (Self : not null access Canvas_Model_Record'Class;
   Item : access Abstract_Item_Record'Class := null)

Item is set to null when the selection was cleared, otherwise it is set to the element that was just added or removed from the selection.

Parameters
Self
Item

Selection_Mode

type Selection_Mode is
  (Selection_None, Selection_Single, Selection_Multiple);

Controls whether items can be selected. Changing the mode always clears the selection.

Enumeration Literal
Selection_None
Selection_Single
Selection_Multiple

Set_Adjustment_Values

procedure Set_Adjustment_Values
  (Self : not null access Canvas_View_Record'Class)

Update the values for both adjustments

Parameters
Self

Set_Child_Layout

procedure Set_Child_Layout
  (Self   : not null access Container_Item_Record'Class;
   Layout : Child_Layout_Strategy)

How should the children of a container be organized: either one on top of another, or one next to another.

Parameters
Self
Layout

Set_Details

procedure Set_Details
  (Self    : not null access Canvas_View_Record'Class;
   Details : out Canvas_Event_Details;
   Event   : Gdk.Event.Gdk_Event_Button)

Set the details from a specific gtk+ event

Parameters
Self
Details
Event

Set_Directed

procedure Set_Directed
  (Self     : not null access Text_Item_Record;
   Directed : Text_Arrow_Direction := No_Text_Arrow)

Change the direction of the arrow. In particular, this is done automatically when the text is used on a link.

Parameters
Self
Directed

Set_Editable

procedure Set_Editable
   (Self   : not null access Editable_Text_Item_Record'Class;
    Editable : Boolean)

Sets whether Self can be edited interactively by double-clicking on it. You should also call Gtkada.Canvas_View.Views.Cancel_Inline_Editing in case some editing was taking place.

Parameters
Self
Editable

Set_Grid_Size

procedure Set_Grid_Size
  (Self : not null access Canvas_View_Record'Class;
   Size : Model_Coordinate := 30.0)

Set the size of the grid. This grid is not visible by default. To display it, you should override Draw_Internal and call one of the functions in Gtkada.Canvas_View.Views.

This grid is also size for snapping of items while they are moved: when they are dragged to a position close to one of the grid lines, they will be moved by a small extra amount to align on this grid line.

Parameters
Self
Size

Set_Height_Range

procedure Set_Height_Range
  (Self     : not null access Container_Item_Record;
   Min, Max : Size := Auto_Size)

Specify a minimal and maximal size for the item, along each axis. The default is for items to occupy the full width of their parent (in vertical layout) or the full height (in horizontal layout), and the child required by their children for the other axis. Calling this procedure overrides any specific size set via Set_Size or one of the constructors for the items, like rectangles and ellipsis, for that axis.

Parameters
Self
Min
Max

Set_Model

procedure Set_Model
   (Self  : not null access Canvas_View_Record'Class;
    Model : access Canvas_Model_Record'Class)

Change the model, and redraw the whole draw.

Parameters
Self
Model

Set_Offset

procedure Set_Offset
  (Self    : not null access Canvas_Link_Record;
   Offset  : Gdouble)

This only applies to arc links, and is used to specify the curve of the arc (this is basically the maximal distance between the straight line and the summit of the arc). Offset must not be 0.0

Parameters
Self
Offset

Set_Position

procedure Set_Position
  (Self     : not null access Abstract_Item_Record;
   Pos      : Gtkada.Style.Point)

Used to change the position of an item (by default an item cannot be moved). You must call the model's Refresh_Layout after moving items.

Parameters
Self
Pos

Set_Position

procedure Set_Position
  (Self     : not null access Canvas_Item_Record;
   Pos      : Gtkada.Style.Point)

Sets the position of the item within its parent (or within the canvas view if Self has no parent).

Parameters
Self
Pos

Set_Position

procedure Set_Position
  (Self     : not null access Container_Item_Record;
   Pos      : Gtkada.Style.Point)

Anchor_X and Anchor_Y indicate which part of the item is at the given coordinates. For instance, (0, 0) indicates that Pos is the location of the top-left corner of the item, but (0.5, 0.5) indicates that Pos is the position of the center of the item.

Parameters
Self
Pos

Set_Position

procedure Set_Position
  (Self     : not null access Container_Item_Record;
   Pos      : Gtkada.Style.Point := (Gdouble'First, Gdouble'First);
   Anchor_X : Percent;
   Anchor_Y : Percent)

Anchor_X and Anchor_Y indicate which part of the item is at the given coordinates. For instance, (0, 0) indicates that Pos is the location of the top-left corner of the item, but (0.5, 0.5) indicates that Pos is the position of the center of the item.

Parameters
Self
Pos
Anchor_X
Anchor_Y

Set_Scale

procedure Set_Scale
  (Self     : not null access Canvas_View_Record;
   Scale    : Gdouble := 1.0;
   Preserve : Model_Point := No_Point)

Changes the scaling factor for Self. This also scrolls the view so that either Preserve or the current center of the view remains at the same location in the widget, as if the user was zooming towards that specific point. See also Gtkada.Canvas_View.Views.Animate_Scale for a way to do this change via an animation.

Parameters
Self
Scale
Preserve

Set_Selection_Mode

procedure Set_Selection_Mode
  (Self : not null access Canvas_Model_Record;
   Mode : Selection_Mode)

Controls whether items can be selected. Changing the mode always clears the selection.

Parameters
Self
Mode

Set_Selection_Style

procedure Set_Selection_Style
  (Self  : not null access Canvas_View_Record;
   Style : Gtkada.Style.Drawing_Style)

The style used to highlight selected items

Parameters
Self
Style

Set_Size

procedure Set_Size
   (Self : not null access Container_Item_Record;
    Width, Height : Size := Auto_Size)

Force a specific size for the item if any of the dimensions is positive. When Auto_Size is given, the size along that axis will be computed automatically. Calling this procedure cancels effects from Set_Size_Range. The size of a container is influenced by its children as follows: * the preferred size for each child is computed, based on its own intrinsic needs (given size for rectangles, text size,...) * if the child has a min and max size given in pixels, these constraints are applied immediately. * the container will then use the maximal computed size amongst its children. * Once the size of the container is known, the size for its children is recomputed when the size or the size constraints were given as percent of the parent size. It means that sizees given in percent do not influence the parent's size computation.

Parameters
Self
Width
Height

Set_Size_Request

procedure Set_Size_Request
  (Self    : not null access Container_Item_Record;
   Width, Height : Gdouble := -1.0)

This procedure should only be called from an override of Size_Request (but it can then be called for any item, not just the one passed in parameter). It can be used to request a specific size for an item, or override the size already computed. When Width or Height is negative, they do not override the existing size request.

Parameters
Self
Width
Height

Set_Snap

procedure Set_Snap
  (Self           : not null access Canvas_View_Record'Class;
   Snap_To_Grid   : Boolean := True;
   Snap_To_Guides : Boolean := False;
   Snap_Margin    : Model_Coordinate := 5.0;
   Guides_Style   : Gtkada.Style.Drawing_Style := Default_Guide_Style)

Configure the snapping feature. When items are moved interactively, they will tend to snap to various coordinates, as defined for instance by Set_Grid_Size. For instance, when any size of the item gets close to one of the grid lines (i.e. less than Snap_Margin), it will be moved an extra small amount so that the coordinate of that size of the item is exactly that of the grid line. This results in nicer alignment of the items.

No snapping to grid occurs if the grid size is set to 0.

Parameters
Self
Snap_To_Grid
Snap_To_Guides
Snap_Margin
Guides_Style

Set_Style

procedure Set_Style
  (Self  : not null access Canvas_Link_Record;
   Style : Drawing_Style)

Return the style used for the drawingo of this link. When changing the style, you must force a refresh of the canvas.

Parameters
Self
Style

Set_Style

procedure Set_Style
  (Self  : not null access Container_Item_Record;
   Style : Drawing_Style)

Return the style used for the drawingo of this item. When changing the style, you must force a refresh of the canvas.

Parameters
Self
Style

Set_Text

procedure Set_Text
  (Self : not null access Text_Item_Record;
   Text : String)

Change the text displayed in the item. This does not force a refresh of the item, and it is likely that you will need to call the Model's Refresh_Layout method to properly recompute sizes of items and link paths.

Parameters
Self
Text

Set_Topleft

procedure Set_Topleft
  (Self         : not null access Canvas_View_Record;
   Topleft      : Model_Point)

Set a specific position for the topleft corner of the visible area. This function is mostly useful to restore previous settings (which you can get through Get_Visible_Area). Interactively, it is likely better to call one of Center_On, Scroll_Into_View or Scale_To_Fit.

Parameters
Self
Topleft

Set_Transform

procedure Set_Transform
  (Self   : not null access Canvas_View_Record;
   Cr     : Cairo.Cairo_Context;
   Item   : access Abstract_Item_Record'Class := null)

Set the transformation matrix for the current settings (scrolling and zooming).

The effect is that any drawing on this context should now be done using the model coordinates, which will automatically be converted to the canvas_coordinates internally.

If Item is specified, all drawing becomes relative to that item instead of the position of the top-left corner of the view. All drawing to this context must then be done in item_coordinates, which will automatically be converted to canvas_coordinates internally.

This procedure does not need to be call directly in general, since the context passed to the Draw primitive of the item has already been set up appropriately.

The default coordinates follow the industry standard of having y increase downwards. This is sometimes unusual for mathematically- oriented people. One solution is to override this procedure in your own view, and call Cairo.Set_Scale as in: procedure Set_Transform (Self, Cr) is Set_Transform (Canvas_View_Record (Self.all)'Access, Cr); Cairo.Set_Scale (Cr, 1.0, -1.0); which will make y increase upwards instead.

Parameters
Self
Cr
Item

Set_Visibility_Threshold

procedure Set_Visibility_Threshold
  (Self      : not null access Abstract_Item_Record;
   Threshold : Gdouble)

When the items bounding box (on the screen) width or height are less than Threshold pixels, the item is automatically hidden. Making the item invisibile does not impact the visibility of links from or to that item (but you could use Include_Related_Items to find these related items. You need to refresh the view afterwards

Parameters
Self
Threshold

Set_Visibility_Threshold

procedure Set_Visibility_Threshold
  (Self      : not null access Canvas_Item_Record;
   Threshold : Gdouble)
Parameters
Self
Threshold

Set_Visibility_Threshold

procedure Set_Visibility_Threshold
  (Self      : not null access Canvas_Link_Record;
   Threshold : Gdouble)
Parameters
Self
Threshold

Set_Waypoints

procedure Set_Waypoints
  (Self     : not null access Canvas_Link_Record;
   Points   : Item_Point_Array;
   Relative : Boolean := False)

Set explicit waypoints for the link, which forces the link to go through the given points. Relative should be true if all

Parameters
Self
Points
Relative

Set_Width_Range

procedure Set_Width_Range
  (Self     : not null access Container_Item_Record;
   Min, Max : Size := Auto_Size)

Specify a minimal and maximal size for the item, along each axis. The default is for items to occupy the full width of their parent (in vertical layout) or the full height (in horizontal layout), and the child required by their children for the other axis. Calling this procedure overrides any specific size set via Set_Size or one of the constructors for the items, like rectangles and ellipsis, for that axis.

Parameters
Self
Min
Max

Show

procedure Show (Self : not null access Abstract_Item_Record'Class)

Hide or show the item unconditionally. This overrides the settings done by Set_Visibility_Threshold.

Parameters
Self

Side_Attachment

type Side_Attachment is (Auto, Top, Right, Bottom, Left, No_Clipping);

Which side of the toplevel item the link is attached to.

For toplevel items, this can be controlled by using the Anchor_Attachment's X and Y properties. But for nested item, this forces the link to start from the toplevel item's border. Here is an example: +----------+ | +-+ | | |A| || +-+ | \1 | B |\ +----------+ \ 2\ +----------------+ \| C | +----------------+

The link 1 is attached to the nested item A, and the side_attachment is set to Right. As a result, it always starts at the same height as A itself. The link 2 is also attached to A, but the side is set to Auto. So the canvas draws the shortest path from A to C (and clips the line to the border of B). So it is not as visible that 2 is linked to A.

The "No_Clipping" side should be used when a link is connected to another link, since in that case there is no notion of link.

Enumeration Literal
Auto
Top
Right
Bottom
Left
No_Clipping

Signal_Inline_Editing_Finished

Signal_Inline_Editing_Finished : constant Glib.Signal_Name :=
   "inline_editing_finished";

Called when the user finishes (cancels ot validates) inline editing of items.

Signal_Inline_Editing_Started

Signal_Inline_Editing_Started : constant Glib.Signal_Name :=
   "inline_editing_started";

Called when the user starts inline editing of items.

Signal_Item_Contents_Changed

Signal_Item_Contents_Changed : constant Glib.Signal_Name :=
  "item_contents_changed";

This signal should be emitted instead of layout_changed when only the contents of an item (but not its size) has changed). This will only trigger the refresh of that specific item.

Signal_Item_Destroyed

Signal_Item_Destroyed : constant Glib.Signal_Name := "item_destroyed";

This signal is emitted just before an item is destroyed.

Signal_Item_Event

Signal_Item_Event : constant Glib.Signal_Name := "item_event";

This signal is emitted whenever the user interacts with an item (button press or release, key events,...). It is recommended to connect to this signal rather than the lower-level Button_Press_Event, Button_Release_Event,... since most information is provided here in the form of the details parameter.

The callback should return True if the event was processed, or False if the default handling should be performed.

The package Gtkada.Canvas_View.Views contains a number of examples of compatible callbacks which enable behaviors such as a moving items, scrolling the canvas by dragging the background,...

Signal_Layout_Changed

Signal_Layout_Changed : constant Glib.Signal_Name := "layout_changed";

Emits or handles the "layout_changed" signal. This signal must be emitted by models whenever new items are added, existing items are resized or removed, or any other event that impacts coordinates of any item in the model. It is recommended to emit this signal only once per batch of changes,

Signal_Selection_Changed

Signal_Selection_Changed : constant Glib.Signal_Name := "selection_changed";

Item is set to null when the selection was cleared, otherwise it is set to the element that was just added or removed from the selection.

Signal_Viewport_Changed

Signal_Viewport_Changed : constant Glib.Signal_Name := "viewport_changed";

This signal is emitted whenever the view is zoomed or scrolled. This can be used for instance to synchronize multiple views, or display a "mini-map" of the whole view.

Size

type Size (Unit : Size_Unit := Unit_Pixels) is record
   case Unit is
      when Unit_Auto | Unit_Fit =>
         null;
      when Unit_Pixels =>
         Length : Model_Coordinate;
      when Unit_Percent =>
         Value  : Percent;
   end case;
end record;
Record fields
Unit
Length
Value

Size_Allocate

procedure Size_Allocate
  (Self  : not null access Container_Item_Record)

Called once the size of the parent object has been decided (i.e. after all the calls to Size_Request). The parent must set its child's position and size, and then call Size_Allocate to let it know about the final size and position. This can be used to compute attributes that need the actual size of the item (gradients, centering or right-aligning objects,...) Alignments and margins are automatically handled by the parent.

Parameters
Self

Size_Request

procedure Size_Request
  (Self    : not null access Container_Item_Record;
   Context : Draw_Context)

Compute the ideal size for Self. It might be either a size specifically forced by the user, or computed from Self's children's own size_request. The size is stored internally in the object. The requested size must not include the margins that were defined in Add_Child. Self can modify its computed position (i.e. the position within its parent) as part of the size computation in this procedure. One example of overridding this procedure is when you are building an item which shoud align some text on two columns (for instance in a UML diagram we might want the field names and their types to each be on their own column. In this case, the container's Size_Request would first call the inherited version (so that each child requests a size), then iterate over the children in each column and compute the maximum requested width for that column. Finally, another pass for the children in each column to call Set_Size_Request and override their requested width.

Parameters
Self
Context

Size_Request

procedure Size_Request
  (Self    : not null access Hr_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Size_Request

procedure Size_Request
  (Self    : not null access Image_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Size_Request

procedure Size_Request
  (Self    : not null access Polyline_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Size_Request

procedure Size_Request
  (Self    : not null access Text_Item_Record;
   Context : Draw_Context)
Parameters
Self
Context

Size_Unit

type Size_Unit is (Unit_Pixels, Unit_Percent, Unit_Auto, Unit_Fit);

A size can be expressed either in actual screen pixels, or proportionnaly to the parent's size. When the unit is Unit_Auto, the size of the item is computed automatically based on its children or its own intrinsic needs (for a text, this is the size needed to display the text in the given font). When the unit is Unit_Fit: this sets the width of a child so that this width plus the child's margins take the full width of the parent container. Setting a width to 100% using Unit_Percent would not take the margins into account, so that the full size (margins+width) might actually be wider than the parent. When the parent layout is horizontal, the above description applies to the height of the child. In both cases, Unit_Fit is ignored for the other axis (height for a vertical layout), in which case the child's height will be that computed from the children.

Enumeration Literal
Unit_Pixels
Unit_Percent
Unit_Auto
Unit_Fit

Text_Arrow_Direction

type Text_Arrow_Direction is
  (No_Text_Arrow,
   Up_Text_Arrow,
   Down_Text_Arrow,
   Left_Text_Arrow,
   Right_Text_Arrow);
Enumeration Literal
No_Text_Arrow
Up_Text_Arrow
Down_Text_Arrow
Left_Text_Arrow
Right_Text_Arrow

Text_Item

type Text_Item is access all Text_Item_Record'Class;

A predefined object that displays itself as text.

Text_Item_Record

type Text_Item_Record is new Container_Item_Record with private;

A predefined object that displays itself as text.

To

procedure To
  (Self : not null access Canvas_Model_Record'Class;
   Item : not null access Abstract_Item_Record'Class;
   Set  : in out Item_Sets.Set)

Append all the items with a link going to Item

Parameters
Self
Item
Set

To_Page_Format

function To_Page_Format
  (Value : Predefined_Page_Format_Type) return Page_Format
Parameters
Value
Return Value

Toplevel_Item_At

function Toplevel_Item_At
  (Self    : not null access Canvas_Model_Record;
   Point   : Model_Point;
   Context : Draw_Context) return Abstract_Item

Return the toplevel item at the specific coordinates (if any). The default implementation simply traverses the list of items, and calls Contains on each child. This function returns the topmost item

Parameters
Self
Point
Context
Return Value

Toplevel_Item_At

function Toplevel_Item_At
  (Self    : not null access List_Canvas_Model_Record;
   Point   : Model_Point;
   Context : Draw_Context) return Abstract_Item
Parameters
Self
Point
Context
Return Value

Translate_And_Draw_Item

procedure Translate_And_Draw_Item
  (Self          : not null access Abstract_Item_Record'Class;
   Context       : Draw_Context;
   As_Outline    : Boolean := False;
   Outline_Style : Drawing_Style := No_Drawing_Style)

Translate the transformation matrix and draw the item. This procedure should be used instead of calling Draw directly. If As_Outline is true, then only the outline of the item is displayed, using the provided style

Parameters
Self
Context
As_Outline
Outline_Style

Union

procedure Union
  (Rect1 : in out Model_Rectangle;
   Rect2 : Model_Rectangle)

Store in Rect1 the minimum rectangle that contains both Rect1 and Rect2.

Parameters
Rect1
Rect2

View_Coordinate

subtype View_Coordinate   is Gdouble;

We use subtypes for convenience in your applications to avoid casts.

View_Get_Type

function View_Get_Type return Glib.GType

Return the internal type

Return Value

View_Margin

View_Margin : constant View_Coordinate := 20.0;

The number of blank pixels on each sides of the view. This avoids having items displays exactly next to the border of the view.

View_Point

type View_Point  is record
   X, Y : View_Coordinate;
end record;

A point in various coordinates

Record fields
X
Y

View_Rectangle

type View_Rectangle   is record
   X, Y, Width, Height : View_Coordinate;
end record;

A rectangle in various coordinates

Record fields
X
Y
Width
Height

View_To_Model

function View_To_Model
  (Self   : not null access Canvas_View_Record;
   P      : View_Point) return Model_Point

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
P
Return Value

View_To_Model

function View_To_Model
  (Self   : not null access Canvas_View_Record;
   Rect   : View_Rectangle) return Model_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
Rect
Return Value

Viewport_Changed

procedure Viewport_Changed
  (Self   : not null access Canvas_View_Record'Class)

This signal is emitted whenever the view is zoomed or scrolled. This can be used for instance to synchronize multiple views, or display a "mini-map" of the whole view.

Parameters
Self

Window_Coordinate

subtype Window_Coordinate is Gdouble;

We use subtypes for convenience in your applications to avoid casts.

Window_Point

type Window_Point  is record
   X, Y : Window_Coordinate;
end record;

A point in various coordinates

Record fields
X
Y

Window_Rectangle

type Window_Rectangle is record
   X, Y, Width, Height : Window_Coordinate;
end record;

A rectangle in various coordinates

Record fields
X
Y
Width
Height

Window_To_Model

function Window_To_Model
  (Self   : not null access Canvas_View_Record;
   P      : Window_Point) return Model_Point

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
P
Return Value

Window_To_Model

function Window_To_Model
  (Self   : not null access Canvas_View_Record;
   Rect   : Window_Rectangle) return Model_Rectangle

Conversion between the various coordinate systems. Calling these should seldom be needed, as Cairo uses a transformation matrix to automatically (and efficiently) do the transformation on your behalf. See the documentation for Set_Transform.

Parameters
Self
Rect
Return Value