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_Layout_Line is new Glib.C_Proxy; | |
| |
type Pango_Wrap_Mode is (Pango_Wrap_Word, Pango_Wrap_Char); | |
|
Subprograms |
---|
Creating a layout | ||
A layout can be created in two ways: either from a widget | ||
procedure Gdk_New (Layout : out Pango_Layout; Context : access Pango.Context.Pango_Context_Record'Class); | ||
Create a new layout, based on context.
| ||
Contexts | ||
function Get_Context (Layout : access Pango_Layout_Record) return Pango.Context.Pango_Context; | ||
Return the context of the layout. The returned value is the internal | ||
procedure Set_Font_Description (Layout : access Pango_Layout_Record; Font : Pango.Font.Pango_Font_Description); | ||
Change the font used in the layout. | ||
procedure Context_Changed (Layout : access Pango_Layout_Record); | ||
Forces recomputation of any state in Layout that might depend | ||
Lines | ||
function Get_Line (Layout : access Pango_Layout_Record; Line : Natural) return Pango_Layout_Line; | ||
Retrieve a particular line from Layout. | ||
procedure Line_Ref (Line : Pango_Layout_Line); | ||
Increase the reference count of Line by 1.
| ||
procedure Line_Unref (Line : Pango_Layout_Line); | ||
Decrease the reference count of Line by 1. If the result is 0, the line | ||
function Line_Index_To_X (Line : Pango_Layout_Line; Index : Integer; Trailing : Integer) return Glib.Gint; | ||
Convert an index within a line to an X position. | ||
Getting the size | ||
Pango internally stores its sizes in pango units, which are a number of | ||
procedure Get_Extents (Layout : access Pango_Layout_Record; Ink_Rect : out Gdk.Rectangle.Gdk_Rectangle; Logical_Rect : out Gdk.Rectangle.Gdk_Rectangle); | ||
Compute the logical and ink extents of Layout. Logical extents | ||
procedure Get_Size (Layout : access Pango_Layout_Record; Width : out Glib.Gint; Height : out Glib.Gint); | ||
Return the logical size, in pango units, of the layout. This is a | ||
procedure Get_Pixel_Extents (Layout : access Pango_Layout_Record; Ink_Rect : out Gdk.Rectangle.Gdk_Rectangle; Logical_Rect : out Gdk.Rectangle.Gdk_Rectangle); | ||
Same as Get_Extents, but the returned values are in pixels (or device | ||
procedure Get_Pixel_Size (Layout : access Pango_Layout_Record; Width : out Glib.Gint; Height : out Glib.Gint); | ||
Same as Get_Size, but the returned values are in pixels.
| ||
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); | ||
Convert from X and Y positions within a layout to the byte index of the | ||
Manipulating the text | ||
When initially created with Gtk.Widget.Create_Pango_Layout, the layout | ||
procedure Set_Text (Layout : access Pango_Layout_Record; Text : String); | ||
Change the text that the layout displays | ||
function Get_Text (Layout : access Pango_Layout_Record) return String; | ||
Return the text currently displayed in the layout. | ||
function Get_Text (Layout : access Pango_Layout_Record) return Gtkada.Types.Chars_Ptr; | ||
Same a Get_Text, but return directly the C string, which is more | ||
function Get_Line_Count (Layout : access Pango_Layout_Record) return Glib.Gint; | ||
Return the number of lines in Layout
| ||
procedure Set_Markup (Layout : access Pango_Layout_Record; Markup : Glib.UTF8_String); | ||
Change the text that layout displays. | ||
Layouting the text | ||
procedure Set_Justify (Layout : access Pango_Layout_Record; Justify : Boolean); | ||
Set whether or not each complete line should be stretched to fill the | ||
function Get_Justify (Layout : access Pango_Layout_Record) return Boolean; | ||
Return True if each complete line should be stretched to fill the entire | ||
procedure Set_Alignment (Layout : access Pango_Layout_Record'Class; Alignment : Pango_Alignment); | ||
Set the alignment for the layout (how partial lines are positioned | ||
function Get_Alignment (Layout : access Pango_Layout_Record) return Pango_Alignment; | ||
Return the alignment for the layout.
| ||
procedure Set_Width (Layout : access Pango_Layout_Record; Width : Glib.Gint); | ||
Set the width to which the lines of Layout should be wrapped. No | ||
function Get_Width (Layout : access Pango_Layout_Record) return Glib.Gint; | ||
Return the wrapping width of Layout
| ||
procedure Set_Wrap (Layout : access Pango_Layout_Record; Mode : Pango_Wrap_Mode); | ||
Sets the wrap style; the wrap style only has an effect if a width is set | ||
function Get_Wrap (Layout : access Pango_Layout_Record) return Pango_Wrap_Mode; | ||
Return the current wrap style
| ||
Attributes | ||
procedure Set_Attributes (Layout : access Pango_Layout_Record; Attributes : Pango.Attributes.Pango_Attr_List); | ||
Set the text attributes for a layout object. | ||
function Get_Attributes (Layout : access Pango_Layout_Record) return Pango.Attributes.Pango_Attr_List; | ||
Get the text attributes from a layout object
|