## Documentation

Table of Contents
Class Inheritance Tree
Widget Screenshots
Package groups

1.     -----------------------------------------------------------------------

2.     --               GtkAda - Ada95 binding for Gtk+/Gnome               --

3.     --                                                                   --

4.     --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   --

5.     --                Copyright (C) 2000-2011, AdaCore                   --

6.     --                                                                   --

7.     -- This library is free software; you can redistribute it and/or     --

8.     -- modify it under the terms of the GNU General Public               --

9.     -- License as published by the Free Software Foundation; either      --

10.     -- version 2 of the License, or (at your option) any later version.  --

11.     --                                                                   --

12.     -- This library is distributed in the hope that it will be useful,   --

13.     -- but WITHOUT ANY WARRANTY; without even the implied warranty of    --

14.     -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --

15.     -- General Public License for more details.                          --

16.     --                                                                   --

17.     -- You should have received a copy of the GNU General Public         --

18.     -- License along with this library; if not, write to the             --

19.     -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      --

20.     -- Boston, MA 02111-1307, USA.                                       --

21.     --                                                                   --

22.     -- As a special exception, if other files instantiate generics from  --

23.     -- this unit, or you link this unit with other files to produce an   --

24.     -- executable, this  unit  does not  by itself cause  the resulting  --

25.     -- executable to be covered by the GNU General Public License. This  --

26.     -- exception does not however invalidate any other reasons why the   --

27.     -- executable file  might be covered by the  GNU Public License.     --

28.     -----------------------------------------------------------------------

30.     --  <description>

31.     --  This package provides an interactive canvas, on which the user can put

32.     --  items, move them with the mouse, etc. The items can be connected together,

33.     --  and the connections remain active while the items are moved.

34.     --

35.     --  It also supports scrolling if put in a Gtk_Scrolled_Window.

36.     --  The canvas will be scrolled (and the selected items moved) if an item is

37.     --  selected and the mouse is dragged on a small area on the side of the canvas

38.     --  or even directly outside of the canvas. Scrolling will continue until the

39.     --  mouse is either released or moved back inside the canvas.

40.     --

41.     --  The scrolling speed will slightly increase over time if the mouse is kept

42.     --  outside of the canvas. This makes the canvas much more comfortable to use

43.     --  for the user.

44.     --

45.     --  All items put in this canvas must inherit from the type Canvas_Item_Record.

46.     --  However, it is your responsability, as a programmer, to provide drawing

47.     --  routines. In fact, all these items should draw in a pixmap, which is then

48.     --  copied automatically to the screen whenever the canvas needs to redraw

49.     --  itself.

50.     --

51.     --  The items can also react to mouse events: mouse clicks are transmitted to

52.     --  the item if the mouse did not move more than a given amount of pixels.

53.     --  To decide what their reaction should be, you should override the

54.     --  On_Button_Click subprogram.

55.     --

56.     --  This canvas is not intended for cases where you want to put hundreds of

57.     --  items on the screen. For instance, it does not provide any smart

58.     --  double-buffering other than the one provided by gtk+ itself, and thus you

59.     --  would get some flicker if there are too many items.

60.     --

61.     --  There are three coordinate systems used by widget. All the subprograms

62.     --  expect a specific coordinate system as input or output. Here are the three

63.     --  systems:

64.     --    - World coordinates

65.     --      The position of an item is reported in pixels, as if the canvas

66.     --      currently had a zoom level of 100%. This is fully independent, at any

67.     --      time, from the current zoom level of the canvas.

68.     --      Since the canvas is considered to expand ad infinitum, the top-left

69.     --      corner doesn't have any specific fixed coordinates. It can be known by

70.     --      checking the current lower value of the adjustments (aka scrollbars).

71.     --

72.     --    - Canvas coordinates

73.     --      This is similar to world coordinates, except these depend on the

74.     --      current zoom level of the canvas. This also affect the width and height

75.     --      of the objects in the canvas.

76.     --      The subprograms To_Canvas_Coordinates and To_World_Coordinates can be

77.     --      used to convert lengths from world to canvas coordinates.

78.     --      The same behavior as world coordinates applies for the top-left corner.

79.     --      All drawing to the screen, in particular for Draw_Background, must be

80.     --      done using this coordinate systems

81.     --

82.     --    - Item coordinates

83.     --      The position of a point is relative to the top-left corner of the

84.     --      current item. This corner therefore has coordinates (0, 0).

85.     --      This coordinate systems assumes a zoom-level of 100%

86.     --

87.     --  Items are selected automatically when they are clicked. If Control is

88.     --  pressed at the same time, multiple items can be selected.

89.     --  If the background is clicked (and control is not pressed), then all items

90.     --  are unselected.

91.     --  Pressing and dragging the mouse in the backgroudn draws a virtual box on

92.     --  the screen. All the items fully included in this box when it is released

93.     --  will be selected (this will replace the current selection if Control was

94.     --  not pressed).

95.     --

96.     --  </description>

97.     --  <group>Drawing</group>

98.     --  <testgtk>create_canvas.adb</testgtk>

99.     --  <screenshot>gtkada-canvas</screenshot>

101.     with Ada.Calendar;

103.     with CairoTo API docTo specTo body;

104.     with Cairo.RegionTo API docTo specTo body;

106.     with Gdk.ColorTo API docTo specTo body;

107.     with Gdk.EventTo API docTo specTo body;

109.     with GlibTo API docTo specTo body;

110.     with Glib.GraphsTo API docTo specTo body;

111.     with Glib.MainTo API docTo specTo body;

113.     with Gtk.AdjustmentTo API docTo specTo body;

114.     with Gtk.Drawing_AreaTo API docTo specTo body;

116.     with Pango.FontTo API docTo specTo body;

117.     with Pango.LayoutTo API docTo specTo body;

119.     package Gtkada.CanvasTo API docTo specTo body is

121.        type Interactive_Canvas_RecordTo API docTo body is new

122.          Gtk.Drawing_Area.Gtk_Drawing_Area_RecordTo API docTo spec with private;

123.        type Interactive_Canvas is access all Interactive_Canvas_RecordTo API docTo specTo body'Class;

124.        --  A canvas on which items are put.

125.        --  Each item can be moved interactively by the user, and links can be

126.        --  drawn automatically from an item to another.

127.        --  This widget can be inserted directly in a scrolled window to provide

128.        --  support for scrolling.

130.        type Canvas_Item_RecordTo API docTo body is abstract new Glib.Graphs.VertexTo API docTo specTo body with private;

131.        type Canvas_Item is access all Canvas_Item_RecordTo API docTo specTo body'Class;

132.        --  An item that can be put on the canvas.

133.        --  This is an abstract type, as it does not provide any default drawing

