1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, 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. --  <description> 
  25. --  The Gtk.Cell_Area_Context.Gtk_Cell_Area_Context object is created by a 
  26. --  given Gtk.Cell_Area.Gtk_Cell_Area implementation via its 
  27. --  Gtk.Cell_Area_Class.Gtk_Cell_Area_Class.create_context virtual method and 
  28. --  is used to store cell sizes and alignments for a series of 
  29. --  Gtk.Tree_Model.Gtk_Tree_Model rows that are requested and rendered in the 
  30. --  same context. 
  31. -- 
  32. --  Gtk.Cell_Layout.Gtk_Cell_Layout widgets can create any number of contexts 
  33. --  in which to request and render groups of data rows. However, it's important 
  34. --  that the same context which was used to request sizes for a given 
  35. --  Gtk.Tree_Model.Gtk_Tree_Model row also be used for the same row when 
  36. --  calling other Gtk.Cell_Area.Gtk_Cell_Area APIs such as Gtk.Cell_Area.Render 
  37. --  and Gtk.Cell_Area.Event. 
  38. -- 
  39. --  </description> 
  40. --  <group>Layout Containers</group> 
  41. pragma Ada_2005; 
  42.  
  43. pragma Warnings (Off, "*is already use-visible*"); 
  44. with Glib;            use Glib; 
  45. with Glib.Object;     use Glib.Object; 
  46. with Glib.Properties; use Glib.Properties; 
  47.  
  48. package Gtk.Cell_Area_Context is 
  49.  
  50.    type Gtk_Cell_Area_Context_Record is new GObject_Record with null record; 
  51.    type Gtk_Cell_Area_Context is access all Gtk_Cell_Area_Context_Record'Class; 
  52.  
  53.    ------------------ 
  54.    -- Constructors -- 
  55.    ------------------ 
  56.  
  57.    function Get_Type return Glib.GType; 
  58.    pragma Import (C, Get_Type, "gtk_cell_area_context_get_type"); 
  59.  
  60.    ------------- 
  61.    -- Methods -- 
  62.    ------------- 
  63.  
  64.    procedure Allocate 
  65.       (Self   : not null access Gtk_Cell_Area_Context_Record; 
  66.        Width  : Gint; 
  67.        Height : Gint); 
  68.    --  Allocates a width and/or a height for all rows which are to be rendered 
  69.    --  with Context. 
  70.    --  Usually allocation is performed only horizontally or sometimes 
  71.    --  vertically since a group of rows are usually rendered side by side 
  72.    --  vertically or horizontally and share either the same width or the same 
  73.    --  height. Sometimes they are allocated in both horizontal and vertical 
  74.    --  orientations producing a homogeneous effect of the rows. This is 
  75.    --  generally the case for Gtk.Tree_View.Gtk_Tree_View when 
  76.    --  Gtk.Tree_View.Gtk_Tree_View:fixed-height-mode is enabled. 
  77.    --  Since 3.0 
  78.    --  "width": the allocated width for all Gtk.Tree_Model.Gtk_Tree_Model rows 
  79.    --  rendered with Context, or -1. 
  80.    --  "height": the allocated height for all Gtk.Tree_Model.Gtk_Tree_Model 
  81.    --  rows rendered with Context, or -1. 
  82.  
  83.    procedure Get_Allocation 
  84.       (Self   : not null access Gtk_Cell_Area_Context_Record; 
  85.        Width  : out Gint; 
  86.        Height : out Gint); 
  87.    --  Fetches the current allocation size for Context. 
  88.    --  If the context was not allocated in width or height, or if the context 
  89.    --  was recently reset with Gtk.Cell_Area_Context.Reset, the returned value 
  90.    --  will be -1. 
  91.    --  Since: gtk+ 3.0 
  92.    --  "width": location to store the allocated width, or null 
  93.    --  "height": location to store the allocated height, or null 
  94.  
  95.    procedure Get_Preferred_Height 
  96.       (Self           : not null access Gtk_Cell_Area_Context_Record; 
  97.        Minimum_Height : out Gint; 
  98.        Natural_Height : out Gint); 
  99.    --  Gets the accumulative preferred height for all rows which have been 
  100.    --  requested with this context. 
  101.    --  After Gtk.Cell_Area_Context.Reset is called and/or before ever 
  102.    --  requesting the size of a Gtk.Cell_Area.Gtk_Cell_Area, the returned 
  103.    --  values are 0. 
  104.    --  Since: gtk+ 3.0 
  105.    --  "minimum_height": location to store the minimum height, or null 
  106.    --  "natural_height": location to store the natural height, or null 
  107.  
  108.    procedure Get_Preferred_Height_For_Width 
  109.       (Self           : not null access Gtk_Cell_Area_Context_Record; 
  110.        Width          : Gint; 
  111.        Minimum_Height : out Gint; 
  112.        Natural_Height : out Gint); 
  113.    --  Gets the accumulative preferred height for Width for all rows which 
  114.    --  have been requested for the same said Width with this context. 
  115.    --  After Gtk.Cell_Area_Context.Reset is called and/or before ever 
  116.    --  requesting the size of a Gtk.Cell_Area.Gtk_Cell_Area, the returned 
  117.    --  values are -1. 
  118.    --  Since: gtk+ 3.0 
  119.    --  "width": a proposed width for allocation 
  120.    --  "minimum_height": location to store the minimum height, or null 
  121.    --  "natural_height": location to store the natural height, or null 
  122.  
  123.    procedure Get_Preferred_Width 
  124.       (Self          : not null access Gtk_Cell_Area_Context_Record; 
  125.        Minimum_Width : out Gint; 
  126.        Natural_Width : out Gint); 
  127.    --  Gets the accumulative preferred width for all rows which have been 
  128.    --  requested with this context. 
  129.    --  After Gtk.Cell_Area_Context.Reset is called and/or before ever 
  130.    --  requesting the size of a Gtk.Cell_Area.Gtk_Cell_Area, the returned 
  131.    --  values are 0. 
  132.    --  Since: gtk+ 3.0 
  133.    --  "minimum_width": location to store the minimum width, or null 
  134.    --  "natural_width": location to store the natural width, or null 
  135.  
  136.    procedure Get_Preferred_Width_For_Height 
  137.       (Self          : not null access Gtk_Cell_Area_Context_Record; 
  138.        Height        : Gint; 
  139.        Minimum_Width : out Gint; 
  140.        Natural_Width : out Gint); 
  141.    --  Gets the accumulative preferred width for Height for all rows which 
  142.    --  have been requested for the same said Height with this context. 
  143.    --  After Gtk.Cell_Area_Context.Reset is called and/or before ever 
  144.    --  requesting the size of a Gtk.Cell_Area.Gtk_Cell_Area, the returned 
  145.    --  values are -1. 
  146.    --  Since: gtk+ 3.0 
  147.    --  "height": a proposed height for allocation 
  148.    --  "minimum_width": location to store the minimum width, or null 
  149.    --  "natural_width": location to store the natural width, or null 
  150.  
  151.    procedure Push_Preferred_Height 
  152.       (Self           : not null access Gtk_Cell_Area_Context_Record; 
  153.        Minimum_Height : Gint; 
  154.        Natural_Height : Gint); 
  155.    --  Causes the minimum and/or natural height to grow if the new proposed 
  156.    --  sizes exceed the current minimum and natural height. 
  157.    --  This is used by Gtk.Cell_Area_Context.Gtk_Cell_Area_Context 
  158.    --  implementations during the request process over a series of 
  159.    --  Gtk.Tree_Model.Gtk_Tree_Model rows to progressively push the requested 
  160.    --  height over a series of Gtk.Cell_Area.Get_Preferred_Height requests. 
  161.    --  Since: gtk+ 3.0 
  162.    --  "minimum_height": the proposed new minimum height for Context 
  163.    --  "natural_height": the proposed new natural height for Context 
  164.  
  165.    procedure Push_Preferred_Width 
  166.       (Self          : not null access Gtk_Cell_Area_Context_Record; 
  167.        Minimum_Width : Gint; 
  168.        Natural_Width : Gint); 
  169.    --  Causes the minimum and/or natural width to grow if the new proposed 
  170.    --  sizes exceed the current minimum and natural width. 
  171.    --  This is used by Gtk.Cell_Area_Context.Gtk_Cell_Area_Context 
  172.    --  implementations during the request process over a series of 
  173.    --  Gtk.Tree_Model.Gtk_Tree_Model rows to progressively push the requested 
  174.    --  width over a series of Gtk.Cell_Area.Get_Preferred_Width requests. 
  175.    --  Since: gtk+ 3.0 
  176.    --  "minimum_width": the proposed new minimum width for Context 
  177.    --  "natural_width": the proposed new natural width for Context 
  178.  
  179.    procedure Reset (Self : not null access Gtk_Cell_Area_Context_Record); 
  180.    --  Resets any previously cached request and allocation data. 
  181.    --  When underlying Gtk.Tree_Model.Gtk_Tree_Model data changes its 
  182.    --  important to reset the context if the content size is allowed to shrink. 
  183.    --  If the content size is only allowed to grow (this is usually an option 
  184.    --  for views rendering large data stores as a measure of optimization), 
  185.    --  then only the row that changed or was inserted needs to be (re)requested 
  186.    --  with Gtk.Cell_Area.Get_Preferred_Width. 
  187.    --  When the new overall size of the context requires that the allocated 
  188.    --  size changes (or whenever this allocation changes at all), the variable 
  189.    --  row sizes need to be re-requested for every row. 
  190.    --  For instance, if the rows are displayed all with the same width from 
  191.    --  top to bottom then a change in the allocated width necessitates a 
  192.    --  recalculation of all the displayed row heights using 
  193.    --  Gtk.Cell_Area.Get_Preferred_Height_For_Width. 
  194.    --  Since 3.0 
  195.  
  196.    ---------------- 
  197.    -- Properties -- 
  198.    ---------------- 
  199.    --  The following properties are defined for this widget. See 
  200.    --  Glib.Properties for more information on properties) 
  201.  
  202.    Area_Property : constant Glib.Properties.Property_Object; 
  203.    --  Type: Gtk.Cell_Area.Gtk_Cell_Area 
  204.    --  The Gtk.Cell_Area.Gtk_Cell_Area this context was created by 
  205.  
  206.    Minimum_Height_Property : constant Glib.Properties.Property_Int; 
  207.    --  The minimum height for the Gtk.Cell_Area.Gtk_Cell_Area in this context 
  208.    --  for all Gtk.Tree_Model.Gtk_Tree_Model rows that this context was 
  209.    --  requested for using Gtk.Cell_Area.Get_Preferred_Height. 
  210.  
  211.    Minimum_Width_Property : constant Glib.Properties.Property_Int; 
  212.    --  The minimum width for the Gtk.Cell_Area.Gtk_Cell_Area in this context 
  213.    --  for all Gtk.Tree_Model.Gtk_Tree_Model rows that this context was 
  214.    --  requested for using Gtk.Cell_Area.Get_Preferred_Width. 
  215.  
  216.    Natural_Height_Property : constant Glib.Properties.Property_Int; 
  217.    --  The natural height for the Gtk.Cell_Area.Gtk_Cell_Area in this context 
  218.    --  for all Gtk.Tree_Model.Gtk_Tree_Model rows that this context was 
  219.    --  requested for using Gtk.Cell_Area.Get_Preferred_Height. 
  220.  
  221.    Natural_Width_Property : constant Glib.Properties.Property_Int; 
  222.    --  The natural width for the Gtk.Cell_Area.Gtk_Cell_Area in this context 
  223.    --  for all Gtk.Tree_Model.Gtk_Tree_Model rows that this context was 
  224.    --  requested for using Gtk.Cell_Area.Get_Preferred_Width. 
  225.  
  226. private 
  227.    Natural_Width_Property : constant Glib.Properties.Property_Int := 
  228.      Glib.Properties.Build ("natural-width"); 
  229.    Natural_Height_Property : constant Glib.Properties.Property_Int := 
  230.      Glib.Properties.Build ("natural-height"); 
  231.    Minimum_Width_Property : constant Glib.Properties.Property_Int := 
  232.      Glib.Properties.Build ("minimum-width"); 
  233.    Minimum_Height_Property : constant Glib.Properties.Property_Int := 
  234.      Glib.Properties.Build ("minimum-height"); 
  235.    Area_Property : constant Glib.Properties.Property_Object := 
  236.      Glib.Properties.Build ("area"); 
  237. end Gtk.Cell_Area_Context;