wxRuby Documentation Home

Wx::TextAttr

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.

Derived from

No base class

Typedefs

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.

Constants

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.

#define TEXT_ATTR_TEXT_COLOUR             0x0001
#define TEXT_ATTR_BACKGROUND_COLOUR       0x0002
#define TEXT_ATTR_FONT_FACE               0x0004
#define TEXT_ATTR_FONT_SIZE               0x0008
#define TEXT_ATTR_FONT_WEIGHT             0x0010
#define TEXT_ATTR_FONT_ITALIC             0x0020
#define TEXT_ATTR_FONT_UNDERLINE          0x0040
#define TEXT_ATTR_FONT \
  TEXT_ATTR_FONT_FACE | TEXT_ATTR_FONT_SIZE | TEXT_ATTR_FONT_WEIGHT \
| TEXT_ATTR_FONT_ITALIC | TEXT_ATTR_FONT_UNDERLINE
#define TEXT_ATTR_ALIGNMENT               0x0080
#define TEXT_ATTR_LEFT_INDENT             0x0100
#define TEXT_ATTR_RIGHT_INDENT            0x0200
#define TEXT_ATTR_TABS                    0x0400

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

Methods

TextAttr.new

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.

TextAttr#get_alignment

TextAttrAlignment get_alignment()

Returns the paragraph alignment.

TextAttr#get_background_colour

Colour get_background_colour()

Return the background colour specified by this attribute.

TextAttr#get_font

Font get_font()

Return the text font specified by this attribute.

TextAttr#get_left_indent

Integer get_left_indent()

Returns the left indent in tenths of a millimetre.

TextAttr#get_left_sub_indent

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.

TextAttr#get_right_indent

Integer get_right_indent()

Returns the right indent in tenths of a millimetre.

TextAttr#get_tabs

ArrayInt get_tabs()

Returns the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.

TextAttr#get_text_colour

Colour get_text_colour()

Return the text colour specified by this attribute.

TextAttr#has_background_colour

Boolean has_background_colour()

Returns true if this style specifies the background colour to use.

TextAttr#has_font

Boolean has_font()

Returns true if this style specifies the font to use.

TextAttr#has_text_colour

Boolean has_text_colour()

Returns true if this style specifies the foreground colour to use.

TextAttr#get_flags

Integer get_flags()

Returns a bitlist indicating which attributes will be set.

TextAttr#is_default

Boolean is_default()

Returns true if this style specifies any non-default attributes.

TextAttr#set_alignment

set_alignment(TextAttrAlignment alignment)

Sets the paragraph alignment.

TextAttr#set_background_colour

set_background_colour(Colour colour)

Sets the background colour.

TextAttr#set_flags

set_flags(Integer flags)

Pass a bitlist indicating which attributes will be set.

TextAttr#set_font

set_font(Font font)

Sets the text font.

TextAttr#set_left_indent

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.

TextAttr#set_right_indent

set_right_indent(Integer indent)

Sets the right indent in tenths of a millimetre.

TextAttr#set_tabs

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.

TextAttr#set_text_colour

set_text_colour(Colour colour)

Sets the text colour.

[This page automatically generated from the Textile source at Wed Sep 09 02:21:27 +0100 2009]