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-2007 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. --  Base class for widgets that have children. 
  27. -- 
  28. --  When writing your own container widgets, you need to fully handle the 
  29. --  size_allocate event, by also resizing all the children (based on their size 
  30. --  requisition). The size_allocate event will always be sent to the parent 
  31. --  when a child calls Gtk.Widget.Queue_Resize. 
  32. --  </description> 
  33. --  <c_version>2.8.17</c_version> 
  34. --  <group>Abstract base classes</group> 
  35.  
  36. with Gdk.Event; 
  37. with Glib.Properties; 
  38. with Glib.Values; 
  39. with Gtk.Adjustment; 
  40. with Gtk.Enums; 
  41. with Gtk.Widget; 
  42.  
  43. package Gtk.Container is 
  44.  
  45.    type Gtk_Container_Record is new Gtk.Widget.Gtk_Widget_Record with private; 
  46.    type Gtk_Container is access all Gtk_Container_Record'Class; 
  47.  
  48.    function Get_Type return Glib.GType; 
  49.    --  Return the internal value associated with a Gtk_Container. 
  50.  
  51.    procedure Set_Border_Width 
  52.      (Container    : access Gtk_Container_Record; 
  53.       Border_Width : Guint); 
  54.    function Get_Border_Width 
  55.      (Container    : access Gtk_Container_Record) return Guint; 
  56.    --  Modify the size of the frame that surrounds the widget. 
  57.    --  The exact visual impact depends on the specific widget class. 
  58.  
  59.    procedure Add 
  60.      (Container : access Gtk_Container_Record; 
  61.       Widget    : access Gtk.Widget.Gtk_Widget_Record'Class); 
  62.    --  Add a new child to the container. 
  63.    --  Note that some containers can have only one child. Nothing is done 
  64.    --  if there is already a child. 
  65.    --  This basically sends the "add" signal (see below) 
  66.  
  67.    procedure Remove 
  68.      (Container : access Gtk_Container_Record; 
  69.       Widget    : access Gtk.Widget.Gtk_Widget_Record'Class); 
  70.    --  Removes Widget from Container. Widget must be inside Container. 
  71.    --  Note that Container will own a reference to Widget, and that this 
  72.    --  may be the last reference held; so removing a widget from its 
  73.    --  container can destroy that widget. If you want to use Widget 
  74.    --  again, you need to add a reference to it while it's not inside 
  75.    --  a container, using Glib.Object.Ref. If you don't want to use Widget 
  76.    --  again it's usually more efficient to simply destroy it directly 
  77.    --  using Gtk.Widget.Destroy since this will remove it from the 
  78.    --  container and help break any circular reference count cycles. 
  79.  
  80.    procedure Set_Resize_Mode 
  81.      (Container   : access Gtk_Container_Record; 
  82.       Resize_Mode : Gtk.Enums.Gtk_Resize_Mode); 
  83.    function Get_Resize_Mode 
  84.      (Container : access Gtk_Container_Record) 
  85.       return Gtk.Enums.Gtk_Resize_Mode; 
  86.    --  Change the resizing behavior for the Container. 
  87.    --  The default value is Resize_Parent. 
  88.  
  89.    function Get_Children 
  90.      (Container : access Gtk_Container_Record) 
  91.       return Gtk.Widget.Widget_List.Glist; 
  92.    --  Return a list of all the children of the container. 
  93.    --  The caller must free the returned list. 
  94.  
  95.    procedure Propagate_Expose 
  96.      (Container : access Gtk_Container_Record; 
  97.       Child     : access Gtk.Widget.Gtk_Widget_Record'Class; 
  98.       Event     : Gdk.Event.Gdk_Event_Expose); 
  99.    --  When a container receives an expose event, it must send synthetic 
  100.    --  expose events to all children that don't have their own Gdk_Window. 
  101.    --  This function provides a convenient way of doing this. A container, 
  102.    --  when it receives an expose event, Propagate_Expose 
  103.    --  once for each child, passing in the event the container received. 
  104.    -- 
  105.    --  Propagate_Expose takes care of deciding whether 
  106.    --  an expose event needs to be sent to the child, intersecting 
  107.    --  the event's area with the child area, and sending the event. 
  108.    -- 
  109.    --  In most cases, a container can simply either simply inherit the 
  110.    --  expose implementation from Gtk_Container, or, do some drawing 
  111.    --  and then chain to the expose implementation from Gtk_Container. 
  112.  
  113.    ----------- 
  114.    -- Focus -- 
  115.    ----------- 
  116.  
  117.    procedure Set_Focus_Chain 
  118.      (Container         : access Gtk_Container_Record; 
  119.       Focusable_Widgets : Gtk.Widget.Widget_List.Glist); 
  120.    --  Set the chain of widgets that can take the focus for a given Container. 
  121.    --  The list should be freed by the user. 
  122.    --  This list indicates in which order the widgets will get the focus when 
  123.    --  the user presses tab or the arrow keys to move from one widget to the 
  124.    --  next. 
  125.  
  126.    procedure Get_Focus_Chain 
  127.      (Container         : access Gtk_Container_Record; 
  128.       Focusable_Widgets : out Gtk.Widget.Widget_List.Glist; 
  129.       Success           : out Boolean); 
  130.    --  Retrieves the focus chain of the container, if one has been 
  131.    --  set explicitly. If no focus chain has been explicitly 
  132.    --  set, GTK+ computes the focus chain based on the positions 
  133.    --  of the children. In that case, GTK+ stores null in 
  134.    --  Focusable_Widgets and returns FALSE. 
  135.    --  The returned list must be freed by the user. 
  136.  
  137.    procedure Unset_Focus_Chain (Container : access Gtk_Container_Record); 
  138.    --  Undoes the effect of Set_Focus_Chain 
  139.  
  140.    procedure Set_Focus_Vadjustment 
  141.      (Container  : access Gtk_Container_Record; 
  142.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  143.    function Get_Focus_Vadjustment 
  144.      (Container : access Gtk_Container_Record) 
  145.       return Gtk.Adjustment.Gtk_Adjustment; 
  146.    --  Set the focus to the vertical adjustment. 
  147.    --  Adjustment should have been created and displayed at some other 
  148.    --  place in your application. 
  149.    --  Container will make sure that Adjustment always matches the range 
  150.    --  for the focus widget's position (y .. y + height). 
  151.  
  152.    procedure Set_Focus_Hadjustment 
  153.      (Container  : access Gtk_Container_Record; 
  154.       Adjustment : Gtk.Adjustment.Gtk_Adjustment); 
  155.    function Get_Focus_Hadjustment 
  156.      (Container : access Gtk_Container_Record) 
  157.       return Gtk.Adjustment.Gtk_Adjustment; 
  158.    --  Set the focus to the horizontal adjustment. 
  159.    --  Adjustment should have been created and displayed at some other 
  160.    --  place in your application. 
  161.    --  Container will make sure that Adjustment always matches the range 
  162.    --  for the focus widget's position (x .. x + width). 
  163.  
  164.    procedure Set_Focus_Child 
  165.      (Container : access Gtk_Container_Record; 
  166.       Child     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  167.    function Get_Focus_Child 
  168.      (Container : access Gtk_Container_Record) return Gtk.Widget.Gtk_Widget; 
  169.    --  Emit a "set_focus_child" signal, to set the child that currently has the 
  170.    --  keyboard focus. 
  171.  
  172.    ---------------- 
  173.    -- Properties -- 
  174.    ---------------- 
  175.  
  176.    procedure Child_Set_Property 
  177.      (Container     : access Gtk_Container_Record; 
  178.       Child         : access Gtk.Widget.Gtk_Widget_Record'Class; 
  179.       Property_Name : String; 
  180.       Value         : Glib.Values.GValue); 
  181.    procedure Child_Get_Property 
  182.      (Container     : access Gtk_Container_Record; 
  183.       Child         : access Gtk.Widget.Gtk_Widget_Record'Class; 
  184.       Property_Name : String; 
  185.       Value         : out Glib.Values.GValue); 
  186.    --  Sets or Gets the value of a child property for Child and Container. This 
  187.    --  is property set at the container level, and that applies to all children 
  188.    --  of that container. These are special type of properties, different from 
  189.    --  the properties associated with each type of widget. 
  190.    --  See also Gtk.Widget.Child_Notify 
  191.    --  You should use Glib.Property_Name to get the name from the property 
  192.    --  declaration in each of the GtkAda packages 
  193.  
  194.    function Class_Find_Child_Property 
  195.      (Cclass        : Glib.Object.GObject_Class; 
  196.       Property_Name : String) return Glib.Param_Spec; 
  197.    --  Finds a child property of a container class by name. The returned value 
  198.    --  describes the property (type, allowed range, description,...) 
  199.    --  You should use Glib.Property_Name to get the name from the property 
  200.    --  declaration in each of the GtkAda packages 
  201.  
  202.    procedure Class_Install_Child_Property 
  203.      (Cclass      : Glib.Object.GObject_Class; 
  204.       Property_Id : Guint; 
  205.       Pspec       : Glib.Param_Spec); 
  206.    --  Installs a child property on a container class. 
  207.    --  The Property_Id is an custom id that you choose for your class. It will 
  208.    --  be used in signals that set or get the property, instead of passing 
  209.    --  around a string. 
  210.  
  211.    function Class_List_Child_Properties 
  212.      (Cclass : Glib.Object.GObject_Class) return Glib.Param_Spec_Array; 
  213.    --  Returns all child properties of a container class. 
  214.  
  215.    ---------------------- 
  216.    -- Forall functions -- 
  217.    ---------------------- 
  218.  
  219.    type Gtk_Callback is 
  220.      access procedure (Item : access Gtk.Widget.Gtk_Widget_Record'Class); 
  221.    --  Function that can be call for each child of a container. 
  222.    --  This is called automatically by the Forall subprogram below. 
  223.  
  224.    procedure Forall 
  225.      (Container : access Gtk_Container_Record; 
  226.       Func      : Gtk_Callback); 
  227.    --  Invokes Func on each child of Container, including children that are 
  228.    --  considered "internal" (implementation details of the container). 
  229.    --  "Internal" children generally weren't added by the user of the 
  230.    --  container, but were added by the container implementation itself. See 
  231.    --  Gtk.Widget.Set_Composite_Name. 
  232.    --  Most applications should use gtk_container_foreach(), rather than 
  233.    --  gtk_container_forall(). 
  234.    --  See also the generic package Forall_Pkg if you want to pass some 
  235.    --  extra data to Func. 
  236.  
  237.    procedure Foreach 
  238.      (Container : access Gtk_Container_Record; 
  239.       Func      : Gtk_Callback); 
  240.    --  Invokes Func on each non-internal child of Container. See Forall for 
  241.    --  details on what constitutes an "internal" child. 
  242.  
  243.    --  <doc_ignore> 
  244.    generic 
  245.       type Data_Type (<>) is private; 
  246.    package For_Pkg is 
  247.       type Gtk_Callback is 
  248.         access procedure (Item : access Gtk.Widget.Gtk_Widget_Record'Class; 
  249.                           Data : in out Data_Type); 
  250.       procedure Forall 
  251.         (Container : access Gtk_Container_Record; 
  252.          Func      : Gtk_Callback; 
  253.          Data      : Data_Type); 
  254.       --  Execute Func for each of the children of Container, including 
  255.       --  internal ones 
  256.  
  257.       procedure Foreach 
  258.         (Container : access Gtk_Container_Record; 
  259.          Func      : Gtk_Callback; 
  260.          Data      : Data_Type); 
  261.       --  Execute Func for each of the children of Container, not including 
  262.       --  internal ones 
  263.    end For_Pkg; 
  264.    --  </doc_ignore> 
  265.  
  266.    -------------------------- 
  267.    -- Widget-level methods -- 
  268.    -------------------------- 
  269.  
  270.    procedure Set_Reallocate_Redraws 
  271.      (Container     : access Gtk_Container_Record; 
  272.       Needs_Redraws : Boolean := False); 
  273.    --  Set the "needs_redraws" field. 
  274.    --  If Needs_Redraws is True, then a "draw" signal is emitted for the 
  275.    --  Container whenever one is emitted for a child. 
  276.  
  277.    function Child_Type 
  278.      (Container : access Gtk_Container_Record) return Gtk.Gtk_Type; 
  279.    --  Return the type of the children in Container. 
  280.    --  If Container can contain any type of widget, Gtk_Type_None is 
  281.    --  returned. 
  282.  
  283.    procedure Resize_Children (Container : access Gtk_Container_Record); 
  284.    --  The container hasn't changed size but one of its children 
  285.    --  queued a resize request. Which means that the allocation 
  286.    --  is not sufficient for the requisition of some child. 
  287.    --  Run through the list of widgets and reallocate their size appropriately. 
  288.  
  289.    ---------------------- 
  290.    -- Signals emission -- 
  291.    ---------------------- 
  292.  
  293.    procedure Check_Resize (Container : access Gtk_Container_Record); 
  294.    --  Emit the "check_resize" signal 
  295.  
  296.    ----------------- 
  297.    -- Obsolescent -- 
  298.    ----------------- 
  299.    --  All subprograms below are now obsolescent in gtk+. They might be removed 
  300.    --  from future versions of gtk+ (and therefore GtkAda). 
  301.    --  To find out whether your code uses any of these, we recommend compiling 
  302.    --  with the -gnatwj switch 
  303.    --  <doc_ignore> 
  304.  
  305.    function Children 
  306.      (Container : access Gtk_Container_Record) 
  307.       return Gtk.Widget.Widget_List.Glist 
  308.       renames Get_Children; 
  309.    --  pragma Obsolescent; 
  310.  
  311.    --  </doc_ignore> 
  312.  
  313.    ---------------- 
  314.    -- Properties -- 
  315.    ---------------- 
  316.  
  317.    --  <properties> 
  318.    --  The following properties are defined for this widget. See 
  319.    --  Glib.Properties for more information on properties. 
  320.    -- 
  321.    --  - Name:  Border_Width_Property 
  322.    --    Type:  Guint 
  323.    --    Flags: read-write 
  324.    --    Descr: The width of the empty border outside the containers children. 
  325.    --    See also:  Set_Border_Width 
  326.    -- 
  327.    --  - Name:  Resize_Mode_Property 
  328.    --    Type:  Gtk_Resize_Mode 
  329.    --    Flags: read-write 
  330.    --    Descr: Specify how resize events are handled 
  331.    --    See also:  Set_Resize_Mode 
  332.    -- 
  333.    --  - Name:  Child_Property 
  334.    --    Type:  Widget 
  335.    --    Flags: writable 
  336.    --    Descr: Can be used to add a new child to the container. 
  337.    --    See also:  Add 
  338.    -- 
  339.    --  - Name:  Reallocate_Redraws_Property 
  340.    --    Type:  Boolean 
  341.    --    Flags: read-write 
  342.    --    Descr: Whether redraws should be reallocated 
  343.    --    See also: Set_Reallocate_Redraws 
  344.    --  </properties> 
  345.  
  346.    Border_Width_Property       : constant Glib.Properties.Property_Uint; 
  347.    Resize_Mode_Property        : constant Gtk.Enums.Property_Gtk_Resize_Mode; 
  348.    Child_Property              : constant Glib.Properties.Property_Object_WO; 
  349.    Reallocate_Redraws_Property : constant Glib.Properties.Property_Boolean; 
  350.  
  351.    ------------- 
  352.    -- Signals -- 
  353.    ------------- 
  354.  
  355.    --  <signals> 
  356.    --  The following new signals are defined for this widget: 
  357.    -- 
  358.    --  - "add" 
  359.    --    procedure Handler (Container : access Gtk_Container_Record'Class; 
  360.    --                       Widget    : access Gtk_Widget_Record'Class); 
  361.    -- 
  362.    --    A new widget is added to the container 
  363.    -- 
  364.    --  - "remove" 
  365.    --    procedure Handler (Container : access Gtk_Container_Record'Class; 
  366.    --                       Widget    : access Gtk_Widget_Record'Class); 
  367.    -- 
  368.    --    A widget is removed from the container 
  369.    -- 
  370.    --  - "check_resize" 
  371.    --    procedure Handler (Container : access Gtk_Container_Record'Class); 
  372.    -- 
  373.    --    Called every time the Container needs resizing. 
  374.    --    Upon receiving this signal, Container should check whether it needs 
  375.    --    to be resized, and if it does should queue a resize request. 
  376.    -- 
  377.    --  - "focus" 
  378.    --    procedure Handler (Container : access Gtk_Container_Record'Class; 
  379.    --                       Direction : Gtk_Direction_Type); 
  380.    -- 
  381.    --    Moves the current selection to a new widget. 
  382.    -- 
  383.    --  - "set-focus-child" 
  384.    --    procedure Handler (Container : access Gtk_Container_Record'Class; 
  385.    --                       Widget    : access Gtk_Widget_Record'Class); 
  386.    -- 
  387.    --    Emitted when a new widget gains the focus. 
  388.    -- 
  389.    --  </signals> 
  390.  
  391.    Signal_Add             : constant Glib.Signal_Name := "add"; 
  392.    Signal_Check_Resize    : constant Glib.Signal_Name := "check_resize"; 
  393.    Signal_Remove          : constant Glib.Signal_Name := "remove"; 
  394.    Signal_Set_Focus_Child : constant Glib.Signal_Name := "set-focus-child"; 
  395.  
  396. private 
  397.    type Gtk_Container_Record is new Gtk.Widget.Gtk_Widget_Record 
  398.      with null record; 
  399.  
  400.    Border_Width_Property       : constant Glib.Properties.Property_Uint := 
  401.      Glib.Properties.Build ("border_width"); 
  402.    Resize_Mode_Property        : constant Gtk.Enums.Property_Gtk_Resize_Mode := 
  403.      Gtk.Enums.Build ("resize_mode"); 
  404.    Child_Property              : constant Glib.Properties.Property_Object_WO := 
  405.      Glib.Properties.Build ("child"); 
  406.    Reallocate_Redraws_Property : constant Glib.Properties.Property_Boolean := 
  407.      Glib.Properties.Build ("reallocate_redraws"); 
  408.  
  409.    pragma Import (C, Get_Type, "gtk_container_get_type"); 
  410. end Gtk.Container; 
  411.  
  412. --  No binding: gtk_container_child_get_valist 
  413. --  No binding: gtk_container_child_set_valist 
  414. --  No binding: gtk_container_child_set 
  415. --  No binding: gtk_container_child_get 
  416. --  No binding: gtk_container_add_with_properties 
  417.  
  418. --  These functions never had a binding, but are now obsolescent 
  419. --  No binding: gtk_container_foreach_full 
  420.  
  421. --  Bound using C glue function: 
  422. --  No binding: gtk_container_get_focus_child