wxTextAttr represents the character and paragraph attributes, or style, for a range of text in a wxTextCtrl.
When setting up a wxTextAttr 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
Include files
<wx/textctrl.h>
Typedefs
wxTextPos is the type containing the index of a position in a text control. wxTextCoord 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 wxTextAttrAlignment { wxTEXT_ALIGNMENT_DEFAULT, wxTEXT_ALIGNMENT_LEFT, wxTEXT_ALIGNMENT_CENTRE, wxTEXT_ALIGNMENT_CENTER = wxTEXT_ALIGNMENT_CENTRE, wxTEXT_ALIGNMENT_RIGHT, wxTEXT_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 wxTEXT_ATTR_TEXT_COLOUR 0x0001 #define wxTEXT_ATTR_BACKGROUND_COLOUR 0x0002 #define wxTEXT_ATTR_FONT_FACE 0x0004 #define wxTEXT_ATTR_FONT_SIZE 0x0008 #define wxTEXT_ATTR_FONT_WEIGHT 0x0010 #define wxTEXT_ATTR_FONT_ITALIC 0x0020 #define wxTEXT_ATTR_FONT_UNDERLINE 0x0040 #define wxTEXT_ATTR_FONT \ wxTEXT_ATTR_FONT_FACE | wxTEXT_ATTR_FONT_SIZE | wxTEXT_ATTR_FONT_WEIGHT \ | wxTEXT_ATTR_FONT_ITALIC | wxTEXT_ATTR_FONT_UNDERLINE #define wxTEXT_ATTR_ALIGNMENT 0x0080 #define wxTEXT_ATTR_LEFT_INDENT 0x0100 #define wxTEXT_ATTR_RIGHT_INDENT 0x0200 #define wxTEXT_ATTR_TABS 0x0400
The values below are the possible return codes of the HitTest method:
// the point asked is ... enum wxTextCtrlHitTestResult { wxTE_HT_UNKNOWN = -2, // this means HitTest() is simply not implemented wxTE_HT_BEFORE, // either to the left or upper wxTE_HT_ON_TEXT, // directly on wxTE_HT_BELOW, // below [the last line] wxTE_HT_BEYOND // after [the end of line] }; // ... the character returned
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 wxTextCtrl::SetStyle will use the default values for them.
wxTextAttrAlignment GetAlignment(void) const
Returns the paragraph alignment.
const wxColour& GetBackgroundColour(void) const
Return the background colour specified by this attribute.
const wxFont& GetFont(void) const
Return the text font specified by this attribute.
Returns the left indent in tenths of a millimetre.
int GetLeftSubIndent(void) const
Returns the left sub indent for all lines but the first line in a paragraph in tenths of a millimetre.
int GetRightIndent(void) const
Returns the right indent in tenths of a millimetre.
const wxArrayInt& GetTabs(void) const
Returns the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.
const wxColour& GetTextColour(void) const
Return the text colour specified by this attribute.
bool HasBackgroundColour(void) const
Returns true if this style specifies the background colour to use.
Returns true if this style specifies the font to use.
bool HasTextColour(void) const
Returns true if this style specifies the foreground colour to use.
Returns a bitlist indicating which attributes will be set.
Returns true if this style specifies any non-default attributes.
Sets the paragraph alignment.
Sets the background colour.
Pass a bitlist indicating which attributes will be set.
Sets the text font.
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.
Sets the right indent in tenths of a millimetre.
Sets the array of integers representing the tab stops. Each array element specifies the tab stop in tenths of a millimetre.
Sets the text colour.
ymasuda 平成17年11月19日