134.        --  routine. You must override the abstract Draw subprogram.

136.        type Canvas_Link_RecordTo API docTo body is new Glib.Graphs.EdgeTo API docTo specTo body with private;

137.        type Canvas_Link is access all Canvas_Link_RecordTo API docTo specTo body'Class;

138.        type Canvas_Link_Access is access all Canvas_Link_RecordTo API docTo specTo body;

139.        --  A link between two items in the canvas.

140.        --  The implementation provided in this package provides links that can

141.        --  be either straight links or curved links.

142.        --  This type is provided as a tagged type so that you can associated your

143.        --  own user data with it.

145.        -------------------

146.        -- Customization --

147.        -------------------

148.        --  These are the default configuration values for the canvas. All the

149.        --  values can be changed by the Configure subprogram.

151.        Default_Annotation_Font  : constant String := "Helvetica 8";

152.        --  Font used when displaying link annotation. See Pango.Font for the

153.        --  format.

155.        Default_Grid_Size        : constant := 15;

156.        --  Number of pixels between two dots on the grid.

157.        --  This is used for both horizontal and vertical orientation.

159.        Default_Arc_Link_Offset  : constant := 25;

160.        --  Distance between two parallel arcs for two links. This is not the exact

161.        --  distance, and it only used to compute the control points for the bezier

162.        --  curves.

164.        Default_Arrow_Angle      : constant := 30;

165.        --  Half angle for the arrows in degres

167.        Default_Arrow_Length     : constant := 6;

168.        --  Length of the arrows in pixels.

170.        Default_Motion_Threshold : constant := 4.0;

171.        --  Mimimum motion the mouse must have before we start moving the selected

172.        --  item. If the mouse has moved less than that amount of pixels in any

173.        --  direction, then the mouse click is considered as being a selection

174.        --  only and is transfered to the item itself.

175.        --  This is in screen coordinates

177.        ----------------

178.        -- Enum types --

179.        ----------------

181.        type Arrow_Type is

182.          (No_Arrow,

183.           --  the link does not have an arrow

185.           Start_Arrow,

186.           --  the link has an arrow at its beginning

188.           End_Arrow,

189.           --  the link has an arrow at the end

191.           Both_Arrow

192.           --  the link has an arrow on both sides

193.          );

194.        --  Indicate whether the links have an arrow or not.

196.        -----------------------

197.        -- Creating a canvas --

198.        -----------------------

200.        procedure Gtk_NewTo API docTo body

201.          (Canvas : out Interactive_CanvasTo API docTo spec; Auto_Layout : Boolean := True);

202.        --  Create a new empty Canvas.

203.        --  If Auto_Layout is True, then the items are automatically positioned as

204.        --  they are put in the canvas, if no coordinates are specified.

206.        procedure InitializeTo API docTo body

207.          (Canvas      : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

208.           Auto_Layout : Boolean := True);

209.        --  Internal function used to initialize the canvas.

211.        procedure ConfigureTo API docTo body

212.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

213.           Grid_Size        : Glib.GuintTo API docTo spec := Default_Grid_SizeTo API docTo spec;

214.           Annotation_Font  : Pango.Font.Pango_Font_DescriptionTo API docTo spec :=

215.                                Pango.Font.From_StringTo API docTo specTo body (Default_Annotation_FontTo API docTo spec);

216.           Arc_Link_Offset  : Glib.GintTo API docTo spec := Default_Arc_Link_OffsetTo API docTo spec;

217.           Arrow_Angle      : Glib.GintTo API docTo spec := Default_Arrow_AngleTo API docTo spec;

218.           Arrow_Length     : Glib.GintTo API docTo spec := Default_Arrow_LengthTo API docTo spec;

219.           Motion_Threshold : Glib.GdoubleTo API docTo spec := Default_Motion_ThresholdTo API docTo spec);

220.        --  Change the parameters for the canvas.

221.        --  A Grid_Size of 0 means than no grid should be drawn in the background of

222.        --  canvas. Note that in that case you can never activate Align_On_Grid.

223.        --  This setting doesn't apply if you have redefined Draw_Background, which

224.        --  may not draw a grid.

226.        function Get_VadjTo API docTo body

227.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class)

228.           return Gtk.Adjustment.Gtk_AdjustmentTo API docTo spec;

229.        --  Return the vertical adjustment associated with Canvas

231.        function Get_HadjTo API docTo body

232.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class)

233.           return Gtk.Adjustment.Gtk_AdjustmentTo API docTo spec;

234.        --  Return the horizontal adjustment associated with Canva

236.        procedure Get_Bounding_BoxTo API docTo body

237.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

238.           Width  : out Glib.GdoubleTo API docTo spec;

239.           Height : out Glib.GdoubleTo API docTo spec);

240.        --  Return the size occupied by the items drawn on the canvas.

242.        procedure Draw_AreaTo API docTo body

243.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

244.           RectTo API docTo body   : Cairo.Region.Cairo_Rectangle_IntTo API docTo spec);

245.        --  Draw in Canvas the specified area.

247.        procedure Draw_AllTo API docTo body

248.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

249.           Cr     : Cairo.Cairo_ContextTo API docTo spec);

250.        --  Draws the whole canvas in Cr. Useful to print the canvas on an SVG or

251.        --  PNG surface.

253.        procedure Draw_BackgroundTo API docTo body

254.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

255.           Cr     : Cairo.Cairo_ContextTo API docTo spec);

256.        --  Draw the background of the canvas. This procedure should be overriden if

257.        --  you want to draw something else on the background. It must first clear

258.        --  the area on the screen.

259.        --

260.        --  The default implementation draws a grid.

261.        --

262.        --  An example implementation that draws a background image is shown at the

263.        --  end of this file.

265.        procedure Draw_GridTo API docTo body

266.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

267.           Cr     : Cairo.Cairo_ContextTo API docTo spec);

268.        --  Helper function that can be called from Draw_Background. It cannot be

269.        --  used directly as Draw_Background, since it doesn't clear the area first.

271.        procedure Set_Orthogonal_LinksTo API docTo body

272.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

273.           Orthogonal : Boolean);

274.        --  If Orthogonal is True, then all the links will be drawn only with

275.        --  vertical and horizontal lines. This is not applied for the second or

276.        --  more link between two items.

278.        function Get_Orthogonal_LinksTo API docTo body

279.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body) return Boolean;

280.        --  Return True if the links are only drawn horizontally and vertically.

282.        procedure Align_On_GridTo API docTo body

283.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

284.           Align  : Boolean := True);

285.        --  Choose whether the items should be aligned on the grid when moved.

286.        --  Existing items are not moved even if you set this parameter to True,

287.        --  this will only take effect the next time the items are moved.

289.        function Get_Align_On_GridTo API docTo body

