KIconEffect class Reference (kdecore Library)

| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KIconEffect Class Reference

Applies effects to icons. More...

`#include <kiconeffect.h>`

Collaboration diagram for KIconEffect:

[legend]
List of all members.

## Public Types
enum | Effects { NoEffect, ToGray, Colorize, ToGamma, DeSaturate, LastEffect }
| This is the enumeration of all possible icon effects. More...
## Public Member Functions
| KIconEffect ()
| Create a new KIconEffect.
void | init ()
| Rereads configuration.
bool | hasEffect (int group, int state) const
| Tests whether an effect has been configured for the given icon group.
QString | fingerprint (int group, int state) const
| Returns a fingerprint for the effect by encoding the given `group` and `state` into a QString.
QImage | apply (QImage src, int group, int state) const
| Applies an effect to an image.
QImage | apply (QImage src, int effect, float value, const QColor rgb, bool trans) const
| Applies an effect to an image.
QPixmap | apply (QPixmap src, int group, int state) const
| Applies an effect to a pixmap.
QPixmap | apply (QPixmap src, int effect, float value, const QColor rgb, bool trans) const
| Applies an effect to a pixmap.
QImage | doublePixels (QImage src) const
| Returns an image twice as large, consisting of 2x2 pixels.
## Static Public Member Functions
void | visualActivate (QWidget *widget, QRect rect)
| Provides visual feedback to show activation of an icon on a widget.
void | toGray (QImage &image, float value)
| Tints an image gray.
void | colorize (QImage &image, const QColor &col, float value)
| Colorizes an image with a specific color.
void | deSaturate (QImage &image, float value)
| Desaturates an image.
void | toGamma (QImage &image, float value)
| Changes the gamma value of an image.
void | semiTransparent (QImage &image)
| Renders an image semi-transparent.
void | semiTransparent (QPixmap &pixmap)
| Renders a pixmap semi-transparent.
void | overlay (QImage &src, QImage &overlay)
| Overlays an image with an other image.

## Detailed Description

Applies effects to icons.

This class applies effects to icons depending on their state and group. For example, it can be used to make all disabled icons in a toolbar grey.

See also:
  KIcon

Definition at line 35 of file kiconeffect.h.

## Member Enumeration Documentation

enum KIconEffect::Effects

| This is the enumeration of all possible icon effects. Note that 'LastEffect' is no valid icon effect but only used internally to check for invalid icon effects. NoEffect: Don't apply any icon effect ToGray: Tints the icon gray Colorize: Tints the icon with an other color ToGamma: Change the gamma value if the icon DeSaturate: Reduce the saturation of the icon Definition at line 55 of file kiconeffect.h.

## Constructor & Destructor Documentation

KIconEffect::KIconEffect | ( |  | ) |

| Create a new KIconEffect. Definition at line 44 of file kiconeffect.cpp. References init().

## Member Function Documentation

void KIconEffect::init | ( |  | ) |

| Rereads configuration. Definition at line 55 of file kiconeffect.cpp. References KGlobal::config(), KConfigBase::readBoolEntry(), KConfigBase::readColorEntry(), KConfigBase::readDoubleNumEntry(), KConfigBase::readEntry(), and KConfigBase::setGroup(). Referenced by KIconEffect().

bool KIconEffect::hasEffect | ( | int | group,
|  | int | state
| ) | const

  | Tests whether an effect has been configured for the given icon group. Parameters:
  group | the group to check, see KIcon::Group
  state | the state to check, see KIcon::States
Returns: true if an effect is configured for the given `group` in `state`, otherwise false. See also: KIcon::Group KIcon::States Definition at line 124 of file kiconeffect.cpp.

QString KIconEffect::fingerprint | ( | int | group,
|  | int | state
| ) | const

  | Returns a fingerprint for the effect by encoding the given `group` and `state` into a QString. This is useful for caching. Parameters:
  group | the group, see KIcon::Group
  state | the state, see KIcon::States
Returns: the fingerprint of the given `group+`state`` Definition at line 129 of file kiconeffect.cpp. References QString::fromLatin1(), QString::isEmpty(), and QString::setNum().

QImage KIconEffect::apply | ( | QImage | src,
|  | int | group,
|  | int | state
| ) | const

  | Applies an effect to an image. The effect to apply depends on the `group` and `state` parameters, and is configured by the user. Parameters:
  src | The image.
  group | The group for the icon, see KIcon::Group
  state | The icon's state, see KIcon::States
Returns: An image with the effect applied. Definition at line 154 of file kiconeffect.cpp. References KIcon::LastState. Referenced by apply().

QImage KIconEffect::apply | ( | QImage | src,
|  | int | effect,
|  | float | value,
|  | const QColor | rgb,
|  | bool | trans
| ) | const

  | Applies an effect to an image. Parameters:
  src | The image.
  effect | The effect to apply, one of KIconEffect::Effects.
  value | Strength of the effect. 0 <= `value` <= 1.
  color | Color parameter for effects that need one.
  trans | Add Transparency if trans = true.
Returns: An image with the effect applied. Definition at line 170 of file kiconeffect.cpp. References colorize(), deSaturate(), semiTransparent(), toGamma(), and toGray().

QPixmap KIconEffect::apply | ( | QPixmap | src,
|  | int | group,
|  | int | state
| ) | const

  | Applies an effect to a pixmap. Parameters:
  src | The pixmap.
  group | The group for the icon, see KIcon::Group
  state | The icon's state, see KIcon::States
Returns: A pixmap with the effect applied. Definition at line 203 of file kiconeffect.cpp. References apply(), and KIcon::LastState.

