1. ----------------------------------------------------------------------- 
  2. --              GtkAda - Ada95 binding for Gtk+/Gnome                -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2001-2006 AdaCore                    -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. -- 
  26. --  Gtk_Size_Group provides a mechanism for grouping a number of widgets 
  27. --  together so they all request the same amount of space. This is typically 
  28. --  useful when you want a column of widgets to have the same size, but you 
  29. --  can't use a Gtk_Table widget. 
  30.  
  31. --  Note that size groups only affect the amount of space requested, not the 
  32. --  size that the widgets finally receive. If you want the widgets in a 
  33. --  Gtk_Size_Group to actually be the same size, you need to pack them in such 
  34. --  a way that they get the size they request and not more. For example, if you 
  35. --  are packing your widgets into a table, you would not include the Fill flag. 
  36. --  </description> 
  37. --  <c_version>2.8.17</c_version> 
  38. --  <testgtk>create_size_groups.adb</testgtk> 
  39.  
  40. with Glib.Object; 
  41. with Glib.Properties; 
  42. with Glib.Generic_Properties; 
  43. pragma Elaborate_All (Glib.Generic_Properties); 
  44. with Gtk.Widget; 
  45.  
  46. package Gtk.Size_Group is 
  47.  
  48.    type Gtk_Size_Group_Record is new Glib.Object.GObject_Record with private; 
  49.    type Gtk_Size_Group is access all Gtk_Size_Group_Record'Class; 
  50.  
  51.    type Size_Group_Mode is (None, Horizontal, Vertical, Both); 
  52.    pragma Convention (C, Size_Group_Mode); 
  53.    --  This type indicates how the size of all widgets in the group match: 
  54.    --  - None: The behavior is the same as if there was no size. Each widget 
  55.    --          requests its most appropriate size. 
  56.    --  - Horizontal: All the widgets in the group will have the same width. 
  57.    --  - Vertical: All the widgets in the group will have the same height 
  58.    --  - Both: All the widgets in the group will have exactly the same size. 
  59.  
  60.    procedure Gtk_New 
  61.      (Size_Group : out Gtk_Size_Group; Mode : Size_Group_Mode := Both); 
  62.    --  Create a new group. 
  63.    --  Initially, it doesn't contain any widget, and you need to add them with 
  64.    --  the Add_Widget procedure. 
  65.  
  66.    procedure Initialize 
  67.      (Size_Group : access Gtk_Size_Group_Record'Class; Mode : Size_Group_Mode); 
  68.    --  Internal initialization function. 
  69.    --  See the section "Creating your own widgets" in the documentation. 
  70.  
  71.    function Get_Type return Gtk.Gtk_Type; 
  72.    --  Return the internal value associated with a Gtk_Size_Group 
  73.  
  74.    procedure Set_Mode 
  75.      (Size_Group : access Gtk_Size_Group_Record; 
  76.       Mode       : Size_Group_Mode); 
  77.    function Get_Mode 
  78.      (Size_Group : access Gtk_Size_Group_Record) return Size_Group_Mode; 
  79.    --  Change the way the group effects the size of its component widgets. 
  80.  
  81.    procedure Add_Widget 
  82.      (Size_Group : access Gtk_Size_Group_Record; 
  83.       Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  84.    --  Add a new widget in the group. 
  85.    --  Its size will be effected by all other widgets in the group: the size 
  86.    --  requisition of the widget will be the maximum of its requisition and the 
  87.    --  requisition of the other widgets in the group (depending on the group 
  88.    --  mode). 
  89.    -- 
  90.    --  A given widget can belong to only one size group. It is removed from its 
  91.    --  previous group before being added to Size_Group. 
  92.  
  93.    procedure Remove_Widget 
  94.      (Size_Group : access Gtk_Size_Group_Record; 
  95.       Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  96.    --  Remove a widget from the group. 
  97.  
  98.    procedure Set_Ignore_Hidden 
  99.      (Size_Group    : access Gtk_Size_Group_Record; Ignore_Hidden : Boolean); 
  100.    function Get_Ignore_Hidden 
  101.      (Size_Group : access Gtk_Size_Group_Record) return Boolean; 
  102.    --  Whether invisible widgets are ignored when calcuating the size for all 
  103.    --  widgets in the group. 
  104.  
  105.    ---------------- 
  106.    -- Properties -- 
  107.    ---------------- 
  108.  
  109.    --  <properties> 
  110.    --  The following properties are defined for this widget. See 
  111.    --  Glib.Properties for more information on properties. 
  112.    -- 
  113.    --  Name:  Mode_Property 
  114.    --  Type:  Size_Group_Mode 
  115.    --  Flags: read-write 
  116.    --  Descr: the directions in which the size group effects the requested 
  117.    --         sizes of its component widgets 
  118.    --  See also: Set_Mode / Get_Mode 
  119.    -- 
  120.    --  Name:  Ignore_Hidden_Property 
  121.    --  Type:  Boolean 
  122.    --  Descr: If TRUE, hidden widgets are ignored 
  123.    -- 
  124.    --  </properties> 
  125.  
  126.    package Size_Group_Mode_Properties is new 
  127.      Glib.Generic_Properties.Generic_Internal_Discrete_Property 
  128.      (Size_Group_Mode); 
  129.    type Property_Size_Group_Mode is new Size_Group_Mode_Properties.Property; 
  130.  
  131.    Mode_Property : constant Property_Size_Group_Mode; 
  132.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean; 
  133.  
  134.    ------------- 
  135.    -- Signals -- 
  136.    ------------- 
  137.  
  138.    --  <signals> 
  139.    --  The following new signals are defined for this widget: 
  140.    -- 
  141.    --  </signals> 
  142.  
  143. private 
  144.    type Gtk_Size_Group_Record is new Glib.Object.GObject_Record 
  145.      with null record; 
  146.  
  147.    Mode_Property : constant Property_Size_Group_Mode := Build ("mode"); 
  148.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean := 
  149.      Glib.Properties.Build ("ignore-hidden"); 
  150.  
  151.    pragma Import (C, Get_Type, "gtk_size_group_get_type"); 
  152. end Gtk.Size_Group;