290.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body) return Boolean;

291.        --  Return True if items are currently aligned on grid.

293.        procedure Move_ToTo API docTo body

294.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

295.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class;

296.           X, Y   : Glib.GintTo API docTo spec := Glib.GintTo API docTo spec'First);

297.        --  Move the item in the canvas, to world coordinates (X, Y).

298.        --  Item is assumed to be already in the canvas.

299.        --  If you leave both coordinates X and Y to their default value, then the

300.        --  item's location will be automatically computed when you layout the

301.        --  canvas (it is your responsability to call Layout).

303.        procedure Set_ItemsTo API docTo body

304.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

305.           ItemsTo API docTo body  : Glib.Graphs.GraphTo API docTo specTo body);

306.        --  Set the items and links to display in the canvas from Items.

307.        --  All items previously in the canvas are removed, and replaced by the

308.        --  vertices in Items.

309.        --  Note that the vertices in Items must be in Canvas_Item_Record'Class, and

310.        --  the links must be in Canvas_Link_Record'Class.

311.        --  If you do not have an automatic layout set up in Canvas, you need to set

312.        --  the coordinates of all the vertices by calling Move_To separately.

313.        --

314.        --  You mustn't destroy items yourself, this is done automatically when the

315.        --  canvas is destroyed.

317.        procedure PutTo API docTo body

318.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

319.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class;

320.           X, Y   : Glib.GintTo API docTo spec := Glib.GintTo API docTo spec'First);

321.        --  Add a new item to the canvas, at world coordinates (X, Y).

322.        --  The item is added at a specific location.

323.        --  If you leave both X and Y to their default value, the item's location

324.        --  will be computed automatically when you call Layout on the canvas,

325.        --  unless Auto_Layout has been set, in which case the position will be

326.        --  computed immediately.

328.        function Item_At_CoordinatesTo API docTo body

329.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

330.           X, Y : Glib.GintTo API docTo spec) return Canvas_ItemTo API docTo spec;

331.        --  Return the item at world coordinates (X, Y) which is on top of all

332.        --  others.

333.        --  null is returned if there is no such item.

335.        function Item_At_CoordinatesTo API docTo body

336.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body; Event : Gdk.Event.Gdk_EventTo API docTo spec)

337.           return Canvas_ItemTo API docTo spec;

338.        --  Same as above, but using the canvas coordinates of the event, taking

339.        --  into account the current zoom level and current scrolling

341.        procedure Item_At_CoordinatesTo API docTo body

342.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

343.           Event  : Gdk.Event.Gdk_EventTo API docTo spec;

344.           Item   : out Canvas_ItemTo API docTo spec;

345.           X, Y   : out Glib.GintTo API docTo spec);

346.        --  Same as above, but also returns the coordinates (X, Y) within the item.

347.        --  The coordinates are not set if Item is null on exit.

349.        procedure ClearTo API docTo body (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body);

350.        --  Remove all items from the canvas

352.        procedure RemoveTo API docTo body

353.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

354.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

355.        --  Remove an item and all the links to and from it from the canvas.

356.        --  The item itself is not freed, but the links are.

357.        --  Nothing is done if the item is not part of the canvas.

359.        procedure Item_UpdatedTo API docTo body

360.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

361.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

362.        --  This should be called when Item has changed the contents of its

363.        --  pixmap, and thus the Canvas should be updated.

365.        procedure Refresh_CanvasTo API docTo body (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body);

366.        --  Redraw the whole canvas (both in the double buffer and on the screen).

368.        procedure Raise_ItemTo API docTo body

369.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

370.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

371.        --  Raise the item so that it is displayed on top of all the others

372.        --  The canvas is refreshed as needed to reflect the change.

373.        --  Nothing happens if Item is not part of the canvas.

375.        procedure Lower_ItemTo API docTo body

376.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

377.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

378.        --  Lower the item so that it is displayed below all the others.

379.        --  The canvas is refreshed as needed to reflect the change.

380.        --  Nothing happens if Item is not part of the canvas.

382.        function Is_On_TopTo API docTo body

383.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

384.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class) return Boolean;

385.        --  Return True if Item is displayed on top of all the others in the canvas.

387.        procedure Show_ItemTo API docTo body

388.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

389.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

390.        --  Scroll the canvas so that Item is visible. Nothing is done if the item

391.        --  is already visible

393.        procedure Align_ItemTo API docTo body

394.          (Canvas  : access Interactive_Canvas_RecordTo API docTo specTo body;

395.           Item    : access Canvas_Item_RecordTo API docTo specTo body'Class;

396.           X_Align : Float := 0.5;

397.           Y_Align : Float := 0.5);

398.        --  Scroll the canvas so that the Item appears at the given location in the

399.        --  canvas. If X_Align is 0.0, the item is align on the left. With 0.5, it

400.        --  is centered horizontally. If 1.0, it is aligned on the right.

402.        function Get_Arrow_AngleTo API docTo body

403.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class) return Glib.GdoubleTo API docTo spec;

404.        --  Return the angle of arrows in the canvas.

406.        function Get_Arrow_LengthTo API docTo body

407.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class) return Glib.GintTo API docTo spec;

408.        --  Return the length of arrows in the canvas.

410.        --------------------------

411.        -- Iterating over items --

412.        --------------------------

414.        type Item_Processor is access function

415.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

416.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class) return Boolean;

418.        procedure For_Each_ItemTo API docTo body

419.          (Canvas            : access Interactive_Canvas_RecordTo API docTo specTo body;

420.           Execute           : Item_ProcessorTo API docTo spec;

421.           Linked_From_Or_To : Canvas_ItemTo API docTo spec := null);

422.        --  Execute an action on each of the items contained in the canvas.

423.        --  If Execute returns False, we stop traversing the list of children.

424.        --  It is safe to remove the items in Item_Processor.

425.        --

426.        --  If Linked_From_Or_To is not null, then only the items linked to this one

427.        --  will be processed. It is possible that a given item will be returned

428.        --  twice, if it is both linked to and from the item.

430.        type Item_IteratorTo API docTo body is private;

432.        function StartTo API docTo body

433.          (Canvas            : access Interactive_Canvas_RecordTo API docTo specTo body;

434.           Linked_From_Or_To : Canvas_ItemTo API docTo spec := null;

435.           Selected_Only     : Boolean := False) return Item_IteratorTo API docTo specTo body;

436.        --  Return the first item in the canvas.

437.        --  The same restriction as above applies if Linked_From_Or_To is not null.

439.        procedure NextTo API docTo body (IterTo API docTo body : in out Item_IteratorTo API docTo specTo body);

440.        function NextTo API docTo body (IterTo API docTo body : Item_IteratorTo API docTo specTo body) return Item_IteratorTo API docTo specTo body;

