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