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 box is a container that can have multiple children, organized either 
  32. --  horizontally or vertically. Two subtypes are provided, Gtk_Hbox and 
  33. --  Gtk_Vbox, to conform to the C API. In Ada, you do not need to distinguish 
  34. --  between the two, but note that the Gtk_Box type is conceptually an abstract 
  35. --  type: there is no way to create a "Gtk_Box", only ways to create either an 
  36. --  horizontal box, or a vertical box. 
  37. -- 
  38. --  Children can be added to one of two positions in the box, either at the 
  39. --  beginning (ie left or top) or at the end (ie right or bottom). Each of 
  40. --  these positions can contain multiple widgets. 
  41. -- 
  42. --  Every time a child is added to the start, it is placed to the right (resp. 
  43. --  the bottom) of the previous widget added to the start. 
  44. -- 
  45. --  Every time a child is added to the end, it is placed to the left (resp. 
  46. --  the top) of the previous widget added to the end. 
  47. -- 
  48. --  There are a number of parameters to specify the behavior of the box when 
  49. --  it is resized, and how the children should be reorganized and/or resized. 
  50. -- 
  51. --  See the testgtk example in the GtkAda distribution to see concrete 
  52. --  examples on how all the parameters for the boxes work. 
  53. -- 
  54. --  </description> 
  55. --  <screenshot>gtk-box</screenshot> 
  56. --  <group>Layout containers</group> 
  57. --  <testgtk>create_box.adb</testgtk> 
  58.  
  59. pragma Warnings (Off, "*is already use-visible*"); 
  60. with Glib;            use Glib; 
  61. with Glib.Properties; use Glib.Properties; 
  62. with Glib.Types;      use Glib.Types; 
  63. with Gtk.Buildable;   use Gtk.Buildable; 
  64. with Gtk.Container;   use Gtk.Container; 
  65. with Gtk.Enums;       use Gtk.Enums; 
  66. with Gtk.Orientable;  use Gtk.Orientable; 
  67. with Gtk.Widget;      use Gtk.Widget; 
  68.  
  69. package Gtk.Box is 
  70.  
  71.    type Gtk_Box_Record is new Gtk_Container_Record with null record; 
  72.    type Gtk_Box is access all Gtk_Box_Record'Class; 
  73.  
  74.    subtype Gtk_Hbox_Record is Gtk_Box_Record; 
  75.    subtype Gtk_Hbox is Gtk_Box; 
  76.  
  77.    subtype Gtk_Vbox_Record is Gtk_Box_Record; 
  78.    subtype Gtk_Vbox is Gtk_Box; 
  79.  
  80.    ------------------ 
  81.    -- Constructors -- 
  82.    ------------------ 
  83.  
  84.    function Get_Type return Glib.GType; 
  85.    pragma Import (C, Get_Type, "gtk_box_get_type"); 
  86.  
  87.    procedure Gtk_New_Hbox 
  88.       (Box         : out Gtk_Hbox; 
  89.        Homogeneous : Boolean := False; 
  90.        Spacing     : Gint := 0); 
  91.    procedure Initialize_Hbox 
  92.       (Box         : access Gtk_Hbox_Record'Class; 
  93.        Homogeneous : Boolean := False; 
  94.        Spacing     : Gint := 0); 
  95.    --  Creates a new Gtk.Box.Gtk_Hbox. 
  96.    --  "homogeneous": True if all children are to be given equal space 
  97.    --  allotments. 
  98.    --  "spacing": the number of pixels to place by default between children. 
  99.  
  100.    function Get_Hbox_Type return Glib.GType; 
  101.    pragma Import (C, Get_Hbox_Type, "gtk_hbox_get_type"); 
  102.  
  103.    procedure Gtk_New_Vbox 
  104.       (Box         : out Gtk_Vbox; 
  105.        Homogeneous : Boolean := False; 
  106.        Spacing     : Gint := 0); 
  107.    procedure Initialize_Vbox 
  108.       (Box         : access Gtk_Vbox_Record'Class; 
  109.        Homogeneous : Boolean := False; 
  110.        Spacing     : Gint := 0); 
  111.    --  Creates a new Gtk.Box.Gtk_Vbox. 
  112.    --  "homogeneous": True if all children are to be given equal space 
  113.    --  allotments. 
  114.    --  "spacing": the number of pixels to place by default between children. 
  115.  
  116.    function Get_Vbox_Type return Glib.GType; 
  117.    pragma Import (C, Get_Vbox_Type, "gtk_vbox_get_type"); 
  118.  
  119.    ------------- 
  120.    -- Methods -- 
  121.    ------------- 
  122.  
  123.    function Get_Homogeneous (Box : access Gtk_Box_Record) return Boolean; 
  124.    procedure Set_Homogeneous 
  125.       (Box         : access Gtk_Box_Record; 
  126.        Homogeneous : Boolean); 
  127.    --  Sets the Gtk.Box.Gtk_Box:homogeneous property of Box, controlling 
  128.    --  whether or not all children of Box are given equal space in the box. 
  129.    --  "homogeneous": a boolean value, True to create equal allotments, False 
  130.    --  for variable allotments 
  131.  
  132.    function Get_Spacing (Box : access Gtk_Box_Record) return Gint; 
  133.    procedure Set_Spacing (Box : access Gtk_Box_Record; Spacing : Gint); 
  134.    --  Sets the Gtk.Box.Gtk_Box:spacing property of Box, which is the number 
  135.    --  of pixels to place between children of Box. 
  136.    --  "spacing": the number of pixels to put between children 
  137.  
  138.    procedure Pack_End 
  139.       (In_Box  : access Gtk_Box_Record; 
  140.        Child   : access Gtk.Widget.Gtk_Widget_Record'Class; 
  141.        Expand  : Boolean := True; 
  142.        Fill    : Boolean := True; 
  143.        Padding : Guint := 0); 
  144.    --  Adds Child to Box, packed with reference to the end of Box. The Child 
  145.    --  is packed after (away from end of) any other child packed with reference 
  146.    --  to the end of Box. 
  147.    --  "child": the Gtk.Widget.Gtk_Widget to be added to Box 
  148.    --  "expand": True if the new child is to be given extra space allocated to 
  149.    --  Box. The extra space will be divided evenly between all children of Box 
  150.    --  that use this option 
  151.    --  "fill": True if space given to Child by the Expand option is actually 
  152.    --  allocated to Child, rather than just padding it. This parameter has no 
  153.    --  effect if Expand is set to False. A child is always allocated the full 
  154.    --  height of a Gtk.Box.Gtk_Hbox and the full width of a Gtk.Box.Gtk_Vbox. 
  155.    --  This option affects the other dimension 
  156.    --  "padding": extra space in pixels to put between this child and its 
  157.    --  neighbors, over and above the global amount specified by 
  158.    --  Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the 
  159.    --  reference ends of Box, then Padding pixels are also put between 
  160.  
  161.    procedure Pack_End_Defaults 
  162.       (Box    : access Gtk_Box_Record; 
  163.        Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  164.    pragma Obsolescent (Pack_End_Defaults); 
  165.    --  Adds Widget to Box, packed with reference to the end of Box. The child 
  166.    --  is packed after any other child packed with reference to the start of 
  167.    --  Box. Parameters for how to pack the child Widget, 
  168.    --  Gtk.Box.Gtk_Box:expand, Gtk.Box.Gtk_Box:fill and 
  169.    --  Gtk.Box.Gtk_Box:padding, are given their default values, True, True, and 
  170.    --  0, respectively. 
  171.    --  Deprecated since 2.14, Use Gtk.Box.Pack_End 
  172.    --  "widget": the Gtk.Widget.Gtk_Widget to be added to Box 
  173.  
  174.    procedure Pack_Start 
  175.       (In_Box  : access Gtk_Box_Record; 
  176.        Child   : access Gtk.Widget.Gtk_Widget_Record'Class; 
  177.        Expand  : Boolean := True; 
  178.        Fill    : Boolean := True; 
  179.        Padding : Guint := 0); 
  180.    --  Adds Child to Box, packed with reference to the start of Box. The Child 
  181.    --  is packed after any other child packed with reference to the start of 
  182.    --  Box. 
  183.    --  "child": the Gtk.Widget.Gtk_Widget to be added to Box 
  184.    --  "expand": True if the new child is to be given extra space allocated to 
  185.    --  "fill": True if space given to Child by the Expand option is actually 
  186.    --  allocated to Child, rather than just padding it. This parameter has no 
  187.    --  effect if Expand is set to False. A child is always allocated the full 
  188.    --  height of a Gtk.Box.Gtk_Hbox and the full width of a Gtk.Box.Gtk_Vbox. 
  189.    --  This option affects the other dimension 
  190.    --  "padding": extra space in pixels to put between this child and its 
  191.    --  neighbors, over and above the global amount specified by 
  192.    --  Gtk.Box.Gtk_Box:spacing property. If Child is a widget at one of the 
  193.    --  reference ends of Box, then Padding pixels are also put between 
  194.  
  195.    procedure Pack_Start_Defaults 
  196.       (Box    : access Gtk_Box_Record; 
  197.        Widget : access Gtk.Widget.Gtk_Widget_Record'Class); 
  198.    pragma Obsolescent (Pack_Start_Defaults); 
  199.    --  Adds Widget to Box, packed with reference to the start of Box. The 
  200.    --  child is packed after any other child packed with reference to the start 
  201.    --  of Box. Parameters for how to pack the child Widget, 
  202.    --  Gtk.Box.Gtk_Box:expand, Gtk.Box.Gtk_Box:fill and 
  203.    --  Gtk.Box.Gtk_Box:padding, are given their default values, True, True, and 
  204.    --  0, respectively. 
  205.    --  Deprecated since 2.14, Use Gtk.Box.Pack_Start 
  206.    --  "widget": the Gtk.Widget.Gtk_Widget to be added to Box 
  207.  
  208.    procedure Query_Child_Packing 
  209.       (Box       : access Gtk_Box_Record; 
  210.        Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  211.        Expand    : out Boolean; 
  212.        Fill      : out Boolean; 
  213.        Padding   : out Guint; 
  214.        Pack_Type : out Gtk.Enums.Gtk_Pack_Type); 
  215.    procedure Set_Child_Packing 
  216.       (Box       : access Gtk_Box_Record; 
  217.        Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  218.        Expand    : Boolean; 
  219.        Fill      : Boolean; 
  220.        Padding   : Guint; 
  221.        Pack_Type : Gtk.Enums.Gtk_Pack_Type); 
  222.    --  Sets the way Child is packed into Box. 
  223.    --  "child": the Gtk.Widget.Gtk_Widget of the child to set 
  224.    --  "expand": the new value of the Gtk.Box.Gtk_Box:expand child property 
  225.    --  "fill": the new value of the Gtk.Box.Gtk_Box:fill child property 
  226.    --  "padding": the new value of the Gtk.Box.Gtk_Box:padding child property 
  227.    --  "pack_type": the new value of the Gtk.Box.Gtk_Box:pack-type child 
  228.    --  property 
  229.  
  230.    procedure Reorder_Child 
  231.       (Box      : access Gtk_Box_Record; 
  232.        Child    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  233.        Position : Gint); 
  234.    --  Moves Child to a new Position in the list of Box children. The list is 
  235.    --  the <structfield>children</structfield> field of Gtk.Box.Gtk_Box-struct, 
  236.    --  and contains both widgets packed GTK_PACK_START as well as widgets 
  237.    --  packed GTK_PACK_END, in the order that these widgets were added to Box. 
  238.    --  A widget's position in the Box children list determines where the widget 
  239.    --  is packed into Box. A child widget at some position in the list will be 
  240.    --  packed just after all other widgets of the same packing type that appear 
  241.    --  earlier in the list. 
  242.    --  "child": the Gtk.Widget.Gtk_Widget to move 
  243.    --  "position": the new position for Child in the list of children of Box, 
  244.    --  starting from 0. If negative, indicates the end of the list 
  245.  
  246.    function Get_Child 
  247.       (Box : access Gtk_Box_Record; 
  248.        Num : Gint) return Gtk.Widget.Gtk_Widget; 
  249.    --  Return the Num-th child of the box, or null if there is no such child 
  250.    --  Since: gtk+ GtkAda 1.0 
  251.  
  252.    --------------------- 
  253.    -- Interfaces_Impl -- 
  254.    --------------------- 
  255.  
  256.    function Get_Orientation 
  257.       (Self : access Gtk_Box_Record) return Gtk.Enums.Gtk_Orientation; 
  258.    procedure Set_Orientation 
  259.       (Self        : access Gtk_Box_Record; 
  260.        Orientation : Gtk.Enums.Gtk_Orientation); 
  261.  
  262.    ---------------- 
  263.    -- Interfaces -- 
  264.    ---------------- 
  265.    --  This class implements several interfaces. See Glib.Types 
  266.    -- 
  267.    --  - "Buildable" 
  268.    -- 
  269.    --  - "Orientable" 
  270.  
  271.    package Implements_Buildable is new Glib.Types.Implements 
  272.      (Gtk.Buildable.Gtk_Buildable, Gtk_Box_Record, Gtk_Box); 
  273.    function "+" 
  274.      (Widget : access Gtk_Box_Record'Class) 
  275.    return Gtk.Buildable.Gtk_Buildable 
  276.    renames Implements_Buildable.To_Interface; 
  277.    function "-" 
  278.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  279.    return Gtk_Box 
  280.    renames Implements_Buildable.To_Object; 
  281.  
  282.    package Implements_Orientable is new Glib.Types.Implements 
  283.      (Gtk.Orientable.Gtk_Orientable, Gtk_Box_Record, Gtk_Box); 
  284.    function "+" 
  285.      (Widget : access Gtk_Box_Record'Class) 
  286.    return Gtk.Orientable.Gtk_Orientable 
  287.    renames Implements_Orientable.To_Interface; 
  288.    function "-" 
  289.      (Interf : Gtk.Orientable.Gtk_Orientable) 
  290.    return Gtk_Box 
  291.    renames Implements_Orientable.To_Object; 
  292.  
  293.    ---------------- 
  294.    -- Properties -- 
  295.    ---------------- 
  296.    --  The following properties are defined for this widget. See 
  297.    --  Glib.Properties for more information on properties) 
  298.    -- 
  299.    --  Name: Homogeneous_Property 
  300.    --  Type: Boolean 
  301.    --  Flags: read-write 
  302.    -- 
  303.    --  Name: Spacing_Property 
  304.    --  Type: Gint 
  305.    --  Flags: read-write 
  306.    --  The following properties are defined for this widget. See 
  307.    --  Glib.Properties for more information on properties) 
  308.    --  The following properties are defined for this widget. See 
  309.    --  Glib.Properties for more information on properties) 
  310.  
  311.    Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  312.    Spacing_Property : constant Glib.Properties.Property_Int; 
  313.  
  314. private 
  315.    Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  316.      Glib.Properties.Build ("homogeneous"); 
  317.    Spacing_Property : constant Glib.Properties.Property_Int := 
  318.      Glib.Properties.Build ("spacing"); 
  319. end Gtk.Box;