441.        --  Move the iterator to the next item.

442.        --  All items will eventually be returned if you do not add new items during

443.        --  the iteration and none are removed. However, it is safe to remove items

444.        --  at any time, except the current item

446.        function GetTo API docTo body (IterTo API docTo body : Item_IteratorTo API docTo specTo body) return Canvas_ItemTo API docTo spec;

447.        --  Return the item pointed to by the iterator.

448.        --  null is returned when there are no more item in the canvas.

450.        function Is_Linked_FromTo API docTo body (IterTo API docTo body : Item_IteratorTo API docTo specTo body) return Boolean;

451.        --  Return True if there is a link from:

452.        --     Get (Iter) -> Linked_From_Or_To

453.        --  Linked_From_Or_To is the item passed to Start. False is returned if this

454.        --  item was null.

456.        -------------

457.        -- Zooming --

458.        -------------

460.        procedure ZoomTo API docTo body

461.          (Canvas  : access Interactive_Canvas_RecordTo API docTo specTo body;

462.           Percent : Glib.GdoubleTo API docTo spec := 1.0;

463.           Length  : Duration := 0.0);

464.        --  Zoom in or out in the canvas.

465.        --

466.        --  Length is the length of the zooming animation.

467.        --

468.        --  Note that one possible use for this function is to refresh the canvas

469.        --  and emit the "zoomed" signal, which might redraw all the items. This can

470.        --  be accomplished by keeping the default 1.0 value for Percent.

472.        function Get_ZoomTo API docTo body

473.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body) return Glib.GdoubleTo API docTo spec;

474.        --  Return the current zoom level

476.        procedure Get_World_CoordinatesTo API docTo body

477.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

478.           X, Y   : out Glib.GdoubleTo API docTo spec;

479.           Width  : out Glib.GdoubleTo API docTo spec;

480.           Height : out Glib.GdoubleTo API docTo spec);

481.        --  Return the world coordinates of Canvas.

483.        ---------------------

484.        -- Layout of items --

485.        ---------------------

487.        type Layout_Algorithm is access procedure

488.          (Canvas          : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

489.           Graph           : Glib.Graphs.GraphTo API docTo specTo body;

490.           Force           : Boolean;

491.           Vertical_Layout : Boolean);

492.        --  A general layout algorithm. It should compute the position of all the

493.        --  vertices of the graph, and set them directly in the graph itself.

494.        --  Note: all the vertices in the graph are of type Canvas_Item_Record'Class

495.        --  and you should use that to set the coordinates through a call to

496.        --  Move_To.

497.        --

498.        --  Algorithms are encouraged to preserve the current layout as much as

499.        --  possible, taking into account items that have been moved manually by

500.        --  the user, so that the latter can preserver his mental map of the graph.

501.        --  However, if Force is set to True, then the whole layout should be

502.        --  recomputed as if all items had just been inserted.

503.        --

504.        --  Items that have just been inserted in the graph, but whose position has

505.        --  never been computed, are set at coordinates (Gint'First, Gint'First).

506.        --  Check the result of Get_Coord.

507.        --

508.        --  This function doesn't need to align items, this is done automatically by

509.        --  the canvas if necessary.

511.        procedure Set_Layout_AlgorithmTo API docTo body

512.          (Canvas    : access Interactive_Canvas_RecordTo API docTo specTo body;

513.           Algorithm : Layout_AlgorithmTo API docTo spec);

514.        --  Set the layout algorithm to use to compute the position of the items.

515.        --  Algorithm mustn't be null.

517.        procedure Default_Layout_AlgorithmTo API docTo body

518.          (Canvas          : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

519.           GraphTo API docTo body           : Glib.Graphs.GraphTo API docTo specTo body;

520.           Force           : Boolean;

521.           Vertical_Layout : Boolean);

522.        --  The default algorithm used in the canvas.

523.        --  Basically, items are put next to each other, unless there is a link

524.        --  between two items. In that case, the second item is put below the first,

525.        --  as space allows.

527.        procedure Set_Auto_LayoutTo API docTo body

528.          (Canvas      : access Interactive_Canvas_RecordTo API docTo specTo body;

529.           Auto_Layout : Boolean);

530.        --  If Auto_Layout is true, then every time an item is inserted in the

531.        --  canvas, the layout algorithm is called. If set to False, it is the

532.        --  responsability of the caller to call Layout below to force a

533.        --  recomputation of the layout, preferably after inserting a number of

534.        --  items.

536.        procedure Set_Layout_OrientationTo API docTo body

537.          (Canvas          : access Interactive_Canvas_RecordTo API docTo specTo body;

538.           Vertical_Layout : Boolean := False);

539.        --  Specify the layout orientation to use for this canvas. The setting is

540.        --  passed as a parameter to the layout algorithm

542.        procedure LayoutTo API docTo body

543.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

544.           Force  : Boolean := False);

545.        --  Recompute the layout of the canvas.

546.        --  Force can be used to control the layout algorithm, as described above

547.        --  for Layout_Algorithm.

549.        -----------

550.        -- Links --

551.        -----------

553.        procedure ConfigureTo API docTo body

554.          (Link  : access Canvas_Link_RecordTo API docTo specTo body;

555.           ArrowTo API docTo body : Arrow_TypeTo API docTo spec := End_Arrow;

556.           Descr : Glib.UTF8_StringTo API docTo spec := "");

557.        --  Configure a link.

558.        --  The link is an oriented bound between two items on the canvas.

559.        --  If Descr is not the empty string, it will be displayed in the middle

560.        --  of the link, and should indicate what the link means.

561.        --  Arrow indicates whether some arrows should be printed as well.

563.        function Get_DescrTo API docTo body

564.          (Link : access Canvas_Link_RecordTo API docTo specTo body) return Glib.UTF8_StringTo API docTo spec;

565.        --  Return the description for the link, or "" if there is none

567.        function Get_Arrow_TypeTo API docTo body

568.          (Link : access Canvas_Link_RecordTo API docTo specTo body) return Arrow_TypeTo API docTo spec;

569.        --  Return the location of the arrows on Link

571.        procedure Set_Src_PosTo API docTo body

572.          (Link : access Canvas_Link_RecordTo API docTo specTo body; X_Pos, Y_Pos : Glib.GfloatTo API docTo spec := 0.5);

573.        --  Set the position of the link's attachment in its source item.

574.        --  X_Pos and Y_Pos should be given between 0.0 and 1.0 (from left to right

575.        --  or top to bottom)..

576.        --  By default, all links are considered to be attached to the center of

577.        --  items. However, in some cases it is more convenient to attach it to a

578.        --  specific part of the item. For instance, you can force a link to always

579.        --  start from the top of the item by setting Y_Pos to 0.0.

