Description
This package provides a high-level object that is capable of arranging text
in a visually correct manner. It supports international character sets,
although all strings should be Utf8, supports left-to-right and
right-to-left writing systems, is capable of handling multi-line texts, and
properly aligns tab characters in the text.
This is the base type that is used in the standard gtk+ widget for all the
widgets that display some text on the screen.
Since it works directly with Pango.Font.Pango_Font_Description fonts, it is
also much better at handling resizing of text, wrapping,... than direct
calls to Gdk.Drawable.Draw_Text.
The idea is that this widget is used to compute the layout of the
characters (ie their screen position). It doesn't do any rendering,
however, and should be used in conjonction with Gdk.Drawable.Draw_Layout to
actually display something on the screen.
This widget is independent from any specific drawing systems, and might for
instance be used to create postscript documents, for direct access to the
win32 API,...
This widget represents one of the fundamental additions to gtk+ 2.0 over
what previously existed in the gtk+ 1.x series. It obsoletes the package
Gdk.Font, which should only be used for legacy applications.
Types
-
type Pango_Alignment is
(Pango_Align_Left,
Pango_Align_Center,
Pango_Align_Right);
-
type Pango_Ellipsize_Mode is
(Ellipsize_None,
Ellipsize_Start,
Ellipsize_Middle,
Ellipsize_End);
-
type Pango_Layout is access all Pango_Layout_Record'Class;
-
-
-
type Pango_Wrap_Mode is
(Pango_Wrap_Word,
Pango_Wrap_Char);
-
type that is used in the standard gtk+ widget for all the
-- widgets that display some text on the screen.
--
-- Since it works directly with Pango.Font.Pango_Font_Description fonts, it is
-- also much better at handling resizing of text, wrapping,... than direct
-- calls to Gdk.Drawable.Draw_Text.
--
-- The idea is that this widget is used to compute the layout of the
-- characters (ie their screen position). It doesn't do any rendering,
-- however, and should be used in conjonction with Gdk.Drawable.Draw_Layout to
-- actually display something on the screen.
--
-- This widget is independent from any specific drawing systems, and might for
-- instance be used to create postscript documents, for direct access to the
-- win32 API,...
--
-- This widget represents one of the fundamental additions to gtk+ 2.0 over
-- what previously existed in the gtk+ 1.x series. It obsoletes the package
-- Gdk.Font, which should only be used for legacy applications.
--
-- </description>
-- <group>Pango, font handling</group>
with Glib;
Subprograms
Creating a layout
A layout can be created in two ways: either from a widget
(
Gtk.Widget.Create_Pango_Layout), from which it will inherit the font
and various other attributes, or directly from a Pango_Context.
-
procedure Gdk_New
(Layout : out Pango_Layout;
Context : access Pango.Context.Pango_Context_Record'Class);
Contexts
-
function Get_Context (Layout : access Pango_Layout_Record)
return Pango.Context.Pango_Context;
-
-
procedure Context_Changed (Layout : access Pango_Layout_Record);
Lines
-
function Get_Line
(Layout : access Pango_Layout_Record;
Line : Natural) return Pango_Layout_Line;
-
procedure Line_Ref (Line : Pango_Layout_Line);
-
procedure Line_Unref (Line : Pango_Layout_Line);
-
function Line_Index_To_X
(Line : Pango_Layout_Line;
Index : Integer;
Trailing : Integer) return Glib.Gint;
Getting the size
Pango internally stores its sizes in pango units, which are a number of
pixels (device units, when not drawing on the screen) multiplied by
Pango_Scale. There are generally equivalent subprograms to get the sizes
directly in pixels.
-
procedure Get_Extents
(Layout : access Pango_Layout_Record;
Ink_Rect : out Gdk.Rectangle.Gdk_Rectangle;
Logical_Rect : out Gdk.Rectangle.Gdk_Rectangle);
-
procedure Get_Size
(Layout : access Pango_Layout_Record;
Width : out Glib.Gint;
Height : out Glib.Gint);
-
procedure Get_Pixel_Extents
(Layout : access Pango_Layout_Record;
Ink_Rect : out Gdk.Rectangle.Gdk_Rectangle;
Logical_Rect : out Gdk.Rectangle.Gdk_Rectangle);
-
procedure Get_Pixel_Size
(Layout : access Pango_Layout_Record;
Width : out Glib.Gint;
Height : out Glib.Gint);
-
procedure XY_To_Index
(Layout : access Pango_Layout_Record;
X_Pango, Y_Pango : Glib.Gint;
Byte_Index : out Integer;
Trailing : out Integer;
Exact : out Boolean);
Manipulating the text
When initially created with
Gtk.Widget.Create_Pango_Layout, the layout
contains some text. Of course, this text may also be changed later in
the life of the layout.
-
procedure Set_Text (Layout : access Pango_Layout_Record; Text : String);
-
function Get_Text (Layout : access Pango_Layout_Record) return String;
-
-
function Get_Line_Count (Layout : access Pango_Layout_Record)
return Glib.Gint;
-
procedure Set_Markup
(Layout :
access Pango_Layout_Record;
Markup :
Glib.UTF8_String);
Layouting the text
-
procedure Set_Justify
(Layout : access Pango_Layout_Record; Justify : Boolean);
-
function Get_Justify (Layout : access Pango_Layout_Record) return Boolean;
-
procedure Set_Alignment
(Layout : access Pango_Layout_Record'Class;
Alignment : Pango_Alignment);
-
function Get_Alignment (Layout : access Pango_Layout_Record)
return Pango_Alignment;
-
procedure Set_Width
(Layout : access Pango_Layout_Record; Width : Glib.Gint);
-
function Get_Width (Layout : access Pango_Layout_Record) return Glib.Gint;
-
procedure Set_Wrap
(Layout : access Pango_Layout_Record; Mode : Pango_Wrap_Mode);
-
function Get_Wrap (Layout : access Pango_Layout_Record)
return Pango_Wrap_Mode;
-
procedure Set_Tabs
(Layout : access Pango_Layout_Record;
Tabs : Pango.Tabs.Pango_Tab_Array);
-
function Get_Tabs
(Layout : access Pango_Layout_Record) return Pango.Tabs.Pango_Tab_Array;
Attributes
-
-