TextAttr represents the character and paragraph attributes, or style, for a range of text in a TextCtrl or RichTextCtrl.
When setting up a TextAttr object, pass a bitlist mask to TextAttr.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.
See also
TextCtrl, RichTextCtrl
__init__ | Constructors. |
Apply | 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). |
EqPartial | Partial equality test. |
GetAlignment | Returns the alignment flags. |
GetBackgroundColour | Returns the background colour. |
GetBulletFont | Returns a string containing the name of the font associated with the bullet symbol. |
GetBulletName | Returns the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD. |
GetBulletNumber | Returns the bullet number. |
GetBulletStyle | Returns the bullet style. |
GetBulletText | Returns the bullet text, which could be a symbol, or (for example) cached outline text. |
GetCharacterStyleName | Returns the name of the character style. |
GetFlags | Returns flags indicating which attributes are applicable. |
GetFont | Creates and returns a font specified by the font attributes in the TextAttr object. |
GetFontAttributes | Gets the font attributes from the given font, using only the attributes specified by flags. |
GetFontEncoding | Returns the font encoding. |
GetFontFaceName | Returns the font face name. |
GetFontFamily | Returns the font family. |
GetFontSize | Returns the font size in points. |
GetFontStyle | Returns the font style. |
GetFontUnderlined | Returns True if the font is underlined. |
GetFontWeight | Returns the font weight. |
GetLeftIndent | Returns the left indent in tenths of a millimetre. |
GetLeftSubIndent | Returns the left sub-indent in tenths of a millimetre. |
GetLineSpacing | Returns the line spacing value, one of TextAttrLineSpacing values. |
GetListStyleName | Returns the name of the list style. |
GetOutlineLevel | Returns the outline level. |
GetParagraphSpacingAfter | Returns the space in tenths of a millimeter after the paragraph. |
GetParagraphSpacingBefore | Returns the space in tenths of a millimeter before the paragraph. |
GetParagraphStyleName | Returns the name of the paragraph style. |
GetRightIndent | Returns the right indent in tenths of a millimeter. |
GetTabs | Returns an array of tab stops, each expressed in tenths of a millimeter. |
GetTextColour | Returns the text foreground colour. |
GetTextEffectFlags | Returns the text effect bits of interest. |
GetTextEffects | Returns the text effects, a bit list of styles. |
GetURL | Returns the URL for the content. |
HasAlignment | Returns True if the attribute object specifies alignment. |
HasBackgroundColour | Returns True if the attribute object specifies a background colour. |
HasBulletName | Returns True if the attribute object specifies a standard bullet name. |
HasBulletNumber | Returns True if the attribute object specifies a bullet number. |
HasBulletStyle | Returns True if the attribute object specifies a bullet style. |
HasBulletText | Returns True if the attribute object specifies bullet text (usually specifying a symbol). |
HasCharacterStyleName | Returns True if the attribute object specifies a character style name. |
HasFlag | Returns True if the flag is present in the attribute object’s flag bitlist. |
HasFont | Returns True if the attribute object specifies any font attributes. |
HasFontEncoding | Returns True if the attribute object specifies an encoding. |
HasFontFaceName | Returns True if the attribute object specifies a font face name. |
HasFontFamily | Returns True if the attribute object specifies a font family. |
HasFontItalic | Returns True if the attribute object specifies italic style. |
HasFontPixelSize | Returns True if the attribute object specifies a font pixel size. |
HasFontPointSize | Returns True if the attribute object specifies a font point size. |
HasFontSize | Returns True if the attribute object specifies a font point or pixel size. |
HasFontUnderlined | Returns True if the attribute object specifies either underlining or no underlining. |
HasFontWeight | Returns True if the attribute object specifies font weight (bold, light or normal). |
HasLeftIndent | Returns True if the attribute object specifies a left indent. |
HasLineSpacing | Returns True if the attribute object specifies line spacing. |
HasListStyleName | Returns True if the attribute object specifies a list style name. |
HasOutlineLevel | Returns True if the attribute object specifies an outline level. |
HasPageBreak | Returns True if the attribute object specifies a page break before this paragraph. |
HasParagraphSpacingAfter | Returns True if the attribute object specifies spacing after a paragraph. |
HasParagraphSpacingBefore | Returns True if the attribute object specifies spacing before a paragraph. |
HasParagraphStyleName | Returns True if the attribute object specifies a paragraph style name. |
HasRightIndent | Returns True if the attribute object specifies a right indent. |
HasTabs | Returns True if the attribute object specifies tab stops. |
HasTextColour | Returns True if the attribute object specifies a text foreground colour. |
HasTextEffects | Returns True if the attribute object specifies text effects. |
HasURL | Returns True if the attribute object specifies a URL. |
IsCharacterStyle | Returns True if the object represents a character style, that is, the flags specify a font or a text background or foreground colour. |
IsDefault | Returns False if we have any attributes set, True otherwise. |
IsParagraphStyle | Returns True if the object represents a paragraph style, that is, the flags specify alignment, indentation, tabs, paragraph spacing, or bullet style. |
Merge | Copies all defined/valid properties from overlay to current object. |
SetAlignment | Sets the paragraph alignment. |
SetBackgroundColour | Sets the background colour. |
SetBulletFont | Sets the name of the font associated with the bullet symbol. |
SetBulletName | Sets the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD. |
SetBulletNumber | Sets the bullet number. |
SetBulletStyle | Sets the bullet style. |
SetBulletText | Sets the bullet text, which could be a symbol, or (for example) cached outline text. |
SetCharacterStyleName | Sets the character style name. |
SetFlags | Sets the flags determining which styles are being specified. |
SetFont | Sets the attributes for the given font. |
SetFontEncoding | Sets the font encoding. |
SetFontFaceName | Sets the font face name. |
SetFontFamily | Sets the font family. |
SetFontPixelSize | Sets the font size in pixels. |
SetFontPointSize | Sets the font size in points. |
SetFontSize | Sets the font size in points. |
SetFontStyle | Sets the font style (normal, italic or slanted). |
SetFontUnderlined | Sets the font underlining. |
SetFontWeight | Sets the font weight. |
SetLeftIndent | Sets the left indent and left subindent in tenths of a millimetre. |
SetLineSpacing | Sets the line spacing. |
SetListStyleName | Sets the list style name. |
SetOutlineLevel | Specifies the outline level. |
SetPageBreak | Specifies a page break before this paragraph. |
SetParagraphSpacingAfter | Sets the spacing after a paragraph, in tenths of a millimetre. |
SetParagraphSpacingBefore | Sets the spacing before a paragraph, in tenths of a millimetre. |
SetParagraphStyleName | Sets the name of the paragraph style. |
SetRightIndent | Sets the right indent in tenths of a millimetre. |
SetTabs | Sets the tab stops, expressed in tenths of a millimetre. |
SetTextColour | Sets the text foreground colour. |
SetTextEffectFlags | Sets the text effect bits of interest. |
SetTextEffects | Sets the text effects, a bit list of styles. |
SetURL | Sets the URL for the content. |
TextAttr represents the character and paragraph attributes, or style, for a range of text in a TextCtrl or RichTextCtrl.
Possible constructors:
TextAttr()
TextAttr(colText, colBack=NullColour, font=NullFont,
alignment=TEXT_ALIGNMENT_DEFAULT)
TextAttr(attr)
Constructors.
Overloaded Implementations:
__init__ (self)
__init__ (self, colText, colBack=NullColour, font=NullFont, alignment=TEXT_ALIGNMENT_DEFAULT)
Parameters: |
|
---|
__init__ (self, attr)
Parameters: | attr (TextAttr) – |
---|
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).
Parameters: | |
---|---|
Return type: | bool |
Partial equality test.
If weakTest is True, attributes of this object do not have to be present if those attributes of attr are present. If weakTest is False, the function will fail if an attribute is present in attr but not in this object.
Parameters: |
|
---|---|
Return type: | bool |
Returns the alignment flags.
See TextAttrAlignment for a list of available styles.
Return type: | TextAttrAlignment |
---|
Returns a string containing the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL.
Return type: | string |
---|
Returns the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD.
Currently the following standard bullet names are supported:
Return type: | string |
---|
Note
For RichTextCtrl users only: if you wish your rich text controls 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.SetRenderer .
Returns the bullet number.
Return type: | int |
---|
Returns the bullet style.
See TextAttrBulletStyle for a list of available styles.
Return type: | int |
---|
Returns the bullet text, which could be a symbol, or (for example) cached outline text.
Return type: | string |
---|
Returns the name of the character style.
Return type: | string |
---|
Returns flags indicating which attributes are applicable.
See SetFlags for a list of available flags.
Return type: | long |
---|
Creates and returns a font specified by the font attributes in the TextAttr object.
Note that TextAttr does not store a Font object, so this is only a temporary font.
For greater efficiency, access the font attributes directly.
Return type: | Font |
---|
Gets the font attributes from the given font, using only the attributes specified by flags.
Parameters: |
|
---|---|
Return type: | bool |
Returns the font encoding.
Return type: | FontEncoding |
---|
Returns the font face name.
Return type: | string |
---|
Returns the font family.
Return type: | FontFamily |
---|
Returns the font size in points.
Return type: | int |
---|
Returns True if the font is underlined.
Return type: | bool |
---|
Returns the font weight.
Return type: | FontWeight |
---|
Returns the left indent in tenths of a millimetre.
Return type: | long |
---|
Returns the left sub-indent in tenths of a millimetre.
Return type: | long |
---|
Returns the line spacing value, one of TextAttrLineSpacing values.
Return type: | int |
---|
Returns the name of the list style.
Return type: | string |
---|
Returns the outline level.
Return type: | int |
---|
Returns the space in tenths of a millimeter after the paragraph.
Return type: | int |
---|
Returns the space in tenths of a millimeter before the paragraph.
Return type: | int |
---|
Returns the name of the paragraph style.
Return type: | string |
---|
Returns the right indent in tenths of a millimeter.
Return type: | long |
---|
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.
Return type: | list of integers |
---|
Returns the text effect bits of interest.
See SetFlags for further information.
Return type: | int |
---|
Returns the text effects, a bit list of styles.
See SetTextEffects for details.
Return type: | int |
---|
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.
Return type: | string |
---|
Returns True if the attribute object specifies alignment.
Return type: | bool |
---|
Returns True if the attribute object specifies a background colour.
Return type: | bool |
---|
Returns True if the attribute object specifies a standard bullet name.
Return type: | bool |
---|
Returns True if the attribute object specifies a bullet number.
Return type: | bool |
---|
Returns True if the attribute object specifies a bullet style.
Return type: | bool |
---|
Returns True if the attribute object specifies bullet text (usually specifying a symbol).
Return type: | bool |
---|
Returns True if the attribute object specifies a character style name.
Return type: | bool |
---|
Returns True if the flag is present in the attribute object’s flag bitlist.
Parameters: | flag (long) – |
---|---|
Return type: | bool |
Returns True if the attribute object specifies any font attributes.
Return type: | bool |
---|
Returns True if the attribute object specifies an encoding.
Return type: | bool |
---|
Returns True if the attribute object specifies a font face name.
Return type: | bool |
---|
Returns True if the attribute object specifies a font family.
Return type: | bool |
---|
Returns True if the attribute object specifies italic style.
Return type: | bool |
---|
Returns True if the attribute object specifies a font pixel size.
Return type: | bool |
---|
Returns True if the attribute object specifies a font point size.
Return type: | bool |
---|
Returns True if the attribute object specifies a font point or pixel size.
Return type: | bool |
---|
Returns True if the attribute object specifies either underlining or no underlining.
Return type: | bool |
---|
Returns True if the attribute object specifies font weight (bold, light or normal).
Return type: | bool |
---|
Returns True if the attribute object specifies a left indent.
Return type: | bool |
---|
Returns True if the attribute object specifies line spacing.
Return type: | bool |
---|
Returns True if the attribute object specifies a list style name.
Return type: | bool |
---|
Returns True if the attribute object specifies an outline level.
Return type: | bool |
---|
Returns True if the attribute object specifies a page break before this paragraph.
Return type: | bool |
---|
Returns True if the attribute object specifies spacing after a paragraph.
Return type: | bool |
---|
Returns True if the attribute object specifies spacing before a paragraph.
Return type: | bool |
---|
Returns True if the attribute object specifies a paragraph style name.
Return type: | bool |
---|
Returns True if the attribute object specifies a right indent.
Return type: | bool |
---|
Returns True if the attribute object specifies tab stops.
Return type: | bool |
---|
Returns True if the attribute object specifies a text foreground colour.
Return type: | bool |
---|
Returns True if the attribute object specifies text effects.
Return type: | bool |
---|
Returns True if the attribute object specifies a URL.
Return type: | bool |
---|
Returns True if the object represents a character style, that is, the flags specify a font or a text background or foreground colour.
Return type: | bool |
---|
Returns False if we have any attributes set, True otherwise.
Return type: | bool |
---|
Returns True if the object represents a paragraph style, that is, the flags specify alignment, indentation, tabs, paragraph spacing, or bullet style.
Return type: | bool |
---|
Overloaded Implementations:
Merge (self, overlay)
Copies all defined/valid properties from overlay to current object.
Parameters: | overlay (TextAttr) – |
---|
Merge (base, overlay)
Creates a new TextAttr which is a merge of base and overlay.
Properties defined in overlay take precedence over those in base. Properties undefined/invalid in both are undefined in the result.
Parameters: | |
---|---|
Return type: |
Sets the paragraph alignment.
See TextAttrAlignment enumeration values.
Of these, TEXT_ALIGNMENT_JUSTIFIED is unimplemented. In future justification may be supported when printing or previewing, only.
Parameters: | alignment (TextAttrAlignment) – |
---|
Sets the name of the font associated with the bullet symbol.
Only valid for attributes with TEXT_ATTR_BULLET_SYMBOL.
Parameters: | font (string) – |
---|
Sets the standard bullet name, applicable if the bullet style is TEXT_ATTR_BULLET_STYLE_STANDARD.
See GetBulletName for a list of supported names, and how to expand the range of supported types.
Parameters: | name (string) – |
---|
Sets the bullet number.
Parameters: | n (int) – |
---|
Sets the bullet style.
The TextAttrBulletStyle enumeration values are all supported, except for TEXT_ATTR_BULLET_STYLE_BITMAP.
Parameters: | style (int) – |
---|
Sets the bullet text, which could be a symbol, or (for example) cached outline text.
Parameters: | text (string) – |
---|
Sets the character style name.
Parameters: | name (string) – |
---|
Sets the flags determining which styles are being specified.
The TextAttrFlags values can be passed in a bitlist.
Parameters: | flags (long) – |
---|
Sets the attributes for the given font.
Note that TextAttr does not store an actual Font object.
Parameters: |
|
---|
Sets the font encoding.
Parameters: | encoding (FontEncoding) – |
---|
Sets the font face name.
Parameters: | faceName (string) – |
---|
Sets the font family.
Parameters: | family (FontFamily) – |
---|
Sets the font size in pixels.
Parameters: | pixelSize (int) – |
---|
Sets the font size in points.
Parameters: | pointSize (int) – |
---|
Sets the font size in points.
Parameters: | pointSize (int) – |
---|
Sets the font style (normal, italic or slanted).
Parameters: | fontStyle (FontStyle) – |
---|
Sets the font underlining.
Parameters: | underlined (bool) – |
---|
Sets the font weight.
Parameters: | fontWeight (FontWeight) – |
---|
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.
Parameters: |
|
---|
Sets the line spacing.
spacing is a multiple, where 10 means single-spacing, 15 means 1.5 spacing, and 20 means float spacing. The TextAttrLineSpacing values are defined for convenience.
Parameters: | spacing (int) – |
---|
Sets the list style name.
Parameters: | name (string) – |
---|
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.
Parameters: | level (int) – |
---|
Specifies a page break before this paragraph.
Parameters: | pageBreak (bool) – |
---|
Sets the spacing after a paragraph, in tenths of a millimetre.
Parameters: | spacing (int) – |
---|
Sets the spacing before a paragraph, in tenths of a millimetre.
Parameters: | spacing (int) – |
---|
Sets the name of the paragraph style.
Parameters: | name (string) – |
---|
Sets the right indent in tenths of a millimetre.
Parameters: | indent (int) – |
---|
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.
Parameters: | tabs (list of integers) – |
---|
Sets the text effect bits of interest.
You should also pass TEXT_ATTR_EFFECTS to SetFlags . See SetFlags for further information.
Parameters: | flags (int) – |
---|
Sets the text effects, a bit list of styles.
The TextAttrEffects enumeration values can be used.
Of these, only TEXT_ATTR_EFFECT_CAPITALS, TEXT_ATTR_EFFECT_STRIKETHROUGH, TEXT_ATTR_EFFECT_SUPERSCRIPT and TEXT_ATTR_EFFECT_SUBSCRIPT 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 SetFlags , and call SetTextEffectFlags with the styles (taken from the above set) that you are interested in setting.
Parameters: | effects (int) – |
---|
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.
Parameters: | url (string) – |
---|
See GetAlignment and SetAlignment
See GetBulletFont and SetBulletFont
See GetBulletName and SetBulletName
See GetBulletNumber and SetBulletNumber
See GetBulletStyle and SetBulletStyle
See GetBulletText and SetBulletText
See GetFontEncoding and SetFontEncoding
See GetFontFaceName and SetFontFaceName
See GetFontFamily and SetFontFamily
See GetFontSize and SetFontSize
See GetFontStyle and SetFontStyle
See GetFontUnderlined and SetFontUnderlined
See GetFontWeight and SetFontWeight
See GetLeftIndent and SetLeftIndent
See GetLeftSubIndent
See GetLineSpacing and SetLineSpacing
See GetListStyleName and SetListStyleName
See GetOutlineLevel and SetOutlineLevel
See GetRightIndent and SetRightIndent
See GetTextColour and SetTextColour
See GetTextEffectFlags and SetTextEffectFlags
See GetTextEffects and SetTextEffects