581.        procedure Set_Dest_PosTo API docTo body

582.          (Link : access Canvas_Link_RecordTo API docTo specTo body; X_Pos, Y_Pos : Glib.GfloatTo API docTo spec := 0.5);

583.        --  Same as Set_Src_Pos for the destination item

585.        procedure Get_Src_PosTo API docTo body

586.          (Link : access Canvas_Link_RecordTo API docTo specTo body; X, Y : out Glib.GfloatTo API docTo spec);

587.        --  Return the attachment position of the link along its source item

589.        procedure Get_Dest_PosTo API docTo body

590.          (Link : access Canvas_Link_RecordTo API docTo specTo body; X, Y : out Glib.GfloatTo API docTo spec);

591.        --  Return the attachment position of the link along its destination item

593.        function Has_LinkTo API docTo body

594.          (Canvas   : access Interactive_Canvas_RecordTo API docTo specTo body;

595.           From, To : access Canvas_Item_RecordTo API docTo specTo body'Class;

596.           Name     : Glib.UTF8_StringTo API docTo spec := "") return Boolean;

597.        --  Test whether there is a link from From to To, with the same name.

598.        --  If Name is the empty string "", then no check is done on the name,

599.        --  and True if returned if there is any link between the two items.

601.        procedure Add_LinkTo API docTo body

602.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

603.           Link   : access Canvas_Link_RecordTo API docTo specTo body'Class;

604.           Src    : access Canvas_Item_RecordTo API docTo specTo body'Class;

605.           Dest   : access Canvas_Item_RecordTo API docTo specTo body'Class;

606.           ArrowTo API docTo body  : Arrow_TypeTo API docTo spec := End_Arrow;

607.           Descr  : Glib.UTF8_StringTo API docTo spec := "");

608.        --  Add Link in the canvas. This connects the two items Src and Dest.

609.        --  Simpler procedure to add a standard link.

610.        --  This takes care of memory allocation, as well as adding the link to

611.        --  the canvas.

613.        procedure Remove_LinkTo API docTo body

614.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

615.           Link   : access Canvas_Link_RecordTo API docTo specTo body'Class);

616.        --  Remove a link from the canvas.

617.        --  It also destroys the link itself, and free the memory allocated to it.

618.        --  Nothing is done if Link does not belong to canvas.

620.        type Link_Processor is access function

621.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

622.           Link   : access Canvas_Link_RecordTo API docTo specTo body'Class) return Boolean;

624.        procedure For_Each_LinkTo API docTo body

625.          (Canvas   : access Interactive_Canvas_RecordTo API docTo specTo body;

626.           Execute  : Link_ProcessorTo API docTo spec;

627.           From, To : Canvas_ItemTo API docTo spec := null);

628.        --  Execute an action on each of the links contained in the canvas.

629.        --  If Execute returns False, we stop traversing the list of links.

630.        --  It is safe to remove the link from the list in Link_Processor.

631.        --

632.        --  (From, To) can be used to limit what links are looked for.

633.        --

634.        --  ??? Would be nicer to give direct access to the Graph iterators

636.        procedure DestroyTo API docTo body (LinkTo API docTo body : in out Canvas_Link_RecordTo API docTo specTo body);

637.        --  Method called every time a link is destroyed. You should override this

638.        --  if you define your own link types.

639.        --  Note that the link might already have been removed from the canvas

640.        --  when this subprogram is called.

641.        --  This shouldn't free the link itself, only its fields.

643.        -------------------

644.        -- Drawing links --

645.        -------------------

646.        --  Drawing of links can be controlled at several levels:

647.        --    - Redefining Update_Links gives control at the canvas level. This can

648.        --      be used to implement routing algorithms for the links where the

649.        --      routes must be computed before any link is actually drawn (otherwise

650.        --      it is better to redefine Draw_Link). It can also be used to control

651.        --      in what order the links should be drawn.

652.        --    - Redefining Draw_Link gives the opportunity to draw links any way you

653.        --      need (several bends, ...). It can be used to control the routing of

654.        --      this specific link, for routing algorithms that only rely on the

655.        --      items layout and not on other links. Otherwise see Update_Links.

656.        --    - Redefining Draw_Straight_Line if slightly lower-level. This is

657.        --      called by the default Draw_Link procedure, once the ends of the

658.        --      links have been computed.

660.        procedure Update_LinksTo API docTo body

661.          (Canvas         : access Interactive_Canvas_RecordTo API docTo specTo body;

662.           Cr             : Cairo.Cairo_ContextTo API docTo spec;

663.           Invert_Mode    : Boolean;

664.           From_Selection : Boolean);

665.        --  Redraw all the links in the canvas, after the items have been laid out.

666.        --

667.        --  If From_Selection is true, then only the links to or from one of the

668.        --  selected items need to be drawn.

670.        procedure Draw_LinkTo API docTo body

671.          (Canvas      : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

672.           Link        : access Canvas_Link_RecordTo API docTo specTo body;

673.           Cr          : Cairo.Cairo_ContextTo API docTo spec;

674.           Edge_Number : Glib.GintTo API docTo spec;

675.           Show_Annotation : Boolean := True);

676.        --  Redraw the link on the canvas.

677.        --  Note that this is a primitive procedure of Link, not of Canvas, and thus

678.        --  can easily be overrided for specific links. The default version draws

679.        --  either straight or arc links (the latter when there are multiple links

680.        --  between two given items).

681.        --  This function shouldn't be called if one of the two ends of the link is

682.        --  invisible.

683.        --

684.        --  Cr is the Cairo_Context that is used to draw the link.

685.        --  The link is drawn using the current cairo brush, so if you need to

686.        --  specify some particular color, you can do it directly in the

687.        --  Cairo_Context

688.        --

689.        --  Edge_Number indicates the index of link in the list of links that join

690.        --  the same source to the same destination. It should be used so that two

691.        --  links do not overlap (for instance, the default is to draw the first

692.        --  link straight, and the others as arcs).

694.        type Item_Side is (East, West, North, South);

695.        --  Each side of an item, along its rectangle bounding box

697.        procedure Clip_LineTo API docTo body

698.          (Src   : access Canvas_Item_RecordTo API docTo specTo body;

699.           Canvas : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

700.           To_X  : Glib.GintTo API docTo spec;

701.           To_Y  : Glib.GintTo API docTo spec;

702.           X_Pos : Glib.GfloatTo API docTo spec;

703.           Y_Pos : Glib.GfloatTo API docTo spec;

704.           SideTo API docTo body  : out Item_SideTo API docTo spec;

705.           X_Out : out Glib.GintTo API docTo spec;

706.           Y_Out : out Glib.GintTo API docTo spec);

