Lay out and display documents.
This class is intended for displaying documents that do not change regularly – any change will cost some time to lay out the complete document again and regenerate all vertex lists.
The benefit of this class is that texture state is shared between all layouts of this class. The time to draw one TextLayout may be roughly the same as the time to draw one IncrementalTextLayout; but drawing ten TextLayout objects in one batch is much faster than drawing ten incremental or scrollable text layouts.
Label and HTMLLabel provide a convenient interface to this class.
Variables: |
|
---|
Constructor:
Create a text layout.
Parameters: |
|
---|
Methods:
begin_update() Indicate that a number of changes to the layout or document are about to occur. delete() Remove this layout from its batch. draw() Draw this text layout. end_update() Perform pending layout changes since begin_update. on_delete_text(start, end) Event handler for AbstractDocument.on_delete_text. on_insert_text(start, text) Event handler for AbstractDocument.on_insert_text. on_style_text(start, end, attributes) Event handler for AbstractDocument.on_style_text.
Attributes:
anchor_x Horizontal anchor alignment. anchor_y Vertical anchor alignment. background_group A group with partial order. content_valign Vertical alignment of content within larger layout box. document dpi Get DPI used by this layout. foreground_decoration_group Rendering group for decorative elements (e.g., glyph underlines) in all text layouts. foreground_group Rendering group for foreground elements (glyphs) in all text layouts. height Height of the layout. multiline Set if multiline layout is enabled. top_group Type: TextLayoutGroup width Width of the layout. x X coordinate of the layout. y Y coordinate of the layout.
Indicate that a number of changes to the layout or document are about to occur.
Changes to the layout or document between calls to begin_update and end_update do not trigger any costly relayout of text. Relayout of all changes is performed when end_update is called.
Note that between the begin_update and end_update calls, values such as content_width and content_height are undefined (i.e., they may or may not be updated to reflect the latest changes).
Remove this layout from its batch.
Draw this text layout.
Note that this method performs very badly if a batch was supplied to the constructor. If you add this layout to a batch, you should ideally use only the batch’s draw method.
Perform pending layout changes since begin_update.
See begin_update.
Event handler for AbstractDocument.on_delete_text.
The event handler is bound by the text layout; there is no need for applications to interact with this method.
Event handler for AbstractDocument.on_insert_text.
The event handler is bound by the text layout; there is no need for applications to interact with this method.
Event handler for AbstractDocument.on_style_text.
The event handler is bound by the text layout; there is no need for applications to interact with this method.
Horizontal anchor alignment.
This property determines the meaning of the x coordinate. It is one of the enumerants:
For the purposes of calculating the position resulting from this alignment, the width of the layout is taken to be width if multiline is True and wrap_lines is True, otherwise content_width.
Type: | str |
---|
Vertical anchor alignment.
This property determines the meaning of the y coordinate. It is one of the enumerants:
For the purposes of calculating the position resulting from this alignment, the height of the layout is taken to be the smaller of height and content_height.
See also content_valign.
Type: | str |
---|
Vertical alignment of content within larger layout box.
This property determines how content is positioned within the layout box when content_height is less than height. It is one of the enumerants:
This property has no effect when content_height is greater than height (in which case the content is aligned to the top) or when height is None (in which case there is no vertical layout box dimension).
Type: | str |
---|
Get DPI used by this layout.
Read-only.
Type: | float |
---|
Height of the layout.
Type: | int |
---|
Set if multiline layout is enabled.
If multiline is False, newline and paragraph characters are ignored and text is not word-wrapped. If True, the text is word-wrapped only if the wrap_lines is True.
Type: | bool |
---|
Width of the layout.
This property has no effect if multiline is False or wrap_lines is False.
Type: | int |
---|
X coordinate of the layout.
See also anchor_x.
Type: | int |
---|
Y coordinate of the layout.
See also anchor_y.
Type: | int |
---|