KDE 4.9 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

Attribute Class Reference

from PyKDE4.ktexteditor import *

Inherits: QTextCharFormat → QTextFormat
Namespace: KTextEditor

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.

    \sa SmartInterface

    Author:
    Hamish Rodda <rodda@kde.org>


    Enumerations

    ActivationType { ActivateMouseIn, ActivateCaretIn }
    CustomProperties { Outline, SelectedForeground, SelectedBackground, BackgroundFillWhitespace, AttributeDynamicEffect, AttributeInternalProperty, AttributeUserProperty }
    Effect { EffectNone, EffectFadeIn, EffectFadeOut, EffectPulse, EffectCycleGradient }

    Methods

     __init__ (self)
     __init__ (self, KTextEditor.Attribute a)
    [KAction] associatedActions (self)
    bool backgroundFillWhitespace (self)
     clear (self)
     clearAssociatedActions (self)
    KSharedPtr dynamicAttribute (self, KTextEditor.Attribute.ActivationType type)
    KTextEditor.Attribute.Effects effects (self)
    bool fontBold (self)
    bool hasAnyProperty (self)
    KTextEditor.Attribute operator += (self, KTextEditor.Attribute a)
    QBrush outline (self)
    QBrush selectedBackground (self)
    QBrush selectedForeground (self)
     setBackgroundFillWhitespace (self, bool fillWhitespace)
     setDynamicAttribute (self, KTextEditor.Attribute.ActivationType type, KSharedPtr attribute)
     setEffects (self, KTextEditor.Attribute.Effects effects)
     setFontBold (self, bool bold=1)
     setOutline (self, QBrush brush)
     setSelectedBackground (self, QBrush brush)
     setSelectedForeground (self, QBrush foreground)

    Method Documentation

    __init__ (   self )

    Default constructor. The resulting Attribute has no properties set to begin with.

    __init__ (  self,
    KTextEditor.Attribute  a
    )

    Copy constructor.

    [KAction] associatedActions (   self )

    Returns a list of currently associated KAction%s.

    bool backgroundFillWhitespace (   self )

    Determine whether background color is drawn over whitespace. Defaults to true if not set.

    Returns:
    whether the background color should be drawn over whitespace

    clear (   self )

    Clear all set properties.

    clearAssociatedActions (   self )

    Clears all associations between KAction%s and this attribute.

    KSharedPtr dynamicAttribute (  self,
    KTextEditor.Attribute.ActivationType  type
    )

    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.

    KTextEditor.Attribute.Effects effects (   self )
    bool fontBold (   self )

    Find out if the font weight is set to QFont.Bold.

    Returns:
    true if the font weight is exactly QFont.Bold, otherwise false

    See also:
    QTextCharFormat.fontWeight()

    bool hasAnyProperty (   self )

    Determine if any properties are set.

    Returns:
    true if any properties are set, otherwise false

    KTextEditor.Attribute operator += (  self,
    KTextEditor.Attribute  a
    )

    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.

    QBrush outline (   self )

    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.

    QBrush selectedBackground (   self )

    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

    QBrush selectedForeground (   self )

    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

    setBackgroundFillWhitespace (  self,
    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.

    setDynamicAttribute (  self,
    KTextEditor.Attribute.ActivationType  type,
    KSharedPtr  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

    Parameters:
    attribute  the attribute to assign. As attribute is refcounted, ownership is not an issue.

    setEffects (  self,
    KTextEditor.Attribute.Effects  effects
    )
    setFontBold (  self,
    bool  bold=1
    )

    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()

    setOutline (  self,
    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.

    setSelectedBackground (  self,
    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

    setSelectedForeground (  self,
    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.


    Enumeration Documentation

    ActivationType

    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 = 0
    ActivateCaretIn 

    CustomProperties

    Custom property types, which may or may not be supported by implementations.

    Enumerator:
    Outline = QTextFormat::UserProperty
    SelectedForeground 
    SelectedBackground 
    BackgroundFillWhitespace 
    AttributeDynamicEffect = 0x10A00
    AttributeInternalProperty = 0x10E00
    AttributeUserProperty = 0x110000

    Effect

    Dynamic effects for display. To do: Pulse and CycleGradient are unclear.

    Enumerator:
    EffectNone = 0x0
    EffectFadeIn = 0x1
    EffectFadeOut = 0x2
    EffectPulse = 0x4
    EffectCycleGradient = 0x8

    • Full Index

    Modules

    • akonadi
    • dnssd
    • kdecore
    • kdeui
    • khtml
    • kio
    • knewstuff
    • kparts
    • kutils
    • nepomuk
    • phonon
    • plasma
    • polkitqt
    • solid
    • soprano
    This documentation is maintained by Simon Edwards.
    KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal