112 } |
112 } |
113 |
113 |
114 TAknLayoutRect layRect; |
114 TAknLayoutRect layRect; |
115 TAknWindowComponentLayout layout = AknLayoutScalable_Avkon::scroll_bg_pane_g1( varietyIndex ); //top |
115 TAknWindowComponentLayout layout = AknLayoutScalable_Avkon::scroll_bg_pane_g1( varietyIndex ); //top |
116 layRect.LayoutRect( rect, layout.LayoutLine() ); |
116 layRect.LayoutRect( rect, layout.LayoutLine() ); |
117 TSize newSize = layRect.Rect().Size(); |
117 TSize newSize( layRect.Rect().Size() ); |
118 iHeadItemSize = (iOrientation == CEikScrollBar::EVertical?newSize.iHeight:newSize.iWidth); |
118 iHeadItemSize = (iOrientation == CEikScrollBar::EVertical?newSize.iHeight:newSize.iWidth); |
119 |
119 |
120 layout = AknLayoutScalable_Avkon::scroll_bg_pane_g3(varietyIndex); // bottom |
120 layout = AknLayoutScalable_Avkon::scroll_bg_pane_g3(varietyIndex); // bottom |
121 layRect.LayoutRect(rect, layout.LayoutLine()); |
121 layRect.LayoutRect(rect, layout.LayoutLine()); |
122 newSize = layRect.Rect().Size(); |
122 newSize = layRect.Rect().Size(); |
123 iTailItemSize = (iOrientation == CEikScrollBar::EVertical?newSize.iHeight:newSize.iWidth); |
123 iTailItemSize = (iOrientation == CEikScrollBar::EVertical?newSize.iHeight:newSize.iWidth); |
124 |
|
125 layout = AknLayoutScalable_Avkon::scroll_bg_pane_g2(varietyIndex); //middle |
|
126 layRect.LayoutRect(rect, layout.LayoutLine()); |
|
127 newSize = layRect.Rect().Size(); |
|
128 // iMidItemSize = (iOrientation == CEikScrollBar::EVertical?newSize.iHeight:newSize.iWidth) * 5; |
|
129 } |
124 } |
130 |
125 |
131 void CAknDoubleSpanScrollIndicator::DrawTiled( |
126 void CAknDoubleSpanScrollIndicator::DrawTiled( |
132 CWindowGc& aGc, const TRect& aRect, |
127 CWindowGc& aGc, const TRect& aRect, |
133 CAknDoubleSpanScrollIndicatorItem *aIndicatorItem) const |
128 CAknDoubleSpanScrollIndicatorItem *aIndicatorItem) const |
153 tailRect.iTl.iY = tailRect.iBr.iY - headRect.Height(); |
148 tailRect.iTl.iY = tailRect.iBr.iY - headRect.Height(); |
154 } |
149 } |
155 midRect.iTl.iY += headRect.Height(); |
150 midRect.iTl.iY += headRect.Height(); |
156 midRect.iBr.iY -= tailRect.Height(); |
151 midRect.iBr.iY -= tailRect.Height(); |
157 midDrawLength = midRect.Height(); |
152 midDrawLength = midRect.Height(); |
158 midSize.SetSize(midRect.Width(), iMidItemSize); |
153 midSize.SetSize(midRect.Width(), midDrawLength); |
159 } |
154 } |
160 else |
155 else |
161 { |
156 { |
162 headRect.SetWidth( iHeadItemSize ); |
157 headRect.SetWidth( iHeadItemSize ); |
163 tailRect.iTl.iX = tailRect.iBr.iX - iTailItemSize; |
158 tailRect.iTl.iX = tailRect.iBr.iX - iTailItemSize; |
164 |
159 |
165 midRect.iTl.iX += iHeadItemSize; |
160 midRect.iTl.iX += iHeadItemSize; |
166 midRect.iBr.iX -= iTailItemSize; |
161 midRect.iBr.iX -= iTailItemSize; |
167 midDrawLength = midRect.Width(); |
162 midDrawLength = midRect.Width(); |
168 midSize.SetSize(iMidItemSize, midRect.Height()); |
163 midSize.SetSize(midDrawLength, midRect.Height()); |
169 } |
164 } |
170 |
165 |
171 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
166 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
172 |
167 |
173 CFbsBitmap *bmp = NULL; |
168 CFbsBitmap *bmp = NULL; |
174 CFbsBitmap *mask = NULL; |
169 CFbsBitmap *mask = NULL; |
175 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iTopId, bmp, mask); |
170 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iTopId, bmp, mask); |
176 AknIconUtils::SetSize(bmp, headRect.Size(), EAspectRatioNotPreserved); |
171 AknIconUtils::SetSize(bmp, headRect.Size(), EAspectRatioNotPreserved); |
177 AknIconUtils::SetSize(mask, headRect.Size(), EAspectRatioNotPreserved); |
172 AknIconUtils::SetSize(mask, headRect.Size(), EAspectRatioNotPreserved); |
178 aGc.BitBltMasked(headRect.iTl, bmp, TRect(TPoint(0, 0), headRect.Size()), mask, ETrue); |
173 aGc.BitBltMasked(headRect.iTl, bmp, TRect(headRect.Size()), mask, ETrue); |
179 |
174 |
180 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iMidId, bmp, mask); |
175 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iMidId, bmp, mask); |
181 AknIconUtils::SetSize(bmp, midSize, EAspectRatioNotPreserved); |
176 AknIconUtils::SetSize(bmp, midSize, EAspectRatioNotPreserved); |
182 AknIconUtils::SetSize(mask, midSize, EAspectRatioNotPreserved); |
177 AknIconUtils::SetSize(mask, midSize, EAspectRatioNotPreserved); |
183 |
178 |
184 TInt count = midDrawLength / iMidItemSize; |
|
185 TPoint destPos(midRect.iTl.iX, midRect.iTl.iY); |
179 TPoint destPos(midRect.iTl.iX, midRect.iTl.iY); |
186 TRect sourRect(TPoint(0, 0), bmp->SizeInPixels()); |
180 TRect sourRect(bmp->SizeInPixels()); |
187 for(TInt i = 0; i < count; i++) |
|
188 { |
|
189 aGc.BitBltMasked(destPos, bmp, sourRect, mask, ETrue); |
|
190 iOrientation == CEikScrollBar::EVertical?destPos.iY += iMidItemSize : destPos.iX += iMidItemSize; |
|
191 } |
|
192 iOrientation == CEikScrollBar::EVertical?sourRect.iBr.iY = midRect.Height() % iMidItemSize |
|
193 :sourRect.iBr.iX = midRect.Width() % iMidItemSize; |
|
194 aGc.BitBltMasked(destPos, bmp, sourRect, mask, ETrue); |
181 aGc.BitBltMasked(destPos, bmp, sourRect, mask, ETrue); |
195 |
182 |
196 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iBottomId, bmp, mask); |
183 AknsUtils::GetCachedMaskedBitmap(skin, aIndicatorItem->iBottomId, bmp, mask); |
197 AknIconUtils::SetSize(bmp, tailRect.Size(), EAspectRatioNotPreserved); |
184 AknIconUtils::SetSize(bmp, tailRect.Size(), EAspectRatioNotPreserved); |
198 AknIconUtils::SetSize(mask, tailRect.Size(), EAspectRatioNotPreserved); |
185 AknIconUtils::SetSize(mask, tailRect.Size(), EAspectRatioNotPreserved); |
199 aGc.BitBltMasked(tailRect.iTl, bmp, TRect(TPoint(0, 0), tailRect.Size()), mask, ETrue); |
186 aGc.BitBltMasked(tailRect.iTl, bmp, TRect(tailRect.Size()), mask, ETrue); |
200 } |
187 } |
201 |
188 |
202 void CAknDoubleSpanScrollIndicator::CalculateRects() |
189 void CAknDoubleSpanScrollIndicator::CalculateRects() |
203 { |
190 { |
204 iBackgroundRect = Rect(); |
191 iBackgroundRect = Rect(); |
287 roomForMovementInSpan; |
262 roomForMovementInSpan; |
288 } |
263 } |
289 |
264 |
290 // If window would cover whole scrollbar, then modify |
265 // If window would cover whole scrollbar, then modify |
291 // it to leave the thumb little short from bottom |
266 // it to leave the thumb little short from bottom |
292 TInt scrollBarHandleMaxSizeInPixels = ScrollHandleMaxVisibleSizeInPixels(); |
267 TInt scrollBarHandleMaxSizeInPixels = iHandleMaxSize; |
|
268 |
293 if (windowSizeInPixels >= scrollBarHeightInPixels) |
269 if (windowSizeInPixels >= scrollBarHeightInPixels) |
294 { |
270 { |
295 windowSizeInPixels = scrollBarHandleMaxSizeInPixels; |
271 windowSizeInPixels = scrollBarHandleMaxSizeInPixels; |
296 } |
272 } |
297 |
273 |
298 TBool doubleSpanInUse = (checkedFieldPosition >= 0) && (checkedFieldSize > 0); |
274 TBool doubleSpanInUse = (checkedFieldPosition >= 0) && (checkedFieldSize > 0); |
299 TInt minHandleBackgroundSize = 0; |
275 TInt minHandleBackgroundSize = iHandleMinSize; |
300 TInt fieldSizeInPixels = 0; // sub field size |
276 TInt fieldSizeInPixels = 0; // sub field size |
301 TInt fieldPositionInPixels = 0; |
277 TInt fieldPositionInPixels = 0; |
|
278 TInt handleMinSize = iHandleMinSize; |
|
279 |
302 if (doubleSpanInUse) |
280 if (doubleSpanInUse) |
303 { |
281 { |
304 fieldSizeInPixels = windowSizeInPixels/checkedFieldSize; |
282 fieldSizeInPixels = windowSizeInPixels/checkedFieldSize; |
305 fieldPositionInPixels = windowSizeInPixels*checkedFieldPosition/checkedFieldSize; |
283 fieldPositionInPixels = windowSizeInPixels*checkedFieldPosition/checkedFieldSize; |
306 minHandleBackgroundSize = HandleBackgroundMinSizeInPixels(); |
284 } |
307 } |
285 |
308 else |
|
309 { |
|
310 minHandleBackgroundSize = HandleMinSizeInPixels(); |
|
311 } |
|
312 |
|
313 TInt handleMinSize = HandleMinSizeInPixels(); |
|
314 // Similar compensation for handle if double span is in use |
286 // Similar compensation for handle if double span is in use |
315 if (doubleSpanInUse && (fieldSizeInPixels < handleMinSize)) |
287 if (doubleSpanInUse && (fieldSizeInPixels < handleMinSize)) |
316 { |
288 { |
317 TInt extraPixels = 0; |
289 TInt extraPixels = 0; |
318 TInt extraPixelCompensationInterval = 0; |
290 TInt extraPixelCompensationInterval = 0; |
680 return layRect.Rect().Height(); |
648 return layRect.Rect().Height(); |
681 else |
649 else |
682 return layRect.Rect().Width(); |
650 return layRect.Rect().Width(); |
683 } |
651 } |
684 |
652 |
685 TInt CAknDoubleSpanScrollIndicator::ScrollHandleMaxVisibleSizeInPixels() |
653 |
686 { |
654 TInt CAknDoubleSpanScrollIndicator::HandleMaxSizeInPixels() |
687 TRect scbRect = Rect(); |
655 { |
|
656 TRect scbRect( Rect() ); |
688 if ( iOrientation == CEikScrollBar::EHorizontal ) |
657 if ( iOrientation == CEikScrollBar::EHorizontal ) |
689 scbRect.SetRect(scbRect.iTl, TSize(scbRect.Height(), scbRect.Width())); |
658 scbRect.SetRect(scbRect.iTl, TSize(scbRect.Height(), scbRect.Width())); |
690 |
659 |
691 TAknLayoutRect layRect; |
660 TAknLayoutRect layRect; |
692 TAknWindowComponentLayout layout = AknLayoutScalable_Avkon::aid_size_max_handle(); |
661 TAknWindowComponentLayout layout = AknLayoutScalable_Avkon::aid_size_max_handle(); |
693 layRect.LayoutRect(scbRect, layout.LayoutLine()); |
662 layRect.LayoutRect(scbRect, layout.LayoutLine()); |
694 return layRect.Rect().Height(); |
663 return layRect.Rect().Height(); |
695 } |
664 } |
696 |
665 |
697 TInt CAknDoubleSpanScrollIndicator::HandleBackgroundMinSizeInPixels() |
|
698 { |
|
699 return HandleMinSizeInPixels(); |
|
700 } |
|
701 |
666 |
702 TInt CAknDoubleSpanScrollIndicator::HandleMinSizeInPixels() |
667 TInt CAknDoubleSpanScrollIndicator::HandleMinSizeInPixels() |
703 { |
668 { |
704 // We have the minimum size as aid value, do not layout to the handle layout as it is not correct |
669 // We have the minimum size as aid value, do not layout to the handle layout as it is not correct |
705 // on behalf of height argument (not set as maximum) |
670 // on behalf of height argument (not set as maximum) |
759 KAknsDrawParamNoClearUnderImage ); |
724 KAknsDrawParamNoClearUnderImage ); |
760 } |
725 } |
761 } |
726 } |
762 } |
727 } |
763 |
728 |
764 void CAknDoubleSpanScrollIndicator::LayoutHandleGraphics() |
|
765 { |
|
766 |
|
767 // We layout the handle middle graphics here according to the given inidcator values |
|
768 TRect rect = Rect(); |
|
769 |
|
770 if (!iHandleBar || rect.IsEmpty()) |
|
771 return; |
|
772 |
|
773 TInt varietyIndex = 0; |
|
774 TInt varietyIndexForHandle = 0; |
|
775 if (iOrientation == CEikScrollBar::EHorizontal) |
|
776 { |
|
777 varietyIndex = 1; |
|
778 varietyIndexForHandle = 2; |
|
779 } |
|
780 |
|
781 TAknLayoutRect layRect; |
|
782 TAknWindowComponentLayout // layout handle bottom & top as they do not scale according to handle size |
|
783 layout = AknLayoutScalable_Avkon::scroll_handle_pane(varietyIndexForHandle); // handle (the shadow if two handles) |
|
784 layRect.LayoutRect(rect, layout.LayoutLine()); |
|
785 layout = AknLayoutScalable_Avkon::scroll_handle_focus_pane(varietyIndex); // focus handle |
|
786 // The horizontal data for focus handle is missing so switch the values from the vertical data |
|
787 TAknWindowLineLayout layoutLine = layout.LayoutLine(); |
|
788 if (iOrientation == CEikScrollBar::EHorizontal) |
|
789 { |
|
790 TInt height = layoutLine.iH; |
|
791 TInt width = layoutLine.iW; |
|
792 layoutLine.iW = height; |
|
793 layoutLine.iH = width; |
|
794 } |
|
795 layRect.LayoutRect(layRect.Rect(), layoutLine); |
|
796 rect = layRect.Rect(); // parent rect is now the focus handle |
|
797 |
|
798 // the retangle includes the variated length of the middle, |
|
799 // the top and bottom graphics must subtracted from the value |
|
800 |
|
801 // do not change the handle retangle, the full size is needed in drawing |
|
802 // set the width or height to be correct |
|
803 if (iOrientation == CEikScrollBar::EVertical) |
|
804 { |
|
805 iHandleRect.iTl.iX = rect.iTl.iX; |
|
806 iHandleRect.iBr.iX = rect.iBr.iX; |
|
807 } |
|
808 else |
|
809 { |
|
810 iHandleRect.iTl.iY = rect.iTl.iY; |
|
811 iHandleRect.iBr.iY = rect.iBr.iY; |
|
812 } |
|
813 } |
|
814 |
729 |
815 TInt CAknDoubleSpanScrollIndicator::GetCurrentThumbSpanInPixels() |
730 TInt CAknDoubleSpanScrollIndicator::GetCurrentThumbSpanInPixels() |
816 { |
731 { |
817 return ( iOrientation == CEikScrollBar::EVertical ? |
732 return ( iOrientation == CEikScrollBar::EVertical ? |
818 iHandleBackgroundRect.Height() : |
733 iHandleBackgroundRect.Height() : |