wxRuby Documentation Home

Wx::RichTextAttr

RichTextAttr represents the character and paragraph attributes, or style,
for a range of text in a RichTextCtrl. This class
is specific to RichTextCtrl, although you can also use the
standard TextAttr class with RichTextCtrl.

When setting up a RichTextAttr object, you can pass a bitlist mask to
set_flags to indicate which style elements
should be changed. As a convenience, when you call a setter such as
set_font, the relevant bit will be set. This
should cover most normal cases.

RichTextAttr stores attributes without a Font object, so is a more
efficient way to query styles than using a TextAttr object.

Derived from

No base class

Constants

The following values can be passed to RichTextAttr::SetAlignment to determine
paragraph alignment.

TEXT_ALIGNMENT_DEFAULT, TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTRE, TEXT_ALIGNMENT_CENTER = TEXT_ALIGNMENT_CENTRE, TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_JUSTIFIED

Of these, TEXT_ALIGNMENT_JUSTIFIED is unimplemented. In future
justification may be supported when printing or previewing, only.

The following values are passed in a bitlist to RichTextAttr::SetFlags
to determine what attributes will be considered when setting the
attributes for a text control.

TEXT_ATTR_TEXT_COLOUR TEXT_ATTR_BACKGROUND_COLOUR TEXT_ATTR_FONT_FACE TEXT_ATTR_FONT_SIZE TEXT_ATTR_FONT_WEIGHT TEXT_ATTR_FONT_ITALIC TEXT_ATTR_FONT_UNDERLINE TEXT_ATTR_FONT # all font attributes: face, size, weight, italic, underline TEXT_ATTR_ALIGNMENT TEXT_ATTR_LEFT_INDENT TEXT_ATTR_RIGHT_INDENT TEXT_ATTR_TABS

Extra formatting flags not in TextAttr

TEXT_ATTR_PARA_SPACING_AFTER TEXT_ATTR_PARA_SPACING_BEFORE TEXT_ATTR_LINE_SPACING TEXT_ATTR_CHARACTER_STYLE_NAME TEXT_ATTR_PARAGRAPH_STYLE_NAME TEXT_ATTR_LIST_STYLE_NAME TEXT_ATTR_BULLET_STYLE TEXT_ATTR_BULLET_NUMBER TEXT_ATTR_BULLET_TEXT TEXT_ATTR_BULLET_NAME TEXT_ATTR_URL TEXT_ATTR_PAGE_BREAK TEXT_ATTR_EFFECTS TEXT_ATTR_OUTLINE_LEVEL

The following styles can be passed to RichTextAttr#set_bullet_style

TEXT_ATTR_BULLET_STYLE_NONE TEXT_ATTR_BULLET_STYLE_ARABIC TEXT_ATTR_BULLET_STYLE_LETTERS_UPPER TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER TEXT_ATTR_BULLET_STYLE_SYMBOL TEXT_ATTR_BULLET_STYLE_BITMAP TEXT_ATTR_BULLET_STYLE_PARENTHESES TEXT_ATTR_BULLET_STYLE_PERIOD TEXT_ATTR_BULLET_STYLE_STANDARD TEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS TEXT_ATTR_BULLET_STYLE_OUTLINE TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE

Of these, TEXT_ATTR_BULLET_STYLE_BITMAP is unimplemented.

The following constants can be passed to RichTextAttr#set_line_spacing

TEXT_ATTR_LINE_SPACING_NORMAL 10 TEXT_ATTR_LINE_SPACING_HALF 15 TEXT_ATTR_LINE_SPACING_TWICE 20

The following styles can be passed to RichTextAttr#set_text_effects

TEXT_ATTR_EFFECT_NONE TEXT_ATTR_EFFECT_CAPITALS TEXT_ATTR_EFFECT_SMALL_CAPITALS TEXT_ATTR_EFFECT_STRIKETHROUGH TEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH TEXT_ATTR_EFFECT_SHADOW TEXT_ATTR_EFFECT_EMBOSS TEXT_ATTR_EFFECT_OUTLINE TEXT_ATTR_EFFECT_ENGRAVE TEXT_ATTR_EFFECT_SUPERSCRIPT TEXT_ATTR_EFFECT_SUBSCRIPT

Of these, only TEXT_ATTR_EFFECT_CAPITALS and TEXT_ATTR_EFFECT_STRIKETHROUGH are implemented.

See also

TextAttr, RichTextCtrl

Methods

RichTextAttr.new

