1 | /* |
2 | * Copyright (C) 2010 Pau Garcia i Quiles <pgquiles@elpauer.org>, |
3 | * based on the region grabber code by Luca Gugelmann <lucag@student.ethz.ch> |
4 | * |
5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU Library General Public License version 2 as |
7 | * published by the Free Software Foundation |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details |
13 | * |
14 | * You should have received a copy of the GNU Library General Public |
15 | * License along with this program; if not, write to the |
16 | * Free Software Foundation, Inc., |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef FREEREGIONGRABBER_H |
21 | #define FREEREGIONGRABBER_H |
22 | |
23 | #include <QWidget> |
24 | #include <QPoint> |
25 | #include <QRect> |
26 | #include <QPolygon> |
27 | |
28 | class QPaintEvent; |
29 | class QMouseEvent; |
30 | |
31 | class FreeRegionGrabber : public QWidget |
32 | { |
33 | Q_OBJECT |
34 | |
35 | public: |
36 | FreeRegionGrabber( const QPolygon &startFreeRegion ); |
37 | ~FreeRegionGrabber(); |
38 | |
39 | protected slots: |
40 | void init(); |
41 | |
42 | signals: |
43 | void freeRegionGrabbed( const QPixmap & ); |
44 | void freeRegionUpdated( const QPolygon & ); |
45 | |
46 | protected: |
47 | void paintEvent( QPaintEvent* e ); |
48 | void mousePressEvent( QMouseEvent* e ); |
49 | void mouseMoveEvent( QMouseEvent* e ); |
50 | void mouseReleaseEvent( QMouseEvent* e ); |
51 | void mouseDoubleClickEvent( QMouseEvent* ); |
52 | void keyPressEvent( QKeyEvent* e ); |
53 | void grabRect(); |
54 | |
55 | QPolygon selection; |
56 | bool mouseDown; |
57 | bool newSelection; |
58 | const int handleSize; |
59 | QRect* mouseOverHandle; |
60 | QPoint dragStartPoint; |
61 | QPolygon selectionBeforeDrag; |
62 | bool showHelp; |
63 | bool grabbing; |
64 | |
65 | QRect helpTextRect; |
66 | |
67 | QPixmap pixmap; |
68 | QPoint pBefore; |
69 | }; |
70 | |
71 | #endif |
72 | |