TextAttr represents the character and paragraph attributes, or style, for a range of text in a TextCtrl.
When setting up a TextAttr object, pass a bitlist mask to SetFlags to indicate which style elements should be changed. As a convenience, when you call a setter such as SetFont, the relevant bit will be set.
No base class
TextPos is the type containing the index of a position in a text
control. TextCoord contains the index of a column or a row in the
control.
Note that although both of these types should probably have been unsigned, due
to backwards compatibility reasons, are defined as long currently.
Their use (instead of plain long) is still encouraged as it makes the
code more readable.
The following values can be passed to SetAlignment to determine paragraph alignment.
enum TextAttrAlignment
{
TEXT_ALIGNMENT_DEFAULT,
TEXT_ALIGNMENT_LEFT,
TEXT_ALIGNMENT_CENTRE,
TEXT_ALIGNMENT_CENTER = TEXT_ALIGNMENT_CENTRE,
TEXT_ALIGNMENT_RIGHT,
TEXT_ALIGNMENT_JUSTIFIED
};
These values are passed in a bitlist to SetFlags to determine what attributes will be considered when setting the attributes for a text control.
TEXT_ATTR_FONT_FACE | TEXT_ATTR_FONT_SIZE | TEXT_ATTR_FONT_WEIGHT \ | TEXT_ATTR_FONT_ITALIC | TEXT_ATTR_FONT_UNDERLINE #define TEXT_ATTR_ALIGNMENT 0×0080 #define TEXT_ATTR_LEFT_INDENT 0×0100 #define TEXT_ATTR_RIGHT_INDENT 0×0200 #define TEXT_ATTR_TABS 0×0400
The values below are the possible return codes of the hit_test method:
// the point asked is ...
enum TextCtrlHitTestResult
{
TE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented
TE_HT_BEFORE, // either to the left or upper
TE_HT_ON_TEXT, // directly on
TE_HT_BELOW, // below [the last line]
TE_HT_BEYOND // after [the end of line]
};
// ... the character returned
TextAttr.new(Colour colText, Colour colBack = NullColour,
Font font = NullFont,
TextAttrAlignment alignment = TEXT_ALIGNMENT_DEFAULT)
The constructors initialize one or more of the text foreground colour, background colour, font, and alignment. The values not initialized in the constructor can be set later, otherwise TextCtrl#set_style will use the default values for them.
TextAttrAlignment get_alignment()
Returns the paragraph alignment.
Colour get_background_colour()
Return the background colour specified by this attribute.
Font get_font()
Return the text font specified by this attribute.
Integer get_left_indent()
Returns the left indent in tenths of a millimetre.
Integer get_left_sub_indent()
Returns the left sub indent for all lines but the first line in a paragraph in tenths of a millimetre.
Integer get_right_indent()
Returns the right indent in tenths of a millimetre.
ArrayInt get_tabs()
Returns the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.
Colour get_text_colour()
Return the text colour specified by this attribute.
Boolean has_background_colour()
Returns true if this style specifies the background colour to use.
Boolean has_font()
Returns true if this style specifies the font to use.
Boolean has_text_colour()
Returns true if this style specifies the foreground colour to use.
Integer get_flags()
Returns a bitlist indicating which attributes will be set.
Boolean is_default()
Returns true if this style specifies any non-default attributes.
set_alignment(TextAttrAlignment alignment)
Sets the paragraph alignment.
set_background_colour(Colour colour)
Sets the background colour.
set_flags(Integer flags)
Pass a bitlist indicating which attributes will be set.
set_font(Font font)
Sets the text font.
set_left_indent(Integer indent, Integer subIndent = 0)
Sets the left indent in tenths of a millimetre. subIndent sets the indent for all lines but the first line in a paragraph relative to the first line.
set_right_indent(Integer indent)
Sets the right indent in tenths of a millimetre.
set_tabs(ArrayInt tabs)
Sets the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.
set_text_colour(Colour colour)
Sets the text colour.
[This page automatically generated from the Textile source at Thu Aug 28 20:29:21 +0100 2008]