707.        --  Clip the line that goes from Src at pos (X_Pos, Y_Pos) to (To_X, To_Y)

708.        --  in world coordinates.

709.        --  The intersection between that line and the border of Rect is returned

710.        --  in (X_Out, Y_Out). The result should be in world coordinates.

711.        --  X_Pos and Y_Pos have the same meaning as Src_X_Pos and Src_Y_Pos in the

712.        --  link record.

713.        --  This procedure is called when computing the position for the links

714.        --  within the default Draw_Link procedure. The default implementation only

715.        --  works with rectangular items. The computed coordinates are then passed

716.        --  on directly to Draw_Straight_Line.

718.        procedure Draw_Straight_LineTo API docTo body

719.          (Link      : access Canvas_Link_RecordTo API docTo specTo body;

720.           Cr        : Cairo.Cairo_ContextTo API docTo spec;

721.           Src_SideTo API docTo body  : Item_SideTo API docTo spec;

722.           X1, Y1    : Glib.GdoubleTo API docTo spec;

723.           Dest_SideTo API docTo body : Item_SideTo API docTo spec;

724.           X2, Y2    : Glib.GdoubleTo API docTo spec);

725.        --  Draw a straight link between two points. This could be overriden if you

726.        --  need to draw an something along the link.

727.        --  The links goes from (Src, X1, Y1) to (Dest, X2, Y2), in canvas

728.        --  coordinates. The coordinates have already been clipped so that they do

729.        --  not override the item.

731.        ---------------

732.        -- Selection --

733.        ---------------

735.        procedure Clear_SelectionTo API docTo body (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body);

736.        --  Clear the list of currently selected items.

738.        procedure Add_To_SelectionTo API docTo body

739.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

740.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

741.        --  Add Item to the selection.  This is only meaningful during a drag

742.        --  operation (ie during a button press and the matching button

743.        --  release). Item will be moved at the same time that the selection is

744.        --  moved.

745.        --  Item is not added again if it is already in the selection.

746.        --  This function can be called from the Button_Click subprogram to force

747.        --  moving items.

748.        --  This emits the "item_selected" signal.

750.        procedure Remove_From_SelectionTo API docTo body

751.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

752.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class);

753.        --  Remove Item from the selection.

754.        --  This emits the "item_unselected" signal.

756.        procedure Select_AllTo API docTo body (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body);

757.        --  Select all the Item in the canvas.

759.        function Is_SelectedTo API docTo body

760.          (Canvas : access Interactive_Canvas_RecordTo API docTo specTo body;

761.           Item   : access Canvas_Item_RecordTo API docTo specTo body'Class) return Boolean;

762.        --  Return True if the item is currently selected

764.        ------------------------

765.        -- Items manipulation --

766.        ------------------------

768.        function CanvasTo API docTo body

769.          (Item : access Canvas_Item_RecordTo API docTo specTo body) return Interactive_CanvasTo API docTo spec;

770.        --  Retrieve the canvas this item is attached to, or null if it does not

771.        --  belong to a canvas.

773.        procedure SelectedTo API docTo body

774.          (Item        : access Canvas_Item_RecordTo API docTo specTo body;

775.           Canvas      : access Interactive_Canvas_RecordTo API docTo specTo body'Class;

776.           Is_Selected : Boolean);

777.        --  Called when the item is selected or unselected.

778.        --  The default is to do nothing.

780.        function Point_In_ItemTo API docTo body

781.          (Item : access Canvas_Item_RecordTo API docTo specTo body;

782.           X, Y : Glib.GintTo API docTo spec) return Boolean;

783.        --  This function should return True if (X, Y) is inside the item. X and Y

784.        --  are in world coordinates.

785.        --  This function is meant to be overriden for non-rectangular items, since

786.        --  the default behavior works for rectangular items.

787.        --  This function is never called for invisible items

789.        procedure Set_Screen_SizeTo API docTo body

790.          (Item   : access Canvas_Item_RecordTo API docTo specTo body;

791.           Width  : Glib.GintTo API docTo spec;

792.           Height : Glib.GintTo API docTo spec);

793.        --  Set the size of bounding box for the item in world coordinates.

794.        --  The item itself needn't occupy the whole area of this bounding box,

795.        --  see Point_In_Item.

796.        --  You need to redraw the item, and call Item_Updated to force the canvas

797.        --  to refresh the screen.

799.        procedure Draw_SelectedTo API docTo body

800.          (Item : access Canvas_Item_RecordTo API docTo specTo body;

801.           Cr   : Cairo.Cairo_ContextTo API docTo spec);

802.        --  Draws a selected item. By default, this adds a semi-transparent overlay

803.        --  above the item, drawn using the below call to Draw

805.        procedure Draw

806.          (Item : access Canvas_Item_RecordTo API docTo specTo body;

807.           Cr   : Cairo.Cairo_ContextTo API docTo spec) is abstract;

808.        --  This subprogram, that must be overridden, should draw the item on

809.        --  Cr. The Item is drawn from coordinates (0,0), and does not need to take

810.        --  care of the zoom level.

811.        --  If you need to change the contents of the item, you should call

812.        --  Item_Updated after having done the drawing.

814.        procedure DestroyTo API docTo body (ItemTo API docTo body : in out Canvas_Item_RecordTo API docTo specTo body);

815.        --  Free the memory occupied by the item (not the item itself). You should

816.        --  override this function if you define your own widget type, but always

817.        --  call the parent's Destroy subprogram.

819.        function On_Button_ClickTo API docTo body

820.          (Item  : access Canvas_Item_RecordTo API docTo specTo body;

821.           Event : Gdk.Event.Gdk_Event_ButtonTo API docTo spec) return Boolean;

822.        --  Function called whenever mouse events occured.

823.        --  The following mouse events may be received:

824.        --    Mouse_Press,

825.        --    Motion_Notify

826.        --      (only once the mouse is pressed, and On_Button_Click returned True),

827.        --    Mouse_Release

828.        --      (only once the mouse is pressed, and On_Button_Click returned True),

829.        --  Returns whether the event was handled or not.

830.        --

831.        --  The coordinates (X, Y) in the Event are relative to the top-left corner

832.        --  of Item.

834.        function Get_CoordTo API docTo body

835.          (Item : access Canvas_Item_RecordTo API docTo specTo body)

836.           return Cairo.Region.Cairo_Rectangle_IntTo API docTo spec;

837.        --  Return the coordinates and size of the bounding box for item, in world

838.        --  coordinates.

839.        --  If the item has never been resized, it initially has a width and height

840.        --  of 1.

842.        procedure Set_VisibilityTo API docTo body

843.          (Item    : access Canvas_Item_RecordTo API docTo specTo body;

844.           Visible : Boolean);

845.        --  Set the visibility status of the item. An invisible item will not be

846.        --  visible on the screen, and will not take part in the computation of the

847.        --  the scrollbars for the canvas.

848.        --  The canvas is not refreshed (this is your responsibility to do it after

849.        --  you have finished doing all the modifications).

851.        function Is_VisibleTo API docTo body (Item : access Canvas_Item_RecordTo API docTo specTo body) return Boolean;

852.        --  Return True if the item is currently visible

854.        function Is_From_Auto_LayoutTo API docTo body

855.          (Item : access Canvas_Item_RecordTo API docTo specTo body) return Boolean;

856.        --  Return True if the current location of the item is the result from the

857.        --  auto layout algorithm.

858.        --  False is returned if the item was moved manually by the user.

860.        --------------------

861.        -- Buffered items --

862.        --------------------

864.        type Buffered_Item_RecordTo API docTo body is new Canvas_Item_RecordTo API docTo specTo body with private;

865.        type Buffered_Item is access all Buffered_Item_RecordTo API docTo specTo body'Class;

866.        --  A widget that has a double-buffer associated. You should use this one

867.        --  when drawing items can take a long time, or you do not want to handle

868.        --  the zoom yourself.

869.        --  You only need to update the contents of the double pixmap when the

870.        --  contents of the item changes, since all the drawing and zooming is

871.        --  taken care of automatically. Once the drawing is done, call Item_Updated

872.        --  to force the canvas to refresh the screen.

873.        --  This buffered_item is meant to handle rectangular items. However, it can

874.        --  be used for polygonal items by overriding Draw. The new version should

875.        --  set the clip mask for the GC, then call Draw for the buffered item, and

876.        --  finally reset the clip mask. The clip mask must take into account the

877.        --  current zoom level.

879.        function SurfaceTo API docTo body (Item : access Buffered_Item_RecordTo API docTo specTo body)

880.           return Cairo.Cairo_SurfaceTo API docTo spec;

881.        --  Return the double-buffer.

883.        -------------

884.        -- Signals --

885.        -------------

887.        --  <signals>

888.        --  The following new signals are defined for this widget:

889.        --

890.        --  - "background_click"

891.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class;

892.        --                     Event  : Gdk.Event.Gdk_Event);

