|
1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation on scrollbar layout. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> SF |
|
20 #include "emailtrace.h" |
|
21 #include <uiacceltk/hitchcock.h> |
|
22 //</cmail> |
|
23 #include <AknUtils.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 |
|
26 #include "fshuiscrollbarlayout.h" |
|
27 #include "fslayoutmanager.h" |
|
28 |
|
29 const TInt KFsScrollbarTextureIdPoolStart = 1000; |
|
30 |
|
31 // ======== LOCAL FUNCTIONS ======== |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // Resolve the greater values from both size arguments. |
|
35 // --------------------------------------------------------------------------- |
|
36 // |
|
37 TSize ExtendSize( const TSize& aSize, const TSize& aSize2 ) |
|
38 { |
|
39 return TSize( |
|
40 aSize.iWidth < aSize2.iWidth ? aSize2.iWidth : aSize.iWidth, |
|
41 aSize.iHeight < aSize2.iHeight ? aSize2.iHeight : aSize.iHeight ); |
|
42 } |
|
43 |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // Resolve the greatest size from scrollbar gridlayouts. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 TSize GetMaxImageSize( |
|
50 CHuiLayout* aLayout1, |
|
51 CHuiLayout* aLayout2, |
|
52 CHuiLayout* aLayout3 ) |
|
53 { |
|
54 TSize retVal( static_cast<CHuiImageVisual*>( |
|
55 &aLayout1->Visual( 0 ) )->Image().Texture().Size() ); |
|
56 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
57 &aLayout1->Visual( 1 ) )->Image().Texture().Size() ); |
|
58 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
59 &aLayout1->Visual( 2 ) )->Image().Texture().Size() ); |
|
60 |
|
61 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
62 &aLayout2->Visual( 0 ) )->Image().Texture().Size() ); |
|
63 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
64 &aLayout2->Visual( 1 ) )->Image().Texture().Size() ); |
|
65 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
66 &aLayout2->Visual( 2 ) )->Image().Texture().Size() ); |
|
67 |
|
68 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
69 &aLayout3->Visual( 0 ) )->Image().Texture().Size() ); |
|
70 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
71 &aLayout3->Visual( 1 ) )->Image().Texture().Size() ); |
|
72 retVal = ExtendSize( retVal, static_cast<CHuiImageVisual*>( |
|
73 &aLayout3->Visual( 2 ) )->Image().Texture().Size() ); |
|
74 |
|
75 return retVal; |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // Creates a new bitmap based on the given source bitmap. New bitmap will be |
|
81 // rotated 90 degrees agains clock direction if wanted. |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 CFbsBitmap* CreateBitmapL( CFbsBitmap* aSourceBitmap, TBool aRotated ) |
|
85 { |
|
86 FUNC_LOG; |
|
87 CFbsBitmap* destinationBitmap( new( ELeave )CFbsBitmap() ); |
|
88 CleanupStack::PushL( destinationBitmap ); |
|
89 |
|
90 TSize sourceBitmapSize( aSourceBitmap->SizeInPixels() ); |
|
91 |
|
92 TSize destinationBitmapSize( 0, 0 ); |
|
93 if ( aRotated ) |
|
94 { |
|
95 destinationBitmapSize = |
|
96 TSize( sourceBitmapSize.iHeight, sourceBitmapSize.iWidth ); |
|
97 } |
|
98 else |
|
99 { |
|
100 destinationBitmapSize = |
|
101 TSize( sourceBitmapSize.iWidth, sourceBitmapSize.iHeight ); |
|
102 } |
|
103 |
|
104 User::LeaveIfError( destinationBitmap->Create( |
|
105 destinationBitmapSize, aSourceBitmap->DisplayMode() ) ); |
|
106 |
|
107 CFbsBitmapDevice* destinationDevice( |
|
108 CFbsBitmapDevice::NewL( destinationBitmap ) ); |
|
109 CleanupStack::PushL( destinationDevice ); |
|
110 |
|
111 CFbsBitGc* destinationGc; |
|
112 User::LeaveIfError( destinationDevice->CreateContext( destinationGc ) ); |
|
113 |
|
114 if ( aRotated ) |
|
115 { |
|
116 // Assume that bitmaps are small and this is called only at |
|
117 // construction. Simply just blit the pixels one by one here. |
|
118 TInt destinationX( 0 ); |
|
119 TInt destinationY( 0 ); |
|
120 |
|
121 for ( TInt sourceY( 0 ); sourceY < sourceBitmapSize.iHeight; |
|
122 sourceY++ ) |
|
123 { |
|
124 for ( TInt sourceX( 0 ); sourceX < sourceBitmapSize.iWidth; |
|
125 sourceX++ ) |
|
126 { |
|
127 destinationX = sourceY; |
|
128 destinationY = sourceX; |
|
129 destinationGc->BitBlt( TPoint( destinationX, destinationY ), |
|
130 aSourceBitmap, |
|
131 TRect( sourceX, sourceY, sourceX + 1, sourceY + 1 ) ); |
|
132 } |
|
133 } |
|
134 } |
|
135 else |
|
136 { |
|
137 destinationGc->BitBlt( TPoint( 0, 0 ), aSourceBitmap ); |
|
138 } |
|
139 |
|
140 delete destinationGc; |
|
141 CleanupStack::PopAndDestroy( destinationDevice ); // destinationDevice |
|
142 CleanupStack::Pop( destinationBitmap ); // destinationBitmap |
|
143 |
|
144 return destinationBitmap; |
|
145 } |
|
146 |
|
147 |
|
148 // --------------------------------------------------------------------------- |
|
149 // Creates a new bitmap and a mask based on the given skin item id. New |
|
150 // bitmap will be rotated 90 degrees agains clock direction if wanted. |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CreateSkinnedBitmapAndMaskL( MAknsSkinInstance* aInstance, |
|
154 const TAknsItemID& aID, |
|
155 CFbsBitmap*& aBitmap, |
|
156 CFbsBitmap*& aMask, |
|
157 TBool aRotated ) |
|
158 { |
|
159 FUNC_LOG; |
|
160 CFbsBitmap* skinnedBitmap( NULL ); |
|
161 CFbsBitmap* skinnedMask( NULL ); |
|
162 |
|
163 // note, real fallback icons are not (yet) available in avkon icon file. |
|
164 TRAP_IGNORE( AknsUtils::CreateIconL( |
|
165 aInstance, aID, skinnedBitmap, skinnedMask, KNullDesC, -1, -1 ) ); |
|
166 |
|
167 if ( !skinnedBitmap ) |
|
168 { |
|
169 AknsUtils::CreateIconL( |
|
170 aInstance, aID, skinnedBitmap, KNullDesC, -1 ); |
|
171 } |
|
172 |
|
173 TRect screenRect; |
|
174 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect ); |
|
175 TAknWindowComponentLayout l( |
|
176 AknLayoutScalable_Avkon::scroll_bg_pane_g1() ); |
|
177 TAknLayoutRect layoutRect; |
|
178 layoutRect.LayoutRect( screenRect, l.LayoutLine() ); |
|
179 TSize itemSize( layoutRect.Rect().Size() ); |
|
180 if ( itemSize.iHeight > itemSize.iWidth ) |
|
181 { |
|
182 itemSize.iHeight = itemSize.iWidth; // make sure item is square |
|
183 } |
|
184 else |
|
185 { |
|
186 itemSize.iWidth = itemSize.iHeight; // make sure item is square |
|
187 } |
|
188 User::LeaveIfError( AknIconUtils::SetSize( skinnedBitmap, itemSize ) ); |
|
189 |
|
190 if ( aRotated ) |
|
191 { |
|
192 // now create rotated copy of the original bitmaps |
|
193 CFbsBitmap* bitmap( CreateBitmapL( skinnedBitmap, aRotated ) ); |
|
194 CleanupStack::PushL( bitmap ); |
|
195 |
|
196 CFbsBitmap* mask( NULL ); |
|
197 if ( skinnedMask ) |
|
198 { |
|
199 mask = CreateBitmapL( skinnedMask, aRotated ); |
|
200 CleanupStack::PushL( mask ); |
|
201 } |
|
202 if ( mask ) |
|
203 { |
|
204 CAknIcon* icon( CAknIcon::NewL() ); |
|
205 icon->SetBitmap( bitmap ); |
|
206 icon->SetMask( mask ); |
|
207 CAknIcon* resultIcon( AknIconUtils::CreateIconL( icon ) ); |
|
208 CleanupStack::Pop( mask ); // mask |
|
209 |
|
210 aBitmap = resultIcon->Bitmap(); |
|
211 aMask = resultIcon->Mask(); |
|
212 |
|
213 resultIcon->SetBitmap( NULL ); |
|
214 resultIcon->SetMask( NULL ); |
|
215 delete resultIcon; |
|
216 } |
|
217 else |
|
218 { |
|
219 CFbsBitmap* resultBitmap( AknIconUtils::CreateIconL( bitmap ) ); |
|
220 aBitmap = resultBitmap; |
|
221 } |
|
222 |
|
223 CleanupStack::Pop( bitmap ); // bitmap |
|
224 |
|
225 // delete originals |
|
226 delete skinnedBitmap; |
|
227 delete skinnedMask; |
|
228 } |
|
229 else |
|
230 { |
|
231 aBitmap = skinnedBitmap; |
|
232 aMask = skinnedMask; |
|
233 } |
|
234 } |
|
235 |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // Add s specific skin image to visual. |
|
239 // --------------------------------------------------------------------------- |
|
240 // |
|
241 void CFsHuiScrollbarLayout::SetImageL( |
|
242 CHuiImageVisual* aVisual, |
|
243 const TAknsItemID& aID, |
|
244 TFsScrollbar aOrientation ) |
|
245 { |
|
246 CFsScrollbarBitmapProvider* provider = new (ELeave) CFsScrollbarBitmapProvider( aID, aOrientation ); |
|
247 iBitmapProviderStack.AppendL( provider ); |
|
248 |
|
249 while ( iOwnerControl->Env().TextureManager().IsLoaded( iTextureCounter ) ) |
|
250 { |
|
251 ++iTextureCounter; |
|
252 } |
|
253 |
|
254 CHuiTexture& texture = iOwnerControl->Env().TextureManager().CreateTextureL( iTextureCounter, provider, EHuiTextureUploadFlagDefault ); |
|
255 iTextureStack.AppendL( &texture ); |
|
256 texture.SetSkinContent( ETrue ); |
|
257 |
|
258 aVisual->SetImage( texture ); |
|
259 aVisual->SetScaleMode( CHuiImageVisual::EScaleFit ); |
|
260 } |
|
261 |
|
262 CFsScrollbarBitmapProvider::CFsScrollbarBitmapProvider( TAknsItemID aID, TFsScrollbar aOrientation ) |
|
263 : iID( aID ), iOrientation( aOrientation ) |
|
264 { |
|
265 } |
|
266 |
|
267 CFsScrollbarBitmapProvider::~CFsScrollbarBitmapProvider() |
|
268 { |
|
269 } |
|
270 |
|
271 void CFsScrollbarBitmapProvider::ProvideBitmapL (TInt /*aId*/, CFbsBitmap *& aBitmap, CFbsBitmap *& aMaskBitmap) |
|
272 { |
|
273 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
274 CreateSkinnedBitmapAndMaskL( |
|
275 skin, iID, aBitmap, aMaskBitmap, EFsScrollbarHorizontal == iOrientation ); |
|
276 } |
|
277 |
|
278 |
|
279 // ======== MEMBER FUNCTIONS ======== |
|
280 |
|
281 CFsHuiScrollbarLayout::CFsHuiScrollbarLayout( MHuiVisualOwner& aOwner ) |
|
282 : CHuiLayout( aOwner ) |
|
283 { |
|
284 FUNC_LOG; |
|
285 } |
|
286 |
|
287 |
|
288 void CFsHuiScrollbarLayout::ConstructL( CHuiControl& aOwnerControl ) |
|
289 { |
|
290 FUNC_LOG; |
|
291 CHuiLayout::ConstructL(); |
|
292 iHorScroll.SetHorizontal( ETrue ); |
|
293 |
|
294 iOwnerControl = &aOwnerControl; |
|
295 iTextureCounter = KFsScrollbarTextureIdPoolStart; |
|
296 } |
|
297 |
|
298 |
|
299 // --------------------------------------------------------------------------- |
|
300 // Construct a new scrollbar layout and give its ownership to a control. |
|
301 // --------------------------------------------------------------------------- |
|
302 // |
|
303 EXPORT_C CFsHuiScrollbarLayout* CFsHuiScrollbarLayout::AddNewL( |
|
304 CHuiControl& aOwnerControl, |
|
305 CHuiLayout* aParentLayout ) |
|
306 { |
|
307 FUNC_LOG; |
|
308 CFsHuiScrollbarLayout* scrollbar( |
|
309 new (ELeave) CFsHuiScrollbarLayout( aOwnerControl ) ); |
|
310 CleanupStack::PushL( scrollbar ); |
|
311 scrollbar->ConstructL( aOwnerControl ); |
|
312 if ( aParentLayout ) |
|
313 { |
|
314 aParentLayout->AppendL( scrollbar ); |
|
315 } |
|
316 // Give ownership to specified owner. |
|
317 aOwnerControl.AppendL( scrollbar ); |
|
318 CleanupStack::Pop( scrollbar ); |
|
319 return scrollbar; |
|
320 } |
|
321 |
|
322 |
|
323 CFsHuiScrollbarLayout::~CFsHuiScrollbarLayout() |
|
324 { |
|
325 FUNC_LOG; |
|
326 delete iVBarBrush; |
|
327 delete iHBarBrush; |
|
328 delete iVThumbBrush; |
|
329 delete iHThumbBrush; |
|
330 iTextureStack.ResetAndDestroy(); |
|
331 iBitmapProviderStack.ResetAndDestroy(); |
|
332 } |
|
333 |
|
334 |
|
335 // --------------------------------------------------------------------------- |
|
336 // Set the range of the scrollbar. Will not actually move the scrollbar until |
|
337 // Update() is called. |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 EXPORT_C void CFsHuiScrollbarLayout::SetRange( |
|
341 TInt aStart, |
|
342 TInt aEnd, |
|
343 TFsScrollbar aScrollbar ) |
|
344 { |
|
345 FUNC_LOG; |
|
346 // Perform the operation on selected scrollbar. |
|
347 EFsScrollbarVertical == aScrollbar |
|
348 ? iVertScroll.SetRange( aStart, aEnd ) |
|
349 : iHorScroll.SetRange( aStart, aEnd ); |
|
350 } |
|
351 |
|
352 |
|
353 // --------------------------------------------------------------------------- |
|
354 // Get scrollbars minimum range value. |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 EXPORT_C TInt CFsHuiScrollbarLayout::RangeStart( TFsScrollbar aScrollbar ) |
|
358 { |
|
359 FUNC_LOG; |
|
360 // Perform the operation on selected scrollbar. |
|
361 return EFsScrollbarVertical == aScrollbar |
|
362 ? iVertScroll.RangeStart() : iHorScroll.RangeStart(); |
|
363 } |
|
364 |
|
365 |
|
366 // --------------------------------------------------------------------------- |
|
367 // Get scrollbars maximum range value. |
|
368 // --------------------------------------------------------------------------- |
|
369 // |
|
370 EXPORT_C TInt CFsHuiScrollbarLayout::RangeEnd( TFsScrollbar aScrollbar ) |
|
371 { |
|
372 FUNC_LOG; |
|
373 // Perform the operation on selected scrollbar. |
|
374 return EFsScrollbarVertical == aScrollbar |
|
375 ? iVertScroll.RangeEnd() : iHorScroll.RangeEnd(); |
|
376 } |
|
377 |
|
378 |
|
379 // --------------------------------------------------------------------------- |
|
380 // Set the count of visible units at the time. |
|
381 // --------------------------------------------------------------------------- |
|
382 // |
|
383 EXPORT_C void CFsHuiScrollbarLayout::SetThumbSpan( |
|
384 TInt aThumbSpan, |
|
385 TFsScrollbar aScrollbar ) |
|
386 { |
|
387 FUNC_LOG; |
|
388 // Perform the operation on selected scrollbar. |
|
389 EFsScrollbarVertical == aScrollbar |
|
390 ? iVertScroll.SetThumbSpan( aThumbSpan ) |
|
391 : iHorScroll.SetThumbSpan( aThumbSpan ); |
|
392 } |
|
393 |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // Get the set value for visible units. |
|
397 // --------------------------------------------------------------------------- |
|
398 // |
|
399 EXPORT_C TInt CFsHuiScrollbarLayout::ThumbSpan( TFsScrollbar aScrollbar ) |
|
400 { |
|
401 FUNC_LOG; |
|
402 // Perform the operation on selected scrollbar. |
|
403 return EFsScrollbarVertical == aScrollbar |
|
404 ? iVertScroll.ThumbSpan() : iHorScroll.ThumbSpan(); |
|
405 } |
|
406 |
|
407 |
|
408 // --------------------------------------------------------------------------- |
|
409 // Adjust the vertical scrollbar's width. |
|
410 // --------------------------------------------------------------------------- |
|
411 // |
|
412 EXPORT_C void CFsHuiScrollbarLayout::SetVerticalScrollbarWidth( |
|
413 TInt aWidth, |
|
414 TInt aLayoutTransitionTime ) |
|
415 { |
|
416 FUNC_LOG; |
|
417 iScrollbarSize.iWidth = aWidth; |
|
418 if ( iVScrollbarLayout ) |
|
419 { |
|
420 iVertScroll.SetThumbSize( |
|
421 TSize( aWidth, iVertScroll.ThumbSize().iHeight ) ); |
|
422 UpdateChildrenLayout( aLayoutTransitionTime ); |
|
423 } |
|
424 } |
|
425 |
|
426 |
|
427 // --------------------------------------------------------------------------- |
|
428 // Adjust the horizontal scrollbar's height. |
|
429 // --------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C void CFsHuiScrollbarLayout::SetHorizontalScrollbarHeight( |
|
432 TInt aHeight, |
|
433 TInt aLayoutTransitionTime ) |
|
434 { |
|
435 FUNC_LOG; |
|
436 iScrollbarSize.iHeight = aHeight; |
|
437 if ( iHScrollbarLayout ) |
|
438 { |
|
439 iHorScroll.SetThumbSize( |
|
440 TSize( iHorScroll.ThumbSize().iWidth, aHeight ) ); |
|
441 UpdateChildrenLayout( aLayoutTransitionTime ); |
|
442 } |
|
443 } |
|
444 |
|
445 |
|
446 // --------------------------------------------------------------------------- |
|
447 // Set the position of the scrollbar. |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 EXPORT_C void CFsHuiScrollbarLayout::SetScrollbarPos( |
|
451 const TInt aPos, |
|
452 TFsScrollbar aScrollbar ) |
|
453 { |
|
454 FUNC_LOG; |
|
455 // Perform the operation on selected scrollbar. |
|
456 EFsScrollbarVertical == aScrollbar |
|
457 ? iVertScroll.SetPos( aPos ) : iHorScroll.SetPos( aPos ); |
|
458 } |
|
459 |
|
460 |
|
461 // --------------------------------------------------------------------------- |
|
462 // Resolve the position of the scrollbar. |
|
463 // --------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C TInt CFsHuiScrollbarLayout::ScrollbarPos( TFsScrollbar aScrollbar ) |
|
466 { |
|
467 FUNC_LOG; |
|
468 // Perform the operation on selected scrollbar. |
|
469 return EFsScrollbarVertical == aScrollbar |
|
470 ? iVertScroll.Pos() : iHorScroll.Pos(); |
|
471 } |
|
472 |
|
473 |
|
474 // --------------------------------------------------------------------------- |
|
475 // Set the scrollbar visibility. |
|
476 // --------------------------------------------------------------------------- |
|
477 // |
|
478 EXPORT_C void CFsHuiScrollbarLayout::SetVisibilityMode( |
|
479 TFsScrollbarVisibility aVisibility, |
|
480 TFsScrollbar aScrollbar ) |
|
481 { |
|
482 FUNC_LOG; |
|
483 // Perform the operation on selected scrollbar. |
|
484 EFsScrollbarVertical == aScrollbar |
|
485 ? iVertScroll.SetVisibleMode( aVisibility ) |
|
486 : iHorScroll.SetVisibleMode( aVisibility ); |
|
487 } |
|
488 |
|
489 |
|
490 // --------------------------------------------------------------------------- |
|
491 // Resolve the scrollbar visibility mode. |
|
492 // --------------------------------------------------------------------------- |
|
493 // |
|
494 EXPORT_C TFsScrollbarVisibility CFsHuiScrollbarLayout::VisibilityMode( |
|
495 TFsScrollbar aScrollbar ) |
|
496 { |
|
497 FUNC_LOG; |
|
498 // Perform the operation on selected scrollbar. |
|
499 return EFsScrollbarVertical == aScrollbar |
|
500 ? iVertScroll.VisibilityMode() : iHorScroll.VisibilityMode(); |
|
501 } |
|
502 |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // Resolve if the specified scrollbar is visible. |
|
506 // --------------------------------------------------------------------------- |
|
507 // |
|
508 EXPORT_C TBool CFsHuiScrollbarLayout::IsScrollbarVisible( |
|
509 TFsScrollbar aScrollbar ) |
|
510 { |
|
511 FUNC_LOG; |
|
512 // Perform the operation on selected scrollbar. |
|
513 return EFsScrollbarVertical == aScrollbar |
|
514 ? iVertScroll.IsVisible() : iHorScroll.IsVisible(); |
|
515 } |
|
516 |
|
517 |
|
518 // --------------------------------------------------------------------------- |
|
519 // Change the scrollbar images to custom images. |
|
520 // --------------------------------------------------------------------------- |
|
521 // |
|
522 EXPORT_C void CFsHuiScrollbarLayout::SetScrollbarImagesL( |
|
523 CHuiImageBrush* aBarBrush, |
|
524 CHuiImageBrush* aThumbBrush, |
|
525 TFsScrollbar aScrollbar ) |
|
526 { |
|
527 FUNC_LOG; |
|
528 SetCustomImageL( aBarBrush, aScrollbar, EFalse ); |
|
529 SetCustomImageL( aThumbBrush, aScrollbar, ETrue ); |
|
530 } |
|
531 |
|
532 |
|
533 // --------------------------------------------------------------------------- |
|
534 // Update the visibility of scrollbars. |
|
535 // --------------------------------------------------------------------------- |
|
536 // |
|
537 EXPORT_C void CFsHuiScrollbarLayout::Update( TInt aLayoutTransitionTime ) |
|
538 { |
|
539 FUNC_LOG; |
|
540 MakeScrollbarVisible( iVertScroll.IsVisible(), EFsScrollbarVertical ); |
|
541 MakeScrollbarVisible( iHorScroll.IsVisible(), EFsScrollbarHorizontal ); |
|
542 UpdateChildrenLayout( aLayoutTransitionTime ); |
|
543 } |
|
544 |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // Remove reference to custom image brushes without releasing those. |
|
548 // This is for cases where ownership of image brushes couldn't be tranfered to |
|
549 // scrollbar layout. |
|
550 // --------------------------------------------------------------------------- |
|
551 // |
|
552 void CFsHuiScrollbarLayout::RemoveCustomImages( TFsScrollbar aScrollbar ) |
|
553 { |
|
554 FUNC_LOG; |
|
555 // Remove the previously set image brushes. |
|
556 for ( TInt i( 0 ); 2 > i; i++ ) |
|
557 { |
|
558 CHuiImageBrush** imageBrush; |
|
559 CHuiDeckLayout* layout; |
|
560 |
|
561 // Custom scrollbar is built from two image brushes. Both need to be |
|
562 // removed. |
|
563 if ( i ) |
|
564 { |
|
565 layout = EFsScrollbarVertical == aScrollbar |
|
566 ? iVScrollbarLayout : iHScrollbarLayout; |
|
567 imageBrush = EFsScrollbarVertical == aScrollbar |
|
568 ? &iVBarBrush : &iHBarBrush; |
|
569 } |
|
570 else |
|
571 { |
|
572 layout = EFsScrollbarVertical == aScrollbar |
|
573 ? iVThumb : iHThumb; |
|
574 imageBrush = EFsScrollbarVertical == aScrollbar |
|
575 ? &iVThumbBrush : &iHThumbBrush; |
|
576 } |
|
577 |
|
578 // Remove the brush from the layout. |
|
579 if ( layout && layout->Brushes() ) |
|
580 { |
|
581 for ( TInt j( layout->Brushes()->Count() - 1 ); 0 <= j; j-- ) |
|
582 { |
|
583 if ( &layout->Brushes()->At( j ) == *imageBrush ) |
|
584 { |
|
585 layout->Brushes()->Remove( j ); |
|
586 break; |
|
587 } |
|
588 } |
|
589 } |
|
590 |
|
591 // Mark the brush as released. CFsAlfScrollbarLayout has the ownership |
|
592 // of this object. |
|
593 *imageBrush = NULL; |
|
594 } |
|
595 } |
|
596 |
|
597 |
|
598 // --------------------------------------------------------------------------- |
|
599 // Resolve the layout's size without the scrollbars. |
|
600 // --------------------------------------------------------------------------- |
|
601 // |
|
602 EXPORT_C THuiRealPoint CFsHuiScrollbarLayout::LayoutSize() |
|
603 { |
|
604 FUNC_LOG; |
|
605 THuiRealPoint layoutSize( Size().RealTarget() ); |
|
606 if ( iVertScroll.IsVisible() ) |
|
607 { |
|
608 layoutSize.iX = layoutSize.iX - iScrollbarSize.iWidth; |
|
609 } |
|
610 if ( iHorScroll.IsVisible() ) |
|
611 { |
|
612 layoutSize.iY = layoutSize.iY - iScrollbarSize.iWidth; |
|
613 } |
|
614 |
|
615 return layoutSize; |
|
616 } |
|
617 |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // From class CHuiLayout. |
|
621 // Change the size of the layout. Children's positions and sizes are updated |
|
622 // accordingly. Each layout class is responsible for determining how to |
|
623 // update children's layout. |
|
624 // --------------------------------------------------------------------------- |
|
625 // |
|
626 EXPORT_C void CFsHuiScrollbarLayout::SetSize( |
|
627 const THuiRealSize& aSize, |
|
628 TInt aTransitionTime ) |
|
629 { |
|
630 FUNC_LOG; |
|
631 CHuiLayout::SetSize( aSize, aTransitionTime ); |
|
632 UpdateChildrenLayout( aTransitionTime ); |
|
633 } |
|
634 |
|
635 |
|
636 // --------------------------------------------------------------------------- |
|
637 // From class CHuiLayout. |
|
638 // Update the layout of one child visual. |
|
639 // --------------------------------------------------------------------------- |
|
640 // |
|
641 EXPORT_C void CFsHuiScrollbarLayout::UpdateChildLayout( |
|
642 TInt aIndex, |
|
643 TInt aTransitionTime ) |
|
644 { |
|
645 FUNC_LOG; |
|
646 CHuiVisual* child( &Visual( aIndex ) ); |
|
647 if ( child == iVScrollbarLayout || child == iHScrollbarLayout ) |
|
648 { |
|
649 // Update vertical or horizontal scrollbar. |
|
650 THuiRealRect rect; |
|
651 ChildRect( ChildOrdinal( aIndex ), rect ); |
|
652 child->SetSize( rect.Size(), aTransitionTime ); |
|
653 child->SetPos( rect.iTl, aTransitionTime ); |
|
654 TSize size( rect.Size() ); |
|
655 |
|
656 CFsScrollbarClet &scrollClet( |
|
657 child == iVScrollbarLayout ? iVertScroll : iHorScroll ); |
|
658 if ( ( ( child == iVScrollbarLayout && !iVBarBrush ) |
|
659 || ( child == iHScrollbarLayout && !iHBarBrush ) ) |
|
660 && scrollClet.IsVisible() ) |
|
661 { |
|
662 scrollClet.AdjustSize( static_cast<CHuiGridLayout*>( |
|
663 &child->Visual( 0 ) ), size, aTransitionTime ); |
|
664 } |
|
665 scrollClet.Update( aTransitionTime ); |
|
666 } |
|
667 else |
|
668 { |
|
669 // Update other child visuals. |
|
670 CHuiLayout::UpdateChildLayout( aIndex, aTransitionTime ); |
|
671 } |
|
672 } |
|
673 |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // From class CHuiLayout. |
|
677 // Determines the size of a child visual according to the layout. |
|
678 // --------------------------------------------------------------------------- |
|
679 // |
|
680 TBool CFsHuiScrollbarLayout::ChildSize( TInt aOrdinal, TSize& aSize ) |
|
681 { |
|
682 FUNC_LOG; |
|
683 THuiRealRect rect; |
|
684 ChildRect( aOrdinal, rect ); |
|
685 aSize = rect.Size(); |
|
686 return ETrue; |
|
687 } |
|
688 |
|
689 |
|
690 // --------------------------------------------------------------------------- |
|
691 // From class CHuiLayout. |
|
692 // Determines the position of a child visual according to the layout. |
|
693 // --------------------------------------------------------------------------- |
|
694 // |
|
695 TBool CFsHuiScrollbarLayout::ChildPos( TInt aOrdinal, TPoint& aPos ) |
|
696 { |
|
697 FUNC_LOG; |
|
698 THuiRealRect rect; |
|
699 ChildRect( aOrdinal, rect ); |
|
700 aPos = rect.iTl; |
|
701 return ETrue; |
|
702 } |
|
703 |
|
704 |
|
705 // --------------------------------------------------------------------------- |
|
706 // From class CHuiLayout. |
|
707 // Update the layout of all children. |
|
708 // --------------------------------------------------------------------------- |
|
709 // |
|
710 void CFsHuiScrollbarLayout::UpdateChildrenLayout( TInt aTransitionTime ) |
|
711 { |
|
712 FUNC_LOG; |
|
713 CHuiLayout::UpdateChildrenLayout( aTransitionTime ); |
|
714 } |
|
715 |
|
716 |
|
717 // --------------------------------------------------------------------------- |
|
718 // From class CHuiLayout. |
|
719 // Determines the position and size of a child visual according to the layout. |
|
720 // --------------------------------------------------------------------------- |
|
721 // |
|
722 TInt CFsHuiScrollbarLayout::ChildRect( TInt aOrdinal, THuiRealRect& aPos ) |
|
723 { |
|
724 FUNC_LOG; |
|
725 const CHuiVisual* visual( &Visual( aOrdinal ) ); |
|
726 TSize size( Size().Target().AsSize() ); |
|
727 THuiRealRect area( size ); |
|
728 |
|
729 if ( visual == iVScrollbarLayout && iVertScroll.IsVisible() ) |
|
730 { |
|
731 // Size and position of vertical scrollbar. |
|
732 if ( CFsLayoutManager::IsMirrored() ) |
|
733 { |
|
734 area.iBr.iX = iScrollbarSize.iWidth; |
|
735 } |
|
736 else |
|
737 { |
|
738 area.iTl.iX = area.iBr.iX - iScrollbarSize.iWidth; |
|
739 } |
|
740 |
|
741 if ( iHorScroll.IsVisible() ) |
|
742 { |
|
743 area.iBr.iY -= iScrollbarSize.iHeight; |
|
744 } |
|
745 } |
|
746 else if ( visual == iHScrollbarLayout && iHorScroll.IsVisible() ) |
|
747 { |
|
748 // Size and position of horizontal scrollbar. |
|
749 area.iTl.iY = area.iBr.iY - iScrollbarSize.iHeight; |
|
750 if ( iVertScroll.IsVisible() ) |
|
751 { |
|
752 if ( CFsLayoutManager::IsMirrored() ) |
|
753 { |
|
754 area.iTl.iX = iScrollbarSize.iWidth; |
|
755 } |
|
756 else |
|
757 { |
|
758 area.iBr.iX -= iScrollbarSize.iWidth; |
|
759 } |
|
760 } |
|
761 } |
|
762 else |
|
763 { |
|
764 // Other visuals size on position depends on the visible scrollbars. |
|
765 if ( iVertScroll.IsVisible() ) |
|
766 { |
|
767 if ( CFsLayoutManager::IsMirrored() ) |
|
768 { |
|
769 area.iTl.iX = iScrollbarSize.iWidth; |
|
770 } |
|
771 else |
|
772 { |
|
773 area.iBr.iX -= iScrollbarSize.iWidth; |
|
774 } |
|
775 } |
|
776 if ( iHorScroll.IsVisible() ) |
|
777 { |
|
778 area.iBr.iY -= iScrollbarSize.iHeight; |
|
779 } |
|
780 } |
|
781 aPos.iTl = area.iTl; |
|
782 aPos.iBr = area.iBr; |
|
783 return THuiLayoutChildRectLayoutUpdateNeeded; |
|
784 } |
|
785 |
|
786 |
|
787 // --------------------------------------------------------------------------- |
|
788 // Create a scrollbar visual. |
|
789 // The scrollbar is only created, but not added to this layout. |
|
790 // --------------------------------------------------------------------------- |
|
791 // |
|
792 void CFsHuiScrollbarLayout::CreateScrollbarL( |
|
793 CHuiDeckLayout*& aScrollbarLayout, |
|
794 CHuiLayout*& aThumbLayout, |
|
795 TFsScrollbar aOrientation ) |
|
796 { |
|
797 FUNC_LOG; |
|
798 CHuiDeckLayout* scrollbarLayout( |
|
799 CHuiDeckLayout::AddNewL( *iOwnerControl ) ); |
|
800 CleanupStack::PushL( scrollbarLayout ); |
|
801 scrollbarLayout->SetClipping( ETrue ); |
|
802 |
|
803 // Create the scrollbar's background. |
|
804 CHuiGridLayout *bg( CreateGridLayoutL( |
|
805 scrollbarLayout, KAknsIIDQsnCpScrollBgTop, |
|
806 KAknsIIDQsnCpScrollBgMiddle, KAknsIIDQsnCpScrollBgBottom, |
|
807 aOrientation ) ); |
|
808 |
|
809 // Create the thumb. |
|
810 CHuiDeckLayout* thumbLayout( |
|
811 CHuiDeckLayout::AddNewL( *iOwnerControl, scrollbarLayout ) ); |
|
812 thumbLayout->SetClipping( ETrue ); |
|
813 |
|
814 // Background is build from two differend image sets. |
|
815 CHuiGridLayout* middle( CreateGridLayoutL( thumbLayout, |
|
816 KAknsIIDQsnCpScrollHandleBgTop, KAknsIIDQsnCpScrollHandleBgMiddle, |
|
817 KAknsIIDQsnCpScrollHandleBgBottom, aOrientation ) ); |
|
818 CHuiGridLayout* top( CreateGridLayoutL( thumbLayout, |
|
819 KAknsIIDQsnCpScrollHandleTop, KAknsIIDQsnCpScrollHandleMiddle, |
|
820 KAknsIIDQsnCpScrollHandleBottom, aOrientation ) ); |
|
821 |
|
822 const TSize maxSize( GetMaxImageSize( bg, middle, top ) ); |
|
823 |
|
824 if ( EFsScrollbarHorizontal == aOrientation ) |
|
825 { |
|
826 if ( !iHBarBrush && !iHThumbBrush ) |
|
827 { |
|
828 SetHorizontalScrollbarHeight( maxSize.iHeight ); |
|
829 } |
|
830 } |
|
831 else |
|
832 { |
|
833 if ( !iVBarBrush && !iVThumbBrush ) |
|
834 { |
|
835 SetVerticalScrollbarWidth( maxSize.iWidth ); |
|
836 } |
|
837 } |
|
838 |
|
839 CleanupStack::Pop( scrollbarLayout ); |
|
840 aScrollbarLayout = scrollbarLayout; |
|
841 aThumbLayout = thumbLayout; |
|
842 } |
|
843 |
|
844 |
|
845 // --------------------------------------------------------------------------- |
|
846 // Create or destroy specific scrollbar visual. |
|
847 // --------------------------------------------------------------------------- |
|
848 // |
|
849 void CFsHuiScrollbarLayout::MakeScrollbarVisible( |
|
850 TBool aVisible, |
|
851 TFsScrollbar aScrollbar ) |
|
852 { |
|
853 FUNC_LOG; |
|
854 CFsScrollbarClet* scroll( NULL ); |
|
855 CHuiDeckLayout** scrollbarLayout( NULL ); |
|
856 CHuiDeckLayout** thumbLayout( NULL ); |
|
857 CHuiImageBrush* barBrush( NULL ); |
|
858 CHuiImageBrush* thumbBrush( NULL ); |
|
859 |
|
860 if ( EFsScrollbarVertical == aScrollbar ) |
|
861 { |
|
862 // Select vertical scrollbar dependent variables. |
|
863 scroll = &iVertScroll; |
|
864 scrollbarLayout = &iVScrollbarLayout; |
|
865 thumbLayout = &iVThumb; |
|
866 barBrush = iVBarBrush; |
|
867 thumbBrush = iVThumbBrush; |
|
868 } |
|
869 else |
|
870 { |
|
871 // Select horizontal scrollbar dependent variables. |
|
872 scroll = &iHorScroll; |
|
873 scrollbarLayout = &iHScrollbarLayout; |
|
874 thumbLayout = &iHThumb; |
|
875 barBrush = iHBarBrush; |
|
876 thumbBrush = iHThumbBrush; |
|
877 } |
|
878 |
|
879 if ( aVisible ) |
|
880 { |
|
881 // The scrollbar is visible. |
|
882 if ( !*scrollbarLayout ) |
|
883 { |
|
884 // Create the scrollbar as it didn't already exists. |
|
885 TRAPD( leaveErr, CreateScrollbarL( |
|
886 (CHuiDeckLayout*&)*scrollbarLayout, |
|
887 (CHuiLayout*&)*thumbLayout, |
|
888 aScrollbar ) ); |
|
889 |
|
890 if ( !leaveErr ) |
|
891 { |
|
892 // Add just created scrollbar to this layout |
|
893 TRAP( leaveErr, AppendL( *scrollbarLayout ) ); |
|
894 if ( !leaveErr ) |
|
895 { |
|
896 (*scrollbarLayout)->SetFlag( EHuiVisualFlagManualSize ); |
|
897 (*scrollbarLayout)->SetFlag( |
|
898 EHuiVisualFlagManualPosition ); |
|
899 } |
|
900 else |
|
901 { |
|
902 (*scrollbarLayout)->RemoveAndDestroyAllD(); |
|
903 *scrollbarLayout = NULL; |
|
904 } |
|
905 } |
|
906 if ( barBrush ) |
|
907 { |
|
908 // Replace the grid layout with custom brush. |
|
909 UseCustomImage( *scrollbarLayout, barBrush, *thumbLayout ); |
|
910 scroll->EnableCustomBarImage(); |
|
911 } |
|
912 if ( thumbBrush ) |
|
913 { |
|
914 // Replace the grid layout with custom brush. |
|
915 UseCustomImage( *thumbLayout, thumbBrush, NULL ); |
|
916 scroll->EnableCustomThumbImage(); |
|
917 } |
|
918 scroll->SetVisuals( *scrollbarLayout, *thumbLayout ); |
|
919 UpdateChildrenLayout(); |
|
920 } |
|
921 } |
|
922 else |
|
923 { |
|
924 // The scrollbar is hidden. |
|
925 if ( *scrollbarLayout ) |
|
926 { |
|
927 // Release the scrollbar object. |
|
928 ClearFlag( EHuiVisualFlagLayoutUpdateNotification ); |
|
929 (*scrollbarLayout)->RemoveAndDestroyAllD(); |
|
930 SetFlag( EHuiVisualFlagLayoutUpdateNotification ); |
|
931 *scrollbarLayout = NULL; |
|
932 *thumbLayout = NULL; |
|
933 scroll->SetVisuals( NULL, NULL ); |
|
934 } |
|
935 } |
|
936 } |
|
937 |
|
938 |
|
939 // --------------------------------------------------------------------------- |
|
940 // Take the custom set image in use. |
|
941 // Default scrollbar is build with grid layout and it must be released first. |
|
942 // --------------------------------------------------------------------------- |
|
943 // |
|
944 TInt CFsHuiScrollbarLayout::UseCustomImage( |
|
945 CHuiDeckLayout* aLayout, |
|
946 CHuiImageBrush* aImage, |
|
947 CHuiDeckLayout* aChildLayout ) |
|
948 { |
|
949 FUNC_LOG; |
|
950 THuiTimedPoint childSize; |
|
951 THuiTimedPoint childPos; |
|
952 if ( aChildLayout ) |
|
953 { |
|
954 // Store the current size and position of the layout. |
|
955 childSize = aChildLayout->Size(); |
|
956 childPos = aChildLayout->Pos(); |
|
957 } |
|
958 for ( TInt i( aLayout->Count() - 1); 0 <= i; i-- ) |
|
959 { |
|
960 // Keep the one defined child layout. It is the thumb layout on |
|
961 // scrollbar layout. |
|
962 if ( &aLayout->Visual( i ) != aChildLayout ) |
|
963 { |
|
964 // Remove all other visuals on this layout. |
|
965 aLayout->Visual( i ).RemoveAndDestroyAllD(); |
|
966 } |
|
967 } |
|
968 if ( aChildLayout ) |
|
969 { |
|
970 // Set the same size and position it had before the values were |
|
971 // reseted on child layout destruction. |
|
972 aChildLayout->Size() = childSize; |
|
973 aChildLayout->Pos() = childPos; |
|
974 } |
|
975 |
|
976 // Append the image to this layout only if it is not added before. |
|
977 TRAPD( leaveErr, |
|
978 { |
|
979 aLayout->EnableBrushesL(); |
|
980 for ( TInt i( aLayout->Brushes()->Count() - 1 ); 0 <= i; i-- ) |
|
981 { |
|
982 if ( &aLayout->Brushes()->At( i ) == aImage ) |
|
983 { |
|
984 // The brush is already set. |
|
985 return KErrNone; |
|
986 } |
|
987 } |
|
988 aLayout->Brushes()->AppendL( aImage, EHuiDoesNotHaveOwnership ); |
|
989 } ); |
|
990 |
|
991 return leaveErr; |
|
992 } |
|
993 |
|
994 |
|
995 // --------------------------------------------------------------------------- |
|
996 // Update scrollbar thumb positions. |
|
997 // --------------------------------------------------------------------------- |
|
998 // |
|
999 void CFsHuiScrollbarLayout::UpdateScrollbars( TInt aLayoutTransitionTime ) |
|
1000 { |
|
1001 FUNC_LOG; |
|
1002 iVertScroll.Update( aLayoutTransitionTime ); |
|
1003 iHorScroll.Update( aLayoutTransitionTime ); |
|
1004 } |
|
1005 |
|
1006 |
|
1007 // --------------------------------------------------------------------------- |
|
1008 // Create a gridlayout with three skin images. Layout is used to construct the |
|
1009 // scrollbar image. |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // |
|
1012 CHuiGridLayout* CFsHuiScrollbarLayout::CreateGridLayoutL( |
|
1013 CHuiLayout* aLayout, |
|
1014 const TAknsItemID& aIdTop, |
|
1015 const TAknsItemID& aIdMiddle, |
|
1016 const TAknsItemID& aIdBottom, |
|
1017 TFsScrollbar aOrientation ) |
|
1018 { |
|
1019 FUNC_LOG; |
|
1020 TInt columns( 1 ); |
|
1021 TInt rows( 3 ); |
|
1022 if ( EFsScrollbarHorizontal == aOrientation ) |
|
1023 { |
|
1024 columns = 3; |
|
1025 rows = 1; |
|
1026 } |
|
1027 |
|
1028 CHuiGridLayout* gridLayout( CHuiGridLayout::AddNewL( |
|
1029 *iOwnerControl, columns, rows, aLayout ) ); |
|
1030 |
|
1031 CHuiImageVisual* top( |
|
1032 CHuiImageVisual::AddNewL( *iOwnerControl, gridLayout ) ); |
|
1033 CHuiImageVisual* middle( |
|
1034 CHuiImageVisual::AddNewL( *iOwnerControl, gridLayout ) ); |
|
1035 CHuiImageVisual* bottom( |
|
1036 CHuiImageVisual::AddNewL( *iOwnerControl, gridLayout ) ); |
|
1037 |
|
1038 SetImageL( top, aIdTop, aOrientation ); |
|
1039 SetImageL( middle, aIdMiddle, aOrientation ); |
|
1040 SetImageL( bottom, aIdBottom, aOrientation ); |
|
1041 |
|
1042 TRect rectTop( top->Image().Texture().Size() ); |
|
1043 TRect rectMiddle( middle->Image().Texture().Size() ); |
|
1044 TRect rectBottom( bottom->Image().Texture().Size() ); |
|
1045 |
|
1046 RArray<TInt> weights; |
|
1047 if ( EFsScrollbarHorizontal == aOrientation ) |
|
1048 { |
|
1049 weights.Append( rectTop.Width() ); |
|
1050 weights.Append( rectMiddle.Width() ); |
|
1051 weights.Append( rectBottom.Width() ); |
|
1052 gridLayout->SetColumnsL( weights ); |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 weights.Append( rectTop.Height() ); |
|
1057 weights.Append( rectMiddle.Height() ); |
|
1058 weights.Append( rectBottom.Height() ); |
|
1059 gridLayout->SetRowsL( weights ); |
|
1060 } |
|
1061 weights.Close(); |
|
1062 |
|
1063 return gridLayout; |
|
1064 } |
|
1065 |
|
1066 |
|
1067 // --------------------------------------------------------------------------- |
|
1068 // Start using a custom set scrollbar image. |
|
1069 // Ownership of the new brush is gained. |
|
1070 // --------------------------------------------------------------------------- |
|
1071 // |
|
1072 void CFsHuiScrollbarLayout::SetCustomImageL( |
|
1073 CHuiImageBrush* aBrush, |
|
1074 TFsScrollbar aScrollbar, |
|
1075 TBool aSetThumbImage ) |
|
1076 { |
|
1077 FUNC_LOG; |
|
1078 if ( !aBrush ) |
|
1079 { |
|
1080 // Null pointer could cause problems. |
|
1081 User::Leave( KErrArgument ); |
|
1082 } |
|
1083 |
|
1084 CHuiImageBrush** imageBrush; |
|
1085 if ( aSetThumbImage ) |
|
1086 { |
|
1087 imageBrush = EFsScrollbarVertical == aScrollbar |
|
1088 ? &iVThumbBrush : &iHThumbBrush; |
|
1089 } |
|
1090 else |
|
1091 { |
|
1092 imageBrush = EFsScrollbarVertical == aScrollbar |
|
1093 ? &iVBarBrush : &iHBarBrush; |
|
1094 } |
|
1095 |
|
1096 if ( *imageBrush |
|
1097 && ( iVScrollbarLayout && EFsScrollbarVertical == aScrollbar ) |
|
1098 || ( iHScrollbarLayout && EFsScrollbarHorizontal == aScrollbar ) ) |
|
1099 { |
|
1100 // Remove the previously set image brush. |
|
1101 CHuiDeckLayout* layout; |
|
1102 if ( aSetThumbImage ) |
|
1103 { |
|
1104 layout = EFsScrollbarVertical == aScrollbar ? iVThumb : iHThumb; |
|
1105 } |
|
1106 else |
|
1107 { |
|
1108 layout = EFsScrollbarVertical == aScrollbar |
|
1109 ? iVScrollbarLayout : iHScrollbarLayout; |
|
1110 } |
|
1111 if ( layout->Brushes() ) |
|
1112 { |
|
1113 for ( TInt i( layout->Brushes()->Count() - 1 ); 0 <= i; i-- ) |
|
1114 { |
|
1115 if ( &layout->Brushes()->At( i ) == *imageBrush ) |
|
1116 { |
|
1117 layout->Brushes()->Remove( i ); |
|
1118 break; |
|
1119 } |
|
1120 } |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 // Release the previously set brush. |
|
1125 delete *imageBrush; |
|
1126 *imageBrush = aBrush; |
|
1127 |
|
1128 if ( ( iVScrollbarLayout && EFsScrollbarVertical == aScrollbar ) |
|
1129 || ( iHScrollbarLayout && EFsScrollbarHorizontal == aScrollbar ) ) |
|
1130 { |
|
1131 // The scrollbar is already visible |
|
1132 CFsScrollbarClet& scrollClet( |
|
1133 EFsScrollbarVertical == aScrollbar ? iVertScroll : iHorScroll ); |
|
1134 CHuiDeckLayout* thumbLayout( |
|
1135 EFsScrollbarVertical == aScrollbar ? iVThumb : iHThumb ); |
|
1136 |
|
1137 // Take the new image brush in use. |
|
1138 if ( aSetThumbImage ) |
|
1139 { |
|
1140 User::LeaveIfError( UseCustomImage( thumbLayout, aBrush, NULL ) ); |
|
1141 scrollClet.EnableCustomThumbImage(); |
|
1142 } |
|
1143 else |
|
1144 { |
|
1145 CHuiDeckLayout* barLayout( EFsScrollbarVertical == aScrollbar |
|
1146 ? iVScrollbarLayout : iHScrollbarLayout ); |
|
1147 User::LeaveIfError( |
|
1148 UseCustomImage( barLayout, aBrush, thumbLayout ) ); |
|
1149 scrollClet.EnableCustomBarImage(); |
|
1150 } |
|
1151 } |
|
1152 } |
|
1153 |