new virtual function to get settings from kipi host using QVariant container
[kdegraphics.git] / ksnapshot / regiongrabber.h
blob589eb158e9eafbe4b6261727502fff44d326bdb5
1 /*
2 * Copyright (C) 2007 Luca Gugelmann <lucag@student.ethz.ch>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Library General Public License version 2 as
6 * published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU Library General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef REGIONGRABBER_H
20 #define REGIONGRABBER_H
22 #include <QWidget>
23 #include <QRegion>
24 #include <QPoint>
25 #include <QVector>
26 #include <QRect>
27 #include <QTimer>
29 class QPaintEvent;
30 class QResizeEvent;
31 class QMouseEvent;
33 class RegionGrabber : public QWidget
35 Q_OBJECT
36 public:
37 RegionGrabber();
38 ~RegionGrabber();
40 protected slots:
41 void init();
42 void displayHelp();
44 signals:
45 void regionGrabbed( const QPixmap & );
47 protected:
48 void paintEvent( QPaintEvent* e );
49 void resizeEvent( QResizeEvent* e );
50 void mousePressEvent( QMouseEvent* e );
51 void mouseMoveEvent( QMouseEvent* e );
52 void mouseReleaseEvent( QMouseEvent* e );
53 void mouseDoubleClickEvent( QMouseEvent* );
54 void keyPressEvent( QKeyEvent* e );
55 void updateHandles();
56 QRegion handleMask() const;
57 QPoint limitPointToRect( const QPoint &p, const QRect &r ) const;
58 void grabRect();
60 QRect selection;
61 bool mouseDown;
62 bool newSelection;
63 const int handleSize;
64 QRect* mouseOverHandle;
65 QPoint dragStartPoint;
66 QRect selectionBeforeDrag;
67 QTimer idleTimer;
68 bool showHelp;
69 bool grabbing;
71 // naming convention for handles
72 // T top, B bottom, R Right, L left
73 // 2 letters: a corner
74 // 1 letter: the handle on the middle of the corresponding side
75 QRect TLHandle, TRHandle, BLHandle, BRHandle;
76 QRect LHandle, THandle, RHandle, BHandle;
78 QVector<QRect*> handles;
79 QPixmap pixmap;
82 #endif