RichTextAttr.new(%(arg-type)Colour% colText, Colour colBack = NULL_COLOUR, TextAttrAlignment alignment = TEXT_ALIGNMENT_DEFAULT)

Constructor.

RichTextAttr#apply

Boolean apply(%(arg-type)RichTextAttr% style, RichTextAttr compareWith = nil)

Applies the attributes in style to the original object, but not those attributes from style that are the same as those in compareWith (if passed).

See also RichTextAttr#combine for a function that does almost the same but returns a new object instead of modifying the original object.

RichTextAttr#combine

RichTextAttr combine(%(arg-type)RichTextAttr% style, RichTextAttr compareWith = nil)

Combines ‘this’ with style, but not applying attributes from style that are the same as those in compareWith (if passed).
A RichTextAttr object is returned and the original object is not changed.

See also RichTextAttr#apply for a function that does almost the same but modifies the original object instead of returning a new one.

RichTextAttr#create_font

Font create_font()

Creates a font from the font attributes.

RichTextAttr#get_alignment

TextAttrAlignment get_alignment()

Returns the alignment flags.
See RichTextAttr#set_alignment for a list of available styles.

RichTextAttr#get_background_colour

Colour get_background_colour()

Returns the background colour.

RichTextAttr#get_bullet_font

String get_bullet_font()

Returns a string containing the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL.

RichTextAttr#get_bullet_name

String get_bullet_name()

Returns the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD.
Currently the following standard bullet names are supported:

If you wish your application to support further bullet graphics, you can derive a
class from RichTextRenderer or RichTextStdRenderer, override DrawStandardBullet and EnumerateStandardBulletNames, and
set an instance of the class using RichTextBuffer#set_renderer.

RichTextAttr#get_bullet_number

Integer get_bullet_number()

Returns the bullet number.

RichTextAttr#get_bullet_style

Integer get_bullet_style()

Returns the bullet style. See
RichTextAttr#set_bullet_style
for a list of available styles.

RichTextAttr#get_bullet_text

String get_bullet_text()

Returns the bullet text, which could be a symbol, or (for example) cached outline text.

RichTextAttr#get_character_style_name

String get_character_style_name()

Returns the name of the character style.

RichTextAttr#get_flags

Integer get_flags()

Returns flags indicating which attributes are applicable.
See RichTextAttr#set_flags for a list of available flags.

RichTextAttr#get_font_attributes

Boolean get_font_attributes(%(arg-type)Font% font)

Sets the font attributes from the given font.

RichTextAttr#get_font_face_name

String get_font_face_name()

Returns the font face name.

RichTextAttr#get_font_size

Integer get_font_size()

Returns the font size in points.

RichTextAttr#get_font_style

Integer get_font_style()

Returns the font style.

RichTextAttr#get_font_underlined

Boolean get_font_underlined()

Returns if the font is underlined.

RichTextAttr#get_font_weight

Integer get_font_weight()

Returns the font weight.

RichTextAttr#get_left_indent

Integer get_left_indent()

Returns the left indent in tenths of a millimetre.

RichTextAttr#get_left_sub_indent

Integer get_left_sub_indent()

Returns the left sub-indent in tenths of a millimetre.

RichTextAttr#get_line_spacing

Integer get_line_spacing()

Returns the line spacing value, one of TEXT_ATTR_LINE_SPACING_NORMAL,
TEXT_ATTR_LINE_SPACING_HALF, and TEXT_ATTR_LINE_SPACING_TWICE.

RichTextAttr#get_list_style_name

String get_list_style_name()

Returns the name of the list style.

RichTextAttr#get_outline_level

Integer get_outline_level()

Returns the outline level.

RichTextAttr#get_paragraph_spacing_after

Integer get_paragraph_spacing_after()

Returns the space in tenths of a millimeter after the paragraph.

RichTextAttr#get_paragraph_spacing_before

Integer get_paragraph_spacing_before()

Returns the space in tenths of a millimeter before the paragraph.

RichTextAttr#get_paragraph_style_name

String get_paragraph_style_name()

Returns the name of the paragraph style.

RichTextAttr#get_right_indent

Integer get_right_indent()

Returns the right indent in tenths of a millimeter.

RichTextAttr#get_tabs

ArrayInt get_tabs()

Returns an array of tab stops, each expressed in tenths of a millimeter. Each stop
is measured from the left margin and therefore each value must be larger than the last.

RichTextAttr#get_text_colour

Colour get_text_colour()

Returns the text foreground colour.

RichTextAttr#get_text_effect_flags

Integer get_text_effect_flags()

