# kdeui Library API Documentation

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

# KPixmapRegionSelectorWidget Class Reference

KPixmapRegionSelectorWidget is a widget that shows a picture and provides the user with a friendly way to select a rectangular subregion of the pixmap. More...

`#include <kpixmapregionselectorwidget.h>`

Inheritance diagram for KPixmapRegionSelectorWidget:

[legend]
Collaboration diagram for KPixmapRegionSelectorWidget:

[legend]
List of all members.

## Public Slots

void | rotateClockwise ()
void | rotateCounterclockwise ()

## Public Member Functions

| KPixmapRegionSelectorWidget (QWidget *parent=0L, const char *name=0L)
| ~KPixmapRegionSelectorWidget ()
void | setPixmap (const QPixmap &pixmap)
QPixmap | pixmap () const
void | setSelectedRegion (const QRect &rect)
QRect | selectedRegion () const
QRect | unzoomedSelectedRegion () const
void | resetSelection ()
QImage | selectedImage () const
void | setSelectionAspectRatio (int width, int height)
void | setFreeSelectionAspectRatio ()
void | setMaximumWidgetSize (int width, int height)
void | rotate (KImageEffect::RotateDirection direction)

## Protected Member Functions

virtual KPopupMenu * | createPopupMenu ()

## Detailed Description

KPixmapRegionSelectorWidget is a widget that shows a picture and provides the user with a friendly way to select a rectangular subregion of the pixmap.

NOTE: There are two copies of this .h and the .cpp file, with subtle differences. One copy is in kdelibs/kdeui, and the other copy is in kdepim/libkdepim This is because kdepim has to remain backwards compatible. Any changes to either file should be made to the other.

Author:
  Antonio Larrosa <larrosa@kde.org>

Since:
  3.4

Definition at line 44 of file kpixmapregionselectorwidget.h.

## Constructor & Destructor Documentation

KPixmapRegionSelectorWidget::KPixmapRegionSelectorWidget | ( | QWidget * | parent = `0L`,
|  | const char * | name = `0L`
| ) |

| Constructor for a KPixmapRegionSelectorWidget. Definition at line 40 of file kpixmapregionselectorwidget.cpp.

KPixmapRegionSelectorWidget::~KPixmapRegionSelectorWidget | ( |  | ) |

| Destructor for a KPixmapRegionSelectorWidget. Definition at line 63 of file kpixmapregionselectorwidget.cpp.

## Member Function Documentation

void KPixmapRegionSelectorWidget::setPixmap | ( | const QPixmap & | pixmap | ) |

Sets the pixmap which will be shown for the user to select a region from.

Parameters:

  | pixmap | The pixmap. Must be non-null.

Definition at line 67 of file kpixmapregionselectorwidget.cpp.

References QPixmap::isNull(), pixmap(), resetSelection(), and QLabel::setPixmap().

Referenced by KPixmapRegionSelectorDialog::getSelectedImage(), and KPixmapRegionSelectorDialog::getSelectedRegion().

QPixmap KPixmapRegionSelectorWidget::pixmap | ( |  | ) | const`[inline]`

Returns:
  the original whole pixmap that we're using in this widget as the pixmap the user is selecting a region from.

Definition at line 69 of file kpixmapregionselectorwidget.h.

Referenced by setPixmap().

void KPixmapRegionSelectorWidget::setSelectedRegion | ( | const QRect & | rect | ) |

| Sets the selected region to be `rect` (in zoomed pixmap coordinates). Definition at line 87 of file kpixmapregionselectorwidget.cpp. References resetSelection(), and unzoomedSelectedRegion().

QRect KPixmapRegionSelectorWidget::selectedRegion | ( |  | ) | const

| Returns the selected region ( in zoomed pixmap coordinates ). Definition at line 82 of file kpixmapregionselectorwidget.cpp.

QRect KPixmapRegionSelectorWidget::unzoomedSelectedRegion | ( |  | ) | const

| Returns the selected region ( in unzoomed, original pixmap coordinates ). Definition at line 388 of file kpixmapregionselectorwidget.cpp. References QRect::height(), QRect::width(), QRect::x(), and QRect::y(). Referenced by KPixmapRegionSelectorDialog::getSelectedRegion(), selectedImage(), and setSelectedRegion().

