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