libtdepim

kpixmapregionselectorwidget.h
1/*
2 This file is part of libtdepim.
3
4 Copyright (C) 2004 Antonio Larrosa <larrosa@kde.org
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21
22#ifndef __KPIXMAPREGIONSELECTORWIDGET_H__
23#define __KPIXMAPREGIONSELECTORWIDGET_H__
24
25#include <tqvbox.h>
26#include <tqpixmap.h>
27#include <tqrect.h>
28#include <tqlabel.h>
29#include <kimageeffect.h>
30
31class TDEPopupMenu;
32
33namespace KPIM {
34
47class KPixmapRegionSelectorWidget : public TQWidget
48{
49 TQ_OBJECT
50
51
52public:
56 KPixmapRegionSelectorWidget( TQWidget *parent = 0L, const char *name=0L);
57
62
67 void setPixmap( const TQPixmap &pixmap );
68
73 TQPixmap pixmap() const { return m_unzoomedPixmap; }
74
78 void setSelectedRegion(const TQRect &rect);
79
83 TQRect selectedRegion() const;
84
88 TQRect unzoomedSelectedRegion() const;
89
93 void resetSelection();
94
99 TQImage selectedImage() const;
100
106 void setSelectionAspectRatio(int width, int height);
107
114
120 void setMaximumWidgetSize( int width, int height );
121
128 void rotate(KImageEffect::RotateDirection direction);
129
130public slots:
134 void rotateClockwise();
139
140protected:
144 virtual TDEPopupMenu *createPopupMenu();
145
146
147private:
148 bool eventFilter(TQObject *obj, TQEvent *ev);
149
154 void updatePixmap();
155
156 TQRect calcSelectionRectangle( const TQPoint &startPoint, const TQPoint & endPoint );
157
158 enum CursorState { None=0, Resizing, Moving };
159 CursorState m_state;
160
161 TQPixmap m_unzoomedPixmap;
162 TQPixmap m_originalPixmap;
163 TQPixmap m_linedPixmap;
164 TQRect m_selectedRegion;
165 TQLabel *m_label;
166
167 TQPoint m_tempFirstClick;
168 double m_forcedAspectRatio;
169
170 int m_maxWidth, m_maxHeight;
171 double m_zoomFactor;
172};
173
174} // for namespace
175
176#endif
KPixmapRegionSelectorWidget is a widget that shows a picture and provides the user with a friendly wa...
void resetSelection()
Resets the selection to use the whole image.
void setSelectedRegion(const TQRect &rect)
Sets the selected region to be rect (in zoomed pixmap coordinates)
void rotate(KImageEffect::RotateDirection direction)
Rotates the image as specified by the direction parameter, also tries to rotate the selected region s...
void rotateClockwise()
Rotates the current image 90º clockwise.
KPixmapRegionSelectorWidget(TQWidget *parent=0L, const char *name=0L)
Constructor for a KPixmapRegionSelectorWidget.
void setFreeSelectionAspectRatio()
Allows the user to do a selection which has any aspect ratio.
TQRect unzoomedSelectedRegion() const
Returns the selected region ( in unzoomed, original pixmap coordinates )
void setSelectionAspectRatio(int width, int height)
Sets the aspect ration that the selected subimage should have.
virtual TDEPopupMenu * createPopupMenu()
Creates a TDEPopupMenu with the menu that appears when clicking with the right button on the label.
void setPixmap(const TQPixmap &pixmap)
Sets the pixmap which will be shown for the user to select a region from.
~KPixmapRegionSelectorWidget()
Destructor for a KPixmapRegionSelectorWidget.
void rotateCounterclockwise()
Rotates the current image 90º counterclockwise.
void setMaximumWidgetSize(int width, int height)
Sets the maximum size for the widget.
TQRect selectedRegion() const
Returns the selected region ( in zoomed pixmap coordinates )
TDEPIM classes for drag and drop of mails.