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 frame widget is a Bin that surrounds its child with a decorative frame 
  26. --  and an optional label. If present, the label is drawn in a gap in the top 
  27. --  side of the frame. The position of the label can be controlled with 
  28. --  Gtk.Frame.Set_Label_Align. 
  29. -- 
  30. --  == GtkFrame as GtkBuildable == 
  31. -- 
  32. --  The GtkFrame implementation of the GtkBuildable interface supports placing 
  33. --  a child in the label position by specifying "label" as the "type" attribute 
  34. --  of a <child> element. A normal content child can be specified without 
  35. --  specifying a <child> type attribute. 
  36. -- 
  37. --  == A UI definition fragment with GtkFrame == 
  38. -- 
  39. --    <object class="GtkFrame"> 
  40. --    <child type="label"> 
  41. --    <object class="GtkLabel" id="frame-label"/> 
  42. --    </child> 
  43. --    <child> 
  44. --    <object class="GtkEntry" id="frame-content"/> 
  45. --    </child> 
  46. --    </object> 
  47. --  </description> 
  48. --  <description> 
  49. --  This is a very convenient widget to visually group related widgets (like 
  50. --  groups of buttons for instance), possibly with a title to explain the 
  51. --  purpose of this group. 
  52. -- 
  53. --  A Gtk_Frame has only one child, so you have to put a container like for 
  54. --  instance a Gtk_Box inside if you want the frame to surround multiple 
  55. --  widgets. 
  56. -- 
  57. --  </description> 
  58. --  <screenshot>gtk-frame</screenshot> 
  59. --  <group>Ornaments</group> 
  60. --  <testgtk>create_frame.adb</testgtk> 
  61. pragma Ada_2005; 
  62.  
  63. pragma Warnings (Off, "*is already use-visible*"); 
  64. with Glib;            use Glib; 
  65. with Glib.Properties; use Glib.Properties; 
  66. with Glib.Types;      use Glib.Types; 
  67. with Gtk.Bin;         use Gtk.Bin; 
  68. with Gtk.Buildable;   use Gtk.Buildable; 
  69. with Gtk.Enums;       use Gtk.Enums; 
  70. with Gtk.Widget;      use Gtk.Widget; 
  71.  
  72. package Gtk.Frame is 
  73.  
  74.    type Gtk_Frame_Record is new Gtk_Bin_Record with null record; 
  75.    type Gtk_Frame is access all Gtk_Frame_Record'Class; 
  76.  
  77.    ------------------ 
  78.    -- Constructors -- 
  79.    ------------------ 
  80.  
  81.    procedure Gtk_New (Frame : out Gtk_Frame; Label : UTF8_String := ""); 
  82.    procedure Initialize 
  83.       (Frame : not null access Gtk_Frame_Record'Class; 
  84.        Label : UTF8_String := ""); 
  85.    --  Creates a new Gtk.Frame.Gtk_Frame, with optional label Label. If Label 
  86.    --  is null, the label is omitted. 
  87.    --  "label": the text to use as the label of the frame 
  88.  
  89.    function Gtk_Frame_New (Label : UTF8_String := "") return Gtk_Frame; 
  90.    --  Creates a new Gtk.Frame.Gtk_Frame, with optional label Label. If Label 
  91.    --  is null, the label is omitted. 
  92.    --  "label": the text to use as the label of the frame 
  93.  
  94.    function Get_Type return Glib.GType; 
  95.    pragma Import (C, Get_Type, "gtk_frame_get_type"); 
  96.  
  97.    ------------- 
  98.    -- Methods -- 
  99.    ------------- 
  100.  
  101.    function Get_Label 
  102.       (Frame : not null access Gtk_Frame_Record) return UTF8_String; 
  103.    --  If the frame's label widget is a Gtk.Label.Gtk_Label, returns the text 
  104.    --  in the label widget. (The frame will have a Gtk.Label.Gtk_Label for the 
  105.    --  label widget if a non-null argument was passed to Gtk.Frame.Gtk_New.) 
  106.  
  107.    procedure Set_Label 
  108.       (Frame : not null access Gtk_Frame_Record; 
  109.        Label : UTF8_String := ""); 
  110.    --  Sets the text of the label. If Label is null, the current label is 
  111.    --  removed. 
  112.    --  "label": the text to use as the label of the frame 
  113.  
  114.    procedure Get_Label_Align 
  115.       (Frame  : not null access Gtk_Frame_Record; 
  116.        Xalign : out Gfloat; 
  117.        Yalign : out Gfloat); 
  118.    --  Retrieves the X and Y alignment of the frame's label. See 
  119.    --  Gtk.Frame.Set_Label_Align. 
  120.    --  "xalign": location to store X alignment of frame's label, or null 
  121.    --  "yalign": location to store X alignment of frame's label, or null 
  122.  
  123.    procedure Set_Label_Align 
  124.       (Frame  : not null access Gtk_Frame_Record; 
  125.        Xalign : Gfloat; 
  126.        Yalign : Gfloat); 
  127.    --  Sets the alignment of the frame widget's label. The default values for 
  128.    --  a newly created frame are 0.0 and 0.5. 
  129.    --  "xalign": The position of the label along the top edge of the widget. A 
  130.    --  value of 0.0 represents left alignment; 1.0 represents right alignment. 
  131.    --  "yalign": The y alignment of the label. A value of 0.0 aligns under the 
  132.    --  frame; 1.0 aligns above the frame. If the values are exactly 0.0 or 1.0 
  133.    --  the gap in the frame won't be painted because the label will be 
  134.    --  completely above or below the frame. 
  135.  
  136.    function Get_Label_Widget 
  137.       (Frame : not null access Gtk_Frame_Record) 
  138.        return Gtk.Widget.Gtk_Widget; 
  139.    --  Retrieves the label widget for the frame. See 
  140.    --  Gtk.Frame.Set_Label_Widget. 
  141.  
  142.    procedure Set_Label_Widget 
  143.       (Frame        : not null access Gtk_Frame_Record; 
  144.        Label_Widget : not null access Gtk.Widget.Gtk_Widget_Record'Class); 
  145.    --  Sets the label widget for the frame. This is the widget that will 
  146.    --  appear embedded in the top edge of the frame as a title. 
  147.    --  "label_widget": the new label widget 
  148.  
  149.    function Get_Shadow_Type 
  150.       (Frame : not null access Gtk_Frame_Record) 
  151.        return Gtk.Enums.Gtk_Shadow_Type; 
  152.    --  Retrieves the shadow type of the frame. See Gtk.Frame.Set_Shadow_Type. 
  153.  
  154.    procedure Set_Shadow_Type 
  155.       (Frame    : not null access Gtk_Frame_Record; 
  156.        The_Type : Gtk.Enums.Gtk_Shadow_Type); 
  157.    --  Sets the shadow type for Frame. 
  158.    --  "type": the new Gtk.Enums.Gtk_Shadow_Type 
  159.  
  160.    ---------------- 
  161.    -- Properties -- 
  162.    ---------------- 
  163.    --  The following properties are defined for this widget. See 
  164.    --  Glib.Properties for more information on properties) 
  165.  
  166.    Label_Property : constant Glib.Properties.Property_String; 
  167.  
  168.    Label_Widget_Property : constant Glib.Properties.Property_Object; 
  169.    --  Type: Gtk.Widget.Gtk_Widget 
  170.  
  171.    Label_Xalign_Property : constant Glib.Properties.Property_Float; 
  172.  
  173.    Label_Yalign_Property : constant Glib.Properties.Property_Float; 
  174.  
  175.    Shadow_Type_Property : constant Gtk.Enums.Property_Gtk_Shadow_Type; 
  176.  
  177.    ---------------- 
  178.    -- Interfaces -- 
  179.    ---------------- 
  180.    --  This class implements several interfaces. See Glib.Types 
  181.    -- 
  182.    --  - "Buildable" 
  183.  
  184.    package Implements_Gtk_Buildable is new Glib.Types.Implements 
  185.      (Gtk.Buildable.Gtk_Buildable, Gtk_Frame_Record, Gtk_Frame); 
  186.    function "+" 
  187.      (Widget : access Gtk_Frame_Record'Class) 
  188.    return Gtk.Buildable.Gtk_Buildable 
  189.    renames Implements_Gtk_Buildable.To_Interface; 
  190.    function "-" 
  191.      (Interf : Gtk.Buildable.Gtk_Buildable) 
  192.    return Gtk_Frame 
  193.    renames Implements_Gtk_Buildable.To_Object; 
  194.  
  195. private 
  196.    Shadow_Type_Property : constant Gtk.Enums.Property_Gtk_Shadow_Type := 
  197.      Gtk.Enums.Build ("shadow-type"); 
  198.    Label_Yalign_Property : constant Glib.Properties.Property_Float := 
  199.      Glib.Properties.Build ("label-yalign"); 
  200.    Label_Xalign_Property : constant Glib.Properties.Property_Float := 
  201.      Glib.Properties.Build ("label-xalign"); 
  202.    Label_Widget_Property : constant Glib.Properties.Property_Object := 
  203.      Glib.Properties.Build ("label-widget"); 
  204.    Label_Property : constant Glib.Properties.Property_String := 
  205.      Glib.Properties.Build ("label"); 
  206. end Gtk.Frame;