# kdeui Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KRootPixmap Class Reference

Creates pseudo-transparent widgets. More...

`#include <krootpixmap.h>`

Inheritance diagram for KRootPixmap:

[legend]
Collaboration diagram for KRootPixmap:

[legend]
List of all members.

## Public Slots

virtual void | start ()
| Starts background handling.
virtual void | stop ()
| Stops background handling.
void | setFadeEffect (double strength, const QColor &color)
| Sets the fade effect.
void | repaint (bool force)
| Repaints the widget background.
void | repaint ()
| Repaints the widget background.
void | setCustomPainting (bool enable)
| Enables custom handling of the background painting.
void | enableExports ()
| Asks KDesktop to export the desktop background as a KSharedPixmap.

## Signals

void | backgroundUpdated (const QPixmap &pm)
| Emitted when the background needs updating and custom painting (see setCustomPainting(bool) ) is enabled.

## Public Member Functions

| KRootPixmap (QWidget *target, const char *name=0)
| Constructs a KRootPixmap.
| KRootPixmap (QWidget *target, QObject *parent, const char *name=0)
| Constructs a KRootPixmap where the parent QObject and target QWidget are different.
virtual | ~KRootPixmap ()
| Destructs the object.
bool | isAvailable () const
| Checks if pseudo-transparency is available.
bool | isActive () const
| Returns true if the KRootPixmap is active.
int | currentDesktop () const
| Returns the number of the current desktop.
bool | customPainting () const
| Returns true if custom painting is enabled, false otherwise.
bool | checkAvailable (bool)
| Deprecated, use isAvailable() instead.

## Protected Member Functions

virtual bool | eventFilter (QObject *, QEvent *)
| Reimplemented to filter the events from the target widget and track its movements.
virtual void | updateBackground (KSharedPixmap *)
| Called when the pixmap has been updated.

## Detailed Description

Creates pseudo-transparent widgets.

A pseudo-transparent widget is a widget with its background pixmap set to that part of the desktop background that it is currently obscuring. This gives a transparency effect.

To create a transparent widget, construct a KRootPixmap and pass it a pointer to your widget. That's it! Moving, resizing and background changes are handled automatically.

Instead of using the default behaviour, you can ask KRootPixmap to emit a backgroundUpdated(const QPixmap &) signal whenever the background needs updating by using setCustomPainting(bool). Alternatively by reimplementing updateBackground(KSharedPixmap*) you can take complete control of the behaviour.

Author:
  Geert Jansen <jansen@kde.org>

Version:
  Id
    krootpixmap.h,v 1.14 2002/03/08 18:01:07 rich Exp

Definition at line 45 of file krootpixmap.h.

## Constructor & Destructor Documentation

KRootPixmap::KRootPixmap | ( | QWidget * | target,
|  | const char * | name = 0
| ) |

Constructs a KRootPixmap.

The KRootPixmap will be created as a child of the target widget so it will be deleted automatically when the widget is destroyed.

Parameters:

  target | A pointer to the widget that you want to make pseudo transparent.

Definition at line 31 of file krootpixmap.cpp.

References KStdAccel::name().

KRootPixmap::KRootPixmap | ( | QWidget * | target,
|  | QObject * | parent,
|  | const char * | name = 0
| ) |

| Constructs a KRootPixmap where the parent QObject and target QWidget are different. Definition at line 37 of file krootpixmap.cpp. References KStdAccel::name().

KRootPixmap::~KRootPixmap | ( |  | ) | `[virtual]`

| Destructs the object. Definition at line 62 of file krootpixmap.cpp.

## Member Function Documentation

bool KRootPixmap::isAvailable | ( |  | ) | const

Checks if pseudo-transparency is available.

Returns:
  `true` if transparency is available, `false` otherwise.

Definition at line 176 of file krootpixmap.cpp.

References currentDesktop(), KSharedPixmap::isAvailable(), KStdAccel::name(), and QObject::name().

Referenced by checkAvailable(), and start().

bool KRootPixmap::isActive | ( |  | ) | const`[inline]`

| Returns true if the KRootPixmap is active. Definition at line 80 of file krootpixmap.h.

