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) |
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-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:52:20 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.