KTextEditor
#include <attribute.h>
Public Types | |
enum | ActivationType { ActivateMouseIn = 0, ActivateCaretIn } |
enum | CustomProperties { Outline = QTextFormat::UserProperty, SelectedForeground, SelectedBackground, BackgroundFillWhitespace, AttributeDynamicEffect = 0x10A00, AttributeInternalProperty = 0x10E00, AttributeUserProperty = 0x110000 } |
enum | Effect { EffectNone = 0x0, EffectFadeIn = 0x1, EffectFadeOut = 0x2, EffectPulse = 0x4, EffectCycleGradient = 0x8 } |
typedef KSharedPtr< Attribute > | Ptr |
Public Member Functions | |
Attribute () | |
Attribute (const Attribute &a) | |
virtual | ~Attribute () |
void | changed () const |
Attribute & | operator+= (const Attribute &a) |
Attribute & | operator= (const Attribute &a) |
Custom properties | |
The following functions provide custom properties which can be set for rendering by editor implementations. | |
bool | fontBold () const |
void | setFontBold (bool bold=true) |
QBrush | outline () const |
void | setOutline (const QBrush &brush) |
QBrush | selectedForeground () const |
void | setSelectedForeground (const QBrush &foreground) |
QBrush | selectedBackground () const |
void | setSelectedBackground (const QBrush &brush) |
bool | backgroundFillWhitespace () const |
void | setBackgroundFillWhitespace (bool fillWhitespace) |
void | clear () |
bool | hasAnyProperty () const |
Action association | |
void | associateAction (KAction *action) |
void | dissociateAction (KAction *action) |
const QList< KAction * > & | associatedActions () const |
void | clearAssociatedActions () |
Dynamic highlighting | |
The following functions allow for text to be highlighted dynamically based on several events. | |
Attribute::Ptr | dynamicAttribute (ActivationType type) const |
void | setDynamicAttribute (ActivationType type, Attribute::Ptr attribute) |
Effects | effects () const |
void | setEffects (Effects effects) |
Public Member Functions inherited from QTextCharFormat | |
QTextCharFormat () | |
QString | anchorHref () const |
QString | anchorName () const |
QStringList | anchorNames () const |
QFont | font () const |
QFont::Capitalization | fontCapitalization () const |
QString | fontFamily () const |
bool | fontFixedPitch () const |
QFont::HintingPreference | fontHintingPreference () const |
bool | fontItalic () const |
bool | fontKerning () const |
qreal | fontLetterSpacing () const |
bool | fontOverline () const |
qreal | fontPointSize () const |
bool | fontStrikeOut () const |
QFont::StyleHint | fontStyleHint () const |
QFont::StyleStrategy | fontStyleStrategy () const |
bool | fontUnderline () const |
int | fontWeight () const |
qreal | fontWordSpacing () const |
bool | isAnchor () const |
bool | isValid () const |
void | setAnchor (bool anchor) |
void | setAnchorHref (const QString &value) |
void | setAnchorName (const QString &name) |
void | setAnchorNames (const QStringList &names) |
void | setFont (const QFont &font) |
void | setFontCapitalization (QFont::Capitalization capitalization) |
void | setFontFamily (const QString &family) |
void | setFontFixedPitch (bool fixedPitch) |
void | setFontHintingPreference (QFont::HintingPreference hintingPreference) |
void | setFontItalic (bool italic) |
void | setFontKerning (bool enable) |
void | setFontLetterSpacing (qreal spacing) |
void | setFontOverline (bool overline) |
void | setFontPointSize (qreal size) |
void | setFontStrikeOut (bool strikeOut) |
void | setFontStyleHint (QFont::StyleHint hint, QFont::StyleStrategy strategy) |
void | setFontStyleStrategy (QFont::StyleStrategy strategy) |
void | setFontUnderline (bool underline) |
void | setFontWeight (int weight) |
void | setFontWordSpacing (qreal spacing) |
void | setTextOutline (const QPen &pen) |
void | setToolTip (const QString &text) |
void | setUnderlineColor (const QColor &color) |
void | setUnderlineStyle (UnderlineStyle style) |
void | setVerticalAlignment (VerticalAlignment alignment) |
QPen | textOutline () const |
QString | toolTip () const |
QColor | underlineColor () const |
UnderlineStyle | underlineStyle () const |
VerticalAlignment | verticalAlignment () const |
Public Member Functions inherited from QTextFormat | |
QTextFormat () | |
QTextFormat (int type) | |
QTextFormat (const QTextFormat &other) | |
~QTextFormat () | |
QBrush | background () const |
bool | boolProperty (int propertyId) const |
QBrush | brushProperty (int propertyId) const |
void | clearBackground () |
void | clearForeground () |
void | clearProperty (int propertyId) |
QColor | colorProperty (int propertyId) const |
qreal | doubleProperty (int propertyId) const |
QBrush | foreground () const |
bool | hasProperty (int propertyId) const |
int | intProperty (int propertyId) const |
bool | isBlockFormat () const |
bool | isCharFormat () const |
bool | isFrameFormat () const |
bool | isImageFormat () const |
bool | isListFormat () const |
bool | isTableCellFormat () const |
bool | isTableFormat () const |
bool | isValid () const |
Qt::LayoutDirection | layoutDirection () const |
QTextLength | lengthProperty (int propertyId) const |
QVector< QTextLength > | lengthVectorProperty (int propertyId) const |
void | merge (const QTextFormat &other) |
int | objectIndex () const |
int | objectType () const |
operator QVariant () const | |
bool | operator!= (const QTextFormat &other) const |
QTextFormat & | operator= (const QTextFormat &other) |
bool | operator== (const QTextFormat &other) const |
QPen | penProperty (int propertyId) const |
QMap< int, QVariant > | properties () const |
QVariant | property (int propertyId) const |
int | propertyCount () const |
void | setBackground (const QBrush &brush) |
void | setForeground (const QBrush &brush) |
void | setLayoutDirection (Qt::LayoutDirection direction) |
void | setObjectIndex (int index) |
void | setObjectType (int type) |
void | setProperty (int propertyId, const QVector< QTextLength > &value) |
void | setProperty (int propertyId, const QVariant &value) |
QString | stringProperty (int propertyId) const |
QTextBlockFormat | toBlockFormat () const |
QTextCharFormat | toCharFormat () const |
QTextFrameFormat | toFrameFormat () const |
QTextImageFormat | toImageFormat () const |
QTextListFormat | toListFormat () const |
QTextTableCellFormat | toTableCellFormat () const |
QTextTableFormat | toTableFormat () const |
int | type () const |
Public Member Functions inherited from QSharedData | |
QSharedData () | |
QSharedData (const QSharedData &other) | |
Additional Inherited Members | |
Public Attributes inherited from QTextFormat | |
typedef | PageBreakFlags |
Detailed Description
A class which provides customized text decorations.
The Attribute class extends QTextCharFormat, the class which Qt uses internally to provide formatting information to characters in a text document.
In addition to its inherited properties, it provides support for:
- several customized text formatting properties
- dynamic highlighting of associated ranges of text
- binding of actions with associated ranges of text (note: not currently implemented)
Implementations are not required to support all properties. In particular, several properties are not supported for dynamic highlighting (notably: font() and fontBold()).
Unfortunately, as QTextFormat's setProperty() is not virtual, changes that are made to this attribute cannot automatically be redrawn. Once you have finished changing properties, you should call changed() to force redrawing of affected ranges of text.
- See also
- SmartInterface
Definition at line 60 of file attribute.h.
Member Typedef Documentation
Definition at line 65 of file attribute.h.
Member Enumeration Documentation
Several automatic activation mechanisms exist for associated attributes.
Using this you can conveniently have your ranges highlighted when either the mouse or cursor enter the range.
Enumerator | |
---|---|
ActivateMouseIn |
Activate attribute on mouse in. |
ActivateCaretIn |
Activate attribute on caret in. |
Definition at line 262 of file attribute.h.
Custom property types, which may or may not be supported by implementations.
Enumerator | |
---|---|
Outline |
Draws an outline around the text. |
SelectedForeground |
Changes the brush used to paint the text when it is selected. |
SelectedBackground |
Changes the brush used to paint the background when it is selected. |
BackgroundFillWhitespace |
Determines whether background color is drawn over whitespace. Defaults to true. |
AttributeDynamicEffect |
Defined to allow storage of dynamic effect information. |
AttributeInternalProperty |
Defined for internal usage of KTextEditor implementations. |
AttributeUserProperty |
Defined to allow 3rd party code to create their own custom attributes - you may use values at or above this property. |
Definition at line 95 of file attribute.h.
Dynamic effects for display.
- Todo:
- Pulse and CycleGradient are unclear.
Enumerator | |
---|---|
EffectNone |
No effect. Just display. |
EffectFadeIn |
Fade in and stay there. |
EffectFadeOut |
Fade out to vanish. |
EffectPulse |
Pulse (throb); change weight. |
EffectCycleGradient |
Cycle colors. |
Definition at line 273 of file attribute.h.
Constructor & Destructor Documentation
Attribute::Attribute | ( | ) |
Default constructor.
The resulting Attribute has no properties set to begin with.
Definition at line 37 of file attribute.cpp.
Attribute::Attribute | ( | const Attribute & | a | ) |
Copy constructor.
Definition at line 42 of file attribute.cpp.
|
virtual |
Virtual destructor.
Definition at line 51 of file attribute.cpp.
Member Function Documentation
void KTextEditor::Attribute::associateAction | ( | KAction * | action | ) |
Associate an action with this attribute.
When assigned to a range, this attribute will enable the associated action(s) when the caret enters the range, and disable them on exit. The action is also added to the context menu when the caret is within an associated range.
Returns a list of currently associated KActions.
Definition at line 171 of file attribute.cpp.
bool Attribute::backgroundFillWhitespace | ( | ) | const |
Determine whether background color is drawn over whitespace.
Defaults to true if not set.
- Returns
- whether the background color should be drawn over whitespace
Definition at line 115 of file attribute.cpp.
void KTextEditor::Attribute::changed | ( | ) | const |
Notify the editor implementation that a property of this attribute has been changed.
This is used to re-render any text which has this attribute assigned to it.
void Attribute::clear | ( | ) |
Clear all set properties.
Definition at line 141 of file attribute.cpp.
void Attribute::clearAssociatedActions | ( | ) |
Clears all associations between KActions and this attribute.
Definition at line 161 of file attribute.cpp.
void KTextEditor::Attribute::dissociateAction | ( | KAction * | action | ) |
Attribute::Ptr Attribute::dynamicAttribute | ( | ActivationType | type | ) | const |
Return the attribute to use when the event referred to by type occurs.
- Parameters
-
type the activation type for which to return the Attribute.
- Returns
- the attribute to be used for events specified by type, or null if none is set.
Definition at line 73 of file attribute.cpp.
Attribute::Effects KTextEditor::Attribute::effects | ( | ) | const |
Definition at line 176 of file attribute.cpp.
bool Attribute::fontBold | ( | ) | const |
Find out if the font weight is set to QFont::Bold.
- Returns
true
if the font weight is exactly QFont::Bold, otherwisefalse
- See also
- QTextCharFormat::fontWeight()
Definition at line 151 of file attribute.cpp.
bool Attribute::hasAnyProperty | ( | ) | const |
Determine if any properties are set.
- Returns
- true if any properties are set, otherwise false
Definition at line 166 of file attribute.cpp.
Addition assignment operator.
Use this to merge another Attribute with this Attribute. Where both attributes have a particular property set, the property in a will be used.
- Parameters
-
a attribute to merge into this attribute.
Definition at line 56 of file attribute.cpp.
Replacement assignment operator.
Use this to overwrite this Attribute with another Attribute.
- Parameters
-
a attribute to assign to this attribute.
Definition at line 189 of file attribute.cpp.
QBrush Attribute::outline | ( | ) | const |
Get the brush used to draw an outline around text, if any.
- Returns
- brush to be used to draw an outline, or Qt::NoBrush if no outline is set.
Definition at line 89 of file attribute.cpp.
QBrush Attribute::selectedBackground | ( | ) | const |
Get the brush used to draw the background of selected text, if any.
- Returns
- brush to be used to draw the background of selected text, or Qt::NoBrush if not set
Definition at line 128 of file attribute.cpp.
QBrush Attribute::selectedForeground | ( | ) | const |
Get the brush used to draw text when it is selected, if any.
- Returns
- brush to be used to draw selected text, or Qt::NoBrush if not set
Definition at line 102 of file attribute.cpp.
void Attribute::setBackgroundFillWhitespace | ( | bool | fillWhitespace | ) |
Set whether background color is drawn over whitespace.
Defaults to true if not set.
Use clearProperty(BackgroundFillWhitespace)
to clear.
- Parameters
-
fillWhitespace whether the background should be drawn over whitespace.
Definition at line 123 of file attribute.cpp.
void Attribute::setDynamicAttribute | ( | ActivationType | type, |
Attribute::Ptr | attribute | ||
) |
Set the attribute to use when the event referred to by type occurs.
- Note
- Nested dynamic attributes are ignored.
- Parameters
-
type the activation type to set the attribute for attribute the attribute to assign. As attribute is refcounted, ownership is not an issue.
Definition at line 81 of file attribute.cpp.
void KTextEditor::Attribute::setEffects | ( | Effects | effects | ) |
Definition at line 184 of file attribute.cpp.
void Attribute::setFontBold | ( | bool | bold = true | ) |
Set the font weight to QFont::Bold.
If bold is false
, the weight will be set to 0 (normal).
- Parameters
-
bold whether the font weight should be bold or not.
- See also
- QTextCharFormat::setFontWeight()
Definition at line 156 of file attribute.cpp.
void Attribute::setOutline | ( | const QBrush & | brush | ) |
Set a brush to be used to draw an outline around text.
Use clearProperty(Outline)
to clear.
- Parameters
-
brush brush to be used to draw an outline.
Definition at line 97 of file attribute.cpp.
void Attribute::setSelectedBackground | ( | const QBrush & | brush | ) |
Set a brush to be used to draw the background of selected text, if any.
Use clearProperty(SelectedBackground)
to clear.
- Parameters
-
brush brush to be used to draw the background of selected text
Definition at line 136 of file attribute.cpp.
void Attribute::setSelectedForeground | ( | const QBrush & | foreground | ) |
Set a brush to be used to draw selected text.
Use clearProperty(SelectedForeground)
to clear.
- Parameters
-
foreground brush to be used to draw selected text.
Definition at line 110 of file attribute.cpp.
The documentation for this class was generated from the following files:
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:27:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.