Returns the text effect bits of interest. See RichTextAttr#set_flags for further information.

RichTextAttr#get_text_effects

Integer get_text_effects()

Returns the text effects, a bit list of styles. See RichTextAttr#set_text_effects for
details.

RichTextAttr#get_url

String get_url()

Returns the URL for the content. Content with TEXT_ATTR_URL style
causes RichTextCtrl to show a hand cursor over it, and RichTextCtrl generates
a TextUrlEvent when the content is clicked.

RichTextAttr#has_alignment

Boolean has_alignment()

Returns if the attribute object specifies alignment.

RichTextAttr#has_background_colour

Boolean has_background_colour()

Returns if the attribute object specifies a background colour.

RichTextAttr#has_bullet_name

Boolean has_bullet_name()

Returns if the attribute object specifies a standard bullet name.

RichTextAttr#has_bullet_number

Boolean has_bullet_number()

Returns if the attribute object specifies a bullet number.

RichTextAttr#has_bullet_style

Boolean has_bullet_style()

Returns if the attribute object specifies a bullet style.

RichTextAttr#has_bullet_text

Boolean has_bullet_text()

Returns if the attribute object specifies bullet text (usually specifying a symbol).

RichTextAttr#has_character_style_name

Boolean has_character_style_name()

Returns if the attribute object specifies a character style name.

RichTextAttr#has_font_face_name

Boolean has_font_face_name()

Returns if the attribute object specifies a font face name.

RichTextAttr#has_flag

Boolean has_flag(%(arg-type)Integer% flag)

Returns if the flag is present in the attribute object’s flag bitlist.

RichTextAttr#has_font

Boolean has_font()

Returns if the attribute object specifies any font attributes.

RichTextAttr#has_font_italic

Boolean has_font_italic()

Returns if the attribute object specifies italic style.

RichTextAttr#has_left_indent

Boolean has_left_indent()

Returns if the attribute object specifies a left indent.

RichTextAttr#has_line_spacing

Boolean has_line_spacing()

Returns if the attribute object specifies line spacing.

RichTextAttr#has_list_style_name

Boolean has_list_style_name()

Returns if the attribute object specifies a list style name.

RichTextAttr#has_outline_level

Boolean has_outline_level()

Returns if the attribute object specifies an outline level.

RichTextAttr#has_page_break

Boolean has_page_break()

Returns if the attribute object specifies a page break before this paragraph.

RichTextAttr#has_paragraph_spacing_after

Boolean has_paragraph_spacing_after()

Returns if the attribute object specifies spacing after a paragraph.

RichTextAttr#has_paragraph_spacing_before

Boolean has_paragraph_spacing_before()

Returns if the attribute object specifies spacing before a paragraph.

RichTextAttr#has_paragraph_style_name

Boolean has_paragraph_style_name()

Returns if the attribute object specifies a paragraph style name.

RichTextAttr#has_right_indent

Boolean has_right_indent()

Returns if the attribute object specifies a right indent.

RichTextAttr#has_font_size

Boolean has_font_size()

Returns if the attribute object specifies a font point size.

RichTextAttr#has_tabs

Boolean has_tabs()

Returns if the attribute object specifies tab stops.

RichTextAttr#has_text_colour

Boolean has_text_colour()

Returns if the attribute object specifies a text foreground colour.

RichTextAttr#has_text_effects

Boolean has_text_effects()

Returns if the attribute object specifies text effects.

RichTextAttr#has_font_underlined

Boolean has_font_underlined()

Returns if the attribute object specifies either underlining or no underlining.

RichTextAttr#has_url

Boolean has_url()

Returns if the attribute object specifies a URL.

RichTextAttr#has_font_weight

Boolean has_font_weight()

Returns if the attribute object specifies font weight (bold, light or normal).

RichTextAttr#is_character_style

Boolean is_character_style()

Returns if the object represents a character style, that is,
the flags specify a font or a text background or foreground colour.

RichTextAttr#is_default

Boolean is_default()

Returns if we have any attributes set, otherwise.

RichTextAttr#is_paragraph_style

Boolean is_paragraph_style()

Returns if the object represents a paragraph style, that is,
the flags specify alignment, indentation, tabs, paragraph spacing, or
bullet style.

RichTextAttr#set_alignment

set_alignment(%(arg-type)TextAttrAlignment% alignment)

Sets the paragraph alignment. These are the possible values for alignment:

