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