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. -- As a special exception, if other files instantiate generics from  -- 
  22. -- this unit, or you link this unit with other files to produce an   -- 
  23. -- executable, this  unit  does not  by itself cause  the resulting  -- 
  24. -- executable to be covered by the GNU General Public License. This  -- 
  25. -- exception does not however invalidate any other reasons why the   -- 
  26. -- executable file  might be covered by the  GNU Public License.     -- 
  27. ----------------------------------------------------------------------- 
  28.  
  29. --  <description> 
  30. -- 
  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. --  </description> 
  42. --  <c_version>2.8.17</c_version> 
  43. --  <testgtk>create_size_groups.adb</testgtk> 
  44.  
  45. with Glib.Object; 
  46. with Glib.Properties; 
  47. with Glib.Generic_Properties; 
  48. pragma Elaborate_All (Glib.Generic_Properties); 
  49. with Gtk.Widget; 
  50.  
  51. package Gtk.Size_Group is 
  52.  
  53.    type Gtk_Size_Group_Record is new Glib.Object.GObject_Record with private; 
  54.    type Gtk_Size_Group is access all Gtk_Size_Group_Record'Class; 
  55.  
  56.    type Size_Group_Mode is (None, Horizontal, Vertical, Both); 
  57.    pragma Convention (C, Size_Group_Mode); 
  58.    --  This type indicates how the size of all widgets in the group match: 
  59.    --  - None: The behavior is the same as if there was no size. Each widget 
  60.    --          requests its most appropriate size. 
  61.    --  - Horizontal: All the widgets in the group will have the same width. 
  62.    --  - Vertical: All the widgets in the group will have the same height 
  63.    --  - Both: All the widgets in the group will have exactly the same size. 
  64.  
  65.    procedure Gtk_New 
  66.      (Size_Group : out Gtk_Size_Group; Mode : Size_Group_Mode := Both); 
  67.    --  Create a new group. 
  68.    --  Initially, it doesn't contain any widget, and you need to add them with 
  69.    --  the Add_Widget procedure. 
  70.  
  71.    procedure Initialize 
  72.      (Size_Group : access Gtk_Size_Group_Record'Class; Mode : Size_Group_Mode); 
  73.    --  Internal initialization function. 
  74.    --  See the section "Creating your own widgets" in the documentation. 
  75.  
  76.    function Get_Type return Gtk.Gtk_Type; 
  77.    --  Return the internal value associated with a Gtk_Size_Group 
  78.  
  79.    procedure Set_Mode 
  80.      (Size_Group : access Gtk_Size_Group_Record; 
  81.       Mode       : Size_Group_Mode); 
  82.    function Get_Mode 
  83.      (Size_Group : access Gtk_Size_Group_Record) return Size_Group_Mode; 
  84.    --  Change the way the group effects the size of its component widgets. 
  85.  
  86.    procedure Add_Widget 
  87.      (Size_Group : access Gtk_Size_Group_Record; 
  88.       Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  89.    --  Add a new widget in the group. 
  90.    --  Its size will be effected by all other widgets in the group: the size 
  91.    --  requisition of the widget will be the maximum of its requisition and the 
  92.    --  requisition of the other widgets in the group (depending on the group 
  93.    --  mode). 
  94.    -- 
  95.    --  A given widget can belong to only one size group. It is removed from its 
  96.    --  previous group before being added to Size_Group. 
  97.  
  98.    procedure Remove_Widget 
  99.      (Size_Group : access Gtk_Size_Group_Record; 
  100.       Widget     : access Gtk.Widget.Gtk_Widget_Record'Class); 
  101.    --  Remove a widget from the group. 
  102.  
  103.    procedure Set_Ignore_Hidden 
  104.      (Size_Group    : access Gtk_Size_Group_Record; Ignore_Hidden : Boolean); 
  105.    function Get_Ignore_Hidden 
  106.      (Size_Group : access Gtk_Size_Group_Record) return Boolean; 
  107.    --  Whether invisible widgets are ignored when calcuating the size for all 
  108.    --  widgets in the group. 
  109.  
  110.    ---------------- 
  111.    -- Properties -- 
  112.    ---------------- 
  113.  
  114.    --  <properties> 
  115.    --  The following properties are defined for this widget. See 
  116.    --  Glib.Properties for more information on properties. 
  117.    -- 
  118.    --  Name:  Mode_Property 
  119.    --  Type:  Size_Group_Mode 
  120.    --  Flags: read-write 
  121.    --  Descr: the directions in which the size group effects the requested 
  122.    --         sizes of its component widgets 
  123.    --  See also: Set_Mode / Get_Mode 
  124.    -- 
  125.    --  Name:  Ignore_Hidden_Property 
  126.    --  Type:  Boolean 
  127.    --  Descr: If TRUE, hidden widgets are ignored 
  128.    -- 
  129.    --  </properties> 
  130.  
  131.    package Size_Group_Mode_Properties is new 
  132.      Glib.Generic_Properties.Generic_Internal_Discrete_Property 
  133.      (Size_Group_Mode); 
  134.    type Property_Size_Group_Mode is new Size_Group_Mode_Properties.Property; 
  135.  
  136.    Mode_Property : constant Property_Size_Group_Mode; 
  137.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean; 
  138.  
  139.    ------------- 
  140.    -- Signals -- 
  141.    ------------- 
  142.  
  143.    --  <signals> 
  144.    --  The following new signals are defined for this widget: 
  145.    -- 
  146.    --  </signals> 
  147.  
  148. private 
  149.    type Gtk_Size_Group_Record is new Glib.Object.GObject_Record 
  150.      with null record; 
  151.  
  152.    Mode_Property : constant Property_Size_Group_Mode := Build ("mode"); 
  153.    Ignore_Hidden_Property : constant Glib.Properties.Property_Boolean := 
  154.      Glib.Properties.Build ("ignore-hidden"); 
  155.  
  156.    pragma Import (C, Get_Type, "gtk_size_group_get_type"); 
  157. end Gtk.Size_Group;