void KPixmapRegionSelectorWidget::resetSelection | ( |  | ) |

| Resets the selection to use the whole image. Definition at line 76 of file kpixmapregionselectorwidget.cpp. References QPixmap::rect(). Referenced by rotate(), setPixmap(), and setSelectedRegion().

QImage KPixmapRegionSelectorWidget::selectedImage | ( |  | ) | const

Returns:
  a QImage object with just the region the user selected from the image

Definition at line 396 of file kpixmapregionselectorwidget.cpp.

References QPixmap::convertToImage(), QImage::copy(), and unzoomedSelectedRegion().

Referenced by KPixmapRegionSelectorDialog::getSelectedImage().

void KPixmapRegionSelectorWidget::setSelectionAspectRatio | ( | int | width,
|  | int | height
| ) |

Sets the aspect ration that the selected subimage should have.

The way to select it, is specifying an example valid `width` and `height`.

See also:
  setFreeSelectionAspectRatio()

Definition at line 402 of file kpixmapregionselectorwidget.cpp.

Referenced by KPixmapRegionSelectorDialog::getSelectedImage(), and KPixmapRegionSelectorDialog::getSelectedRegion().

void KPixmapRegionSelectorWidget::setFreeSelectionAspectRatio | ( |  | ) |

Allows the user to do a selection which has any aspect ratio.

This is the default.

See also:
  setSelectionAspectRatio()

Definition at line 407 of file kpixmapregionselectorwidget.cpp.

void KPixmapRegionSelectorWidget::setMaximumWidgetSize | ( | int | width,
|  | int | height
| ) |

Sets the maximum size for the widget.

If the image is larger than this (either horizontally or vertically), it's scaled to adjust to the maximum size (preserving the aspect ratio)

Definition at line 412 of file kpixmapregionselectorwidget.cpp.

References QPixmap::convertFromImage(), QPixmap::convertToImage(), QRect::height(), QPixmap::height(), QPixmap::isNull(), QRect::isValid(), QPixmap::rect(), QWidget::resize(), QImage::smoothScale(), QRect::width(), QPixmap::width(), QRect::x(), and QRect::y().

Referenced by KPixmapRegionSelectorDialog::getSelectedImage(), and KPixmapRegionSelectorDialog::getSelectedRegion().

void KPixmapRegionSelectorWidget::rotate | ( | KImageEffect::RotateDirection | direction | ) |

Rotates the image as specified by the `direction` parameter, also tries to rotate the selected region so that it doesn't change, as long as the forced aspect ratio setting is respected, in other case, the selected region is resetted.

Definition at line 160 of file kpixmapregionselectorwidget.cpp.

References QPixmap::convertFromImage(), QPixmap::convertToImage(), QRect::height(), QPixmap::height(), resetSelection(), KImageEffect::rotate(), QRect::setRect(), QRect::width(), QPixmap::width(), QRect::x(), and QRect::y().

Referenced by rotateClockwise(), and rotateCounterclockwise().

void KPixmapRegionSelectorWidget::rotateClockwise | ( |  | ) | `[slot]`

| Rotates the current image 90º clockwise. Definition at line 199 of file kpixmapregionselectorwidget.cpp. References rotate(). Referenced by createPopupMenu().

void KPixmapRegionSelectorWidget::rotateCounterclockwise | ( |  | ) | `[slot]`

| Rotates the current image 90º counterclockwise. Definition at line 204 of file kpixmapregionselectorwidget.cpp. References rotate(). Referenced by createPopupMenu().

KPopupMenu * KPixmapRegionSelectorWidget::createPopupMenu | ( |  | ) | `[protected, virtual]`

| Creates a KPopupMenu with the menu that appears when clicking with the right button on the label. Definition at line 138 of file kpixmapregionselectorwidget.cpp. References KPopupMenu::insertTitle(), rotateClockwise(), and rotateCounterclockwise().

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

- kpixmapregionselectorwidget.h
- kpixmapregionselectorwidget.cpp

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:21:53 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003