|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbCore module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #ifndef HBSCROLLAREA_H |
|
27 #define HBSCROLLAREA_H |
|
28 |
|
29 #include <hbwidget.h> |
|
30 |
|
31 class HbScrollAreaPrivate; |
|
32 class HbGestureSceneFilter; |
|
33 class HbScrollBar; |
|
34 |
|
35 |
|
36 class HB_CORE_EXPORT HbScrollArea : public HbWidget |
|
37 { |
|
38 Q_OBJECT |
|
39 |
|
40 Q_PROPERTY(Qt::Orientations scrollDirections READ scrollDirections WRITE setScrollDirections) |
|
41 Q_PROPERTY(ClampingStyle clampingStyle READ clampingStyle WRITE setClampingStyle) |
|
42 Q_PROPERTY(ScrollingStyle scrollingStyle READ scrollingStyle WRITE setScrollingStyle) |
|
43 Q_PROPERTY(bool frictionEnabled READ frictionEnabled WRITE setFrictionEnabled) |
|
44 Q_PROPERTY(bool longPressEnabled READ longPressEnabled WRITE setLongPressEnabled ) |
|
45 Q_PROPERTY(ScrollBarPolicy verticalScrollBarPolicy READ verticalScrollBarPolicy WRITE setVerticalScrollBarPolicy) |
|
46 Q_PROPERTY(ScrollBarPolicy horizontalScrollBarPolicy READ horizontalScrollBarPolicy WRITE setHorizontalScrollBarPolicy) |
|
47 Q_PROPERTY(Qt::Alignment alignment READ alignment WRITE setAlignment) |
|
48 Q_PROPERTY(bool continuationIndicators READ continuationIndicators WRITE setContinuationIndicators) |
|
49 |
|
50 Q_ENUMS(ClampingStyle) |
|
51 Q_ENUMS(ScrollingStyle) |
|
52 Q_ENUMS(ScrollBarPolicy) |
|
53 |
|
54 public: |
|
55 explicit HbScrollArea(QGraphicsItem *parent = 0); |
|
56 virtual ~HbScrollArea(); |
|
57 |
|
58 enum ClampingStyle { |
|
59 StrictClamping = 0, |
|
60 BounceBackClamping, |
|
61 NoClamping |
|
62 }; |
|
63 |
|
64 enum ScrollingStyle { |
|
65 Pan = 0, |
|
66 PanOrFlick, |
|
67 PanWithFollowOn |
|
68 }; |
|
69 |
|
70 enum ScrollBarPolicy { |
|
71 ScrollBarAsNeeded = Qt::ScrollBarAsNeeded, |
|
72 ScrollBarAlwaysOff = Qt::ScrollBarAlwaysOff, |
|
73 ScrollBarAlwaysOn = Qt::ScrollBarAlwaysOn, |
|
74 ScrollBarAutoHide |
|
75 }; |
|
76 |
|
77 QGraphicsWidget *contentWidget() const; |
|
78 void setContentWidget(QGraphicsWidget *widget); |
|
79 QGraphicsWidget *takeContentWidget(); |
|
80 |
|
81 ClampingStyle clampingStyle() const; |
|
82 void setClampingStyle(ClampingStyle value); |
|
83 |
|
84 ScrollingStyle scrollingStyle() const; |
|
85 void setScrollingStyle(ScrollingStyle value); |
|
86 |
|
87 Qt::Orientations scrollDirections() const; |
|
88 void setScrollDirections(Qt::Orientations value); |
|
89 |
|
90 bool frictionEnabled() const; |
|
91 void setFrictionEnabled(bool value); |
|
92 |
|
93 bool longPressEnabled() const; |
|
94 void setLongPressEnabled(bool value); |
|
95 |
|
96 ScrollBarPolicy verticalScrollBarPolicy() const; |
|
97 void setVerticalScrollBarPolicy(ScrollBarPolicy policy); |
|
98 HbScrollBar *verticalScrollBar() const; |
|
99 void setVerticalScrollBar(HbScrollBar *scrollBar); |
|
100 |
|
101 ScrollBarPolicy horizontalScrollBarPolicy() const; |
|
102 void setHorizontalScrollBarPolicy(ScrollBarPolicy policy); |
|
103 HbScrollBar *horizontalScrollBar() const; |
|
104 void setHorizontalScrollBar(HbScrollBar *scrollBar); |
|
105 |
|
106 Qt::Alignment alignment() const; |
|
107 void setAlignment(Qt::Alignment alignment); |
|
108 |
|
109 bool continuationIndicators() const; |
|
110 void setContinuationIndicators(bool indication); |
|
111 |
|
112 bool isScrolling() const; |
|
113 bool isDragging() const; |
|
114 void ensureVisible(const QPointF &position, qreal xMargin = 0.0, qreal yMargin = 0.0); |
|
115 |
|
116 void scrollContentsTo (const QPointF &newPosition, int time = 0); |
|
117 |
|
118 protected: |
|
119 HbScrollArea(HbScrollAreaPrivate &dd, QGraphicsItem *parent); |
|
120 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); |
|
121 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); |
|
122 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; |
|
123 virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value); |
|
124 virtual bool event(QEvent *event); |
|
125 virtual void focusOutEvent(QFocusEvent *event); |
|
126 virtual bool scrollByAmount(const QPointF &delta); |
|
127 virtual void polish(HbStyleParameters ¶ms); |
|
128 virtual bool eventFilter(QObject *obj, QEvent *event); |
|
129 |
|
130 signals: |
|
131 void scrollingStarted(); |
|
132 void scrollingEnded(); |
|
133 void scrollDirectionsChanged(Qt::Orientations newValue); |
|
134 void gestureSceneFilterChanged(HbGestureSceneFilter *newFilter); |
|
135 void scrollPositionChanged(const QPointF &newPosition); |
|
136 |
|
137 protected slots: |
|
138 virtual void upGesture(int value); |
|
139 virtual void downGesture(int value); |
|
140 virtual void leftGesture(int value); |
|
141 virtual void rightGesture(int value); |
|
142 virtual void panGesture(const QPointF &point); |
|
143 virtual void longPressGesture(const QPointF &point); |
|
144 |
|
145 private: |
|
146 Q_DECLARE_PRIVATE_D(d_ptr, HbScrollArea) |
|
147 Q_PRIVATE_SLOT(d_func(), void _q_animateScrollTimeout()) |
|
148 Q_PRIVATE_SLOT(d_func(), void _q_hideScrollBars()) |
|
149 Q_PRIVATE_SLOT(d_func(), void _q_thumbPositionChanged(qreal value, Qt::Orientation orientation)) |
|
150 Q_PRIVATE_SLOT(d_func(), void _q_groovePressed(qreal value, Qt::Orientation orientation)) |
|
151 |
|
152 |
|
153 }; |
|
154 |
|
155 #endif // HBSCROLLAREA_H |