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