1. ------------------------------------------------------------------------------ 
  2. --                                                                          -- 
  3. --      Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet       -- 
  4. --                     Copyright (C) 2000-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  The Gtk.Aspect_Frame.Gtk_Aspect_Frame is useful when you want pack a 
  26. --  widget so that it can resize but always retains the same aspect ratio. For 
  27. --  instance, one might be drawing a small preview of a larger image. 
  28. --  Gtk.Aspect_Frame.Gtk_Aspect_Frame derives from Gtk.Frame.Gtk_Frame, so it 
  29. --  can draw a label and a frame around the child. The frame will be 
  30. --  "shrink-wrapped" to the size of the child. 
  31. -- 
  32. --  </description> 
  33. --  <group>Layout Containers</group> 
  34. --  <testgtk>create_frame.adb</testgtk> 
  35. pragma Ada_2005; 
  36.  
  37. pragma Warnings (Off, "*is already use-visible*"); 
  38. with Glib;            use Glib; 
  39. with Glib.Properties; use Glib.Properties; 
  40. with Glib.Types;      use Glib.Types; 
  41. with Gtk.Buildable;   use Gtk.Buildable; 
  42. with Gtk.Frame;       use Gtk.Frame; 
  43.  
  44. package Gtk.Aspect_Frame is 
  45.  
  46.    type Gtk_Aspect_Frame_Record is new Gtk_Frame_Record with null record; 
  47.    type Gtk_Aspect_Frame is access all Gtk_Aspect_Frame_Record'Class; 
  48.  
  49.    ------------------ 
  50.    -- Constructors -- 
  51.    ------------------ 
  52.  
  53.    procedure Gtk_New 
  54.       (Aspect_Frame : out Gtk_Aspect_Frame; 
  55.        Label        : UTF8_String := ""; 
  56.        Xalign       : Gfloat; 
  57.        Yalign       : Gfloat; 
  58.        Ratio        : Gfloat; 
  59.        Obey_Child   : Boolean); 
  60.    procedure Initialize 
  61.       (Aspect_Frame : not null access Gtk_Aspect_Frame_Record'Class; 
  62.        Label        : UTF8_String := ""; 
  63.        Xalign       : Gfloat; 
  64.        Yalign       : Gfloat; 
  65.        Ratio        : Gfloat; 
  66.        Obey_Child   : Boolean); 
  67.    --  Create a new Gtk.Aspect_Frame.Gtk_Aspect_Frame. 
  68.    --  "label": Label text. 
  69.    --  "xalign": Horizontal alignment of the child within the allocation of 
  70.    --  the Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left 
  71.    --  aligned) to 1.0 (right aligned) 
  72.    --  "yalign": Vertical alignment of the child within the allocation of the 
  73.    --  Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (top aligned) to 
  74.    --  1.0 (bottom aligned) 
  75.    --  "ratio": The desired aspect ratio. 
  76.    --  "obey_child": If True, Ratio is ignored, and the aspect ratio is taken 
  77.    --  from the requistion of the child. 
  78.  
  79.    function Gtk_Aspect_Frame_New 
  80.       (Label      : UTF8_String := ""; 
  81.        Xalign     : Gfloat; 
  82.        Yalign     : Gfloat; 
  83.        Ratio      : Gfloat; 
  84.        Obey_Child : Boolean) return Gtk_Aspect_Frame; 
  85.    --  Create a new Gtk.Aspect_Frame.Gtk_Aspect_Frame. 
  86.    --  "label": Label text. 
  87.    --  "xalign": Horizontal alignment of the child within the allocation of 
  88.    --  the Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left 
  89.    --  aligned) to 1.0 (right aligned) 
  90.    --  "yalign": Vertical alignment of the child within the allocation of the 
  91.    --  Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (top aligned) to 
  92.    --  1.0 (bottom aligned) 
  93.    --  "ratio": The desired aspect ratio. 
  94.    --  "obey_child": If True, Ratio is ignored, and the aspect ratio is taken 
  95.    --  from the requistion of the child. 
  96.  
  97.    function Get_Type return Glib.GType; 
  98.    pragma Import (C, Get_Type, "gtk_aspect_frame_get_type"); 
  99.  
  100.    ------------- 
  101.    -- Methods -- 
  102.    ------------- 
  103.  
  104.    procedure Set 
  105.       (Aspect_Frame : not null access Gtk_Aspect_Frame_Record; 
  106.        Xalign       : Gfloat; 
  107.        Yalign       : Gfloat; 
  108.        Ratio        : Gfloat; 
  109.        Obey_Child   : Boolean); 
  110.    --  Set parameters for an existing Gtk.Aspect_Frame.Gtk_Aspect_Frame. 
  111.    --  "xalign": Horizontal alignment of the child within the allocation of 
  112.    --  the Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (left 
  113.    --  aligned) to 1.0 (right aligned) 
  114.    --  "yalign": Vertical alignment of the child within the allocation of the 
  115.    --  Gtk.Aspect_Frame.Gtk_Aspect_Frame. This ranges from 0.0 (top aligned) to 
  116.    --  1.0 (bottom aligned) 
  117.    --  "ratio": The desired aspect ratio. 
  118.    --  "obey_child": If True, Ratio is ignored, and the aspect ratio is taken 
  119.    --  from the requistion of the child. 
  120.  
  121.    ---------------- 
  122.    -- Properties -- 
  123.    ---------------- 
  124.    --  The following properties are defined for this widget. See 
  125.    --  Glib.Properties for more information on properties) 
  126.  
  127.    Obey_Child_Property : constant Glib.Properties.Property_Boolean; 
  128.  
  129.    Ratio_Property : constant Glib.Properties.Property_Float; 
  130.  
  131.    Xalign_Property : constant Glib.Properties.Property_Float; 
  132.  
  133.    Yalign_Property : constant Glib.Properties.Property_Float; 
  134.  
  135.    ---------------- 
  136.    -- Interfaces -- 
  137.    ---------------- 
  138.    --  This class implements several interfaces. See Glib.Types 
  139.    -- 
  140.    --  - "Buildable" 
  141.  
  142.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  143.      (Gtk.Buildable.Gtk_Buildable, Gtk_Aspect_Frame_Record, Gtk_Aspect_Frame); 
  144.    function "+" 
  145.      (Widget : access Gtk_Aspect_Frame_Record'Class) 
  146.    return Gtk.Buildable.Gtk_Buildable 
  147.    renames Implements_Gtk_Buildable.To_Interface; 
  148.    function "-" 
  149.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  150.    return Gtk_Aspect_Frame 
  151.    renames Implements_Gtk_Buildable.To_Object; 
  152.  
  153. private 
  154.    Yalign_Property : constant Glib.Properties.Property_Float := 
  155.      Glib.Properties.Build ("yalign"); 
  156.    Xalign_Property : constant Glib.Properties.Property_Float := 
  157.      Glib.Properties.Build ("xalign"); 
  158.    Ratio_Property : constant Glib.Properties.Property_Float := 
  159.      Glib.Properties.Build ("ratio"); 
  160.    Obey_Child_Property : constant Glib.Properties.Property_Boolean := 
  161.      Glib.Properties.Build ("obey-child"); 
  162. end Gtk.Aspect_Frame;