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-2009, 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. -- 
  27. --  A box is a container that can have multiple children, organized either 
  28. --  horizontally or vertically. Two subtypes are provided, Gtk_Hbox and 
  29. --  Gtk_Vbox, to conform to the C API. In Ada, you do not need to 
  30. --  distinguish between the two, but note that the Gtk_Box type is conceptually 
  31. --  an abstract type: there is no way to create a "Gtk_Box", only ways to 
  32. --  create either an horizontal box, or a vertical box. 
  33. -- 
  34. --  Children can be added to one of two positions in the box, either at the 
  35. --  beginning (ie left or top) or at the end (ie right or bottom). Each of 
  36. --  these positions can contain multiple widgets. 
  37. -- 
  38. --  Every time a child is added to the start, it is placed to the right 
  39. --  (resp. the bottom) of the previous widget added to the start. 
  40. -- 
  41. --  Every time a child is added to the end, it is placed to the left (resp. 
  42. --  the top) of the previous widget added to the end. 
  43. -- 
  44. --  There are a number of parameters to specify the behavior of the box when 
  45. --  it is resized, and how the children should be reorganized and/or resized. 
  46. -- 
  47. --  See the testgtk example in the GtkAda distribution to see concrete examples 
  48. --  on how all the parameters for the boxes work. 
  49. -- 
  50. --  </description> 
  51. --  <c_version>2.14</c_version> 
  52. --  <group>Layout containers</group> 
  53. --  <testgtk>create_box.adb</testgtk> 
  54. --  <screenshot>gtk-box</screenshot> 
  55.  
  56. with Glib.Properties; 
  57. with Gtk.Container; 
  58. with Gtk.Enums; 
  59. with Gtk.Widget; 
  60.  
  61. package Gtk.Box is 
  62.  
  63.    type Gtk_Box_Record is new Gtk.Container.Gtk_Container_Record with private; 
  64.    subtype Gtk_Hbox_Record is Gtk_Box_Record; 
  65.    subtype Gtk_Vbox_Record is Gtk_Box_Record; 
  66.  
  67.    type Gtk_Box is access all Gtk_Box_Record'Class; 
  68.    subtype Gtk_Hbox is Gtk_Box; 
  69.    subtype Gtk_Vbox is Gtk_Box; 
  70.  
  71.    procedure Gtk_New_Vbox 
  72.      (Box         : out Gtk_Box; 
  73.       Homogeneous : Boolean := False; 
  74.       Spacing     : Gint := 0); 
  75.    --  Create a new vertical box. 
  76.    --  Its children will be placed one above the other. 
  77.    --  If Homogeneous is True, all the children will be allocated exactly the 
  78.    --  same screen real-estate, whereas if it is False, each child can have 
  79.    --  its own size. 
  80.    --  Spacing is the space left between two adjacent children. 
  81.  
  82.    procedure Gtk_New_Hbox 
  83.      (Box         : out Gtk_Box; 
  84.       Homogeneous : Boolean := False; 
  85.       Spacing     : Gint := 0); 
  86.    --  Create a new horizontal box. 
  87.    --  Its children will be placed one besides the other. 
  88.    --  If Homogeneous is True, all the children will be allocated exactly the 
  89.    --  same screen real-estate, whereas if it is False, each child can have 
  90.    --  its own size. 
  91.    --  Spacing is the space left between two adjacent children. 
  92.  
  93.    procedure Initialize_Vbox 
  94.      (Box         : access Gtk_Box_Record'Class; 
  95.       Homogeneous : Boolean := False; 
  96.       Spacing     : Gint := 0); 
  97.    --  Internal initialization function. 
  98.    --  See the section "Creating your own widgets" in the documentation. 
  99.  
  100.    procedure Initialize_Hbox 
  101.      (Box         : access Gtk_Box_Record'Class; 
  102.       Homogeneous : Boolean := False; 
  103.       Spacing     : Gint := 0); 
  104.    --  Internal initialization function. 
  105.    --  See the section "Creating your own widgets" in the documentation. 
  106.  
  107.    function Get_Type return Gtk.Gtk_Type; 
  108.    --  Return the internal value associated with a Gtk_Box. 
  109.  
  110.    function Get_Hbox_Type return Gtk.Gtk_Type; 
  111.    --  Return the internal value associated with a Gtk_HBox. 
  112.  
  113.    function Get_Vbox_Type return Gtk.Gtk_Type; 
  114.    --  Return the internal value associated with a Gtk_VBox. 
  115.  
  116.    procedure Pack_Start 
  117.      (In_Box  : access Gtk_Box_Record; 
  118.       Child   : access Gtk.Widget.Gtk_Widget_Record'Class; 
  119.       Expand  : Boolean := True; 
  120.       Fill    : Boolean := True; 
  121.       Padding : Gint    := 0); 
  122.    --  Add a new child to the beginning of the box (ie left or top part). 
  123.    --  It is added to the right (resp. the bottom) of the previous child added 
  124.    --  to the beginning of the box. Note that a child added to the beginning of 
  125.    --  the box will always remain on the left (resp. top) of all the children 
  126.    --  added to the end of the box. 
  127.    -- 
  128.    --  If Expand is False, the size allocated for each size will be the one 
  129.    --  requested by the widget (or the largest child if Homogeneous was set to 
  130.    --  true when the box was created). Otherwise, the total size of the box is 
  131.    --  divided between all the children. Note that this does not mean that the 
  132.    --  children have to occupy all the space given to them... 
  133.    -- 
  134.    --  If Fill is True, then the widget will be resized so as to occupy all the 
  135.    --  space allocated to them. This is only relevant if Expand is True, since 
  136.    --  otherwise the space allocated is the same one as the child's size. 
  137.    -- 
  138.    --  Padding is the amount of space left around the widget when it is drawn. 
  139.  
  140.    procedure Pack_End 
  141.      (In_Box  : access Gtk_Box_Record; 
  142.       Child   : access Gtk.Widget.Gtk_Widget_Record'Class; 
  143.       Expand  : Boolean := True; 
  144.       Fill    : Boolean := True; 
  145.       Padding : Gint    := 0); 
  146.    --  Add a new child to the end of the box (ie right or bottom part). 
  147.    --  It is added to the left (resp. top) of the previous child added to the 
  148.    --  end of the box. Note that a child added to the end of the box will 
  149.    --  always remain on the right (resp. bottom) of all the children added to 
  150.    --  the beginning of the box. 
  151.    -- 
  152.    --  See Pack_Start for an explanation of all the parameters. 
  153.  
  154.    procedure Set_Homogeneous 
  155.      (In_Box      : access Gtk_Box_Record; 
  156.       Homogeneous : Boolean); 
  157.    function Get_Homogeneous 
  158.      (In_Box : access Gtk_Box_Record) return Boolean; 
  159.    --  Modify or get the homogeneous parameter for the box. 
  160.    --  If the box is homogeneous, then all its children will be allocated the 
  161.    --  same amount of space, even if they are not resized to occupy it 
  162.    --  (depending on the parameters given to Pack_Start and Pack_End). 
  163.  
  164.    procedure Set_Spacing 
  165.      (In_Box  : access Gtk_Box_Record; 
  166.       Spacing : Gint); 
  167.    function Get_Spacing (In_Box : access Gtk_Box_Record) return Gint; 
  168.    --  Modify the spacing for the box. 
  169.    --  I.e. the amount of space left between two adjacent children. 
  170.  
  171.    procedure Reorder_Child 
  172.      (In_Box : access Gtk_Box_Record; 
  173.       Child  : access Gtk.Widget.Gtk_Widget_Record'Class; 
  174.       Pos    : Guint); 
  175.    --  Move the Child to a new position. 
  176.    --  Nothing is done if Child is not in the box. 
  177.    --  Pos starts at 0, and indicates the position of the child relative to all 
  178.    --  other children, no matter where they were packed  (the beginning or the 
  179.    --  end of the box). 
  180.  
  181.    procedure Set_Child_Packing 
  182.      (In_Box    : access Gtk_Box_Record; 
  183.       Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  184.       Expand    : Boolean; 
  185.       Fill      : Boolean; 
  186.       Padding   : Gint; 
  187.       Pack_Type : Gtk.Enums.Gtk_Pack_Type); 
  188.    procedure Query_Child_Packing 
  189.      (In_Box   : access Gtk_Box_Record; 
  190.       Child    : access Gtk.Widget.Gtk_Widget_Record'Class; 
  191.       Expand   : out Boolean; 
  192.       Fill     : out Boolean; 
  193.       Padding  : out Gint; 
  194.       PackType : out Gtk.Enums.Gtk_Pack_Type); 
  195.    --  Get information on how the child was packed in the box. 
  196.    --  The results are undefined if Child is not in the box. 
  197.  
  198.    function Get_Child 
  199.      (Box : access Gtk_Box_Record; Num : Gint) return Gtk.Widget.Gtk_Widget; 
  200.    --  Return the Num-th child of the box, or null if there is no such child. 
  201.  
  202.    ----------------- 
  203.    -- Obsolescent -- 
  204.    ----------------- 
  205.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  206.    --  from future versions of gtk+ (and therefore GtkAda). 
  207.    --  To find out whether your code uses any of these, we recommend compiling 
  208.    --  with the -gnatwj switch 
  209.    --  <doc_ignore> 
  210.  
  211.    procedure Pack_Start_Defaults 
  212.      (In_Box  : access Gtk_Box_Record; 
  213.       Child   : access Gtk.Widget.Gtk_Widget_Record'Class); 
  214.    pragma Obsolescent;  --  Pack_Start_Defaults 
  215.    --  This is the same as Pack_Start if you use the default parameter values. 
  216.    --  It is provided for backward compatibility only. 
  217.  
  218.    procedure Pack_End_Defaults 
  219.      (In_Box  : access Gtk_Box_Record; 
  220.       Child   : access Gtk.Widget.Gtk_Widget_Record'Class); 
  221.    pragma Obsolescent;  --  Pack_End_Defaults 
  222.    --  This is the same as Pack_End if you use the default parameter values. 
  223.    --  It is provided for backward compatibility only. 
  224.  
  225.    ---------------- 
  226.    -- Properties -- 
  227.    ---------------- 
  228.    --  The following properties are defined for this widget. See 
  229.    --  Glib.Properties for more information on properties. 
  230.  
  231.    --  <properties> 
  232.    --  - Name:  Spacing_Property 
  233.    --    Type:  Gint 
  234.    --    Flags: read-write 
  235.    --    Descr: The amount of space between children. 
  236.    --    See also: Set_Spacing and Get_Spacing 
  237.    -- 
  238.    --  - Name:  Homogeneous_Property 
  239.    --    Type:  Boolean 
  240.    --    Flags: read-write 
  241.    --    Descr: Whether the childrenshould all be the same size. 
  242.    --    See also: Set_Homogeneous 
  243.    --  </properties> 
  244.  
  245.    Spacing_Property     : constant Glib.Properties.Property_Int; 
  246.    Homogeneous_Property : constant Glib.Properties.Property_Boolean; 
  247.  
  248.    ---------------------- 
  249.    -- Child Properties -- 
  250.    ---------------------- 
  251.    --  The following properties can be set on children of this widget. See 
  252.    --  in particular Gtk.Containers.Child_Set_Property. 
  253.  
  254.    --  <child_properties> 
  255.    --  Name:  Expand_Property 
  256.    --  Type:  Boolean 
  257.    --  Descr: Whether the child should receive extra space when the parent 
  258.    --         grows 
  259.    -- 
  260.    --  Name:  Fill_Property 
  261.    --  Type:  Boolean 
  262.    --  Descr: Whether extra space given to the child should be allocated to the 
  263.    --         child or used as padding 
  264.    -- 
  265.    --  Name:  Pack_Type_Property 
  266.    --  Type:  Enum 
  267.    --  Descr: A GtkPackType indicating whether the child is packed with 
  268.    --         reference to the start or end of the parent 
  269.    -- 
  270.    --  Name:  Padding_Property 
  271.    --  Type:  Uint 
  272.    --  Descr: Extra space to put between the child and its neighbors, in pixels 
  273.    -- 
  274.    --  Name:  Position_Property 
  275.    --  Type:  Int 
  276.    --  Descr: The index of the child in the parent 
  277.    --  </child_properties> 
  278.  
  279.    Expand_Property    : constant Glib.Properties.Property_Boolean; 
  280.    Fill_Property      : constant Glib.Properties.Property_Boolean; 
  281.    Pack_Type_Property : constant Gtk.Enums.Property_Pack_Type; 
  282.    Padding_Property   : constant Glib.Properties.Property_Uint; 
  283.    Position_Property  : constant Glib.Properties.Property_Int; 
  284.  
  285.    ------------- 
  286.    -- Signals -- 
  287.    ------------- 
  288.  
  289.    --  <signals> 
  290.    --  The following new signals are defined for this widget: 
  291.    --  </signals> 
  292.  
  293. private 
  294.    type Gtk_Box_Record is new Gtk.Container.Gtk_Container_Record 
  295.      with null record; 
  296.  
  297.    Spacing_Property : constant Glib.Properties.Property_Int := 
  298.      Glib.Properties.Build ("spacing"); 
  299.    Homogeneous_Property : constant Glib.Properties.Property_Boolean := 
  300.      Glib.Properties.Build ("homogeneous"); 
  301.  
  302.    Expand_Property : constant Glib.Properties.Property_Boolean := 
  303.      Glib.Properties.Build ("expand"); 
  304.    Fill_Property : constant Glib.Properties.Property_Boolean := 
  305.      Glib.Properties.Build ("fill"); 
  306.    Pack_Type_Property : constant Gtk.Enums.Property_Pack_Type := 
  307.      Gtk.Enums.Build ("pack-type"); 
  308.    Padding_Property : constant Glib.Properties.Property_Uint := 
  309.      Glib.Properties.Build ("padding"); 
  310.    Position_Property : constant Glib.Properties.Property_Int := 
  311.      Glib.Properties.Build ("position"); 
  312.  
  313.    pragma Import (C, Get_Type,      "gtk_box_get_type"); 
  314.    pragma Import (C, Get_Hbox_Type, "gtk_hbox_get_type"); 
  315.    pragma Import (C, Get_Vbox_Type, "gtk_vbox_get_type"); 
  316. end Gtk.Box;