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. --  Gtk_Size_Group provides a mechanism for grouping a number of widgets 
  32. --  together so they all request the same amount of space. This is typically 
  33. --  useful when you want a column of widgets to have the same size, but you 
  34. --  can't use a Gtk_Table widget. 
  35. -- 
  36. --  Note that size groups only affect the amount of space requested, not the 
  37. --  size that the widgets finally receive. If you want the widgets in a 
  38. --  Gtk_Size_Group to actually be the same size, you need to pack them in such 
  39. --  a way that they get the size they request and not more. For example, if you 
  40. --  are packing your widgets into a table, you would not include the Fill flag. 
  41. -- 
  42. --  </description> 
  43. --  <testgtk>create_size_groups.adb</testgtk> 
  44.  
  45. pragma Warnings (Off, "*is already use-visible*"); 
  46. with Glib;                    use Glib; 
  47. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  48. with Glib.Object;             use Glib.Object; 
  49. with Glib.Properties;         use Glib.Properties; 
  50. with Glib.Types;              use Glib.Types; 
  51. with Gtk.Buildable;           use Gtk.Buildable; 
  52. with Gtk.Widget;              use Gtk.Widget; 
  53.  
  54. package Gtk.Size_Group is 
  55.  
  56.    type Gtk_Size_Group_Record is new GObject_Record with null record; 
  57.    type Gtk_Size_Group is access all Gtk_Size_Group_Record'Class; 
  58.  
  59.    type Size_Group_Mode is (None, Horizontal, Vertical, Both); 
  60.    pragma Convention (C, Size_Group_Mode); 
  61.    --  This type indicates how the size of all widgets in the group match: 
  62.    --  - None: The behavior is the same as if there was no size. Each widget 
  63.    --          requests its most appropriate size. 
  64.    --  - Horizontal: All the widgets in the group will have the same width. 
  65.    --  - Vertical: All the widgets in the group will have the same height 
  66.    --  - Both: All the widgets in the group will have exactly the same size. 
  67.  
  68.    package Size_Group_Mode_Properties is new 
  69.    Glib.Generic_Properties.Generic_Internal_Discrete_Property 
  70.      (Size_Group_Mode); 
  71.    type Property_Size_Group_Mode is new Size_Group_Mode_Properties.Property; 
  72.  
  73.    ------------------ 
  74.    -- Constructors -- 
  75.    ------------------ 
  76.  
  77.    procedure Gtk_New 
  78.       (Size_Group : out Gtk_Size_Group; 
  79.        Mode       : Size_Group_Mode := Both); 
  80.    procedure Initialize 
  81.       (Size_Group : access Gtk_Size_Group_Record'Class; 
  82.        Mode       : Size_Group_Mode := Both); 
  83.    --  Create a new Gtk.Size_Group.Gtk_Size_Group. 
  84.    --  "mode": the mode for the new size group. 
  85.  
  86.    function Get_Type return Glib.GType; 
  87.    pragma Import (C, Get_Type, "gtk_size_group_get_type"); 
  88.  
  89.    ------------- 
  90.    -- Methods -- 
  91.    ------------- 
  92.  
  93.    procedure Add_Widget 
  94.       (Size_Group : access Gtk_Size_Group_Record; 
  95.        Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  96.    --  Adds a widget to a Gtk.Size_Group.Gtk_Size_Group. In the future, the 
  97.    --  requisition of the widget will be determined as the maximum of its 
  98.    --  requisition and the requisition of the other widgets in the size group. 
  99.    --  Whether this applies horizontally, vertically, or in both directions 
  100.    --  depends on the mode of the size group. See Gtk.Size_Group.Set_Mode. When 
  101.    --  the widget is destroyed or no longer referenced elsewhere, it will be 
  102.    --  removed from the size group. 
  103.    --  "widget": the Gtk.Widget.Gtk_Widget to add 
  104.  
  105.    function Get_Ignore_Hidden 
  106.       (Size_Group : access Gtk_Size_Group_Record) return Boolean; 
  107.    procedure Set_Ignore_Hidden 
  108.       (Size_Group    : access Gtk_Size_Group_Record; 
  109.        Ignore_Hidden : Boolean); 
  110.    --  Sets whether unmapped widgets should be ignored when calculating the 
  111.    --  size. 
  112.    --  Since: gtk+ 2.8 
  113.    --  "ignore_hidden": whether unmapped widgets should be ignored when 
  114.    --  calculating the size 
  115.  
  116.    function Get_Mode 
  117.       (Size_Group : access Gtk_Size_Group_Record) return Size_Group_Mode; 
  118.    procedure Set_Mode 
  119.       (Size_Group : access Gtk_Size_Group_Record; 
  120.        Mode       : Size_Group_Mode); 
  121.    --  Sets the Size_Group_Mode of the size group. The mode of the size group 
  122.    --  determines whether the widgets in the size group should all have the 
  123.    --  same horizontal requisition (%GTK_SIZE_GROUP_MODE_HORIZONTAL) all have 
  124.    --  the same vertical requisition (%GTK_SIZE_GROUP_MODE_VERTICAL), or should 
  125.    --  all have the same requisition in both directions 
  126.    --  (%GTK_SIZE_GROUP_MODE_BOTH). 
  127.    --  "mode": the mode to set for the size group. 
  128.  
  129.    function Get_Widgets 
  130.       (Size_Group : access Gtk_Size_Group_Record) 
  131.        return Gtk.Widget.Widget_SList.GSlist; 
  132.    --  Returns the list of widgets associated with Size_Group. widgets. The 
  133.    --  list is owned by GTK+ and should not be modified. 
  134.    --  Since: gtk+ 2.10 
  135.  
  136.    procedure Remove_Widget 
  137.       (Size_Group : access Gtk_Size_Group_Record; 
  138.        Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  139.    --  Removes a widget from a Gtk.Size_Group.Gtk_Size_Group. 
  140.    --  "widget": the Gtk.Widget.Gtk_Widget to remove 
  141.  
  142.    ---------------- 
  143.    -- Interfaces -- 
  144.    ---------------- 
  145.    --  This class implements several interfaces. See Glib.Types 
  146.    -- 
  147.    --  - "Buildable" 
  148.  
  149.    package Implements_Buildable is new Glib.Types.Implements 
  150.      (Gtk.Buildable.Gtk_Buildable, Gtk_Size_Group_Record, Gtk_Size_Group); 
  151.    function "+" 
  152.      (Widget : access Gtk_Size_Group_Record'Class) 
  153.    return Gtk.Buildable.Gtk_Buildable 
  154.    renames Implements_Buildable.To_Interface; 
  155.    function "-" 
  156.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  157.    return Gtk_Size_Group 
  158.    renames Implements_Buildable.To_Object; 
  159.  
  160.    ---------------- 
  161.    -- Properties -- 
  162.    ---------------- 
  163.    --  The following properties are defined for this widget. See 
  164.    --  Glib.Properties for more information on properties) 
  165.    -- 
  166.    --  Name: Ignore_Hidden_Property 
  167.    --  Type: Boolean 
  168.    --  Flags: read-write 
  169.    --  If True, unmapped widgets are ignored when determining the size of the 
  170.    --  group. 
  171.    -- 
  172.    --  Name: Mode_Property 
  173.    --  Type: Size_Group_Mode 
  174.    --  Flags: read-write 
  175.  
  176.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean; 
  177.    Mode_Property : constant Gtk.Size_Group.Property_Size_Group_Mode; 
  178.  
  179. private 
  180.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean := 
  181.      Glib.Properties.Build ("ignore-hidden"); 
  182.    Mode_Property : constant Gtk.Size_Group.Property_Size_Group_Mode := 
  183.      Gtk.Size_Group.Build ("mode"); 
  184. end Gtk.Size_Group;