int KRootPixmap::currentDesktop | ( |  | ) | const

| Returns the number of the current desktop. Definition at line 68 of file krootpixmap.cpp. Referenced by eventFilter(), isAvailable(), and repaint().

bool KRootPixmap::customPainting | ( |  | ) | const`[inline]`

Returns true if custom painting is enabled, false otherwise.

See also:
  setCustomPainting(bool)

Definition at line 91 of file krootpixmap.h.

bool KRootPixmap::checkAvailable | ( | bool |  | ) | `[inline]`

| Deprecated, use isAvailable() instead. This class or method is obsolete, it is provided for compatibility only. Definition at line 98 of file krootpixmap.h. References isAvailable().

void KRootPixmap::start | ( |  | ) | `[virtual, slot]`

| Starts background handling. Definition at line 76 of file krootpixmap.cpp. References enableExports(), isAvailable(), and repaint().

void KRootPixmap::stop | ( |  | ) | `[virtual, slot]`

| Stops background handling. Definition at line 93 of file krootpixmap.cpp. References QTimer::stop().

void KRootPixmap::setFadeEffect | ( | double | strength,
|  | const QColor & | color
| ) | `[slot]`

Sets the fade effect.

This effect will fade the background to the specified color.

Parameters:

  strength | A value between 0 and 1, indicating the strength of the fade. A value of 0 will not change the image, a value of 1 will make it the fade color everywhere, and in between.
  color | The color to fade to.

Definition at line 100 of file krootpixmap.cpp.

References repaint().

void KRootPixmap::repaint | ( | bool | force | ) | `[slot]`

Repaints the widget background.

Normally, you shouldn't need this as it is handled automatically.

Parameters:

  force | Force a repaint, even if the contents did not change.

Definition at line 151 of file krootpixmap.cpp.

References currentDesktop(), QWidget::height(), KSharedPixmap::loadFromShared(), QWidget::mapToGlobal(), QWidget::rect(), updateBackground(), and QWidget::width().

void KRootPixmap::repaint | ( |  | ) | `[slot]`

| Repaints the widget background. Normally, you shouldn't need this as it is handled automatically. This is equivalent to calling repaint( false ). Definition at line 145 of file krootpixmap.cpp. Referenced by setFadeEffect(), and start().

void KRootPixmap::setCustomPainting | ( | bool | enable | ) | `[inline, slot]`

| Enables custom handling of the background painting. If custom painting is enabled then KRootPixmap will emit a backgroundUpdated() signal when the background for the target widget changes, instead of applying the new background. Definition at line 145 of file krootpixmap.h.

void KRootPixmap::enableExports | ( |  | ) | `[slot]`

| Asks KDesktop to export the desktop background as a KSharedPixmap. This method uses DCOP to call KBackgroundIface/setExport(int). Definition at line 183 of file krootpixmap.cpp. References DCOPClient::attach(), DCOPClient::isAttached(), and DCOPClient::send(). Referenced by start().

void KRootPixmap::backgroundUpdated | ( | const QPixmap & | pm | ) | `[signal]`

Emitted when the background needs updating and custom painting (see setCustomPainting(bool) ) is enabled.

Parameters:

  pm | A pixmap containing the new background.

Referenced by updateBackground().

bool KRootPixmap::eventFilter | ( | QObject * | ,
|  | QEvent * |
| ) | `[protected, virtual]`

| Reimplemented to filter the events from the target widget and track its movements. Reimplemented from QObject. Definition at line 114 of file krootpixmap.cpp. References currentDesktop(), KNotifyClient::event(), and QTimer::start().

void KRootPixmap::updateBackground | ( | KSharedPixmap * |  | ) | `[protected, virtual]`

| Called when the pixmap has been updated. The default implementation applies the fade effect, then sets the target's background, or emits backgroundUpdated(const QPixmap &) depending on the painting mode. Definition at line 210 of file krootpixmap.cpp. References backgroundUpdated(), KPixmapIO::convertToImage(), KPixmapIO::convertToPixmap(), and KImageEffect::fade(). Referenced by repaint().

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

- krootpixmap.h
- krootpixmap.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 13:04:43 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001