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