1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2011-2013, AdaCore               -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  Regions -- Representing a pixel-aligned area 
  30. --  <description> 
  31. --  Bindings to the Cairo 2D graphics library. 
  32. --  Regions are a simple graphical data type representing an area of integer- 
  33. --  aligned rectangles. Thay are often used on raster surfaces to track areas 
  34. --  of interest, such as change or clip areas. 
  35. --  </description> 
  36. -- 
  37. --  <c_version>1.10</c_version> 
  38. --  <group>Cairo</group> 
  39.  
  40. package Cairo.Region is 
  41.  
  42.    type Cairo_Region is private; 
  43.    --  A Cairo_Region represents a set of integer-aligned rectangles. 
  44.    -- 
  45.    --  It allows set-theoretical operations like Union and Intersect to be 
  46.    --  performed on them. 
  47.    -- 
  48.    --  Memory management of Cairo_Region is done with Reference and 
  49.    --  Destroy. 
  50.    -- 
  51.    --  Since: 1.10 
  52.  
  53.    Null_Region : constant Cairo_Region; 
  54.  
  55.    type Cairo_Rectangle_Int is record 
  56.       X, Y, Width, Height : aliased Gint; 
  57.    end record; 
  58.  
  59.    type Cairo_Region_Overlap is 
  60.      (Cairo_Region_Overlap_In,    --  Completely inside region 
  61.       Cairo_Region_Overlap_Out,   --  Completely outside region 
  62.       Cairo_Region_Overlap_Part   --  Partly inside region 
  63.      ); 
  64.    --  Used as the return value for Contains_Rectangle. 
  65.    pragma Convention (C, Cairo_Region_Overlap); 
  66.  
  67.    function Create return Cairo_Region; 
  68.    --  Allocates a new empty region object. 
  69.    -- 
  70.    --  Returns: A newly allocated Cairo_Region. Free with Destroy. This 
  71.    --  function always returns a valid Cairo_Region; if memory cannot be 
  72.    --  allocated, then a special error object is returned where all operations 
  73.    --  on the object do nothing. You can check for this with Status. 
  74.  
  75.    function Create_Rectangle 
  76.      (Rectangle : access Cairo_Rectangle_Int) return Cairo_Region; 
  77.    --  Allocates a new region object containing Rectangle. 
  78.    -- 
  79.    --  Returns: A newly allocated Cairo_Region. Free with Destroy. This 
  80.    --  function always returns a valid Cairo_Region; if memory cannot be 
  81.    --  allocated, then a special error object is returned where all operations 
  82.    --  on the object do nothing. You can check for this with Status. 
  83.  
  84.    function Copy (Original : Cairo_Region) return Cairo_Region; 
  85.    --  Allocates a new Cairo_Region object copying the area from Original. 
  86.    -- 
  87.    --  Returns: A newly allocated Cairo_Region. Free with Destroy. This 
  88.    --  function always returns a valid Cairo_Region; if memory cannot be 
  89.    --  allocated, then a special error object is returned where all operations 
  90.    --  on the object do nothing. You can check for this with Status. 
  91.  
  92.    function Reference (Region : Cairo_Region) return Cairo_Region; 
  93.    --  Increases the reference count on Region by one. This prefents Region 
  94.    --  from being destroyed until a matching call to Destroy is made. 
  95.  
  96.    procedure Destroy (Region : Cairo_Region); 
  97.    --  Destroys a Cairo_Region object created with Create, Copy or 
  98.    --  Create_Rectangle. 
  99.  
  100.    function "=" (A, B : Cairo_Region) return Boolean; 
  101.    --  Compares whether A is equivalent to B. Null_Region as an argument is 
  102.    --  equal to itself, but not to any non-Null_Region region. 
  103.  
  104.    function Status (Region : Cairo_Region) return Cairo_Status; 
  105.    --  Checks whether an error has occured for this region object. 
  106.    -- 
  107.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory 
  108.  
  109.    procedure Get_Extents 
  110.      (Region  : Cairo_Region; 
  111.       Extents : out Cairo_Rectangle_Int); 
  112.    --  Gets the bounding rectangle of Region as a Cairo_Rectangle_Int 
  113.  
  114.    function Num_Rectangles (Region : Cairo_Region) return Gint; 
  115.    --  Returns the number of rectangle contained in Region 
  116.  
  117.    procedure Get_Rectangle 
  118.      (Region    : Cairo_Region; 
  119.       Nth       : Gint; 
  120.       Rectangle : out Cairo_Rectangle_Int); 
  121.    --  Stores the Nth rectangle from the region in Rectangle. 
  122.  
  123.    function Is_Empty (Region : Cairo_Region) return Boolean; 
  124.    --  Checks whether Region is empty. 
  125.  
  126.    function Contains_Rectangle 
  127.      (Region    : Cairo_Region; 
  128.       Rectangle : access Cairo_Rectangle_Int) return Cairo_Region_Overlap; 
  129.    --  Checks whether Rectangle is inside, outside or partially contained in 
  130.    --  Region 
  131.  
  132.    function Contains_Point 
  133.      (Region : Cairo_Region; 
  134.       X      : Gint; 
  135.       Y      : Gint) return Boolean; 
  136.    --  Checks whether (X,Y) is contained in Region. 
  137.  
  138.    procedure Translate 
  139.      (Region : Cairo_Region; 
  140.       dX     : Gint; 
  141.       dY     : Gint); 
  142.    --  Translates Region by (dX,dY). 
  143.  
  144.    function Subtract 
  145.      (Dst   : Cairo_Region; 
  146.       Other : Cairo_Region) return Cairo_Status; 
  147.    --  Subtracts Other from Dst and places the result in Dst. 
  148.    -- 
  149.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  150.  
  151.    function Subtract_Rectangle 
  152.      (Dst       : Cairo_Region; 
  153.       Rectangle : access Cairo_Rectangle_Int) return Cairo_Status; 
  154.    --  Subtracts Rectangle from Dst and places the result in Dst. 
  155.    -- 
  156.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  157.  
  158.    function Intersect 
  159.      (Dst   : Cairo_Region; 
  160.       Other : Cairo_Region) return Cairo_Status; 
  161.    --  Computes the intersection of Dst with Other and places the result in Dst 
  162.    -- 
  163.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  164.  
  165.    function Intersect_Rectangle 
  166.      (Dst       : Cairo_Region; 
  167.       Rectangle : access Cairo_Rectangle_Int) return Cairo_Status; 
  168.    --  Computes the intersection of Dst with Rectangle and places the result in 
  169.    --  Dst. 
  170.    -- 
  171.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  172.  
  173.    function Union 
  174.      (Dst   : Cairo_Region; 
  175.       Other : Cairo_Region) return Cairo_Status; 
  176.    --  Computes the union of Dst with Other and places the result in Dst. 
  177.    -- 
  178.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  179.  
  180.    function Union_Rectangle 
  181.      (Dst       : Cairo_Region; 
  182.       Rectangle : access Cairo_Rectangle_Int) return Cairo_Status; 
  183.    --  Computes the union of Dst with Rectangle and places the result in Dst. 
  184.    -- 
  185.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  186.  
  187.    function Do_Xor 
  188.      (Dst   : Cairo_Region; 
  189.       Other : Cairo_Region) return Cairo_Status; 
  190.    --  Computes the exclusive difference of Dst with Other and places the 
  191.    --  result in Dst. 
  192.    -- 
  193.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  194.  
  195.    function Xor_Rectangle 
  196.      (Dst       : Cairo_Region; 
  197.       Rectangle : access Cairo_Rectangle_Int) return Cairo_Status; 
  198.    --  Computes the exclusive difference of Dst with Rectangle and places the 
  199.    --  result in Dst. 
  200.    -- 
  201.    --  Returns: Cairo_Status_Success or Cairo_Status_No_Memory. 
  202.  
  203. private 
  204.  
  205.    pragma Convention (C, Cairo_Rectangle_Int); 
  206.  
  207.    type Cairo_Region is new System.Address; 
  208.    Null_Region : constant Cairo_Region := Cairo_Region (System.Null_Address); 
  209.  
  210.    pragma Import (C, Create, "cairo_region_create"); 
  211.    pragma Import (C, Create_Rectangle, "cairo_region_create_rectangle"); 
  212.    pragma Import (C, Copy, "cairo_region_copy"); 
  213.    pragma Import (C, Reference, "cairo_region_reference"); 
  214.    pragma Import (C, Destroy, "cairo_region_destroy"); 
  215.    pragma Import (C, Status, "cairo_region_status"); 
  216.    pragma Import (C, Get_Extents, "cairo_region_get_extents"); 
  217.    pragma Import (C, Num_Rectangles, "cairo_region_num_rectangles"); 
  218.    pragma Import (C, Get_Rectangle, "cairo_region_get_rectangle"); 
  219.    pragma Import (C, Contains_Rectangle, "cairo_region_contains_rectangle"); 
  220.    pragma Import (C, Translate, "cairo_region_translate"); 
  221.    pragma Import (C, Subtract, "cairo_region_subtract"); 
  222.    pragma Import (C, Subtract_Rectangle, "cairo_region_subtract_rectangle"); 
  223.    pragma Import (C, Intersect, "cairo_region_intersect"); 
  224.    pragma Import (C, Intersect_Rectangle, "cairo_region_intersect_rectangle"); 
  225.    pragma Import (C, Union, "cairo_region_union"); 
  226.    pragma Import (C, Union_Rectangle, "cairo_region_union_rectangle"); 
  227.    pragma Import (C, Do_Xor, "cairo_region_xor"); 
  228.    pragma Import (C, Xor_Rectangle, "cairo_region_xor_rectangle"); 
  229.    pragma Inline ("="); 
  230.    pragma Inline (Is_Empty); 
  231.  
  232. end Cairo.Region;