/usr/include/ktexteditor/attribute.h is in kdelibs5-dev 4:4.8.2-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | /* This file is part of the KDE libraries
* Copyright (C) 2003-2005 Hamish Rodda <rodda@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KDELIBS_KTEXTEDITOR_ATTRIBUTE_H
#define KDELIBS_KTEXTEDITOR_ATTRIBUTE_H
#include <QtGui/QTextFormat>
#include <ksharedptr.h>
#include <ktexteditor/ktexteditor_export.h>
class KAction;
namespace KTextEditor
{
class SmartRange;
/**
* \brief 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:
* \li several customized text formatting properties
* \li dynamic highlighting of associated ranges of text
* \li 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\>
*/
class KTEXTEDITOR_EXPORT Attribute : public QTextCharFormat, public KShared
{
friend class SmartRange;
public:
typedef KSharedPtr<Attribute> Ptr;
/**
* Default constructor. The resulting Attribute has no properties set to begin with.
*/
Attribute();
/**
* Copy constructor.
*/
Attribute(const Attribute& a);
/**
* Virtual destructor.
*/
virtual ~Attribute();
/**
* 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 changed() const;
//BEGIN custom properties
/**
* Custom property types, which may or may not be supported by implementations.
*/
enum CustomProperties {
/// Draws an outline around the text
Outline = QTextFormat::UserProperty,
/// Changes the brush used to paint the text when it is selected
SelectedForeground,
/// Changes the brush used to paint the background when it is selected
SelectedBackground,
/// Determines whether background color is drawn over whitespace. Defaults to true.
BackgroundFillWhitespace,
/// Defined to allow storage of dynamic effect information
AttributeDynamicEffect = 0x10A00,
/// Defined for internal usage of KTextEditor implementations
AttributeInternalProperty = 0x10E00,
/// Defined to allow 3rd party code to create their own custom attributes - you may use values at or above this property.
AttributeUserProperty = 0x110000
};
/**
* \name Custom properties
*
* The following functions provide custom properties which can be set for
* rendering by editor implementations.
* \{
*/
/**
* Find out if the font weight is set to QFont::Bold.
*
* \return \c true if the font weight is exactly QFont::Bold, otherwise \c false
*
* \see QTextCharFormat::fontWeight()
*/
bool fontBold() const;
/**
* Set the font weight to QFont::Bold. If \a bold is \p false, the weight will be set to 0 (normal).
*
* \param bold whether the font weight should be bold or not.
*
* \see QTextCharFormat::setFontWeight()
*/
void setFontBold(bool bold = true);
/**
* Get the brush used to draw an outline around text, if any.
*
* \return brush to be used to draw an outline, or Qt::NoBrush if no outline is set.
*/
QBrush outline() const;
/**
* Set a brush to be used to draw an outline around text.
*
* Use \p clearProperty(Outline) to clear.
*
* \param brush brush to be used to draw an outline.
*/
void setOutline(const QBrush& brush);
/**
* Get the brush used to draw text when it is selected, if any.
*
* \return brush to be used to draw selected text, or Qt::NoBrush if not set
*/
QBrush selectedForeground() const;
/**
* Set a brush to be used to draw selected text.
*
* Use \p clearProperty(SelectedForeground) to clear.
*
* \param foreground brush to be used to draw selected text.
*/
void setSelectedForeground(const QBrush& foreground);
/**
* Get the brush used to draw the background of selected text, if any.
*
* \return brush to be used to draw the background of selected text, or Qt::NoBrush if not set
*/
QBrush selectedBackground() const;
/**
* Set a brush to be used to draw the background of selected text, if any.
*
* Use \p clearProperty(SelectedBackground) to clear.
*
* \param brush brush to be used to draw the background of selected text
*/
void setSelectedBackground(const QBrush& brush);
/**
* Determine whether background color is drawn over whitespace. Defaults to true if not set.
*
* \return whether the background color should be drawn over whitespace
*/
bool backgroundFillWhitespace() const;
/**
* Set whether background color is drawn over whitespace. Defaults to true if not set.
*
* Use \p clearProperty(BackgroundFillWhitespace) to clear.
*
* \param fillWhitespace whether the background should be drawn over whitespace.
*/
void setBackgroundFillWhitespace(bool fillWhitespace);
// Fix deficiencies in QText{Char}Format
/**
* Clear all set properties.
*/
void clear();
/**
* Determine if any properties are set.
*
* \return \e true if any properties are set, otherwise \e false
*/
bool hasAnyProperty() const;
//END
//BEGIN Action association
/**
* \}
* \name Action association
*
* The following functions allow for KAction%s to be associated with attributes,
* and thus with ranges which use this attribute.
*
* \note This feature is currently not implemented (ETA KDE 4.1).
* \{
*/
/**
* 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.
*
* \param action KAction to associate with this Attribute
*/
void associateAction(KAction* action);
/**
* Remove the association with an action from this attribute; it will no
* longer be managed by associated ranges.
*
* \param action KAction to dissociate from this Attribute
*/
void dissociateAction(KAction* action);
/**
* Returns a list of currently associated KAction%s.
*/
const QList<KAction*>& associatedActions() const;
/**
* Clears all associations between KAction%s and this attribute.
*/
void clearAssociatedActions();
//!\}
//END
//BEGIN Dynamic highlighting
/**
* 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.
*/
enum ActivationType {
/// Activate attribute on mouse in
ActivateMouseIn = 0,
/// Activate attribute on caret in
ActivateCaretIn
};
/**
* Dynamic effects for display.
* \todo Pulse and CycleGradient are unclear.
*/
enum Effect {
EffectNone = 0x0 /**< No effect. Just display. */,
EffectFadeIn = 0x1 /**< Fade in and stay there. */,
EffectFadeOut = 0x2 /**< Fade out to vanish. */,
EffectPulse = 0x4 /**< Pulse (throb); change weight. */,
EffectCycleGradient = 0x8 /**< Cycle colors. */
};
Q_DECLARE_FLAGS(Effects, Effect)
/**
* \name Dynamic highlighting
*
* The following functions allow for text to be highlighted dynamically based on
* several events.
* \{
*/
/**
* Return the attribute to use when the event referred to by \a type occurs.
*
* \param type the activation type for which to return the Attribute.
*
* \returns the attribute to be used for events specified by \a type, or null if none is set.
*/
Attribute::Ptr dynamicAttribute(ActivationType type) const;
/**
* Set the attribute to use when the event referred to by \a type occurs.
*
* \note Nested dynamic attributes are ignored.
*
* \param type the activation type to set the attribute for
* \param attribute the attribute to assign. As attribute is refcounted, ownership is not an issue.
*/
void setDynamicAttribute(ActivationType type, Attribute::Ptr attribute);
Effects effects() const;
void setEffects(Effects effects);
//!\}
//END
/**
* Addition assignment operator. Use this to merge another Attribute with this Attribute.
* Where both attributes have a particular property set, the property in \a a will
* be used.
*
* \param a attribute to merge into this attribute.
*/
Attribute& operator+=(const Attribute& a);
/**
* Replacement assignment operator. Use this to overwrite this Attribute with another Attribute.
*
* \param a attribute to assign to this attribute.
*/
Attribute& operator=(const Attribute& a);
protected:
/**
* \internal
* Add a range using this attribute.
* \param range range using this attribute.
*
void addRange(SmartRange* range);
**
* \internal
* Remove a range which is no longer using this attribute.
* \param range range no longer using this attribute.
*
void removeRange(SmartRange* range);*/
private:
class AttributePrivate* const d;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Attribute::Effects)
}
#endif
// kate: space-indent on; indent-width 2; replace-tabs on;
|