TEXT_ALIGNMENT_DEFAULT, TEXT_ALIGNMENT_LEFT, TEXT_ALIGNMENT_CENTRE, TEXT_ALIGNMENT_CENTER = TEXT_ALIGNMENT_CENTRE, TEXT_ALIGNMENT_RIGHT, TEXT_ALIGNMENT_JUSTIFIED

Of these, TEXT_ALIGNMENT_JUSTIFIED is unimplemented. In future
justification may be supported when printing or previewing, only.

RichTextAttr#set_background_colour

set_background_colour(%(arg-type)Colour% colBack)

Sets the background colour.

RichTextAttr#set_bullet_font

set_bullet_font(%(arg-type)String% font)

Sets the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL.

RichTextAttr#set_bullet_name

set_bullet_name(%(arg-type)String% name)

Sets the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD.
See RichTextAttr#get_bullet_name for a list
of supported names, and how to expand the range of supported types.

RichTextAttr#set_bullet_number

set_bullet_number(%(arg-type)Integer% n)

Sets the bullet number.

RichTextAttr#set_bullet_style

set_bullet_style(%(arg-type)Integer% style)

Sets the bullet style. The following styles can be passed:

TEXT_ATTR_BULLET_STYLE_NONE TEXT_ATTR_BULLET_STYLE_ARABIC TEXT_ATTR_BULLET_STYLE_LETTERS_UPPER TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER TEXT_ATTR_BULLET_STYLE_SYMBOL TEXT_ATTR_BULLET_STYLE_BITMAP TEXT_ATTR_BULLET_STYLE_PARENTHESES TEXT_ATTR_BULLET_STYLE_PERIOD TEXT_ATTR_BULLET_STYLE_STANDARD TEXT_ATTR_BULLET_STYLE_RIGHT_PARENTHESIS TEXT_ATTR_BULLET_STYLE_OUTLINE TEXT_ATTR_BULLET_STYLE_ALIGN_LEFT TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT TEXT_ATTR_BULLET_STYLE_ALIGN_CENTRE

Currently TEXT_ATTR_BULLET_STYLE_BITMAP is not supported.

RichTextAttr#set_bullet_text

set_bullet_text(%(arg-type)String% text)

Sets the bullet text, which could be a symbol, or (for example) cached outline text.

RichTextAttr#set_character_style_name

set_character_style_name(%(arg-type)String% name)

Sets the character style name.

RichTextAttr#set_flags

set_flags(%(arg-type)Integer% flags)

Sets the flags determining which styles are being specified. The following
flags can be passed in a bitlist:

Standard TextAttr constants

TEXT_ATTR_TEXT_COLOUR TEXT_ATTR_BACKGROUND_COLOUR TEXT_ATTR_FONT_FACE TEXT_ATTR_FONT_SIZE TEXT_ATTR_FONT_WEIGHT TEXT_ATTR_FONT_ITALIC TEXT_ATTR_FONT_UNDERLINE TEXT_ATTR_FONT TEXT_ATTR_ALIGNMENT TEXT_ATTR_LEFT_INDENT TEXT_ATTR_RIGHT_INDENT TEXT_ATTR_TABS

Extra formatting flags not in TextAttr

TEXT_ATTR_PARA_SPACING_AFTER TEXT_ATTR_PARA_SPACING_BEFORE TEXT_ATTR_LINE_SPACING TEXT_ATTR_CHARACTER_STYLE_NAME TEXT_ATTR_PARAGRAPH_STYLE_NAME TEXT_ATTR_LIST_STYLE_NAME TEXT_ATTR_BULLET_STYLE TEXT_ATTR_BULLET_NUMBER TEXT_ATTR_BULLET_TEXT TEXT_ATTR_BULLET_NAME TEXT_ATTR_URL TEXT_ATTR_PAGE_BREAK TEXT_ATTR_EFFECTS TEXT_ATTR_OUTLINE_LEVEL

RichTextAttr#set_font_face_name

set_font_face_name(%(arg-type)String% faceName)

Sets the paragraph alignment.

RichTextAttr#set_font_size

set_font_size(%(arg-type)Integer% pointSize)

Sets the font size in points.

RichTextAttr#set_font_style

set_font_style(%(arg-type)Integer% fontStyle)

Sets the font style (normal, italic or slanted).

RichTextAttr#set_font_underlined

set_font_underlined(%(arg-type)Boolean% underlined)

Sets the font underlining.

RichTextAttr#set_font_weight

set_font_weight(%(arg-type)Integer% fontWeight)

Sets the font weight.

RichTextAttr#set_left_indent

set_left_indent(%(arg-type)Integer% indent, Integer subIndent = 0)

Sets the left indent and left subindent in tenths of a millimetre.