QPixmap KIconEffect::apply | ( | QPixmap | src,
|  | int | effect,
|  | float | value,
|  | const QColor | rgb,
|  | bool | trans
| ) | const

  | Applies an effect to a pixmap. Parameters:
  src | The pixmap.
  effect | The effect to apply, one of KIconEffect::Effects.
  value | Strength of the effect. 0 <= `value` <= 1.
  color | Color parameter for effects that need one.
  trans | Add Transparency if trans = true.
Returns: A pixmap with the effect applied. Definition at line 219 of file kiconeffect.cpp. References apply(), QPixmap::convertFromImage(), QPixmap::convertToImage(), and semiTransparent().

QImage KIconEffect::doublePixels | ( | QImage | src | ) | const

  | Returns an image twice as large, consisting of 2x2 pixels. Parameters:
  src | the image.
Returns: the scaled image. Definition at line 458 of file kiconeffect.cpp. References QImage::bytesPerLine(), QImage::color(), QImage::create(), QImage::depth(), QImage::hasAlphaBuffer(), QImage::height(), QImage::numColors(), QImage::scanLine(), QImage::setAlphaBuffer(), QImage::setColor(), and QImage::width().

void KIconEffect::visualActivate | ( | QWidget * | widget,
|  | QRect | rect
| ) | `[static]`

  | Provides visual feedback to show activation of an icon on a widget. Not strictly an 'icon effect', but in practice that's what it looks like. This method does nothing if the global 'Visual feedback on activation' option is not activated (See kcontrol/Peripherals/Mouse). Parameters:
  widget | The widget on which the effect should be painted
  rect | This rectangle defines the effect's borders
Definition at line 622 of file kiconeffect.cpp. References QRect::center(), QPainter::drawRect(), QPainter::flush(), QRect::height(), QPainter::setPen(), QPainter::setRasterOp(), QRect::setRect(), KGlobalSettings::visualActivate(), KGlobalSettings::visualActivateSpeed(), QRect::width(), QPoint::x(), and QPoint::y().

void KIconEffect::toGray | ( | QImage & | image,
|  | float | value
| ) | `[static]`

  | Tints an image gray. Parameters:
  image | The image
  value | Strength of the effect. 0 <= `value` <= 1
Definition at line 250 of file kiconeffect.cpp. References QImage::bits(), QImage::colorTable(), QImage::depth(), QImage::height(), QImage::numColors(), and QImage::width(). Referenced by apply().

void KIconEffect::colorize | ( | QImage & | image,
|  | const QColor & | col,
|  | float | value
| ) | `[static]`

  | Colorizes an image with a specific color. Parameters:
  image | The image
  col | The color with which the `image` is tinted
  value | Strength of the effect. 0 <= `value` <= 1
Definition at line 272 of file kiconeffect.cpp. References QImage::bits(), QColor::blue(), QImage::colorTable(), QImage::depth(), QColor::green(), QImage::height(), QImage::numColors(), QColor::red(), and QImage::width(). Referenced by apply().

void KIconEffect::deSaturate | ( | QImage & | image,
|  | float | value
| ) | `[static]`

  | Desaturates an image. Parameters:
  image | The image
  value | Strength of the effect. 0 <= `value` <= 1
Definition at line 313 of file kiconeffect.cpp. References QImage::bits(), QColor::blue(), QImage::colorTable(), QImage::depth(), QColor::green(), QImage::height(), QImage::numColors(), QColor::red(), QColor::setHsv(), QColor::setRgb(), and QImage::width(). Referenced by apply().

void KIconEffect::toGamma | ( | QImage & | image,
|  | float | value
| ) | `[static]`

  | Changes the gamma value of an image. Parameters:
  image | The image
  value | Strength of the effect. 0 <= `value` <= 1
Definition at line 331 of file kiconeffect.cpp. References QImage::bits(), QImage::colorTable(), QImage::depth(), QImage::height(), QImage::numColors(), QColor::rgb(), QColor::setRgb(), and QImage::width(). Referenced by apply().

void KIconEffect::semiTransparent | ( | QImage & | image | ) | `[static]`

  | Renders an image semi-transparent. Parameters:
  image | The image
Definition at line 353 of file kiconeffect.cpp. References QImage::color(), QImage::depth(), QImage::height(), QImage::numColors(), QImage::scanLine(), QImage::setAlphaBuffer(), QImage::setColor(), QImage::setPixel(), and QImage::width(). Referenced by apply(), and semiTransparent().

void KIconEffect::semiTransparent | ( | QPixmap & | pixmap | ) | `[static]`

  | Renders a pixmap semi-transparent. Parameters:
  image | The pixmap
Definition at line 427 of file kiconeffect.cpp. References QPixmap::convertFromImage(), QPixmap::convertToImage(), QImage::create(), QImage::fill(), QImage::height(), QPixmap::mask(), QImage::scanLine(), semiTransparent(), QPixmap::setMask(), QPixmap::size(), and QImage::width().

void KIconEffect::overlay | ( | QImage & | src,
|  | QImage & | overlay
| ) | `[static]`

  | Overlays an image with an other image. Parameters:
  src | The image
  overlay | The image to overlay `src` with
Definition at line 507 of file kiconeffect.cpp. References QImage::color(), QImage::depth(), QImage::hasAlphaBuffer(), QImage::height(), QImage::numColors(), QImage::scanLine(), QImage::setColor(), QImage::setNumColors(), QImage::size(), and QImage::width(). Referenced by KIconLoader::loadIcon().

The documentation for this class was generated from the following files:

- kiconeffect.h
- kiconeffect.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:49:14 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001