893.        --

894.        --  Called every time the user clicks in the background (ie not on an item,

895.        --  or On_Button_Click would be called).

896.        --  This is called both on Button_Release and Button_Press events.

897.        --  The coordinates (X, Y) in the Event are relative to the top-left corner

898.        --  of Canvas.

899.        --

900.        --  - "item_selected"

901.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class;

902.        --                     Item   : Canvas_Item);

903.        --

904.        --  Emitted when the user has clicked on an item to select it, ie before any

905.        --  drag even has occured. This is a good time to add other items to the

906.        --  selection if you need. At thee same time, the primitive operation

907.        --  Selected is called for the item.

908.        --

909.        --  - "item_unselected"

910.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class;

911.        --                     Item   : Canvas_Item);

912.        --

913.        --  Emitted when the Item was unselected. At the same time, the primitive

914.        --  operation Selected is called for the item.

915.        --

916.        --  - "item_moved"

917.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class;

918.        --                     Item   : Canvas_Item);

919.        --

920.        --  Emitted when Item has been moved. New coordinates have been assigned to

921.        --  Item. However, the canvas hasn't been refreshed yet. This signal might

922.        --  be called multiple time when the user finishes a drag action, in case

923.        --  there were several selected items.

924.        --

925.        --  - "zoomed"

926.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class);

927.        --

928.        --  Emitted when the canvas has been zoomed in or out. You do not need to

929.        --  redraw the items yourself, since this will be handled by calls to Draw

930.        --

931.        --  - "set_scroll_adjustments"

