Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:22:51

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QSCROLLER_H
0006 #define QSCROLLER_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtCore/QObject>
0010 #include <QtCore/QPointF>
0011 #include <QtWidgets/QScrollerProperties>
0012 
0013 class tst_QScroller;
0014 
0015 QT_REQUIRE_CONFIG(scroller);
0016 
0017 QT_BEGIN_NAMESPACE
0018 
0019 
0020 class QWidget;
0021 class QScrollerPrivate;
0022 class QScrollerProperties;
0023 #ifndef QT_NO_GESTURES
0024 class QFlickGestureRecognizer;
0025 class QMouseFlickGestureRecognizer;
0026 #endif
0027 
0028 class Q_WIDGETS_EXPORT QScroller : public QObject
0029 {
0030     Q_OBJECT
0031     Q_PROPERTY(State state READ state NOTIFY stateChanged)
0032     Q_PROPERTY(QScrollerProperties scrollerProperties READ scrollerProperties
0033                WRITE setScrollerProperties NOTIFY scrollerPropertiesChanged)
0034 
0035 public:
0036     enum State
0037     {
0038         Inactive,
0039         Pressed,
0040         Dragging,
0041         Scrolling
0042     };
0043     Q_ENUM(State)
0044 
0045     enum ScrollerGestureType
0046     {
0047         TouchGesture,
0048         LeftMouseButtonGesture,
0049         RightMouseButtonGesture,
0050         MiddleMouseButtonGesture
0051     };
0052 
0053     enum Input
0054     {
0055         InputPress = 1,
0056         InputMove,
0057         InputRelease
0058     };
0059 
0060     static bool hasScroller(QObject *target);
0061 
0062     static QScroller *scroller(QObject *target);
0063     static const QScroller *scroller(const QObject *target);
0064 
0065 #ifndef QT_NO_GESTURES
0066     static Qt::GestureType grabGesture(QObject *target, ScrollerGestureType gestureType = TouchGesture);
0067     static Qt::GestureType grabbedGesture(QObject *target);
0068     static void ungrabGesture(QObject *target);
0069 #endif
0070 
0071     static QList<QScroller *> activeScrollers();
0072 
0073     QObject *target() const;
0074 
0075     State state() const;
0076 
0077     bool handleInput(Input input, const QPointF &position, qint64 timestamp = 0);
0078 
0079     void stop();
0080     QPointF velocity() const;
0081     QPointF finalPosition() const;
0082     QPointF pixelPerMeter() const;
0083 
0084     QScrollerProperties scrollerProperties() const;
0085 
0086     void setSnapPositionsX( const QList<qreal> &positions );
0087     void setSnapPositionsX( qreal first, qreal interval );
0088     void setSnapPositionsY( const QList<qreal> &positions );
0089     void setSnapPositionsY( qreal first, qreal interval );
0090 
0091 public Q_SLOTS:
0092     void setScrollerProperties(const QScrollerProperties &prop);
0093     void scrollTo(const QPointF &pos);
0094     void scrollTo(const QPointF &pos, int scrollTime);
0095     void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin);
0096     void ensureVisible(const QRectF &rect, qreal xmargin, qreal ymargin, int scrollTime);
0097     void resendPrepareEvent();
0098 
0099 Q_SIGNALS:
0100     void stateChanged(QScroller::State newstate);
0101     void scrollerPropertiesChanged(const QScrollerProperties &);
0102 
0103 private:
0104     QScrollerPrivate *d_ptr;
0105 
0106     QScroller(QObject *target);
0107     virtual ~QScroller();
0108 
0109     Q_DISABLE_COPY(QScroller)
0110     Q_DECLARE_PRIVATE(QScroller)
0111 
0112     friend class ::tst_QScroller;
0113 #ifndef QT_NO_GESTURES
0114     friend class QFlickGestureRecognizer;
0115 #endif
0116 };
0117 
0118 QT_END_NAMESPACE
0119 
0120 #endif // QSCROLLER_H