Description
A
Gtk_Label is a light widget associated with some text you want
to display on the screen. You can change the text dynamically if
needed.
The text can be on multiple lines if you separate each line with
the ASCII.LF character. However, this is not the recommended way
to display long texts (see the Gtk_Text widget instead).
Mnemonics
=========
Labels may contain mnemonics. Mnemonics are underlined characters in the
label, used for keyboard navigation. Mnemonics are created by providing
string with an underscore before the mnemonic character, such as "_File",
to the functions gtk_new_with_mnemonic or set_text_with_mnemonic().
Mnemonics automatically activate any activatable widget the label is
inside, such as a Gtk_Button; if the label is not inside the mnemonic's
target widget, you have to tell the label about the target using
set_mnemonic_widget(). For instance:
declare
Button : Gtk_Button;
Label : Gtk_Label;
begin
Gtk_New (Button);
Gtk_New_With_Mnemonic (Label, "_File");
Add (Button, Label);
end;
However, there exists a convenience function in Gtk.Button to create such
a button already.
Markup
======
To make it easy to format text in a label (changing colors, fonts, etc.),
label text can be provided in a simple markup format. Here's how to create
a label with a small font:
Gtk_New (Label, "hello");
The markup must be valid, and <>& characters must be escaped with
< > and &
Markup strings are just a convenient way to set the Pango_Attr_List on
label; Set_Attributes() may be a simpler way to set attributes in some
cases. Be careful though; Pango_Attr_List tends to cause
internationalization problems, unless you're applying attributes to the
entire string (i.e. unless you set the range of each attribute to [0,
G_MAXINT)). The reason is that specifying the start_index and end_index for
a Pango_Attribute requires knowledge of the exact string being displayed,
so translations will cause problems.
Selectable labels
=================
Labels can be made selectable with Set_Selectable. Selectable
labels allow the user to copy the label contents to the clipboard. Only
should be made selectable.
Subprograms
-
procedure Gtk_New (Label : out Gtk_Label; Str : UTF8_String := "");
procedure Initialize
(Label : access Gtk_Label_Record'Class; Str : UTF8_String);
-
procedure Gtk_New_With_Mnemonic (Label : out Gtk_Label; Str : UTF8_String);
procedure Initialize_With_Mnemonic
(Label : access Gtk_Label_Record'Class; Str : UTF8_String);
-
-
procedure Set_Justify
(Label : access Gtk_Label_Record;
Jtype : Enums.Gtk_Justification);
function Get_Justify
(Label : access Gtk_Label_Record) return Enums.Gtk_Justification;
-
procedure Set_Line_Wrap (Label : access Gtk_Label_Record; Wrap : Boolean);
function Get_Line_Wrap (Label : access Gtk_Label_Record) return Boolean;
-
procedure Set_Selectable
(Label : access Gtk_Label_Record; Selectable : Boolean);
function Get_Selectable (Label : access Gtk_Label_Record) return Boolean;
-
procedure Set_Use_Markup
(Label : access Gtk_Label_Record; Markup : Boolean);
function Get_Use_Markup (Label : access Gtk_Label_Record) return Boolean;
-
procedure Set_Use_Underline
(Label : access Gtk_Label_Record; Underline : Boolean);
function Get_Use_Underline (Label : access Gtk_Label_Record) return Boolean;
-
procedure Set_Angle (Label : access Gtk_Label_Record; Angle : Gdouble);
function Get_Angle (Label : access Gtk_Label_Record) return Gdouble;
-
-
procedure Set_Text (Label : access Gtk_Label_Record; Str : UTF8_String);
function Get_Text (Label : access Gtk_Label_Record) return UTF8_String;
-
procedure Set_Label (Label : access Gtk_Label_Record; Str : String);
function Get_Label (Label : access Gtk_Label_Record) return String;
-
-
procedure Get_Layout_Offsets
(Label : access Gtk_Label_Record;
X, Y : out Gint);
-
procedure Set_Max_Width_Chars
(Label : access Gtk_Label_Record; N_Chars : Gint);
function Get_Max_Width_Chars (Label : access Gtk_Label_Record) return Gint;
-
procedure Set_Width_Chars (Label : access Gtk_Label_Record; N_Chars : Gint);
function Get_Width_Chars (Label : access Gtk_Label_Record) return Gint;
-
procedure Set_Single_Line_Mode
(Label : access Gtk_Label_Record;
Single_Line_Mode : Boolean);
function Get_Single_Line_Mode
(Label : access Gtk_Label_Record) return Boolean;
-
function Get_Mnemonic_Keyval
(Label : access Gtk_Label_Record) return Gdk.Types.Gdk_Key_Type;
-
-
procedure Set_Text_With_Mnemonic
(Label : access Gtk_Label_Record;
Str : UTF8_String);
-
procedure Set_Markup (Label : access Gtk_Label_Record; Str : UTF8_String);
-
procedure Set_Markup_With_Mnemonic
(Label : access Gtk_Label_Record;
Str : UTF8_String);
-
-
procedure Select_Region
(Label : access Gtk_Label_Record;
Start_Offset : Integer := -1;
End_Offset : Integer := -1);
-
procedure Get_Selection_Bounds
(Label : access Gtk_Label_Record;
First, Last : out Gint;
Has_Selection : out Boolean);
-
procedure Set_Pattern
(Label : access Gtk_Label_Record;
Pattern : String);