The sub-indent is an offset from the left of the paragraph, and is used
for all but the first line in a paragraph. A positive value will cause
the first line to appear to the left of the subsequent lines, and a
negative value will cause the first line to be indented relative to the
subsequent lines.

RichTextBuffer uses indentation to render a bulleted item. The left
indent is the distance between the margin and the bullet. The content of
the paragraph, including the first line, starts at leftMargin +
leftSubIndent. So the distance between the left edge of the bullet and
the left of the actual paragraph is leftSubIndent.

RichTextAttr#set_line_spacing

set_line_spacing(%(arg-type)Integer% spacing)

Sets the line spacing. spacing is a multiple, where 10 means single-spacing,
15 means 1.5 spacing, and 20 means double spacing. The following constants are
defined for convenience:

TEXT_ATTR_LINE_SPACING_NORMAL 10 TEXT_ATTR_LINE_SPACING_HALF 15 TEXT_ATTR_LINE_SPACING_TWICE 20

RichTextAttr#set_list_style_name

set_list_style_name(%(arg-type)String% name)

Sets the list style name.

RichTextAttr#set_outline_level

set_outline_level(%(arg-type)Integer% level)

Specifies the outline level. Zero represents normal text. At present, the outline level is
not used, but may be used in future for determining list levels and for applications
that need to store document structure information.

RichTextAttr#set_page_break

set_page_break(%(arg-type)Boolean% pageBreak = true)

Specifies a page break before this paragraph.

RichTextAttr#set_paragraph_spacing_after

set_paragraph_spacing_after(%(arg-type)Integer% spacing)

Sets the spacing after a paragraph, in tenths of a millimetre.

RichTextAttr#set_paragraph_spacing_before

set_paragraph_spacing_before(%(arg-type)Integer% spacing)

Sets the spacing before a paragraph, in tenths of a millimetre.

RichTextAttr#set_paragraph_style_name

set_paragraph_style_name(%(arg-type)String% name)

Sets the name of the paragraph style.

RichTextAttr#set_right_indent

set_right_indent(%(arg-type)Integer% indent)

Sets the right indent in tenths of a millimetre.

RichTextAttr#set_tabs

set_tabs( ArrayInt tabs)

Sets the tab stops, expressed in tenths of a millimetre. Each stop is
measured from the left margin and therefore each value must be larger
than the last.

RichTextAttr#set_text_colour

set_text_colour(%(arg-type)Colour% colText)

Sets the text foreground colout.

RichTextAttr#set_text_effect_flags

set_text_effect_flags(%(arg-type)Integer% flags)

Sets the text effect bits of interest. You should also pass TEXT_ATTR_EFFECTS to RichTextAttr#set_flags.
See RichTextAttr#set_flags for further information.

RichTextAttr#set_text_effects

set_text_effects(%(arg-type)Integer% effects)

Sets the text effects, a bit list of styles.

The following styles can be passed:

TEXT_ATTR_EFFECT_NONE TEXT_ATTR_EFFECT_CAPITALS TEXT_ATTR_EFFECT_SMALL_CAPITALS TEXT_ATTR_EFFECT_STRIKETHROUGH TEXT_ATTR_EFFECT_DOUBLE_STRIKETHROUGH TEXT_ATTR_EFFECT_SHADOW TEXT_ATTR_EFFECT_EMBOSS TEXT_ATTR_EFFECT_OUTLINE TEXT_ATTR_EFFECT_ENGRAVE TEXT_ATTR_EFFECT_SUPERSCRIPT TEXT_ATTR_EFFECT_SUBSCRIPT

Of these, only TEXT_ATTR_EFFECT_CAPITALS and
TEXT_ATTR_EFFECT_STRIKETHROUGH are implemented.
TEXT_ATTR_EFFECT_CAPITALS capitalises text when displayed (leaving the
case of the actual buffer text unchanged), and
TEXT_ATTR_EFFECT_STRIKETHROUGH draws a line through text.

To set effects, you should also pass TEXT_ATTR_EFFECTS to RichTextAttr#set_flags, and call RichTextAttr#set_text_effect_flags with the styles (taken from the
above set) that you are interested in setting.

RichTextAttr#set_url

set_url(%(arg-type)String% url)

Sets the URL for the content. Sets the TEXT_ATTR_URL style; content with
this style causes RichTextCtrl to show a hand cursor over it, and
RichTextCtrl generates a TextUrlEvent when the content is clicked.

[This page automatically generated from the Textile source at 2023-06-09 00:45:30 +0000]