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. --  GtkGrid is a container which arranges its child widgets in rows and 
  26. --  columns. It is a very similar to Gtk.Table.Gtk_Table and Gtk.Box.Gtk_Box, 
  27. --  but it consistently uses Gtk.Widget.Gtk_Widget's 
  28. --  Gtk.Widget.Gtk_Widget:margin and Gtk.Widget.Gtk_Widget:expand properties 
  29. --  instead of custom child properties, and it fully supports <link 
  30. --  linkend="geometry-management">height-for-width geometry management</link>. 
  31. -- 
  32. --  Children are added using Gtk.Grid.Attach. They can span multiple rows or 
  33. --  columns. It is also possible to add a child next to an existing child, 
  34. --  using Gtk.Grid.Attach_Next_To. The behaviour of GtkGrid when several 
  35. --  children occupy the same grid cell is undefined. 
  36. -- 
  37. --  GtkGrid can be used like a Gtk.Box.Gtk_Box by just using 
  38. --  Gtk.Container.Add, which will place children next to each other in the 
  39. --  direction determined by the Gtk.Orientable.Gtk_Orientable:orientation 
  40. --  property. 
  41. -- 
  42. --  </description> 
  43. pragma Ada_2005; 
  44.  
  45. pragma Warnings (Off, "*is already use-visible*"); 
  46. with Glib;            use Glib; 
  47. with Glib.Properties; use Glib.Properties; 
  48. with Glib.Types;      use Glib.Types; 
  49. with Gtk.Buildable;   use Gtk.Buildable; 
  50. with Gtk.Container;   use Gtk.Container; 
  51. with Gtk.Enums;       use Gtk.Enums; 
  52. with Gtk.Orientable;  use Gtk.Orientable; 
  53. with Gtk.Widget;      use Gtk.Widget; 
  54.  
  55. package Gtk.Grid is 
  56.  
  57.    type Gtk_Grid_Record is new Gtk_Container_Record with null record; 
  58.    type Gtk_Grid is access all Gtk_Grid_Record'Class; 
  59.  
  60.    ------------------ 
  61.    -- Constructors -- 
  62.    ------------------ 
  63.  
  64.    procedure Gtk_New (Self : out Gtk_Grid); 
  65.    procedure Initialize (Self : not null access Gtk_Grid_Record'Class); 
  66.    --  Creates a new grid widget. 
  67.  
  68.    function Gtk_Grid_New return Gtk_Grid; 
  69.    --  Creates a new grid widget. 
  70.  
  71.    function Get_Type return Glib.GType; 
  72.    pragma Import (C, Get_Type, "gtk_grid_get_type"); 
  73.  
  74.    ------------- 
  75.    -- Methods -- 
  76.    ------------- 
  77.  
  78.    procedure Attach 
  79.       (Self   : not null access Gtk_Grid_Record; 
  80.        Child  : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  81.        Left   : Gint; 
  82.        Top    : Gint; 
  83.        Width  : Gint := 1; 
  84.        Height : Gint := 1); 
  85.    --  Adds a widget to the grid. 
  86.    --  The position of Child is determined by Left and Top. The number of 
  87.    --  'cells' that Child will occupy is determined by Width and Height. 
  88.    --  "child": the widget to add 
  89.    --  "left": the column number to attach the left side of Child to 
  90.    --  "top": the row number to attach the top side of Child to 
  91.    --  "width": the number of columns that Child will span 
  92.    --  "height": the number of rows that Child will span 
  93.  
  94.    procedure Attach_Next_To 
  95.       (Self    : not null access Gtk_Grid_Record; 
  96.        Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  97.        Sibling : access Gtk.Widget.Gtk_Widget_Record'Class; 
  98.        Side    : Gtk.Enums.Gtk_Position_Type; 
  99.        Width   : Gint := 1; 
  100.        Height  : Gint := 1); 
  101.    --  Adds a widget to the grid. 
  102.    --  The widget is placed next to Sibling, on the side determined by Side. 
  103.    --  When Sibling is null, the widget is placed in row (for left or right 
  104.    --  placement) or column 0 (for top or bottom placement), at the end 
  105.    --  indicated by Side. 
  106.    --  Attaching widgets labeled [1], [2], [3] with Sibling == null and Side 
  107.    --  == Gtk.Enums.Pos_Left yields a layout of [3][2][1]. 
  108.    --  "child": the widget to add 
  109.    --  "sibling": the child of Grid that Child will be placed next to, or null 
  110.    --  to place Child at the beginning or end 
  111.    --  "side": the side of Sibling that Child is positioned next to 
  112.    --  "width": the number of columns that Child will span 
  113.    --  "height": the number of rows that Child will span 
  114.  
  115.    function Get_Child_At 
  116.       (Self : not null access Gtk_Grid_Record; 
  117.        Left : Gint; 
  118.        Top  : Gint) return Gtk.Widget.Gtk_Widget; 
  119.    --  Gets the child of Grid whose area covers the grid cell whose upper left 
  120.    --  corner is at Left, Top. 
  121.    --  Since: gtk+ 3.2 
  122.    --  "left": the left edge of the cell 
  123.    --  "top": the top edge of the cell 
  124.  
  125.    function Get_Column_Homogeneous 
  126.       (Self : not null access Gtk_Grid_Record) return Boolean; 
  127.    --  Returns whether all columns of Grid have the same width. 
  128.  
  129.    procedure Set_Column_Homogeneous 
  130.       (Self        : not null access Gtk_Grid_Record; 
  131.        Homogeneous : Boolean); 
  132.    --  Sets whether all columns of Grid will have the same width. 
  133.    --  "homogeneous": True to make columns homogeneous 
  134.  
  135.    function Get_Column_Spacing 
  136.       (Self : not null access Gtk_Grid_Record) return Guint; 
  137.    --  Returns the amount of space between the columns of Grid. 
  138.  
  139.    procedure Set_Column_Spacing 
  140.       (Self    : not null access Gtk_Grid_Record; 
  141.        Spacing : Guint); 
  142.    --  Sets the amount of space between columns of Grid. 
  143.    --  "spacing": the amount of space to insert between columns 
  144.  
  145.    function Get_Row_Homogeneous 
  146.       (Self : not null access Gtk_Grid_Record) return Boolean; 
  147.    --  Returns whether all rows of Grid have the same height. 
  148.  
  149.    procedure Set_Row_Homogeneous 
  150.       (Self        : not null access Gtk_Grid_Record; 
  151.        Homogeneous : Boolean); 
  152.    --  Sets whether all rows of Grid will have the same height. 
  153.    --  "homogeneous": True to make rows homogeneous 
  154.  
  155.    function Get_Row_Spacing 
  156.       (Self : not null access Gtk_Grid_Record) return Guint; 
  157.    --  Returns the amount of space between the rows of Grid. 
  158.  
  159.    procedure Set_Row_Spacing 
  160.       (Self    : not null access Gtk_Grid_Record; 
  161.        Spacing : Guint); 
  162.    --  Sets the amount of space between rows of Grid. 
  163.    --  "spacing": the amount of space to insert between rows 
  164.  
  165.    procedure Insert_Column 
  166.       (Self     : not null access Gtk_Grid_Record; 
  167.        Position : Gint); 
  168.    --  Inserts a column at the specified position. 
  169.    --  Children which are attached at or to the right of this position are 
  170.    --  moved one column to the right. Children which span across this position 
  171.    --  are grown to span the new column. 
  172.    --  Since: gtk+ 3.2 
  173.    --  "position": the position to insert the column at 
  174.  
  175.    procedure Insert_Next_To 
  176.       (Self    : not null access Gtk_Grid_Record; 
  177.        Sibling : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  178.        Side    : Gtk.Enums.Gtk_Position_Type); 
  179.    --  Inserts a row or column at the specified position. 
  180.    --  The new row or column is placed next to Sibling, on the side determined 
  181.    --  by Side. If Side is Gtk.Enums.Pos_Top or Gtk.Enums.Pos_Bottom, a row is 
  182.    --  inserted. If Side is Gtk.Enums.Pos_Left of Gtk.Enums.Pos_Right, a column 
  183.    --  is inserted. 
  184.    --  Since: gtk+ 3.2 
  185.    --  "sibling": the child of Grid that the new row or column will be placed 
  186.    --  next to 
  187.    --  "side": the side of Sibling that Child is positioned next to 
  188.  
  189.    procedure Insert_Row 
  190.       (Self     : not null access Gtk_Grid_Record; 
  191.        Position : Gint); 
  192.    --  Inserts a row at the specified position. 
  193.    --  Children which are attached at or below this position are moved one row 
  194.    --  down. Children which span across this position are grown to span the new 
  195.    --  row. 
  196.    --  Since: gtk+ 3.2 
  197.    --  "position": the position to insert the row at 
  198.  
  199.    --------------------------------------------- 
  200.    -- Inherited subprograms (from interfaces) -- 
  201.    --------------------------------------------- 
  202.    --  Methods inherited from the Buildable interface are not duplicated here 
  203.    --  since they are meant to be used by tools, mostly. If you need to call 
  204.    --  them, use an explicit cast through the "-" operator below. 
  205.  
  206.    function Get_Orientation 
  207.       (Self : not null access Gtk_Grid_Record) 
  208.        return Gtk.Enums.Gtk_Orientation; 
  209.  
  210.    procedure Set_Orientation 
  211.       (Self        : not null access Gtk_Grid_Record; 
  212.        Orientation : Gtk.Enums.Gtk_Orientation); 
  213.  
  214.    ---------------- 
  215.    -- Properties -- 
  216.    ---------------- 
  217.    --  The following properties are defined for this widget. See 
  218.    --  Glib.Properties for more information on properties) 
  219.  
  220.    Column_Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  221.  
  222.    Column_Spacing_Property : constant Glib.Properties.Property_Int; 
  223.  
  224.    Row_Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  225.  
  226.    Row_Spacing_Property : constant Glib.Properties.Property_Int; 
  227.  
  228.    ---------------- 
  229.    -- Interfaces -- 
  230.    ---------------- 
  231.    --  This class implements several interfaces. See Glib.Types 
  232.    -- 
  233.    --  - "Buildable" 
  234.    -- 
  235.    --  - "Orientable" 
  236.  
  237.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  238.      (Gtk.Buildable.Gtk_Buildable, Gtk_Grid_Record, Gtk_Grid); 
  239.    function "+" 
  240.      (Widget : access Gtk_Grid_Record'Class) 
  241.    return Gtk.Buildable.Gtk_Buildable 
  242.    renames Implements_Gtk_Buildable.To_Interface; 
  243.    function "-" 
  244.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  245.    return Gtk_Grid 
  246.    renames Implements_Gtk_Buildable.To_Object; 
  247.  
  248.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  249.      (Gtk.Orientable.Gtk_Orientable, Gtk_Grid_Record, Gtk_Grid); 
  250.    function "+" 
  251.      (Widget : access Gtk_Grid_Record'Class) 
  252.    return Gtk.Orientable.Gtk_Orientable 
  253.    renames Implements_Gtk_Orientable.To_Interface; 
  254.    function "-" 
  255.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  256.    return Gtk_Grid 
  257.    renames Implements_Gtk_Orientable.To_Object; 
  258.  
  259. private 
  260.    Row_Spacing_Property : constant Glib.Properties.Property_Int := 
  261.      Glib.Properties.Build ("row-spacing"); 
  262.    Row_Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  263.      Glib.Properties.Build ("row-homogeneous"); 
  264.    Column_Spacing_Property : constant Glib.Properties.Property_Int := 
  265.      Glib.Properties.Build ("column-spacing"); 
  266.    Column_Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  267.      Glib.Properties.Build ("column-homogeneous"); 
  268. end Gtk.Grid;