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 GtkBox widget organizes child widgets into a rectangular area. 
  26. -- 
  27. --  The rectangular area of a GtkBox is organized into either a single row or 
  28. --  a single column of child widgets depending upon the orientation. Thus, all 
  29. --  children of a GtkBox are allocated one dimension in common, which is the 
  30. --  height of a row, or the width of a column. 
  31. -- 
  32. --  GtkBox uses a notion of *packing*. Packing refers to adding widgets with 
  33. --  reference to a particular position in a Gtk.Container.Gtk_Container. For a 
  34. --  GtkBox, there are two reference positions: the *start* and the *end* of the 
  35. --  box. For a vertical Gtk.Box.Gtk_Box, the start is defined as the top of the 
  36. --  box and the end is defined as the bottom. For a horizontal Gtk.Box.Gtk_Box 
  37. --  the start is defined as the left side and the end is defined as the right 
  38. --  side. 
  39. -- 
  40. --  Use repeated calls to Gtk.Box.Pack_Start to pack widgets into a GtkBox 
  41. --  from start to end. Use Gtk.Box.Pack_End to add widgets from end to start. 
  42. --  You may intersperse these calls and add widgets from both ends of the same 
  43. --  GtkBox. 
  44. -- 
  45. --  Because GtkBox is a Gtk.Container.Gtk_Container, you may also use 
  46. --  Gtk.Container.Add to insert widgets into the box, and they will be packed 
  47. --  with the default values for Gtk.Box.Gtk_Box:expand and 
  48. --  Gtk.Box.Gtk_Box:fill. Use Gtk.Container.Remove to remove widgets from the 
  49. --  GtkBox. 
  50. -- 
  51. --  Use Gtk.Box.Set_Homogeneous to specify whether or not all children of the 
  52. --  GtkBox are forced to get the same amount of space. 
  53. -- 
  54. --  Use Gtk.Box.Set_Spacing to determine how much space will be minimally 
  55. --  placed between all children in the GtkBox. Note that spacing is added 
  56. --  *between* the children, while padding added by Gtk.Box.Pack_Start or 
  57. --  Gtk.Box.Pack_End is added *on either side* of the widget it belongs to. 
  58. -- 
  59. --  Use Gtk.Box.Reorder_Child to move a GtkBox child to a different place in 
  60. --  the box. 
  61. -- 
  62. --  Use Gtk.Box.Set_Child_Packing to reset the Gtk.Box.Gtk_Box:expand, 
  63. --  Gtk.Box.Gtk_Box:fill and Gtk.Box.Gtk_Box:padding child properties. Use 
  64. --  Gtk.Box.Query_Child_Packing to query these fields. 
  65. -- 
  66. --  Note: 
  67. -- 
  68. --  Note that a single-row or single-column Gtk.Grid.Gtk_Grid provides exactly 
  69. --  the same functionality as Gtk.Box.Gtk_Box. 
  70. -- 
  71. --  </description> 
  72. --  <description> 
  73. --  See the testgtk example in the GtkAda distribution to see concrete 
  74. --  examples on how all the parameters for the boxes work. 
  75. -- 
  76. --  </description> 
  77. --  <screenshot>gtk-box</screenshot> 
  78. --  <group>Layout containers</group> 
  79. --  <testgtk>create_box.adb</testgtk> 
  80. pragma Ada_2005; 
  81.  
  82. pragma Warnings (Off, "*is already use-visible*"); 
  83. with Glib;            use Glib; 
  84. with Glib.Properties; use Glib.Properties; 
  85. with Glib.Types;      use Glib.Types; 
  86. with Gtk.Buildable;   use Gtk.Buildable; 
  87. with Gtk.Container;   use Gtk.Container; 
  88. with Gtk.Enums;       use Gtk.Enums; 
  89. with Gtk.Orientable;  use Gtk.Orientable; 
  90. with Gtk.Widget;      use Gtk.Widget; 
  91.  
  92. package Gtk.Box is 
  93.  
  94.    type Gtk_Box_Record is new Gtk_Container_Record with null record; 
  95.    type Gtk_Box is access all Gtk_Box_Record'Class; 
  96.  
  97.    subtype Gtk_Hbox_Record is Gtk_Box_Record; 
  98.    subtype Gtk_Hbox is Gtk_Box; 
  99.  
  100.    subtype Gtk_Vbox_Record is Gtk_Box_Record; 
  101.    subtype Gtk_Vbox is Gtk_Box; 
  102.  
  103.    ------------------ 
  104.    -- Constructors -- 
  105.    ------------------ 
  106.  
  107.    procedure Gtk_New 
  108.       (Box         : out Gtk_Box; 
  109.        Orientation : Gtk.Enums.Gtk_Orientation; 
  110.        Spacing     : Gint); 
  111.    procedure Initialize 
  112.       (Box         : not null access Gtk_Box_Record'Class; 
  113.        Orientation : Gtk.Enums.Gtk_Orientation; 
  114.        Spacing     : Gint); 
  115.    --  Creates a new Gtk.Box.Gtk_Box. 
  116.    --  Since: gtk+ 3.0 
  117.    --  "orientation": the box's orientation. 
  118.    --  "spacing": the number of pixels to place by default between children. 
  119.  
  120.    function Gtk_Box_New 
  121.       (Orientation : Gtk.Enums.Gtk_Orientation; 
  122.        Spacing     : Gint) return Gtk_Box; 
  123.    --  Creates a new Gtk.Box.Gtk_Box. 
  124.    --  Since: gtk+ 3.0 
  125.    --  "orientation": the box's orientation. 
  126.    --  "spacing": the number of pixels to place by default between children. 
  127.  
  128.    function Get_Type return Glib.GType; 
  129.    pragma Import (C, Get_Type, "gtk_box_get_type"); 
  130.  
  131.    procedure Gtk_New_Hbox 
  132.       (Box         : out Gtk_Hbox; 
  133.        Homogeneous : Boolean := False; 
  134.        Spacing     : Gint := 0); 
  135.    procedure Initialize_Hbox 
  136.       (Box         : not null access Gtk_Hbox_Record'Class; 
  137.        Homogeneous : Boolean := False; 
  138.        Spacing     : Gint := 0); 
  139.    --  Creates a new Gtk.Box.Gtk_Hbox. 
  140.    --  "homogeneous": True if all children are to be given equal space 
  141.    --  allotments. 
  142.    --  "spacing": the number of pixels to place by default between children. 
  143.  
  144.    function Gtk_Hbox_New 
  145.       (Homogeneous : Boolean := False; 
  146.        Spacing     : Gint := 0) return Gtk_Hbox; 
  147.    --  Creates a new Gtk.Box.Gtk_Hbox. 
  148.    --  "homogeneous": True if all children are to be given equal space 
  149.    --  allotments. 
  150.    --  "spacing": the number of pixels to place by default between children. 
  151.  
  152.    function Get_Hbox_Type return Glib.GType; 
  153.    pragma Import (C, Get_Hbox_Type, "gtk_hbox_get_type"); 
  154.  
  155.    procedure Gtk_New_Vbox 
  156.       (Box         : out Gtk_Vbox; 
  157.        Homogeneous : Boolean := False; 
  158.        Spacing     : Gint := 0); 
  159.    procedure Initialize_Vbox 
  160.       (Box         : not null access Gtk_Vbox_Record'Class; 
  161.        Homogeneous : Boolean := False; 
  162.        Spacing     : Gint := 0); 
  163.    --  Creates a new Gtk.Box.Gtk_Vbox. 
  164.    --  "homogeneous": True if all children are to be given equal space 
  165.    --  allotments. 
  166.    --  "spacing": the number of pixels to place by default between children. 
  167.  
  168.    function Gtk_Vbox_New 
  169.       (Homogeneous : Boolean := False; 
  170.        Spacing     : Gint := 0) return Gtk_Vbox; 
  171.    --  Creates a new Gtk.Box.Gtk_Vbox. 
  172.    --  "homogeneous": True if all children are to be given equal space 
  173.    --  allotments. 
  174.    --  "spacing": the number of pixels to place by default between children. 
  175.  
  176.    function Get_Vbox_Type return Glib.GType; 
  177.    pragma Import (C, Get_Vbox_Type, "gtk_vbox_get_type"); 
  178.  
  179.    ------------- 
  180.    -- Methods -- 
  181.    ------------- 
  182.  
  183.    function Get_Homogeneous 
  184.       (Box : not null access Gtk_Box_Record) return Boolean; 
  185.    --  Returns whether the box is homogeneous (all children are the same 
  186.    --  size). See Gtk.Box.Set_Homogeneous. 
  187.  
  188.    procedure Set_Homogeneous 
  189.       (Box         : not null access Gtk_Box_Record; 
  190.        Homogeneous : Boolean); 
  191.    --  Sets the Gtk.Box.Gtk_Box:homogeneous property of Box, controlling 
  192.    --  whether or not all children of Box are given equal space in the box. 
  193.    --  "homogeneous": a boolean value, True to create equal allotments, False 
  194.    --  for variable allotments 
  195.  
  196.    function Get_Spacing (Box : not null access Gtk_Box_Record) return Gint; 
  197.    --  Gets the value set by Gtk.Box.Set_Spacing. 
  198.  
  199.    procedure Set_Spacing 
  200.       (Box     : not null access Gtk_Box_Record; 
  201.        Spacing : Gint); 
  202.    --  Sets the Gtk.Box.Gtk_Box:spacing property of Box, which is the number 
  203.    --  of pixels to place between children of Box. 
  204.    --  "spacing": the number of pixels to put between children 
  205.  
  206.    procedure Pack_End 
  207.       (In_Box  : not null access Gtk_Box_Record; 
  208.        Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  209.        Expand  : Boolean := True; 
  210.        Fill    : Boolean := True; 
  211.        Padding : Guint := 0); 
  212.    --  Adds Child to Box, packed with reference to the end of Box. The Child 
  213.    --  is packed after (away from end of) any other child packed with reference 
  214.    --  to the end of Box. 
  215.    --  "child": the Gtk.Widget.Gtk_Widget to be added to Box 
  216.    --  "expand": True if the new child is to be given extra space allocated to 
  217.    --  Box. The extra space will be divided evenly between all children of Box 
  218.    --  that use this option 
  219.    --  "fill": True if space given to Child by the Expand option is actually 
  220.    --  allocated to Child, rather than just padding it. This parameter has no 
  221.    --  effect if Expand is set to False. A child is always allocated the full 
  222.    --  height of a horizontal Gtk.Box.Gtk_Box and the full width of a vertical 
  223.    --  Gtk.Box.Gtk_Box. This option affects the other dimension 
  224.    --  "padding": extra space in pixels to put between this child and its 
  225.    --  neighbors, over and above the global amount specified by 
  226.    --  Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the 
  227.    --  reference ends of Box, then Padding pixels are also put between Child 
  228.    --  and the reference edge of Box 
  229.  
  230.    procedure Pack_Start 
  231.       (In_Box  : not null access Gtk_Box_Record; 
  232.        Child   : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  233.        Expand  : Boolean := True; 
  234.        Fill    : Boolean := True; 
  235.        Padding : Guint := 0); 
  236.    --  Adds Child to Box, packed with reference to the start of Box. The Child 
  237.    --  is packed after any other child packed with reference to the start of 
  238.    --  Box. 
  239.    --  "child": the Gtk.Widget.Gtk_Widget to be added to Box 
  240.    --  "expand": True if the new child is to be given extra space allocated to 
  241.    --  Box. The extra space will be divided evenly between all children that 
  242.    --  use this option 
  243.    --  "fill": True if space given to Child by the Expand option is actually 
  244.    --  allocated to Child, rather than just padding it. This parameter has no 
  245.    --  effect if Expand is set to False. A child is always allocated the full 
  246.    --  height of a horizontal Gtk.Box.Gtk_Box and the full width of a vertical 
  247.    --  Gtk.Box.Gtk_Box. This option affects the other dimension 
  248.    --  "padding": extra space in pixels to put between this child and its 
  249.    --  neighbors, over and above the global amount specified by 
  250.    --  Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the 
  251.    --  reference ends of Box, then Padding pixels are also put between Child 
  252.    --  and the reference edge of Box 
  253.  
  254.    procedure Query_Child_Packing 
  255.       (Box       : not null access Gtk_Box_Record; 
  256.        Child     : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  257.        Expand    : out Boolean; 
  258.        Fill      : out Boolean; 
  259.        Padding   : out Guint; 
  260.        Pack_Type : out Gtk.Enums.Gtk_Pack_Type); 
  261.    --  Obtains information about how Child is packed into Box. 
  262.    --  "child": the Gtk.Widget.Gtk_Widget of the child to query 
  263.    --  "expand": pointer to return location for Gtk.Box.Gtk_Box:expand child 
  264.    --  property 
  265.    --  "fill": pointer to return location for Gtk.Box.Gtk_Box:fill child 
  266.    --  property 
  267.    --  "padding": pointer to return location for Gtk.Box.Gtk_Box:padding child 
  268.    --  property 
  269.    --  "pack_type": pointer to return location for Gtk.Box.Gtk_Box:pack-type 
  270.    --  child property 
  271.  
  272.    procedure Set_Child_Packing 
  273.       (Box       : not null access Gtk_Box_Record; 
  274.        Child     : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  275.        Expand    : Boolean; 
  276.        Fill      : Boolean; 
  277.        Padding   : Guint; 
  278.        Pack_Type : Gtk.Enums.Gtk_Pack_Type); 
  279.    --  Sets the way Child is packed into Box. 
  280.    --  "child": the Gtk.Widget.Gtk_Widget of the child to set 
  281.    --  "expand": the new value of the Gtk.Box.Gtk_Box:expand child property 
  282.    --  "fill": the new value of the Gtk.Box.Gtk_Box:fill child property 
  283.    --  "padding": the new value of the Gtk.Box.Gtk_Box:padding child property 
  284.    --  "pack_type": the new value of the Gtk.Box.Gtk_Box:pack-type child 
  285.    --  property 
  286.  
  287.    procedure Reorder_Child 
  288.       (Box      : not null access Gtk_Box_Record; 
  289.        Child    : not null access Gtk.Widget.Gtk_Widget_Record'Class; 
  290.        Position : Gint); 
  291.    --  Moves Child to a new Position in the list of Box children. The list is 
  292.    --  the <structfield>children</structfield> field of Gtk.Box.Gtk_Box-struct, 
  293.    --  and contains both widgets packed GTK_PACK_START as well as widgets 
  294.    --  packed GTK_PACK_END, in the order that these widgets were added to Box. 
  295.    --  A widget's position in the Box children list determines where the 
  296.    --  widget is packed into Box. A child widget at some position in the list 
  297.    --  will be packed just after all other widgets of the same packing type 
  298.    --  that appear earlier in the list. 
  299.    --  "child": the Gtk.Widget.Gtk_Widget to move 
  300.    --  "position": the new position for Child in the list of children of Box, 
  301.    --  starting from 0. If negative, indicates the end of the list 
  302.  
  303.    function Get_Child 
  304.       (Box : not null access Gtk_Box_Record; 
  305.        Num : Gint) return Gtk.Widget.Gtk_Widget; 
  306.    --  Return the Num-th child of the box, or null if there is no such child 
  307.    --  Since: gtk+ GtkAda 1.0 
  308.  
  309.    --------------------------------------------- 
  310.    -- Inherited subprograms (from interfaces) -- 
  311.    --------------------------------------------- 
  312.    --  Methods inherited from the Buildable interface are not duplicated here 
  313.    --  since they are meant to be used by tools, mostly. If you need to call 
  314.    --  them, use an explicit cast through the "-" operator below. 
  315.  
  316.    function Get_Orientation 
  317.       (Self : not null access Gtk_Box_Record) 
  318.        return Gtk.Enums.Gtk_Orientation; 
  319.  
  320.    procedure Set_Orientation 
  321.       (Self        : not null access Gtk_Box_Record; 
  322.        Orientation : Gtk.Enums.Gtk_Orientation); 
  323.  
  324.    ---------------- 
  325.    -- Properties -- 
  326.    ---------------- 
  327.    --  The following properties are defined for this widget. See 
  328.    --  Glib.Properties for more information on properties) 
  329.  
  330.    Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  331.  
  332.    Spacing_Property : constant Glib.Properties.Property_Int; 
  333.  
  334.    ---------------- 
  335.    -- Interfaces -- 
  336.    ---------------- 
  337.    --  This class implements several interfaces. See Glib.Types 
  338.    -- 
  339.    --  - "Buildable" 
  340.    -- 
  341.    --  - "Orientable" 
  342.  
  343.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  344.      (Gtk.Buildable.Gtk_Buildable, Gtk_Box_Record, Gtk_Box); 
  345.    function "+" 
  346.      (Widget : access Gtk_Box_Record'Class) 
  347.    return Gtk.Buildable.Gtk_Buildable 
  348.    renames Implements_Gtk_Buildable.To_Interface; 
  349.    function "-" 
  350.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  351.    return Gtk_Box 
  352.    renames Implements_Gtk_Buildable.To_Object; 
  353.  
  354.    package Implements_Gtk_Orientable is new Glib.Types.Implements 
  355.      (Gtk.Orientable.Gtk_Orientable, Gtk_Box_Record, Gtk_Box); 
  356.    function "+" 
  357.      (Widget : access Gtk_Box_Record'Class) 
  358.    return Gtk.Orientable.Gtk_Orientable 
  359.    renames Implements_Gtk_Orientable.To_Interface; 
  360.    function "-" 
  361.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  362.    return Gtk_Box 
  363.    renames Implements_Gtk_Orientable.To_Object; 
  364.  
  365. private 
  366.    Spacing_Property : constant Glib.Properties.Property_Int := 
  367.      Glib.Properties.Build ("spacing"); 
  368.    Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  369.      Glib.Properties.Build ("homogeneous"); 
  370. end Gtk.Box;