1------------------------------------------------------------------------------ 2-- GtkAda - Ada95 binding for Gtk+/Gnome -- 3-- -- 4-- Copyright (C) 1998-2015, AdaCore -- 5-- -- 6-- This library is free software; you can redistribute it and/or modify it -- 7-- under terms of the GNU General Public License as published by the Free -- 8-- Software Foundation; either version 3, or (at your option) any later -- 9-- version. This library is distributed in the hope that it will be useful, -- 10-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- 11-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- 12-- -- 13-- As a special exception under Section 7 of GPL version 3, you are granted -- 14-- additional permissions described in the GCC Runtime Library Exception, -- 15-- version 3.1, as published by the Free Software Foundation. -- 16-- -- 17-- You should have received a copy of the GNU General Public License and -- 18-- a copy of the GCC Runtime Library Exception along with this program; -- 19-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- 20-- <http://www.gnu.org/licenses/>. -- 21-- -- 22------------------------------------------------------------------------------ 23 24-- Various support utilities for the models 25 26with Gtkada.Canvas_View.Rtrees; use Gtkada.Canvas_View.Rtrees; 27 28package Gtkada.Canvas_View.Models is 29 30 ------------ 31 -- Rtrees -- 32 ------------ 33 -- A wrapper around another model, which provides efficient geospatial 34 -- queries, like finding the smaller enclosing rectangle for all the 35 -- items, or all the items within a given region. 36 -- The items are stored in the base model, and the Rtree model adds 37 -- an extra data structure on top of it to speed up the queries. 38 -- When new items are added to the model, Refresh_Layout *must* be 39 -- called to refresh the internal cache (but this should always be done 40 -- in any case to refresh the display of links for instance). 41 -- 42 -- Wrapping a model in a Rtree means that the speed of displaying the 43 -- canvas (and more importantly scrolling it) now depends on the number 44 -- of items on the screen, not the total number of items in the model). 45 -- As a result, it is possible to have models with hundreds of 46 -- thousands of items. 47 48 generic 49 type Base_Model_Record is new Canvas_Model_Record with private; 50 -- The underlying implementation of the model (which for instance 51 -- provides support for Add and Remove), and for which the Rtree 52 -- is used as a wrapper. 53 54 package Rtree_Models is 55 type Rtree_Model_Record is new Base_Model_Record with private; 56 type Rtree_Model is access all Rtree_Model_Record'Class; 57 58 procedure Gtk_New (Self : out Rtree_Model); 59 procedure Initialize 60 (Self : not null access Rtree_Model_Record'Class); 61 -- Create a new Rtree model. 62 63 overriding procedure For_Each_Item 64 (Self : not null access Rtree_Model_Record; 65 Callback : not null access procedure 66 (Item : not null access Abstract_Item_Record'Class); 67 Selected_Only : Boolean := False; 68 Filter : Item_Kind_Filter := Kind_Any; 69 In_Area : Model_Rectangle := No_Rectangle); 70 overriding function Bounding_Box 71 (Self : not null access Rtree_Model_Record; 72 Margin : Model_Coordinate := 0.0) 73 return Model_Rectangle; 74 overriding function Toplevel_Item_At 75 (Self : not null access Rtree_Model_Record; 76 Point : Model_Point; 77 Context : Draw_Context) return Abstract_Item; 78 overriding procedure Refresh_Layout 79 (Self : not null access Rtree_Model_Record; 80 Send_Signal : Boolean := True); 81 82 private 83 type Rtree_Model_Record is new Base_Model_Record with record 84 Items_Tree, Links_Tree : Rtree 85 (Min_Children => Default_Min_Children, 86 Max_Children => Default_Max_Children); 87 end record; 88 end Rtree_Models; 89 90end Gtkada.Canvas_View.Models; 91