src/declarative/graphicsitems/qdeclarativeflickable_p.h
changeset 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 QtDeclarative module 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.
       
    15 **
       
    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.
       
    23 **
       
    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.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QDECLARATIVEFLICKABLE_H
       
    43 #define QDECLARATIVEFLICKABLE_H
       
    44 
       
    45 #include "qdeclarativeitem.h"
       
    46 
       
    47 QT_BEGIN_HEADER
       
    48 
       
    49 QT_BEGIN_NAMESPACE
       
    50 
       
    51 QT_MODULE(Declarative)
       
    52 
       
    53 class QDeclarativeFlickablePrivate;
       
    54 class QDeclarativeFlickableVisibleArea;
       
    55 class Q_DECLARATIVE_EXPORT QDeclarativeFlickable : public QDeclarativeItem
       
    56 {
       
    57     Q_OBJECT
       
    58 
       
    59     Q_PROPERTY(qreal contentWidth READ contentWidth WRITE setContentWidth NOTIFY contentWidthChanged)
       
    60     Q_PROPERTY(qreal contentHeight READ contentHeight WRITE setContentHeight NOTIFY contentHeightChanged)
       
    61     Q_PROPERTY(qreal contentX READ contentX WRITE setContentX NOTIFY contentXChanged)
       
    62     Q_PROPERTY(qreal contentY READ contentY WRITE setContentY NOTIFY contentYChanged)
       
    63 
       
    64     Q_PROPERTY(qreal horizontalVelocity READ horizontalVelocity NOTIFY horizontalVelocityChanged)
       
    65     Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged)
       
    66 
       
    67     Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged) // deprecated
       
    68     Q_PROPERTY(BoundsBehavior boundsBehavior READ boundsBehavior WRITE setBoundsBehavior NOTIFY boundsBehaviorChanged)
       
    69     Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged)
       
    70     Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged)
       
    71     Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged)
       
    72     Q_PROPERTY(bool movingHorizontally READ isMovingHorizontally NOTIFY movingHorizontallyChanged)
       
    73     Q_PROPERTY(bool movingVertically READ isMovingVertically NOTIFY movingVerticallyChanged)
       
    74     Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged)
       
    75     Q_PROPERTY(bool flickingHorizontally READ isFlickingHorizontally NOTIFY flickingHorizontallyChanged)
       
    76     Q_PROPERTY(bool flickingVertically READ isFlickingVertically NOTIFY flickingVerticallyChanged)
       
    77     Q_PROPERTY(FlickableDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickableDirectionChanged) // deprecated
       
    78     Q_PROPERTY(FlickableDirection flickableDirection READ flickableDirection WRITE setFlickableDirection NOTIFY flickableDirectionChanged)
       
    79 
       
    80     Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged)
       
    81     Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged)
       
    82 
       
    83     Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged)
       
    84     Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged)
       
    85     Q_PROPERTY(bool atXBeginning READ isAtXBeginning NOTIFY isAtBoundaryChanged)
       
    86     Q_PROPERTY(bool atYBeginning READ isAtYBeginning NOTIFY isAtBoundaryChanged)
       
    87 
       
    88     Q_PROPERTY(QDeclarativeFlickableVisibleArea *visibleArea READ visibleArea CONSTANT)
       
    89 
       
    90     Q_PROPERTY(QDeclarativeListProperty<QObject> flickableData READ flickableData)
       
    91     Q_PROPERTY(QDeclarativeListProperty<QGraphicsObject> flickableChildren READ flickableChildren)
       
    92     Q_CLASSINFO("DefaultProperty", "flickableData")
       
    93 
       
    94     Q_ENUMS(FlickableDirection)
       
    95     Q_ENUMS(BoundsBehavior)
       
    96 
       
    97 public:
       
    98     QDeclarativeFlickable(QDeclarativeItem *parent=0);
       
    99     ~QDeclarativeFlickable();
       
   100 
       
   101     QDeclarativeListProperty<QObject> flickableData();
       
   102     QDeclarativeListProperty<QGraphicsObject> flickableChildren();
       
   103 
       
   104     bool overShoot() const;
       
   105     void setOverShoot(bool);
       
   106 
       
   107     enum BoundsBehavior { StopAtBounds, DragOverBounds, DragAndOvershootBounds };
       
   108     BoundsBehavior boundsBehavior() const;
       
   109     void setBoundsBehavior(BoundsBehavior);
       
   110 
       
   111     qreal contentWidth() const;
       
   112     void setContentWidth(qreal);
       
   113 
       
   114     qreal contentHeight() const;
       
   115     void setContentHeight(qreal);
       
   116 
       
   117     qreal contentX() const;
       
   118     void setContentX(qreal pos);
       
   119 
       
   120     qreal contentY() const;
       
   121     void setContentY(qreal pos);
       
   122 
       
   123     bool isMoving() const;
       
   124     bool isMovingHorizontally() const;
       
   125     bool isMovingVertically() const;
       
   126     bool isFlicking() const;
       
   127     bool isFlickingHorizontally() const;
       
   128     bool isFlickingVertically() const;
       
   129 
       
   130     int pressDelay() const;
       
   131     void setPressDelay(int delay);
       
   132 
       
   133     qreal maximumFlickVelocity() const;
       
   134     void setMaximumFlickVelocity(qreal);
       
   135 
       
   136     qreal flickDeceleration() const;
       
   137     void setFlickDeceleration(qreal);
       
   138 
       
   139     bool isInteractive() const;
       
   140     void setInteractive(bool);
       
   141 
       
   142     qreal horizontalVelocity() const;
       
   143     qreal verticalVelocity() const;
       
   144 
       
   145     bool isAtXEnd() const;
       
   146     bool isAtXBeginning() const;
       
   147     bool isAtYEnd() const;
       
   148     bool isAtYBeginning() const;
       
   149 
       
   150     QDeclarativeItem *viewport();
       
   151 
       
   152     enum FlickableDirection { AutoFlickDirection=0x00, HorizontalFlick=0x01, VerticalFlick=0x02, HorizontalAndVerticalFlick=0x03 };
       
   153     FlickableDirection flickDirection() const; // deprecated
       
   154     void setFlickDirection(FlickableDirection); // deprecated
       
   155     FlickableDirection flickableDirection() const;
       
   156     void setFlickableDirection(FlickableDirection);
       
   157 
       
   158 Q_SIGNALS:
       
   159     void contentWidthChanged();
       
   160     void contentHeightChanged();
       
   161     void contentXChanged();
       
   162     void contentYChanged();
       
   163     void movingChanged();
       
   164     void movingHorizontallyChanged();
       
   165     void movingVerticallyChanged();
       
   166     void flickingChanged();
       
   167     void flickingHorizontallyChanged();
       
   168     void flickingVerticallyChanged();
       
   169     void horizontalVelocityChanged();
       
   170     void verticalVelocityChanged();
       
   171     void isAtBoundaryChanged();
       
   172     void pageChanged();
       
   173     void flickableDirectionChanged();
       
   174     void interactiveChanged();
       
   175     void overShootChanged();
       
   176     void boundsBehaviorChanged();
       
   177     void maximumFlickVelocityChanged();
       
   178     void flickDecelerationChanged();
       
   179     void pressDelayChanged();
       
   180     void movementStarted();
       
   181     void movementEnded();
       
   182     void flickStarted();
       
   183     void flickEnded();
       
   184 
       
   185 protected:
       
   186     virtual bool sceneEventFilter(QGraphicsItem *, QEvent *);
       
   187     void mousePressEvent(QGraphicsSceneMouseEvent *event);
       
   188     void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
       
   189     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
       
   190     void wheelEvent(QGraphicsSceneWheelEvent *event);
       
   191     void timerEvent(QTimerEvent *event);
       
   192 
       
   193     QDeclarativeFlickableVisibleArea *visibleArea();
       
   194 
       
   195 protected Q_SLOTS:
       
   196     virtual void ticked();
       
   197     void movementStarting();
       
   198     void movementEnding();
       
   199 
       
   200 protected:
       
   201     virtual qreal minXExtent() const;
       
   202     virtual qreal minYExtent() const;
       
   203     virtual qreal maxXExtent() const;
       
   204     virtual qreal maxYExtent() const;
       
   205     qreal vWidth() const;
       
   206     qreal vHeight() const;
       
   207     virtual void viewportMoved();
       
   208     virtual void geometryChanged(const QRectF &newGeometry,
       
   209                                  const QRectF &oldGeometry);
       
   210     bool sendMouseEvent(QGraphicsSceneMouseEvent *event);
       
   211 
       
   212     bool xflick() const;
       
   213     bool yflick() const;
       
   214     void cancelFlick();
       
   215 
       
   216 protected:
       
   217     QDeclarativeFlickable(QDeclarativeFlickablePrivate &dd, QDeclarativeItem *parent);
       
   218 
       
   219 private:
       
   220     Q_DISABLE_COPY(QDeclarativeFlickable)
       
   221     Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeFlickable)
       
   222     friend class QDeclarativeFlickableVisibleArea;
       
   223 };
       
   224 
       
   225 QT_END_NAMESPACE
       
   226 
       
   227 QML_DECLARE_TYPE(QDeclarativeFlickable)
       
   228 
       
   229 QT_END_HEADER
       
   230 
       
   231 #endif