66 */ |
66 */ |
67 |
67 |
68 /*! |
68 /*! |
69 \fn void HbScrollBar::valueChanged( qreal value, Qt::Orientation orientation ) |
69 \fn void HbScrollBar::valueChanged( qreal value, Qt::Orientation orientation ) |
70 |
70 |
71 This signal is emitted when thumb position is changed from user interaction. |
71 This signal is emitted when thumb position is changed by the user. |
72 */ |
72 */ |
|
73 |
|
74 /*! |
|
75 \fn void valueChangeRequested( qreal value, Qt::Orientation orientation ); |
|
76 |
|
77 This signal is emitted when the user presses scrollbar groove. |
|
78 |
|
79 \param value, the new value of scrollbar after the change |
|
80 */ |
|
81 |
|
82 /*! |
|
83 \primitives |
|
84 \primitive{groove} HbFrameItem representing the groove of a scrollbar. |
|
85 \primitive{handle} HbFrameItem representing the handle of a scrollbar. |
|
86 \primitive{toucharea} HbTouchArea representing the scrollbar toucharea. |
|
87 */ |
73 |
88 |
74 HbScrollBarPrivate::HbScrollBarPrivate(): |
89 HbScrollBarPrivate::HbScrollBarPrivate(): |
75 mOrientation(Qt::Vertical), |
90 mOrientation(Qt::Vertical), |
76 mCurrentPosition(0.5), |
91 mCurrentPosition(0.5), |
77 mPageSize(1.0), |
92 mPageSize(1.0), |
122 q->updatePrimitives(); |
137 q->updatePrimitives(); |
123 } |
138 } |
124 |
139 |
125 void HbScrollBarPrivate::updatePosition() |
140 void HbScrollBarPrivate::updatePosition() |
126 { |
141 { |
127 if(!mHandleGeometry.isValid() || !handleItem) |
|
128 return; |
|
129 if (handleItem){ |
142 if (handleItem){ |
130 if (mOrientation == Qt::Vertical) { |
143 if (mOrientation == Qt::Vertical) { |
131 handleItem->setPos(mHandleGeometry.topLeft().x(), mCurrentPosition * (mBoundingRect.height() - mHandleGeometry.height())); |
144 handleItem->setPos(mTopLeft, mCurrentPosition * mLimitingFactor); |
132 } else { |
145 } else { |
133 handleItem->setPos(mCurrentPosition * (mBoundingRect.width() - mHandleGeometry.width()), mHandleGeometry.topLeft().y()); |
146 handleItem->setPos(mCurrentPosition * mLimitingFactor, mTopLeft); |
134 } |
147 } |
135 } |
148 } |
136 } |
149 } |
137 |
150 |
138 void HbScrollBarPrivate::sizeHelper() |
151 void HbScrollBarPrivate::sizeHelper() |
140 if(!polished) |
153 if(!polished) |
141 return; |
154 return; |
142 Q_Q(HbScrollBar); |
155 Q_Q(HbScrollBar); |
143 if(handleItem){ |
156 if(handleItem){ |
144 HbFrameItem *item = qgraphicsitem_cast<HbFrameItem*>(handleItem); |
157 HbFrameItem *item = qgraphicsitem_cast<HbFrameItem*>(handleItem); |
145 mBoundingRect = q->boundingRect(); |
158 QRectF bRect = q->boundingRect(); |
146 if(item){ |
159 if(item){ |
147 if (mOrientation == Qt::Vertical) { |
160 if (mOrientation == Qt::Vertical) { |
148 qreal height(mPageSize * mBoundingRect.height()); |
161 qreal height(mPageSize * bRect.height()); |
149 if(!qFuzzyCompare(item->preferredHeight(),height)){ |
162 if(!qFuzzyCompare(item->preferredHeight(),height)){ |
150 item->setPreferredHeight(height); |
163 item->setPreferredHeight(height); |
151 item->resize(item->size().width(), height); |
164 item->resize(item->size().width(), height); |
152 } |
165 } |
|
166 mLimitingFactor = bRect.height() - item->geometry().height(); |
|
167 mTopLeft = item->geometry().topLeft().x(); |
153 } else { |
168 } else { |
154 qreal width(mPageSize * mBoundingRect.width()); |
169 qreal width(mPageSize * bRect.width()); |
155 if(!qFuzzyCompare(item->preferredWidth(),width)){ |
170 if(!qFuzzyCompare(item->preferredWidth(),width)){ |
156 item->setPreferredWidth(width); |
171 item->setPreferredWidth(width); |
157 item->resize(width, item->size().height()); |
172 item->resize(width, item->size().height()); |
158 } |
173 } |
|
174 mLimitingFactor = bRect.width() - item->geometry().width(); |
|
175 mTopLeft = item->geometry().topLeft().y(); |
159 } |
176 } |
160 mHandleGeometry = item->geometry(); |
|
161 updatePosition(); |
177 updatePosition(); |
162 } |
178 } |
163 } |
179 } |
164 } |
180 } |
165 |
181 |
238 /*! |
254 /*! |
239 Returns the value of the scrollbar. The value is in range of 0.0 to 1.0. |
255 Returns the value of the scrollbar. The value is in range of 0.0 to 1.0. |
240 The value corresponds to the position of the thumb. |
256 The value corresponds to the position of the thumb. |
241 |
257 |
242 \sa HbScrollBar::setValue() |
258 \sa HbScrollBar::setValue() |
243 */ |
259 */ |
244 qreal HbScrollBar::value() const |
260 qreal HbScrollBar::value() const |
245 { |
261 { |
246 Q_D( const HbScrollBar ); |
262 Q_D( const HbScrollBar ); |
247 return d->mCurrentPosition; |
263 return d->mCurrentPosition; |
248 } |
264 } |
252 For example if the pageSize is 0.2 it means that the overall size of the content |
268 For example if the pageSize is 0.2 it means that the overall size of the content |
253 is five times larger than what is shown currently. |
269 is five times larger than what is shown currently. |
254 |
270 |
255 The size is in range of 0.0 to 1.0. |
271 The size is in range of 0.0 to 1.0. |
256 \sa HbScrollBar::setPageSize() |
272 \sa HbScrollBar::setPageSize() |
257 */ |
273 */ |
258 qreal HbScrollBar::pageSize() const |
274 qreal HbScrollBar::pageSize() const |
259 { |
275 { |
260 Q_D( const HbScrollBar ); |
276 Q_D( const HbScrollBar ); |
261 return d->mPageSize; |
277 return d->mPageSize; |
262 } |
278 } |
263 |
279 |
264 /*! |
280 /*! |
265 Returns the orientation of scrollbar. |
281 Returns the orientation of scrollbar. |
266 |
282 |
267 \sa HbScrollBar::setOrientation() |
283 \sa HbScrollBar::setOrientation() |
268 */ |
284 */ |
269 Qt::Orientation HbScrollBar::orientation() const |
285 Qt::Orientation HbScrollBar::orientation() const |
270 { |
286 { |
271 Q_D( const HbScrollBar ); |
287 Q_D( const HbScrollBar ); |
272 return d->mOrientation; |
288 return d->mOrientation; |
273 } |
289 } |
316 */ |
332 */ |
317 void HbScrollBar::setValue( qreal value ) |
333 void HbScrollBar::setValue( qreal value ) |
318 { |
334 { |
319 Q_D(HbScrollBar); |
335 Q_D(HbScrollBar); |
320 |
336 |
321 value = qBound(static_cast<qreal>(0.0), value, static_cast<qreal>(1.0)); |
337 value = qBound(qreal(0.0), value, qreal(1.0)); |
322 if( !qFuzzyCompare(d->mCurrentPosition,value )) { |
338 if( !qFuzzyCompare(d->mCurrentPosition,value )) { |
323 d->mCurrentPosition = value; |
339 d->mCurrentPosition = value; |
324 d->updatePosition(); |
340 d->updatePosition(); |
325 } |
341 } |
326 } |
342 } |
334 \sa HbScrollBar::pageSize() |
350 \sa HbScrollBar::pageSize() |
335 */ |
351 */ |
336 void HbScrollBar::setPageSize( qreal size ) |
352 void HbScrollBar::setPageSize( qreal size ) |
337 { |
353 { |
338 Q_D(HbScrollBar); |
354 Q_D(HbScrollBar); |
339 size = qBound(static_cast<qreal>(0.0), size, static_cast<qreal>(1.0)); |
355 size = qBound(qreal(0.0), size, qreal(1.0)); |
340 |
356 |
341 if(!qFuzzyCompare(d->mPageSize,size)) { |
357 if(!qFuzzyCompare(d->mPageSize,size)) { |
342 d->mPageSize = size; |
358 d->mPageSize = size; |
343 d->sizeHelper(); |
359 d->sizeHelper(); |
344 } |
360 } |
600 { |
616 { |
601 HbWidget::resizeEvent(event); |
617 HbWidget::resizeEvent(event); |
602 Q_D(HbScrollBar); |
618 Q_D(HbScrollBar); |
603 if (d->handleItem) { |
619 if (d->handleItem) { |
604 HbFrameItem* item = (qgraphicsitem_cast<HbFrameItem*>(d->handleItem)); |
620 HbFrameItem* item = (qgraphicsitem_cast<HbFrameItem*>(d->handleItem)); |
605 d->mHandleGeometry = item->geometry(); |
621 QRectF geo = item->geometry(); |
|
622 if (d->mOrientation == Qt::Vertical) { |
|
623 d->mTopLeft = geo.topLeft().x(); |
|
624 d->mLimitingFactor = boundingRect().height() - geo.height(); |
|
625 } else { |
|
626 d->mTopLeft = geo.topLeft().y(); |
|
627 d->mLimitingFactor = boundingRect().width() - geo.width(); |
|
628 } |
606 } |
629 } |
607 } |
630 } |
608 |
631 |
609 /*! |
632 /*! |
610 \reimp |
633 \reimp |