932.        --  procedure Handler (Canvas : access Interactive_Canvas_Record'Class);

933.        --

934.        --  Emitted when the canvas has scrolled.

935.        --

936.        --  </signals>

938.        Signal_Background_Click       : constant Glib.Signal_NameTo API docTo spec :=

939.                                          "background_click";

940.        Signal_Item_Selected          : constant Glib.Signal_NameTo API docTo spec :=

941.                                          "item_selected";

942.        Signal_Item_Unselected        : constant Glib.Signal_NameTo API docTo spec :=

943.                                          "item_unselected";

944.        Signal_Item_Moved             : constant Glib.Signal_NameTo API docTo spec :=

945.                                          "item_moved";

946.        Signal_Zoomed                 : constant Glib.Signal_NameTo API docTo spec :=

947.                                          "zoomed";

948.        Signal_Set_Scroll_Adjustments : constant Glib.Signal_NameTo API docTo spec :=

949.                                          "set_scroll_adjustments";

951.     private

953.        type String_Access is access Glib.UTF8_StringTo API docTo spec;

955.        type Canvas_Link_RecordTo API docTo spec is new Glib.Graphs.EdgeTo API docTo specTo body with record

956.           Descr      : String_Access;

957.           Arrow      : Arrow_TypeTo API docTo spec := End_Arrow;

959.           Src_X_Pos  : Glib.GfloatTo API docTo spec := 0.5;

960.           Src_Y_Pos  : Glib.GfloatTo API docTo spec := 0.5;

961.           Dest_X_Pos : Glib.GfloatTo API docTo spec := 0.5;

962.           Dest_Y_Pos : Glib.GfloatTo API docTo spec := 0.5;

963.           --  Position of the link's attachment in each of the src and dest items.

964.        end record;

966.        type Interactive_Canvas_RecordTo API docTo spec is new

967.          Gtk.Drawing_Area.Gtk_Drawing_Area_RecordTo API docTo spec

968.        with record

969.           Children          : Glib.Graphs.GraphTo API docTo specTo body;

970.           World_X, World_Y  : Glib.GdoubleTo API docTo spec;

971.           --  The World coordinates at canvas (0,0)

973.           Layout            : Layout_AlgorithmTo API docTo spec := Default_Layout_AlgorithmTo API docTo specTo body'Access;

974.           Auto_Layout       : Boolean := True;

975.           Vertical_Layout   : Boolean := False;

976.           --  The algorithm to use when laying out items on the canvas.

978.           World_X_At_Click  : Glib.GdoubleTo API docTo spec;

979.           World_Y_At_Click  : Glib.GdoubleTo API docTo spec;

980.           --  Coordinates of the last button_press event in the canvas.

981.           --  These are world-coordinates, so that even if the canvas is scrolled

982.           --  they remain valid

984.           Selected_Count    : Natural := 0;

985.           --  Number of selected items

987.           Offset_X_World    : Glib.GintTo API docTo spec;

988.           Offset_Y_World    : Glib.GintTo API docTo spec;

989.           --  How much world-coordinates have we moved the mouse since the last

990.           --  button press event ?

992.           Mouse_Has_Moved   : Boolean;

993.           --  True if mouse has moved while the button was clicked. This is used

994.           --  to distinguish between item motion and item selection.

996.           Background_Press  : Boolean;

997.           --  True if the mouse press event occured in the background

999.           Item_Press        : Canvas_ItemTo API docTo spec;

1000.           --  Points to the canvas item that received the press event

1002.           Show_Item                    : Canvas_ItemTo API docTo spec;

1003.           Show_Canvas_X, Show_Canvas_Y : Glib.GdoubleTo API docTo spec;

1004.           --  The item that should be made visible when the canvas is resized.

1005.           --  This is required since the canvas doesn't necessarily have a size yet

1006.           --  when Show_Item() is called the first time.

1008.           Grid_Size         : Glib.GuintTo API docTo spec := Default_Grid_SizeTo API docTo spec;

1009.           --  The current number of pixels between each dot of the grid. If this

1010.           --  is strictly below 2, the grid is not drawn.

1012.           Arc_Link_Offset   : Glib.GintTo API docTo spec := Default_Arc_Link_OffsetTo API docTo spec;

1013.           Arrow_Angle       : Glib.GdoubleTo API docTo spec;

1014.           Arrow_Length      : Glib.GintTo API docTo spec := Default_Arrow_LengthTo API docTo spec;

1015.           Motion_Threshold  : Glib.GdoubleTo API docTo spec := Default_Motion_ThresholdTo API docTo spec;

1016.           Align_On_Grid     : Boolean := False;

1018.           Black_Color     : Gdk.Color.Gdk_ColorTo API docTo specTo body := Gdk.Color.Null_ColorTo API docTo specTo body;

1019.           Sel_Color       : Gdk.Color.Gdk_ColorTo API docTo specTo body := Gdk.Color.Null_ColorTo API docTo specTo body;

1021.           Annotation_Layout : Pango.Layout.Pango_LayoutTo API docTo spec;

1022.           --  Layout used to draw the annotations

1024.           Hadj, Vadj        : Gtk.Adjustment.Gtk_AdjustmentTo API docTo spec;

1025.           Scrolling_Timeout_Id : Glib.Main.G_Source_IdTo API docTo spec := 0;

1027.           Orthogonal_Links : Boolean := False;

1028.           --  True if the links should be orthogonal

1030.           Surround_Box_Scroll : Glib.GdoubleTo API docTo spec;

1031.           --  Amount of scrolling for each step while the cursor is left in the

1032.           --  surrounding box.

1034.           Zoom                : Glib.GdoubleTo API docTo spec := 1.0;

1035.           --  Zoom level in percent (100% is normal size)

1037.           Initial_Zoom        : Glib.GdoubleTo API docTo spec := 1.0;

1038.           Target_Zoom         : Glib.GdoubleTo API docTo spec := 1.0;

1039.           Zoom_Duration       : Duration := 0.0;

1040.           Zoom_Start          : Ada.Calendar.Time;

1041.           Zoom_X              : Glib.GdoubleTo API docTo spec := 0.0;

1042.           Zoom_Y              : Glib.GdoubleTo API docTo spec := 0.0;

1043.           --  Variables used while smooth-scrolling the canvas

1045.           Freeze           : Boolean := False;

1046.        end record;

1048.        type Canvas_Item_RecordTo API docTo spec is abstract new Glib.Graphs.VertexTo API docTo specTo body with record

1049.           Canvas           : Interactive_CanvasTo API docTo spec := null;

1050.           Coord            : aliased Cairo.Region.Cairo_Rectangle_IntTo API docTo spec;

1051.           --  This is the bounding box of the item

1053.           Visible          : Boolean := True;

1054.           Selected         : Boolean := False;

1056.           From_Auto_Layout : Boolean := True;

1057.           --  True if the item's current location is the result of the automatic

1058.           --  layout algorithm.

1059.        end record;

1061.        type Buffered_Item_RecordTo API docTo spec is new Canvas_Item_RecordTo API docTo specTo body with record

1062.           Pixmap : Cairo.Cairo_SurfaceTo API docTo spec := Cairo.Null_SurfaceTo API docTo spec;

1063.        end record;

1065.        procedure Set_Screen_Size

1066.          (Item   : access Buffered_Item_RecordTo API docTo specTo body;

1067.           Width, Height  : Glib.GintTo API docTo spec);

1068.        --  See documentation from inherited subprogram

1070.        procedure Draw

1071.          (Item : access Buffered_Item_RecordTo API docTo specTo body;

1072.           Cr   : Cairo.Cairo_ContextTo API docTo spec);

1073.        --  Draw the item's double-buffer onto Dest.

1075.        procedure Destroy (Item : in out Buffered_Item_RecordTo API docTo specTo body);

1076.        --  Free the double-buffer allocated for the item

1078.        type Item_IteratorTo API docTo spec is record

1079.           Vertex            : Glib.Graphs.Vertex_IteratorTo API docTo spec;

1080.           Edge              : Glib.Graphs.Edge_IteratorTo API docTo specTo body;

1081.           Linked_From_Or_To : Canvas_ItemTo API docTo spec;

1082.           Selected_Only     : Boolean;

1083.        end record;

1085.        pragma Inline (Get_Arrow_TypeTo API docTo specTo body);

1087.     end Gtkada.CanvasTo API docTo specTo body;

1089.     --  <example>

1090.     --  --  The following example shows a possible Draw_Background procedure,

1091.     --  --  that draws a background image on the canvas's background. It fully

1092.     --  --  handles zooming and tiling of the image. Note that drawing a large

1093.     --  --  image will dramatically slow down the performances.

1094.     --

1095.     --  Bg_Image : constant String := "my_background.png";

1096.     --

1097.     --  procedure Draw_Background

1098.     --    (Canvas : access Image_Canvas_Record;

1099.     --     Cr     : Cairo.Cairo_Context)

1100.     --  is

1101.     --     Surface    : Cairo.Cairo_Surface;

1102.     --     Background : Cairo.Cairo_Pattern;

1103.     --  begin

1104.     --     Surface := Cairo.Png.Create_From_Png (Bg_Image);

1105.     --     Background := Cairo.Pattern.Create_For_Surface (Surface);

1106.     --     Cairo.Pattern.Set_Extend (Canvas.Background, Cairo_Extend_Repeat);

1107.     --     Destroy (Surface);

1109.     --     Cairo.Save (Cr);

1110.     --     Cairo.Set_Source (Cr, Canvas.Background);

1111.     --     Cairo.Paint (Cr);

1112.     --     Cairo.Restore (Cr);

1113.     --  end Draw_Background;

1114.     --  </example>