1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the demonstration applications of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
47 QT_FORWARD_DECLARE_CLASS(QBypassWidget
)
49 class HoverPoints
: public QObject
77 HoverPoints(QWidget
*widget
, PointShape shape
);
79 bool eventFilter(QObject
*object
, QEvent
*event
);
83 inline QRectF
boundingRect() const;
84 void setBoundingRect(const QRectF
&boundingRect
) { m_bounds
= boundingRect
; }
86 QPolygonF
points() const { return m_points
; }
87 void setPoints(const QPolygonF
&points
);
89 QSizeF
pointSize() const { return m_pointSize
; }
90 void setPointSize(const QSizeF
&size
) { m_pointSize
= size
; }
92 SortType
sortType() const { return m_sortType
; }
93 void setSortType(SortType sortType
) { m_sortType
= sortType
; }
95 ConnectionType
connectionType() const { return m_connectionType
; }
96 void setConnectionType(ConnectionType connectionType
) { m_connectionType
= connectionType
; }
98 void setConnectionPen(const QPen
&pen
) { m_connectionPen
= pen
; }
99 void setShapePen(const QPen
&pen
) { m_pointPen
= pen
; }
100 void setShapeBrush(const QBrush
&brush
) { m_pointBrush
= brush
; }
102 void setPointLock(int pos
, LockType lock
) { m_locks
[pos
] = lock
; }
104 void setEditable(bool editable
) { m_editable
= editable
; }
105 bool editable() const { return m_editable
; }
108 void setEnabled(bool enabled
);
109 void setDisabled(bool disabled
) { setEnabled(!disabled
); }
112 void pointsChanged(const QPolygonF
&points
);
115 void firePointChange();
118 inline QRectF
pointBoundingRect(int i
) const;
119 void movePoint(int i
, const QPointF
&newPos
, bool emitChange
= true);
127 ConnectionType m_connectionType
;
129 QVector
<uint
> m_locks
;
136 QHash
<int, int> m_fingerPointMapping
;
140 QPen m_connectionPen
;
144 inline QRectF
HoverPoints::pointBoundingRect(int i
) const
146 QPointF p
= m_points
.at(i
);
147 qreal w
= m_pointSize
.width();
148 qreal h
= m_pointSize
.height();
149 qreal x
= p
.x() - w
/ 2;
150 qreal y
= p
.y() - h
/ 2;
151 return QRectF(x
, y
, w
, h
);
154 inline QRectF
HoverPoints::boundingRect() const
156 if (m_bounds
.isEmpty())
157 return m_widget
->rect();
162 #endif // HOVERPOINTS_H