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.Table.Gtk_Table functions allow the programmer to arrange widgets 
  26. --  in rows and columns, making it easy to align many widgets next to each 
  27. --  other, horizontally and vertically. 
  28. -- 
  29. --  Tables are created with a call to Gtk.Table.Gtk_New, the size of which can 
  30. --  later be changed with Gtk.Table.Resize. 
  31. -- 
  32. --  Widgets can be added to a table using Gtk.Table.Attach or the more 
  33. --  convenient (but slightly less flexible) Gtk.Table.Attach_Defaults. 
  34. -- 
  35. --  To alter the space next to a specific row, use Gtk.Table.Set_Row_Spacing, 
  36. --  and for a column, Gtk.Table.Set_Col_Spacing. The gaps between *all* rows or 
  37. --  columns can be changed by calling Gtk.Table.Set_Row_Spacings or 
  38. --  Gtk.Table.Set_Col_Spacings respectively. Note that spacing is added 
  39. --  *between* the children, while padding added by Gtk.Table.Attach is added 
  40. --  *on either side* of the widget it belongs to. 
  41. -- 
  42. --  Gtk.Table.Set_Homogeneous, can be used to set whether all cells in the 
  43. --  table will resize themselves to the size of the largest widget in the 
  44. --  table. 
  45. -- 
  46. --  Note: Gtk.Table.Gtk_Table has been deprecated. Use Gtk.Grid.Gtk_Grid 
  47. --  instead. It provides the same capabilities as GtkTable for arranging 
  48. --  widgets in a rectangular grid, but does support height-for-width geometry 
  49. --  management. 
  50. -- 
  51. --  </description> 
  52. --  <group>Layout containers</group> 
  53. pragma Ada_2005; 
  54.  
  55. pragma Warnings (Off, "*is already use-visible*"); 
  56. with Glib;            use Glib; 
  57. with Glib.Properties; use Glib.Properties; 
  58. with Glib.Types;      use Glib.Types; 
  59. with Gtk.Buildable;   use Gtk.Buildable; 
  60. with Gtk.Container;   use Gtk.Container; 
  61. with Gtk.Enums;       use Gtk.Enums; 
  62. with Gtk.Widget;      use Gtk.Widget; 
  63.  
  64. package Gtk.Table is 
  65.  
  66.    type Gtk_Table_Record is new Gtk_Container_Record with null record; 
  67.    type Gtk_Table is access all Gtk_Table_Record'Class; 
  68.  
  69.    ------------------ 
  70.    -- Constructors -- 
  71.    ------------------ 
  72.  
  73.    procedure Gtk_New 
  74.       (Table       : out Gtk_Table; 
  75.        Rows        : Guint; 
  76.        Columns     : Guint; 
  77.        Homogeneous : Boolean); 
  78.    procedure Initialize 
  79.       (Table       : not null access Gtk_Table_Record'Class; 
  80.        Rows        : Guint; 
  81.        Columns     : Guint; 
  82.        Homogeneous : Boolean); 
  83.    --  Create a new table. The width allocated to the table is divided into 
  84.    --  Columns columns, which all have the same width if Homogeneous is True. 
  85.    --  If Homogeneous is False, the width will be calculated with the children 
  86.    --  contained in the table. Same behavior for the rows. 
  87.    --  "rows": The number of rows the new table should have. 
  88.    --  "columns": The number of columns the new table should have. 
  89.    --  "homogeneous": If set to True, all table cells are resized to the size 
  90.    --  of the cell containing the largest widget. 
  91.  
  92.    function Gtk_Table_New 
  93.       (Rows        : Guint; 
  94.        Columns     : Guint; 
  95.        Homogeneous : Boolean) return Gtk_Table; 
  96.    --  Create a new table. The width allocated to the table is divided into 
  97.    --  Columns columns, which all have the same width if Homogeneous is True. 
  98.    --  If Homogeneous is False, the width will be calculated with the children 
  99.    --  contained in the table. Same behavior for the rows. 
  100.    --  "rows": The number of rows the new table should have. 
  101.    --  "columns": The number of columns the new table should have. 
  102.    --  "homogeneous": If set to True, all table cells are resized to the size 
  103.    --  of the cell containing the largest widget. 
  104.  
  105.    function Get_Type return Glib.GType; 
  106.    pragma Import (C, Get_Type, "gtk_table_get_type"); 
  107.  
  108.    ------------- 
  109.    -- Methods -- 
  110.    ------------- 
  111.  
  112.    procedure Attach 
  113.       (Table         : not null access Gtk_Table_Record; 
  114.        Child         : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  115.        Left_Attach   : Guint; 
  116.        Right_Attach  : Guint; 
  117.        Top_Attach    : Guint; 
  118.        Bottom_Attach : Guint; 
  119.        Xoptions      : Gtk.Enums.Gtk_Attach_Options := Expand or Fill; 
  120.        Yoptions      : Gtk.Enums.Gtk_Attach_Options := Expand or Fill; 
  121.        Xpadding      : Guint := 0; 
  122.        Ypadding      : Guint := 0); 
  123.    pragma Obsolescent (Attach); 
  124.    --  Insert a new widget in the table. All the attachments are relative to 
  125.    --  the separations between columns and rows (for instance, to insert a 
  126.    --  widget spanning the first two columns in the table, you should put 
  127.    --  Left_Attach=0 and Right_Attach=2). Same behavior for the rows. Xoptions 
  128.    --  and Yoptions indicate the behavior of the child when the table is 
  129.    --  resized (whether the child can shrink or expand). See the description in 
  130.    --  Gtk.Box for more information on the possible values. Xpadding and 
  131.    --  Ypadding are the amount of space left around the child. 
  132.    --  Deprecated since 3.4, Use Gtk.Grid.Attach with Gtk.Grid.Gtk_Grid. Note 
  133.    --  that the attach arguments differ between those two functions. 
  134.    --  "child": The widget to add. 
  135.    --  "left_attach": the column number to attach the left side of a child 
  136.    --  widget to. 
  137.    --  "right_attach": the column number to attach the right side of a child 
  138.    --  widget to. 
  139.    --  "top_attach": the row number to attach the top of a child widget to. 
  140.    --  "bottom_attach": the row number to attach the bottom of a child widget 
  141.    --  to. 
  142.    --  "xoptions": Used to specify the properties of the child widget when the 
  143.    --  table is resized. 
  144.    --  "yoptions": The same as xoptions, except this field determines 
  145.    --  behaviour of vertical resizing. 
  146.    --  "xpadding": An integer value specifying the padding on the left and 
  147.    --  right of the widget being added to the table. 
  148.    --  "ypadding": The amount of padding above and below the child widget. 
  149.  
  150.    procedure Attach_Defaults 
  151.       (Table         : not null access Gtk_Table_Record; 
  152.        Widget        : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  153.        Left_Attach   : Guint; 
  154.        Right_Attach  : Guint; 
  155.        Top_Attach    : Guint; 
  156.        Bottom_Attach : Guint); 
  157.    pragma Obsolescent (Attach_Defaults); 
  158.    --  Insert a new widget in the table, with default values. No padding is 
  159.    --  put around the child, and the options are set to Expand and Fill. This 
  160.    --  call is similar to Attach with default values and is only provided for 
  161.    --  compatibility. 
  162.    --  Deprecated since 3.4, Use Gtk.Grid.Attach with Gtk.Grid.Gtk_Grid. Note 
  163.    --  that the attach arguments differ between those two functions. 
  164.    --  "widget": The child widget to add. 
  165.    --  "left_attach": The column number to attach the left side of the child 
  166.    --  widget to. 
  167.    --  "right_attach": The column number to attach the right side of the child 
  168.    --  widget to. 
  169.    --  "top_attach": The row number to attach the top of the child widget to. 
  170.    --  "bottom_attach": The row number to attach the bottom of the child 
  171.    --  widget to. 
  172.  
  173.    function Get_Col_Spacing 
  174.       (Table  : not null access Gtk_Table_Record; 
  175.        Column : Guint) return Guint; 
  176.    pragma Obsolescent (Get_Col_Spacing); 
  177.    --  Gets the amount of space between column Col, and column Col + 1. See 
  178.    --  Gtk.Table.Set_Col_Spacing. 
  179.    --  Deprecated since 3.4, Gtk.Grid.Gtk_Grid does not offer a replacement 
  180.    --  for this functionality. 
  181.    --  "column": a column in the table, 0 indicates the first column 
  182.  
  183.    procedure Set_Col_Spacing 
  184.       (Table   : not null access Gtk_Table_Record; 
  185.        Column  : Guint; 
  186.        Spacing : Guint); 
  187.    pragma Obsolescent (Set_Col_Spacing); 
  188.    --  Set the spacing in pixels between Column and the next one. 
  189.    --  Deprecated since 3.4, Use Gtk.Widget.Set_Margin_Left and 
  190.    --  Gtk.Widget.Set_Margin_Right on the widgets contained in the row if you 
  191.    --  need this functionality. Gtk.Grid.Gtk_Grid does not support per-row 
  192.    --  spacing. 
  193.    --  "column": the column whose spacing should be changed. 
  194.    --  "spacing": number of pixels that the spacing should take up. 
  195.  
  196.    function Get_Default_Col_Spacing 
  197.       (Table : not null access Gtk_Table_Record) return Guint; 
  198.    pragma Obsolescent (Get_Default_Col_Spacing); 
  199.    --  Gets the default column spacing for the table. This is the spacing that 
  200.    --  will be used for newly added columns. (See Gtk.Table.Set_Col_Spacings) 
  201.    --  Deprecated since 3.4, Use Gtk.Grid.Get_Column_Spacing with 
  202.    --  Gtk.Grid.Gtk_Grid. 
  203.  
  204.    function Get_Default_Row_Spacing 
  205.       (Table : not null access Gtk_Table_Record) return Guint; 
  206.    pragma Obsolescent (Get_Default_Row_Spacing); 
  207.    --  Gets the default row spacing for the table. This is the spacing that 
  208.    --  will be used for newly added rows. (See Gtk.Table.Set_Row_Spacings) 
  209.    --  Deprecated since 3.4, Use Gtk.Grid.Get_Row_Spacing with 
  210.    --  Gtk.Grid.Gtk_Grid. 
  211.  
  212.    function Get_Homogeneous 
  213.       (Table : not null access Gtk_Table_Record) return Boolean; 
  214.    pragma Obsolescent (Get_Homogeneous); 
  215.    --  Returns whether the table cells are all constrained to the same width 
  216.    --  and height. (See gtk_table_set_homogenous ()) 
  217.    --  Deprecated since 3.4, Use Gtk.Grid.Get_Row_Homogeneous and 
  218.    --  Gtk.Grid.Get_Column_Homogeneous with Gtk.Grid.Gtk_Grid. 
  219.  
  220.    procedure Set_Homogeneous 
  221.       (Table       : not null access Gtk_Table_Record; 
  222.        Homogeneous : Boolean); 
  223.    pragma Obsolescent (Set_Homogeneous); 
  224.    --  Indicate the homogeneous status of the table. If Homogeneous is True, 
  225.    --  the rows and columns of the table will all be allocated the same width 
  226.    --  or height. 
  227.    --  Deprecated since 3.4, Use Gtk.Grid.Set_Row_Homogeneous and 
  228.    --  Gtk.Grid.Set_Column_Homogeneous with Gtk.Grid.Gtk_Grid. 
  229.    --  "homogeneous": Set to True to ensure all table cells are the same size. 
  230.    --  Set to False if this is not your desired behaviour. 
  231.  
  232.    function Get_Row_Spacing 
  233.       (Table : not null access Gtk_Table_Record; 
  234.        Row   : Guint) return Guint; 
  235.    pragma Obsolescent (Get_Row_Spacing); 
  236.    --  Gets the amount of space between row Row, and row Row + 1. See 
  237.    --  Gtk.Table.Set_Row_Spacing. 
  238.    --  Deprecated since 3.4, Gtk.Grid.Gtk_Grid does not offer a replacement 
  239.    --  for this functionality. 
  240.    --  "row": a row in the table, 0 indicates the first row 
  241.  
  242.    procedure Set_Row_Spacing 
  243.       (Table   : not null access Gtk_Table_Record; 
  244.        Row     : Guint; 
  245.        Spacing : Guint); 
  246.    pragma Obsolescent (Set_Row_Spacing); 
  247.    --  Changes the space between a given table row and the subsequent row. 
  248.    --  Deprecated since 3.4, Use Gtk.Widget.Set_Margin_Top and 
  249.    --  Gtk.Widget.Set_Margin_Bottom on the widgets contained in the row if you 
  250.    --  need this functionality. Gtk.Grid.Gtk_Grid does not support per-row 
  251.    --  spacing. 
  252.    --  "row": row number whose spacing will be changed. 
  253.    --  "spacing": number of pixels that the spacing should take up. 
  254.  
  255.    procedure Get_Size 
  256.       (Table   : not null access Gtk_Table_Record; 
  257.        Rows    : out Guint; 
  258.        Columns : out Guint); 
  259.    pragma Obsolescent (Get_Size); 
  260.    --  Gets the number of rows and columns in the table. 
  261.    --  Since: gtk+ 2.22 
  262.    --  Deprecated since 3.4, Gtk.Grid.Gtk_Grid does not expose the number of 
  263.    --  columns and rows. 
  264.    --  "rows": return location for the number of rows, or null 
  265.    --  "columns": return location for the number of columns, or null 
  266.  
  267.    procedure Resize 
  268.       (Table   : not null access Gtk_Table_Record; 
  269.        Rows    : Guint; 
  270.        Columns : Guint); 
  271.    pragma Obsolescent (Resize); 
  272.    --  If you need to change a table's size *after* it has been created, this 
  273.    --  function allows you to do so. 
  274.    --  Deprecated since 3.4, Gtk.Grid.Gtk_Grid resizes automatically. 
  275.    --  "rows": The new number of rows. 
  276.    --  "columns": The new number of columns. 
  277.  
  278.    procedure Set_Col_Spacings 
  279.       (Table   : not null access Gtk_Table_Record; 
  280.        Spacing : Guint); 
  281.    pragma Obsolescent (Set_Col_Spacings); 
  282.    --  Sets the space between every column in Table equal to Spacing. 
  283.    --  Deprecated since 3.4, Use Gtk.Grid.Set_Column_Spacing with 
  284.    --  Gtk.Grid.Gtk_Grid. 
  285.    --  "spacing": the number of pixels of space to place between every column 
  286.    --  in the table. 
  287.  
  288.    procedure Set_Row_Spacings 
  289.       (Table   : not null access Gtk_Table_Record; 
  290.        Spacing : Guint); 
  291.    pragma Obsolescent (Set_Row_Spacings); 
  292.    --  Sets the space between every row in Table equal to Spacing. 
  293.    --  Deprecated since 3.4, Use Gtk.Grid.Set_Row_Spacing with 
  294.    --  Gtk.Grid.Gtk_Grid. 
  295.    --  "spacing": the number of pixels of space to place between every row in 
  296.    --  the table. 
  297.  
  298.    ---------------- 
  299.    -- Properties -- 
  300.    ---------------- 
  301.    --  The following properties are defined for this widget. See 
  302.    --  Glib.Properties for more information on properties) 
  303.  
  304.    Column_Spacing_Property : constant Glib.Properties.Property_Uint; 
  305.  
  306.    Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  307.  
  308.    N_Columns_Property : constant Glib.Properties.Property_Uint; 
  309.  
  310.    N_Rows_Property : constant Glib.Properties.Property_Uint; 
  311.  
  312.    Row_Spacing_Property : constant Glib.Properties.Property_Uint; 
  313.  
  314.    ---------------- 
  315.    -- Interfaces -- 
  316.    ---------------- 
  317.    --  This class implements several interfaces. See Glib.Types 
  318.    -- 
  319.    --  - "Buildable" 
  320.  
  321.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  322.      (Gtk.Buildable.Gtk_Buildable, Gtk_Table_Record, Gtk_Table); 
  323.    function "+" 
  324.      (Widget : access Gtk_Table_Record'Class) 
  325.    return Gtk.Buildable.Gtk_Buildable 
  326.    renames Implements_Gtk_Buildable.To_Interface; 
  327.    function "-" 
  328.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  329.    return Gtk_Table 
  330.    renames Implements_Gtk_Buildable.To_Object; 
  331.  
  332. private 
  333.    Row_Spacing_Property : constant Glib.Properties.Property_Uint := 
  334.      Glib.Properties.Build ("row-spacing"); 
  335.    N_Rows_Property : constant Glib.Properties.Property_Uint := 
  336.      Glib.Properties.Build ("n-rows"); 
  337.    N_Columns_Property : constant Glib.Properties.Property_Uint := 
  338.      Glib.Properties.Build ("n-columns"); 
  339.    Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  340.      Glib.Properties.Build ("homogeneous"); 
  341.    Column_Spacing_Property : constant Glib.Properties.Property_Uint := 
  342.      Glib.Properties.Build ("column-spacing"); 
  343. end Gtk.Table;