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-2011, 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. --  A Gtk_Aspect_Frame is the same type of widget as a frame, but it 
  27. --  constrains its child to a specific aspect ratio between its width and its 
  28. --  height. 
  29. -- 
  30. --  This ratio can either be given explicitly by the user, or chosen from the 
  31. --  widget's initial size request (might be different from the one if was 
  32. --  actually given). 
  33. -- 
  34. --  </description> 
  35. --  <group>Layout Containers</group> 
  36. --  <testgtk>create_frame.adb.adb</testgtk> 
  37.  
  38. pragma Warnings (Off, "*is already use-visible*"); 
  39. with Glib;            use Glib; 
  40. with Glib.Properties; use Glib.Properties; 
  41. with Glib.Types;      use Glib.Types; 
  42. with Gtk.Buildable;   use Gtk.Buildable; 
  43. with Gtk.Frame;       use Gtk.Frame; 
  44. with Gtk.Widget;      use Gtk.Widget; 
  45.  
  46. package Gtk.Aspect_Frame is 
  47.  
  48.    type Gtk_Aspect_Frame_Record is new Gtk_Frame_Record with null record; 
  49.    type Gtk_Aspect_Frame is access all Gtk_Aspect_Frame_Record'Class; 
  50.  
  51.    ------------------ 
  52.    -- Constructors -- 
  53.    ------------------ 
  54.  
  55.    procedure Gtk_New 
  56.       (Aspect_Frame : out Gtk_Aspect_Frame; 
  57.        Label        : UTF8_String := ""; 
  58.        Xalign       : Gfloat; 
  59.        Yalign       : Gfloat; 
  60.        Ratio        : Gfloat; 
  61.        Obey_Child   : Boolean); 
  62.    procedure Initialize 
  63.       (Aspect_Frame : access Gtk_Aspect_Frame_Record'Class; 
  64.        Label        : UTF8_String := ""; 
  65.        Xalign       : Gfloat; 
  66.        Yalign       : Gfloat; 
  67.        Ratio        : Gfloat; 
  68.        Obey_Child   : Boolean); 
  69.    --  Create a new Gtk.Aspect_Frame.Gtk_Aspect_Frame. 
  70.    --  "label": Label text. 
  71.    --  "xalign": Horizontal alignment of the child within the allocation of 
  72.    --  the Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left 
  73.    --  aligned) to 1.0 (right aligned) 
  74.    --  "yalign": Vertical alignment of the child within the allocation of the 
  75.    --  Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left aligned) 
  76.    --  to 1.0 (right aligned) 
  77.    --  "ratio": The desired aspect ratio. 
  78.    --  "obey_child": If True, Ratio is ignored, and the aspect ratio is taken 
  79.    --  from the requistion of the child. 
  80.  
  81.    function Get_Type return Glib.GType; 
  82.    pragma Import (C, Get_Type, "gtk_aspect_frame_get_type"); 
  83.  
  84.    ------------- 
  85.    -- Methods -- 
  86.    ------------- 
  87.  
  88.    procedure Set 
  89.       (Aspect_Frame : access Gtk_Aspect_Frame_Record; 
  90.        Xalign       : Gfloat; 
  91.        Yalign       : Gfloat; 
  92.        Ratio        : Gfloat; 
  93.        Obey_Child   : Boolean); 
  94.    --  Set parameters for an existing Gtk.Aspect_Frame.Gtk_Aspect_Frame. 
  95.    --  "xalign": Horizontal alignment of the child within the allocation of 
  96.    --  the Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left 
  97.    --  aligned) to 1.0 (right aligned) 
  98.    --  "yalign": Vertical alignment of the child within the allocation of the 
  99.    --  Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left aligned) 
  100.    --  to 1.0 (right aligned) 
  101.    --  "ratio": The desired aspect ratio. 
  102.    --  "obey_child": If True, Ratio is ignored, and the aspect ratio is taken 
  103.    --  from the requistion of the child. 
  104.  
  105.    ------------ 
  106.    -- Fields -- 
  107.    ------------ 
  108.  
  109.    function Get_Xalign 
  110.       (Aspect_Frame : access Gtk_Aspect_Frame_Record) return Gfloat; 
  111.  
  112.    function Get_Yalign 
  113.       (Aspect_Frame : access Gtk_Aspect_Frame_Record) return Gfloat; 
  114.  
  115.    function Get_Ratio 
  116.       (Aspect_Frame : access Gtk_Aspect_Frame_Record) return Gfloat; 
  117.  
  118.    ---------------- 
  119.    -- Interfaces -- 
  120.    ---------------- 
  121.    --  This class implements several interfaces. See Glib.Types 
  122.    -- 
  123.    --  - "Buildable" 
  124.  
  125.    package Implements_Buildable is new Glib.Types.Implements 
  126.      (Gtk.Buildable.Gtk_Buildable, Gtk_Aspect_Frame_Record, Gtk_Aspect_Frame); 
  127.    function "+" 
  128.      (Widget : access Gtk_Aspect_Frame_Record'Class) 
  129.    return Gtk.Buildable.Gtk_Buildable 
  130.    renames Implements_Buildable.To_Interface; 
  131.    function "-" 
  132.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  133.    return Gtk_Aspect_Frame 
  134.    renames Implements_Buildable.To_Object; 
  135.  
  136.    ---------------- 
  137.    -- Properties -- 
  138.    ---------------- 
  139.    --  The following properties are defined for this widget. See 
  140.    --  Glib.Properties for more information on properties) 
  141.    -- 
  142.    --  Name: Obey_Child_Property 
  143.    --  Type: Boolean 
  144.    --  Flags: read-write 
  145.    -- 
  146.    --  Name: Ratio_Property 
  147.    --  Type: Gfloat 
  148.    --  Flags: read-write 
  149.    -- 
  150.    --  Name: Xalign_Property 
  151.    --  Type: Gfloat 
  152.    --  Flags: read-write 
  153.    -- 
  154.    --  Name: Yalign_Property 
  155.    --  Type: Gfloat 
  156.    --  Flags: read-write 
  157.  
  158.    Obey_Child_Property : constant Glib.Properties.Property_Boolean; 
  159.    Ratio_Property : constant Glib.Properties.Property_Float; 
  160.    Xalign_Property : constant Glib.Properties.Property_Float; 
  161.    Yalign_Property : constant Glib.Properties.Property_Float; 
  162.  
  163. private 
  164.    Obey_Child_Property : constant Glib.Properties.Property_Boolean := 
  165.      Glib.Properties.Build ("obey-child"); 
  166.    Ratio_Property : constant Glib.Properties.Property_Float := 
  167.      Glib.Properties.Build ("ratio"); 
  168.    Xalign_Property : constant Glib.Properties.Property_Float := 
  169.      Glib.Properties.Build ("xalign"); 
  170.    Yalign_Property : constant Glib.Properties.Property_Float := 
  171.      Glib.Properties.Build ("yalign"); 
  172. end Gtk.Aspect_Frame;