1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2011, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. --  A Gtk_Table is a container that can contain any number of children. Each 
  27. --  of them is attached to a specific row and a specific column in widget. 
  28. -- 
  29. --  Every row in the table must have the same height, and every column must 
  30. --  have the same width if the table was said as Homogeneous. But you can also 
  31. --  decide to have an heterogeneous table, where the width and height are set 
  32. --  by the children contained in the table. Check out the Gtk_Sheet widget for 
  33. --  a different kind of table that can also contain text and images in a more 
  34. --  efficient way. 
  35. -- 
  36. --  </description> 
  37. --  <group>Layout containers</group> 
  38.  
  39. pragma Warnings (Off, "*is already use-visible*"); 
  40. with Glib;            use Glib; 
  41. with Glib.Properties; use Glib.Properties; 
  42. with Glib.Types;      use Glib.Types; 
  43. with Gtk.Buildable;   use Gtk.Buildable; 
  44. with Gtk.Container;   use Gtk.Container; 
  45. with Gtk.Enums;       use Gtk.Enums; 
  46. with Gtk.Widget;      use Gtk.Widget; 
  47.  
  48. package Gtk.Table is 
  49.  
  50.    type Gtk_Table_Record is new Gtk_Container_Record with null record; 
  51.    type Gtk_Table is access all Gtk_Table_Record'Class; 
  52.  
  53.    ------------------ 
  54.    -- Constructors -- 
  55.    ------------------ 
  56.  
  57.    procedure Gtk_New 
  58.       (Table       : out Gtk_Table; 
  59.        Rows        : Guint; 
  60.        Columns     : Guint; 
  61.        Homogeneous : Boolean); 
  62.    procedure Initialize 
  63.       (Table       : access Gtk_Table_Record'Class; 
  64.        Rows        : Guint; 
  65.        Columns     : Guint; 
  66.        Homogeneous : Boolean); 
  67.    --  Create a new table. The width allocated to the table is divided into 
  68.    --  Columns columns, which all have the same width if Homogeneous is True. 
  69.    --  If Homogeneous is False, the width will be calculated with the children 
  70.    --  contained in the table. Same behavior for the rows. 
  71.  
  72.    function Get_Type return Glib.GType; 
  73.    pragma Import (C, Get_Type, "gtk_table_get_type"); 
  74.  
  75.    ------------- 
  76.    -- Methods -- 
  77.    ------------- 
  78.  
  79.    procedure Attach 
  80.       (Table         : access Gtk_Table_Record; 
  81.        Child         : access Gtk.Widget.Gtk_Widget_Record'Class; 
  82.        Left_Attach   : Guint; 
  83.        Right_Attach  : Guint; 
  84.        Top_Attach    : Guint; 
  85.        Bottom_Attach : Guint; 
  86.        Xoptions      : Gtk.Enums.Gtk_Attach_Options := Expand or Fill; 
  87.        Yoptions      : Gtk.Enums.Gtk_Attach_Options := Expand or Fill; 
  88.        Xpadding      : Guint := 0; 
  89.        Ypadding      : Guint := 0); 
  90.    --  Insert a new widget in the table. All the attachments are relative to 
  91.    --  the separations between columns and rows (for instance, to insert a 
  92.    --  widget spanning the first two columns in the table, you should put 
  93.    --  Left_Attach=0 and Right_Attach=2). Same behavior for the rows. Xoptions 
  94.    --  and Yoptions indicate the behavior of the child when the table is 
  95.    --  resized (whether the child can shrink or expand). See the description in 
  96.    --  Gtk.Box for more information on the possible values. Xpadding and 
  97.    --  Ypadding are the amount of space left around the child. 
  98.  
  99.    procedure Attach_Defaults 
  100.       (Table         : access Gtk_Table_Record; 
  101.        Widget        : access Gtk.Widget.Gtk_Widget_Record'Class; 
  102.        Left_Attach   : Guint; 
  103.        Right_Attach  : Guint; 
  104.        Top_Attach    : Guint; 
  105.        Bottom_Attach : Guint); 
  106.    --  Insert a new widget in the table, with default values. No padding is 
  107.    --  put around the child, and the options are set to Expand and Fill. This 
  108.    --  call is similar to Attach with default values and is only provided for 
  109.    --  compatibility. 
  110.  
  111.    function Get_Col_Spacing 
  112.       (Table  : access Gtk_Table_Record; 
  113.        Column : Guint) return Guint; 
  114.    procedure Set_Col_Spacing 
  115.       (Table   : access Gtk_Table_Record; 
  116.        Column  : Guint; 
  117.        Spacing : Guint); 
  118.    --  Set the spacing in pixels between Column and the next one. 
  119.  
  120.    function Get_Default_Col_Spacing 
  121.       (Table : access Gtk_Table_Record) return Guint; 
  122.    --  Gets the default column spacing for the table. This is the spacing that 
  123.    --  will be used for newly added columns. (See Gtk.Table.Set_Col_Spacings) 
  124.    --  Returns the default column spacing 
  125.  
  126.    function Get_Default_Row_Spacing 
  127.       (Table : access Gtk_Table_Record) return Guint; 
  128.    --  Gets the default row spacing for the table. This is the spacing that 
  129.    --  will be used for newly added rows. (See Gtk.Table.Set_Row_Spacings) 
  130.    --  Returns the default row spacing 
  131.  
  132.    function Get_Homogeneous (Table : access Gtk_Table_Record) return Boolean; 
  133.    procedure Set_Homogeneous 
  134.       (Table       : access Gtk_Table_Record; 
  135.        Homogeneous : Boolean); 
  136.    --  Indicate the homogeneous status of the table. If Homogeneous is True, 
  137.    --  the rows and columns of the table will all be allocated the same width 
  138.    --  or height. 
  139.  
  140.    function Get_Row_Spacing 
  141.       (Table : access Gtk_Table_Record; 
  142.        Row   : Guint) return Guint; 
  143.    procedure Set_Row_Spacing 
  144.       (Table   : access Gtk_Table_Record; 
  145.        Row     : Guint; 
  146.        Spacing : Guint); 
  147.  
  148.    procedure Get_Size 
  149.       (Table   : access Gtk_Table_Record; 
  150.        Rows    : out Guint; 
  151.        Columns : out Guint); 
  152.    --  Returns the number of rows and columns in the table. 
  153.    --  Since: gtk+ 2.22 
  154.    --  "rows": return location for the number of rows, or null 
  155.    --  "columns": return location for the number of columns, or null 
  156.  
  157.    procedure Resize 
  158.       (Table   : access Gtk_Table_Record; 
  159.        Rows    : Guint; 
  160.        Columns : Guint); 
  161.  
  162.    procedure Set_Col_Spacings 
  163.       (Table   : access Gtk_Table_Record; 
  164.        Spacing : Guint); 
  165.  
  166.    procedure Set_Row_Spacings 
  167.       (Table   : access Gtk_Table_Record; 
  168.        Spacing : Guint); 
  169.  
  170.    ---------------- 
  171.    -- Interfaces -- 
  172.    ---------------- 
  173.    --  This class implements several interfaces. See Glib.Types 
  174.    -- 
  175.    --  - "Buildable" 
  176.  
  177.    package Implements_Buildable is new Glib.Types.Implements 
  178.      (Gtk.Buildable.Gtk_Buildable, Gtk_Table_Record, Gtk_Table); 
  179.    function "+" 
  180.      (Widget : access Gtk_Table_Record'Class) 
  181.    return Gtk.Buildable.Gtk_Buildable 
  182.    renames Implements_Buildable.To_Interface; 
  183.    function "-" 
  184.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  185.    return Gtk_Table 
  186.    renames Implements_Buildable.To_Object; 
  187.  
  188.    ---------------- 
  189.    -- Properties -- 
  190.    ---------------- 
  191.    --  The following properties are defined for this widget. See 
  192.    --  Glib.Properties for more information on properties) 
  193.    -- 
  194.    --  Name: Column_Spacing_Property 
  195.    --  Type: Guint 
  196.    --  Flags: read-write 
  197.    -- 
  198.    --  Name: Homogeneous_Property 
  199.    --  Type: Boolean 
  200.    --  Flags: read-write 
  201.    -- 
  202.    --  Name: N_Columns_Property 
  203.    --  Type: Guint 
  204.    --  Flags: read-write 
  205.    -- 
  206.    --  Name: N_Rows_Property 
  207.    --  Type: Guint 
  208.    --  Flags: read-write 
  209.    -- 
  210.    --  Name: Row_Spacing_Property 
  211.    --  Type: Guint 
  212.    --  Flags: read-write 
  213.  
  214.    Column_Spacing_Property : constant Glib.Properties.Property_Uint; 
  215.    Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  216.    N_Columns_Property : constant Glib.Properties.Property_Uint; 
  217.    N_Rows_Property : constant Glib.Properties.Property_Uint; 
  218.    Row_Spacing_Property : constant Glib.Properties.Property_Uint; 
  219.  
  220. private 
  221.    Column_Spacing_Property : constant Glib.Properties.Property_Uint := 
  222.      Glib.Properties.Build ("column-spacing"); 
  223.    Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  224.      Glib.Properties.Build ("homogeneous"); 
  225.    N_Columns_Property : constant Glib.Properties.Property_Uint := 
  226.      Glib.Properties.Build ("n-columns"); 
  227.    N_Rows_Property : constant Glib.Properties.Property_Uint := 
  228.      Glib.Properties.Build ("n-rows"); 
  229.    Row_Spacing_Property : constant Glib.Properties.Property_Uint := 
  230.      Glib.Properties.Build ("row-spacing"); 
  231. end Gtk.Table;