Windows doesn't #define STD{IN,OUT,ERR}_FILENO
[qt-netbsd.git] / demos / shared / hoverpoints.h
blob23ac8c1e1c7f83218244e09e0902fbc18a0f84d7
1 /****************************************************************************
2 **
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
6 **
7 ** This file is part of the demonstration applications of the Qt Toolkit.
8 **
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
14 ** this package.
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.
38 ** $QT_END_LICENSE$
40 ****************************************************************************/
42 #ifndef HOVERPOINTS_H
43 #define HOVERPOINTS_H
45 #include <QtGui>
47 QT_FORWARD_DECLARE_CLASS(QBypassWidget)
49 class HoverPoints : public QObject
51 Q_OBJECT
52 public:
53 enum PointShape {
54 CircleShape,
55 RectangleShape
58 enum LockType {
59 LockToLeft = 0x01,
60 LockToRight = 0x02,
61 LockToTop = 0x04,
62 LockToBottom = 0x08
65 enum SortType {
66 NoSort,
67 XSort,
68 YSort
71 enum ConnectionType {
72 NoConnection,
73 LineConnection,
74 CurveConnection
77 HoverPoints(QWidget *widget, PointShape shape);
79 bool eventFilter(QObject *object, QEvent *event);
81 void paintPoints();
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; }
107 public slots:
108 void setEnabled(bool enabled);
109 void setDisabled(bool disabled) { setEnabled(!disabled); }
111 signals:
112 void pointsChanged(const QPolygonF &points);
114 public:
115 void firePointChange();
117 private:
118 inline QRectF pointBoundingRect(int i) const;
119 void movePoint(int i, const QPointF &newPos, bool emitChange = true);
121 QWidget *m_widget;
123 QPolygonF m_points;
124 QRectF m_bounds;
125 PointShape m_shape;
126 SortType m_sortType;
127 ConnectionType m_connectionType;
129 QVector<uint> m_locks;
131 QSizeF m_pointSize;
132 int m_currentIndex;
133 bool m_editable;
134 bool m_enabled;
136 QHash<int, int> m_fingerPointMapping;
138 QPen m_pointPen;
139 QBrush m_pointBrush;
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();
158 else
159 return m_bounds;
162 #endif // HOVERPOINTS_H