|
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 : Freestyle tree list visualizer implementation |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 //////SYSTEM INCLUDES |
|
20 #include "emailtrace.h" |
|
21 #include <AknUtils.h> |
|
22 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
23 //#include <fsconfig.h> |
|
24 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
25 #include <StringLoader.h> |
|
26 #include <avkon.rsg> // R_AVKON_EMPTY_POPUP_LIST_TEXT |
|
27 #include <centralrepository.h> |
|
28 |
|
29 //////TOOLKIT INCLUDES |
|
30 // <cmail> SF |
|
31 #include <alf/alfstatic.h> |
|
32 #include <alf/alfownership.h> |
|
33 #include <alf/alfevent.h> |
|
34 #include <alf/alfimage.h> |
|
35 #include <alf/alfenv.h> |
|
36 #include <alf/alfcontrolgroup.h> |
|
37 //layouts |
|
38 #include <alf/alfflowlayout.h> |
|
39 #include <alf/alfdecklayout.h> |
|
40 #include <alf/alfgridlayout.h> |
|
41 //brushes |
|
42 #include <alf/alfbrusharray.h> |
|
43 #include <alf/alfbrush.h> |
|
44 #include <alf/alfborderbrush.h> |
|
45 #include <alf/alfimagebrush.h> |
|
46 #include <alf/alfgradientbrush.h> |
|
47 #include <alf/alfframebrush.h> |
|
48 #include <alf/alfshadowborderbrush.h> |
|
49 //metrics |
|
50 #include <alf/alfmetric.h> |
|
51 #include <alf/alftimedvalue.h> |
|
52 //visuals |
|
53 #include <alf/alfvisual.h> |
|
54 #include <alf/alfimagevisual.h> |
|
55 // </cmail> |
|
56 |
|
57 |
|
58 //////PROJECT INCLUDES |
|
59 #include "fstreevisualizerbase.h" |
|
60 #include "fstreeplainrootvisualizer.h" |
|
61 #include "fstree.h" |
|
62 #include "fstreeiterator.h" |
|
63 #include "fsgenericpanic.h" |
|
64 #include "fsfadeeffect.h" |
|
65 #include "fstreeplainonelineitemdata.h" |
|
66 #include "fsslideeffect.h" |
|
67 #include "fstreeplainonelineitemvisualizer.h" |
|
68 #include "fstreelist.h" |
|
69 #include "fstreevisualizerobserver.h" |
|
70 #include "fscenrepkeys.h" |
|
71 #include "fswatermark.h" |
|
72 #include "fslayoutmanager.h" |
|
73 #include "fsseparatordata.h" |
|
74 ////alf specific |
|
75 #include "fsalfscrollbarlayout.h" |
|
76 #include "fsalftextstylemanager.h" |
|
77 #include "fsinteractioninterval.h" |
|
78 |
|
79 #include <aknphysics.h> |
|
80 |
|
81 //CONSTANTS |
|
82 const TInt KDefaultShadowWidth = 4; |
|
83 const TInt KFSListDefaultSelectorBorderWidth = 0; |
|
84 const TInt KZero = 0; |
|
85 _LIT8( KPropertyItemId, "PropItemID" ); |
|
86 |
|
87 // check from aknphysicsconstants.h |
|
88 const TInt KFlickMaxDuration( 500000 ); |
|
89 |
|
90 // ======== LOCAL FUNCTIONS ======== |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Deletes and sets pointer to NULL. |
|
94 // --------------------------------------------------------------------------- |
|
95 template<class T> void SafeDelete(T*& aPtr) |
|
96 { |
|
97 delete aPtr; |
|
98 aPtr = NULL; |
|
99 } |
|
100 |
|
101 // ======== MEMBER FUNCTIONS ======== |
|
102 |
|
103 // TWorld::TItem |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // TWorld::TItem::TItem |
|
107 // --------------------------------------------------------------------------- |
|
108 TWorld::TItem::TItem(const TFsTreeItemId aId, const TRect& aRect) : |
|
109 iId(aId) |
|
110 { |
|
111 SetRect(aRect); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // TWorld::TItem::Rect |
|
116 // --------------------------------------------------------------------------- |
|
117 TRect TWorld::TItem::Rect() const |
|
118 { |
|
119 return TRect(TPoint(0, iY), TPoint(0, iY + iHeight)); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // TWorld::TItem::SetRect |
|
124 // --------------------------------------------------------------------------- |
|
125 void TWorld::TItem::SetRect(const TRect& aRect) |
|
126 { |
|
127 iY = aRect.iTl.iY; |
|
128 iHeight = aRect.Height(); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // TWorld::TItem::Move |
|
133 // --------------------------------------------------------------------------- |
|
134 void TWorld::TItem::Move(TInt aDy) |
|
135 { |
|
136 iY += aDy; |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // TWorld::TItem::Top |
|
141 // --------------------------------------------------------------------------- |
|
142 TInt TWorld::TItem::Top() const |
|
143 { |
|
144 return iY; |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // TWorld::TItem::TopLeft |
|
149 // --------------------------------------------------------------------------- |
|
150 TPoint TWorld::TItem::TopLeft() const |
|
151 { |
|
152 return TPoint(0, iY); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // TWorld::TItem::Height |
|
157 // --------------------------------------------------------------------------- |
|
158 TInt TWorld::TItem::Height() const |
|
159 { |
|
160 return iHeight; |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // TWorld::TItem::Bottom |
|
165 // --------------------------------------------------------------------------- |
|
166 TInt TWorld::TItem::Bottom() const |
|
167 { |
|
168 return iY + iHeight; |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------------------------- |
|
172 // TWorld::TItem::Bottom |
|
173 // --------------------------------------------------------------------------- |
|
174 TPoint TWorld::TItem::BottomRight() const |
|
175 { |
|
176 return TPoint(0, iY + iHeight); |
|
177 } |
|
178 |
|
179 // TWorld |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // TWorld::TWorld |
|
183 // --------------------------------------------------------------------------- |
|
184 TWorld::TWorld() : |
|
185 iBatchUpdateOngoing(EFalse) |
|
186 { |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // TWorld::~TWorld |
|
191 // --------------------------------------------------------------------------- |
|
192 TWorld::~TWorld() |
|
193 { |
|
194 iItems.Reset(); |
|
195 iObservers.Reset(); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // TWorld::AddObserverL |
|
200 // --------------------------------------------------------------------------- |
|
201 void TWorld::AddObserverL(MObserver& aObserver) |
|
202 { |
|
203 iObservers.AppendL(&aObserver); |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // TWorld::RemoveObserver |
|
208 // --------------------------------------------------------------------------- |
|
209 void TWorld::RemoveObserver(MObserver& aObserver) |
|
210 { |
|
211 const TInt index(iObservers.Find(&aObserver)); |
|
212 if (index != KErrNotFound) |
|
213 { |
|
214 iObservers.Remove(index); |
|
215 } |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // TWorld::AppendL |
|
220 // --------------------------------------------------------------------------- |
|
221 void TWorld::AppendL(const TFsTreeItemId aId, const TSize& aSize) |
|
222 { |
|
223 const TInt count(iItems.Count()); |
|
224 TPoint tl; |
|
225 if (count > 0) |
|
226 { |
|
227 tl.iY = iItems[count - 1].Bottom(); |
|
228 } |
|
229 const TRect modifiedRect(TRect(tl, aSize)); |
|
230 iItems.AppendL(TItem(aId, modifiedRect)); |
|
231 iHeight += aSize.iHeight; |
|
232 UpdatedL(); |
|
233 } |
|
234 |
|
235 // --------------------------------------------------------------------------- |
|
236 // TWorld::InsertL |
|
237 // --------------------------------------------------------------------------- |
|
238 void TWorld::InsertL(const TFsTreeItemId aId, const TSize& aSize, |
|
239 const TInt aSlot) |
|
240 { |
|
241 if (aSlot >= iItems.Count()) |
|
242 { |
|
243 AppendL(aId, aSize); |
|
244 } |
|
245 else |
|
246 { |
|
247 const TPoint topLeft(iItems[aSlot].TopLeft()); |
|
248 iItems.InsertL(TItem(aId, TRect(topLeft, aSize)), aSlot); |
|
249 MoveBy(aSlot + 1, aSize.iHeight); |
|
250 iHeight += aSize.iHeight; |
|
251 UpdatedL(); |
|
252 } |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // TWorld::RemoveL |
|
257 // --------------------------------------------------------------------------- |
|
258 void TWorld::RemoveL(const TFsTreeItemId aId) |
|
259 { |
|
260 for (TInt i = iItems.Count() - 1; i >= 0; i--) |
|
261 { |
|
262 const TFsTreeItemId itemId(iItems[i].iId); |
|
263 if (itemId == aId) |
|
264 { |
|
265 const TItem item(iItems[i]); |
|
266 iItems.Remove(i); |
|
267 const TInt delta(-item.Height()); |
|
268 MoveBy(i, delta); |
|
269 iHeight += delta; |
|
270 UpdatedL(); |
|
271 break; |
|
272 } |
|
273 } |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // TWorld::RemoveAllL |
|
278 // --------------------------------------------------------------------------- |
|
279 void TWorld::RemoveAllL() |
|
280 { |
|
281 iHeight = 0; |
|
282 iItems.Reset(); |
|
283 UpdatedL(); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // TWorld::Height |
|
288 // --------------------------------------------------------------------------- |
|
289 TInt TWorld::Height() const |
|
290 { |
|
291 return iHeight; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // TWorld::ItemCount |
|
296 // --------------------------------------------------------------------------- |
|
297 TInt TWorld::ItemCount() const |
|
298 { |
|
299 return iItems.Count(); |
|
300 } |
|
301 |
|
302 // --------------------------------------------------------------------------- |
|
303 // TWorld::Item |
|
304 // --------------------------------------------------------------------------- |
|
305 TFsTreeItemId TWorld::Item(TInt aIndex) const |
|
306 { |
|
307 return iItems[aIndex].iId; |
|
308 } |
|
309 |
|
310 // --------------------------------------------------------------------------- |
|
311 // TWorld::IndexOfItem |
|
312 // --------------------------------------------------------------------------- |
|
313 TInt TWorld::IndexOfItem(TFsTreeItemId aItem) const |
|
314 { |
|
315 for (TInt i = 0; i < iItems.Count(); i++) |
|
316 { |
|
317 if (iItems[i].iId == aItem) |
|
318 { |
|
319 return i; |
|
320 } |
|
321 } |
|
322 return KErrNotFound; |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // TWorld::MoveBy |
|
327 // --------------------------------------------------------------------------- |
|
328 void TWorld::MoveBy(const TInt aSlot, const TInt aDelta) |
|
329 { |
|
330 const TInt count(iItems.Count()); |
|
331 for (TInt i = aSlot; i < count; i++) |
|
332 { |
|
333 iItems[i].Move(aDelta); |
|
334 } |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // TWorld::UpdatedL |
|
339 // --------------------------------------------------------------------------- |
|
340 void TWorld::UpdatedL() |
|
341 { |
|
342 if (!iBatchUpdateOngoing) |
|
343 { |
|
344 for (TInt i = iObservers.Count() - 1; i >= 0; i--) |
|
345 { |
|
346 iObservers[i]->WorldUpdatedL(*this); |
|
347 } |
|
348 } |
|
349 } |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // TWorld::GetItemsL |
|
353 // Uses binary search. |
|
354 // --------------------------------------------------------------------------- |
|
355 void TWorld::GetItemsL(RArray<TFsTreeItemId>& aItems, TInt aY, TInt aHeight, |
|
356 TInt& aOffset) |
|
357 { |
|
358 // First find first visible item using binary search algorithm |
|
359 aItems.Reset(); |
|
360 TInt i(0); |
|
361 aOffset = 0; |
|
362 if (aY > Height()) |
|
363 { |
|
364 aHeight = -1; |
|
365 } |
|
366 else if (aY > 0) |
|
367 { |
|
368 TInt top(0); |
|
369 TInt bottom(iItems.Count() - 1); |
|
370 while (top <= bottom) |
|
371 { |
|
372 TInt middle(top + (bottom - top) / 2); |
|
373 TInt topCoord(iItems[middle].Top()); |
|
374 TInt bottomCoord(iItems[middle].Bottom()); |
|
375 if (aY < topCoord) |
|
376 { |
|
377 if (bottom == middle) |
|
378 { |
|
379 bottom--; |
|
380 } |
|
381 else |
|
382 { |
|
383 bottom = middle; |
|
384 } |
|
385 } |
|
386 else if (aY > bottomCoord) |
|
387 { |
|
388 if (top == middle) |
|
389 { |
|
390 top++; |
|
391 } |
|
392 else |
|
393 { |
|
394 top = middle; |
|
395 } |
|
396 } |
|
397 else |
|
398 { |
|
399 aOffset = aY - topCoord; |
|
400 aHeight += aOffset; |
|
401 i = middle; |
|
402 break; |
|
403 } |
|
404 } |
|
405 } |
|
406 else |
|
407 { |
|
408 aOffset = aY; |
|
409 aHeight += aY; |
|
410 } |
|
411 |
|
412 // If item was found, collect enough items to fill the view |
|
413 while (aHeight >= 0 && i < iItems.Count()) |
|
414 { |
|
415 aItems.AppendL(iItems[i].iId); |
|
416 aHeight -= iItems[i++].Height(); |
|
417 } |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // TWorld::BeginUpdate |
|
422 // --------------------------------------------------------------------------- |
|
423 void TWorld::BeginUpdate() |
|
424 { |
|
425 iBatchUpdateOngoing = ETrue; |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // TWorld::EndUpdateL |
|
430 // --------------------------------------------------------------------------- |
|
431 void TWorld::EndUpdateL() |
|
432 { |
|
433 if (iBatchUpdateOngoing) |
|
434 { |
|
435 iBatchUpdateOngoing = EFalse; |
|
436 UpdatedL(); |
|
437 } |
|
438 } |
|
439 |
|
440 // --------------------------------------------------------------------------- |
|
441 // TWorld::IsUpdating |
|
442 // --------------------------------------------------------------------------- |
|
443 TBool TWorld::IsUpdating() const |
|
444 { |
|
445 return iBatchUpdateOngoing; |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------------------------- |
|
449 // TWorld::Recalculate |
|
450 // --------------------------------------------------------------------------- |
|
451 void TWorld::Recalculate(const CFsTree& aTree) |
|
452 { |
|
453 TPoint tl; |
|
454 iHeight = 0; |
|
455 for (TInt i = 0; i < iItems.Count(); i++) |
|
456 { |
|
457 TItem& item(iItems[i]); |
|
458 MFsTreeItemVisualizer* visualizer(aTree.ItemVisualizer(item.iId)); |
|
459 TSize size(visualizer->Size()); |
|
460 item.SetRect(TRect(tl, size)); |
|
461 tl.iY += size.iHeight; |
|
462 iHeight += size.iHeight; |
|
463 } |
|
464 } |
|
465 |
|
466 // --------------------------------------------------------------------------- |
|
467 // TWorld::GetItemRect |
|
468 // --------------------------------------------------------------------------- |
|
469 TInt TWorld::GetItemRect(const TFsTreeItemId aItemId, TRect& aRect) const |
|
470 { |
|
471 TInt result(KErrNotFound); |
|
472 for (TInt i = iItems.Count() - 1; i >= 0; i--) |
|
473 { |
|
474 if (iItems[i].iId == aItemId) |
|
475 { |
|
476 result = i; |
|
477 aRect = iItems[i].Rect(); |
|
478 break; |
|
479 } |
|
480 } |
|
481 return result; |
|
482 } |
|
483 |
|
484 // --------------------------------------------------------------------------- |
|
485 // TWorld::GetItemRectByIndex |
|
486 // --------------------------------------------------------------------------- |
|
487 TInt TWorld::GetItemRectByIndex(const TInt aIndex, TRect& aRect) const |
|
488 { |
|
489 TInt result(KErrNotFound); |
|
490 if (aIndex < iItems.Count() && aIndex >= 0) |
|
491 { |
|
492 aRect = iItems[aIndex].Rect(); |
|
493 result = KErrNone; |
|
494 } |
|
495 return result; |
|
496 } |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // TWorld::CheckIntegrity |
|
500 // --------------------------------------------------------------------------- |
|
501 TBool TWorld::CheckIntegrity() const |
|
502 { |
|
503 TBool result(ETrue); |
|
504 if (iItems.Count() > 1) |
|
505 { |
|
506 TRect prev(iItems[0].Rect()); |
|
507 for (TInt i = 1; i < iItems.Count() - 1; i++) |
|
508 { |
|
509 const TRect& curr(iItems[i].Rect()); |
|
510 if (prev.Intersects(curr)) |
|
511 { |
|
512 result = EFalse; |
|
513 break; |
|
514 } |
|
515 prev.iBr.iY += curr.Height(); |
|
516 } |
|
517 } |
|
518 return result; |
|
519 } |
|
520 |
|
521 // TViewPort |
|
522 |
|
523 // --------------------------------------------------------------------------- |
|
524 // TViewPort::TViewPort |
|
525 // --------------------------------------------------------------------------- |
|
526 TViewPort::TViewPort(MObserver& aObserver, TWorld& aWorld) : |
|
527 iObserver(aObserver), iWorld(aWorld) |
|
528 { |
|
529 } |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // TViewPort::SetPositionL |
|
533 // --------------------------------------------------------------------------- |
|
534 void TViewPort::SetPositionL(const TPoint& aPosition, TBool aInformUpdate) |
|
535 { |
|
536 iPosition = aPosition; |
|
537 // Do validation! |
|
538 if (aInformUpdate) |
|
539 { |
|
540 UpdatedL(); |
|
541 } |
|
542 } |
|
543 |
|
544 // --------------------------------------------------------------------------- |
|
545 // TViewPort::SetCenterPositionL |
|
546 // --------------------------------------------------------------------------- |
|
547 void TViewPort::SetCenterPositionL(const TPoint& aPosition, |
|
548 TBool aInformUpdate) |
|
549 { |
|
550 iPosition = TPoint(aPosition.iX - iSize.iWidth / 2, aPosition.iY |
|
551 - iSize.iHeight / 2); |
|
552 // Do validation! |
|
553 if (aInformUpdate) |
|
554 { |
|
555 UpdatedL(); |
|
556 } |
|
557 } |
|
558 |
|
559 // --------------------------------------------------------------------------- |
|
560 // TViewPort::Position |
|
561 // --------------------------------------------------------------------------- |
|
562 const TPoint& TViewPort::Position() const |
|
563 { |
|
564 return iPosition; |
|
565 } |
|
566 |
|
567 // --------------------------------------------------------------------------- |
|
568 // TViewPort::CenterPosition |
|
569 // --------------------------------------------------------------------------- |
|
570 TPoint TViewPort::CenterPosition() const |
|
571 { |
|
572 TPoint result(iPosition.iX + iSize.iWidth / 2, iPosition.iY |
|
573 + iSize.iHeight / 2); |
|
574 return result; |
|
575 } |
|
576 |
|
577 // --------------------------------------------------------------------------- |
|
578 // TViewPort::SetSizeL |
|
579 // --------------------------------------------------------------------------- |
|
580 void TViewPort::SetSizeL(const TSize& aSize) |
|
581 { |
|
582 iSize = aSize; |
|
583 // Do validation! |
|
584 if (!iWorld.IsUpdating()) |
|
585 { |
|
586 UpdatedL(); |
|
587 } |
|
588 } |
|
589 |
|
590 // --------------------------------------------------------------------------- |
|
591 // TViewPort::Size |
|
592 // --------------------------------------------------------------------------- |
|
593 const TSize& TViewPort::Size() const |
|
594 { |
|
595 return iSize; |
|
596 } |
|
597 |
|
598 // --------------------------------------------------------------------------- |
|
599 // TViewPort::GetVisibleItemsL |
|
600 // --------------------------------------------------------------------------- |
|
601 void TViewPort::GetVisibleItemsL(RArray<TFsTreeItemId>& aItemsToBeRemoved, |
|
602 RArray<TFsTreeItemId>& aItemsToBeAdded, TInt& aOffset, |
|
603 TBool& aFullUpdate) |
|
604 { |
|
605 RArray<TFsTreeItemId> tempItems; |
|
606 CleanupClosePushL(tempItems); |
|
607 iWorld.GetItemsL(tempItems, iPosition.iY, iSize.iHeight, aOffset); |
|
608 iCache.UpdateL(tempItems, aItemsToBeRemoved, aItemsToBeAdded, aFullUpdate); |
|
609 CleanupStack::PopAndDestroy(); // tempItems |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------------------------- |
|
613 // TViewPort::IsScrollBarNeeded |
|
614 // --------------------------------------------------------------------------- |
|
615 TBool TViewPort::IsScrollBarNeeded() const |
|
616 { |
|
617 return iWorld.Height() > iSize.iHeight; |
|
618 } |
|
619 |
|
620 // --------------------------------------------------------------------------- |
|
621 // TViewPort::UpdatedL |
|
622 // --------------------------------------------------------------------------- |
|
623 void TViewPort::UpdatedL() |
|
624 { |
|
625 iObserver.ViewPortUpdatedL(*this); |
|
626 } |
|
627 |
|
628 // --------------------------------------------------------------------------- |
|
629 // TViewPort::WorldUpdatedL |
|
630 // --------------------------------------------------------------------------- |
|
631 void TViewPort::WorldUpdatedL(const TWorld& aWorld) |
|
632 { |
|
633 // recreate viewable set if needed |
|
634 if (iPosition.iY > aWorld.Height() || (iPosition.iY + iSize.iHeight |
|
635 > aWorld.Height() && iSize.iHeight <= aWorld.Height())) |
|
636 { |
|
637 iPosition.iY = Max(0, aWorld.Height() - iSize.iHeight); |
|
638 } |
|
639 else if (iSize.iHeight > aWorld.Height() && iPosition.iY > 0) |
|
640 { |
|
641 iPosition.iY = 0; |
|
642 } |
|
643 iObserver.ViewPortUpdatedL(*this); |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // TViewPort::ScrollToItemL |
|
648 // --------------------------------------------------------------------------- |
|
649 void TViewPort::ScrollToItemL(const TFsTreeItemId aItemId, |
|
650 TBool aInformUpdate) |
|
651 { |
|
652 TRect itemRect; |
|
653 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
654 { |
|
655 SetPositionL(itemRect.iTl, aInformUpdate); |
|
656 } |
|
657 } |
|
658 |
|
659 // --------------------------------------------------------------------------- |
|
660 // TViewPort::CenterToItemL |
|
661 // --------------------------------------------------------------------------- |
|
662 void TViewPort::CenterToItemL(const TFsTreeItemId aItemId, |
|
663 TBool aInformUpdate) |
|
664 { |
|
665 TRect itemRect; |
|
666 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
667 { |
|
668 TInt top(itemRect.iTl.iY); |
|
669 top -= (iSize.iHeight - itemRect.Height()) / 2; |
|
670 LimitTop(top); |
|
671 SetPositionL(TPoint(iPosition.iX, top), aInformUpdate); |
|
672 } |
|
673 } |
|
674 |
|
675 // --------------------------------------------------------------------------- |
|
676 // TViewPort::ItemToPositionL |
|
677 // Tries to scroll view so that given item is in given position aPosition. |
|
678 // --------------------------------------------------------------------------- |
|
679 void TViewPort::ItemToPositionL(const TFsTreeItemId aItemId, |
|
680 const TPoint& aPosition, const TBool aInformUpdate, |
|
681 const TPositionHint aHint) |
|
682 { |
|
683 TRect itemRect; |
|
684 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
685 { |
|
686 TInt top(itemRect.iTl.iY); |
|
687 top -= aPosition.iY; |
|
688 LimitTop(top); |
|
689 if (aHint == EPositionAfterExpand) |
|
690 { |
|
691 const TInt error( iWorld.GetItemRectByIndex( |
|
692 iWorld.IndexOfItem(aItemId) + 1, itemRect) ); |
|
693 if (!error) |
|
694 { |
|
695 if (itemRect.iBr.iY - top > iSize.iHeight) |
|
696 { |
|
697 top += itemRect.iBr.iY - top - iSize.iHeight; |
|
698 LimitTop(top); |
|
699 } |
|
700 } |
|
701 } |
|
702 SetPositionL(TPoint(iPosition.iX, top), aInformUpdate); |
|
703 } |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------------------------- |
|
707 // TViewPort::ScrollItemToViewL |
|
708 // Scrolls item to view. Item is set as top most item, if it is above the current |
|
709 // display area or bottom most item if it is below the current display area. |
|
710 // --------------------------------------------------------------------------- |
|
711 void TViewPort::ScrollItemToViewL(const TFsTreeItemId aItemId, |
|
712 TBool aInformUpdate) |
|
713 { |
|
714 TRect itemRect; |
|
715 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
716 { |
|
717 if (itemRect.iTl.iY < iPosition.iY) |
|
718 { |
|
719 SetPositionL(itemRect.iTl, aInformUpdate); |
|
720 } |
|
721 if (itemRect.iBr.iY > iPosition.iY + iSize.iHeight) |
|
722 { |
|
723 SetPositionL( |
|
724 TPoint(iPosition.iX, itemRect.iBr.iY - iSize.iHeight), |
|
725 aInformUpdate); |
|
726 } |
|
727 } |
|
728 } |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // TViewPort::MakeViewFullyOccupiedL |
|
732 // --------------------------------------------------------------------------- |
|
733 void TViewPort::MakeViewFullyOccupiedL(TBool aInformUpdate) |
|
734 { |
|
735 TInt top(iPosition.iY); |
|
736 LimitTop(top); |
|
737 SetPositionL(TPoint(iPosition.iX, top), aInformUpdate); |
|
738 } |
|
739 |
|
740 // --------------------------------------------------------------------------- |
|
741 // TViewPort::TopItem |
|
742 // --------------------------------------------------------------------------- |
|
743 TFsTreeItemId TViewPort::TopItem() const |
|
744 { |
|
745 return iCache.TopItem(); |
|
746 } |
|
747 |
|
748 // --------------------------------------------------------------------------- |
|
749 // TViewPort::ClearCache |
|
750 // --------------------------------------------------------------------------- |
|
751 void TViewPort::ClearCache() |
|
752 { |
|
753 iCache.Clear(); |
|
754 } |
|
755 |
|
756 // --------------------------------------------------------------------------- |
|
757 // TViewPort::ItemRect |
|
758 // --------------------------------------------------------------------------- |
|
759 TRect TViewPort::ItemRect(const TFsTreeItemId aItemId) const |
|
760 { |
|
761 TRect itemRect; |
|
762 if (!iCache.IsClear() && iCache.ContainsItem(aItemId)) |
|
763 { |
|
764 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
765 { |
|
766 itemRect.Move(0, -iPosition.iY); |
|
767 } |
|
768 } |
|
769 return itemRect; |
|
770 } |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // TViewPort::ItemFullyVisible |
|
774 // --------------------------------------------------------------------------- |
|
775 TBool TViewPort::ItemFullyVisible(const TFsTreeItemId aItemId) const |
|
776 { |
|
777 TBool result(EFalse); |
|
778 if (!iCache.IsClear() && iCache.ContainsItem(aItemId)) |
|
779 { |
|
780 TRect itemRect; |
|
781 if (iWorld.GetItemRect(aItemId, itemRect) != KErrNotFound) |
|
782 { |
|
783 if (itemRect.Height()) |
|
784 { |
|
785 const TRect viewRect(iPosition, iSize); |
|
786 result = viewRect.Contains(itemRect.iTl) |
|
787 && viewRect.Contains(itemRect.iBr); |
|
788 } |
|
789 } |
|
790 } |
|
791 return result; |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // TViewPort::ItemRect |
|
796 // --------------------------------------------------------------------------- |
|
797 void TViewPort::LimitTop(TInt& aTop) const |
|
798 { |
|
799 aTop = Min(iWorld.Height() - iSize.iHeight, aTop); |
|
800 aTop = Max(0, aTop); |
|
801 } |
|
802 |
|
803 // --------------------------------------------------------------------------- |
|
804 // TViewPort::TCache::TCache |
|
805 // --------------------------------------------------------------------------- |
|
806 TViewPort::TCache::TCache() : |
|
807 iClear(ETrue) |
|
808 { |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------------------------- |
|
812 // TViewPort::TCache::~TCache |
|
813 // --------------------------------------------------------------------------- |
|
814 TViewPort::TCache::~TCache() |
|
815 { |
|
816 iCachedItems.Reset(); |
|
817 } |
|
818 |
|
819 // --------------------------------------------------------------------------- |
|
820 // TViewPort::TCache::Clear |
|
821 // --------------------------------------------------------------------------- |
|
822 void TViewPort::TCache::Clear() |
|
823 { |
|
824 iClear = ETrue; |
|
825 iCachedItems.Reset(); |
|
826 } |
|
827 |
|
828 // --------------------------------------------------------------------------- |
|
829 // TViewPort::TCache::IsClear |
|
830 // --------------------------------------------------------------------------- |
|
831 TBool TViewPort::TCache::IsClear() const |
|
832 { |
|
833 return iClear; |
|
834 } |
|
835 |
|
836 // --------------------------------------------------------------------------- |
|
837 // TViewPort::TCache::ContainsItem |
|
838 // --------------------------------------------------------------------------- |
|
839 TBool TViewPort::TCache::ContainsItem(const TFsTreeItemId aItemId) const |
|
840 { |
|
841 return iCachedItems.Find(aItemId) != KErrNotFound; |
|
842 } |
|
843 |
|
844 // --------------------------------------------------------------------------- |
|
845 // TViewPort::TCache::UpdateL |
|
846 // --------------------------------------------------------------------------- |
|
847 void TViewPort::TCache::UpdateL(const RArray<TFsTreeItemId>& aItems, RArray< |
|
848 TFsTreeItemId>& aItemsToBeRemoved, |
|
849 RArray<TFsTreeItemId>& aItemsToBeAdded, TBool& aFullUpdate) |
|
850 { |
|
851 aFullUpdate = iClear; |
|
852 if (!iClear) |
|
853 { |
|
854 // find items in cache, missing in new set => items to be removed |
|
855 aItemsToBeRemoved.Reset(); |
|
856 for (TInt i = 0; i < iCachedItems.Count(); i++) |
|
857 { |
|
858 if (aItems.Find(iCachedItems[i]) == KErrNotFound) |
|
859 { |
|
860 aItemsToBeRemoved.AppendL(iCachedItems[i]); |
|
861 } |
|
862 } |
|
863 |
|
864 // find items in new set, missing in cache => items to be added |
|
865 aItemsToBeAdded.Reset(); |
|
866 for (TInt i = 0; i < aItems.Count(); i++) |
|
867 { |
|
868 if (iCachedItems.Find(aItems[i]) == KErrNotFound) |
|
869 { |
|
870 aItemsToBeAdded.AppendL(aItems[i]); |
|
871 } |
|
872 else |
|
873 { |
|
874 aItemsToBeAdded.AppendL(KFsTreeNoneID); |
|
875 } |
|
876 } |
|
877 } |
|
878 else |
|
879 { |
|
880 // find items in new set, missing in cache => items to be added |
|
881 aItemsToBeAdded.Reset(); |
|
882 for (TInt i = 0; i < aItems.Count(); i++) |
|
883 { |
|
884 aItemsToBeAdded.AppendL(aItems[i]); |
|
885 } |
|
886 } |
|
887 // finally update cache |
|
888 iCachedItems.Reset(); |
|
889 for (TInt i = 0; i < aItems.Count(); i++) |
|
890 { |
|
891 iCachedItems.AppendL(aItems[i]); |
|
892 } |
|
893 iClear = EFalse; |
|
894 } |
|
895 |
|
896 // --------------------------------------------------------------------------- |
|
897 // TViewPort::TCache::TopItem |
|
898 // --------------------------------------------------------------------------- |
|
899 TFsTreeItemId TViewPort::TCache::TopItem() const |
|
900 { |
|
901 if (iClear || !iCachedItems.Count()) |
|
902 { |
|
903 return KFsTreeNoneID; |
|
904 } |
|
905 return iCachedItems[0]; |
|
906 } |
|
907 |
|
908 // --------------------------------------------------------------------------- |
|
909 // Two-phased constructor. |
|
910 // --------------------------------------------------------------------------- |
|
911 // |
|
912 EXPORT_C CFsTreeVisualizerBase* CFsTreeVisualizerBase::NewL( |
|
913 CAlfControl* aOwnerControl, CAlfLayout& aParent, |
|
914 const TBool aDirectTouchMode) |
|
915 { |
|
916 FUNC_LOG; |
|
917 CFsTreeVisualizerBase* self = new (ELeave) CFsTreeVisualizerBase( |
|
918 aOwnerControl, aParent, aDirectTouchMode); |
|
919 CleanupStack::PushL(self); |
|
920 self->ConstructL(); |
|
921 CleanupStack::Pop(self); |
|
922 return self; |
|
923 } |
|
924 |
|
925 // --------------------------------------------------------------------------- |
|
926 // C++ destructor. |
|
927 // --------------------------------------------------------------------------- |
|
928 // |
|
929 CFsTreeVisualizerBase::~CFsTreeVisualizerBase() |
|
930 { |
|
931 FUNC_LOG; |
|
932 delete iDragHandler; |
|
933 delete iPhysics; |
|
934 if (iOwnerControl) |
|
935 { |
|
936 iOwnerControl->Env().RemoveActionObserver(this); |
|
937 } |
|
938 delete iBorderBrush; |
|
939 iVisibleItems.Close(); |
|
940 iVisibleItemsBackground.Close(); |
|
941 iCustomPageUpKeys.Close(); |
|
942 iCustomPageDownKeys.Close(); |
|
943 delete iFadeEffect; |
|
944 delete iSlideEffect; |
|
945 delete iWatermark; |
|
946 delete iTextStyleManager; |
|
947 delete iIntx; |
|
948 // <cmail> Change scrollbar to avkon (to support skinning & touch) |
|
949 delete iScrollBar; |
|
950 // </cmail> |
|
951 } |
|
952 |
|
953 // --------------------------------------------------------------------------- |
|
954 //Sets data model for the visualizer. |
|
955 // --------------------------------------------------------------------------- |
|
956 // |
|
957 void CFsTreeVisualizerBase::SetTreeData(CFsTree& aTreeData) |
|
958 { |
|
959 FUNC_LOG; |
|
960 iTreeData = &aTreeData; |
|
961 } |
|
962 |
|
963 // --------------------------------------------------------------------------- |
|
964 // Adds custom key which triggers page-up event. |
|
965 // --------------------------------------------------------------------------- |
|
966 // |
|
967 void CFsTreeVisualizerBase::AddCustomPageUpKey(TInt aKeyCode) |
|
968 { |
|
969 FUNC_LOG; |
|
970 iCustomPageUpKeys.InsertInOrder(aKeyCode); |
|
971 } |
|
972 |
|
973 // --------------------------------------------------------------------------- |
|
974 // Removes given key code from custom page-up event key codes. |
|
975 // --------------------------------------------------------------------------- |
|
976 // |
|
977 TBool CFsTreeVisualizerBase::RemoveCustomPageUpKey(TInt aKeyCode) |
|
978 { |
|
979 FUNC_LOG; |
|
980 TBool keyRemoved = EFalse; |
|
981 |
|
982 TInt index = iCustomPageUpKeys.FindInOrder(aKeyCode); |
|
983 if (index != KErrNotFound) |
|
984 { |
|
985 iCustomPageUpKeys.Remove(index); |
|
986 keyRemoved = ETrue; |
|
987 } |
|
988 |
|
989 return keyRemoved; |
|
990 } |
|
991 |
|
992 // --------------------------------------------------------------------------- |
|
993 // Checks whether given key is a custom key for page-up event. |
|
994 // --------------------------------------------------------------------------- |
|
995 // |
|
996 TBool CFsTreeVisualizerBase::IsCustomPageUpKey(TInt aKeyCode) |
|
997 { |
|
998 FUNC_LOG; |
|
999 TBool keyExists = EFalse; |
|
1000 TInt index = iCustomPageUpKeys.FindInOrder(aKeyCode); |
|
1001 if (index != KErrNotFound) |
|
1002 { |
|
1003 keyExists = ETrue; |
|
1004 } |
|
1005 return keyExists; |
|
1006 } |
|
1007 |
|
1008 // --------------------------------------------------------------------------- |
|
1009 // Adds custom key which triggers page-down event. |
|
1010 // --------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CFsTreeVisualizerBase::AddCustomPageDownKey(TInt aKeyCode) |
|
1013 { |
|
1014 FUNC_LOG; |
|
1015 iCustomPageDownKeys.InsertInOrder(aKeyCode); |
|
1016 } |
|
1017 |
|
1018 // --------------------------------------------------------------------------- |
|
1019 // Removes given key code from custom page-down event key codes. |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // |
|
1022 TBool CFsTreeVisualizerBase::RemoveCustomPageDownKey(TInt aKeyCode) |
|
1023 { |
|
1024 FUNC_LOG; |
|
1025 TBool keyRemoved = EFalse; |
|
1026 |
|
1027 TInt index = iCustomPageDownKeys.FindInOrder(aKeyCode); |
|
1028 if (index != KErrNotFound) |
|
1029 { |
|
1030 iCustomPageDownKeys.Remove(index); |
|
1031 keyRemoved = ETrue; |
|
1032 } |
|
1033 |
|
1034 return keyRemoved; |
|
1035 } |
|
1036 |
|
1037 // --------------------------------------------------------------------------- |
|
1038 // Checks whether given key is a custom key for page-down event. |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // |
|
1041 TBool CFsTreeVisualizerBase::IsCustomPageDownKey(TInt aKeyCode) |
|
1042 { |
|
1043 FUNC_LOG; |
|
1044 TBool keyExists = EFalse; |
|
1045 TInt index = iCustomPageDownKeys.FindInOrder(aKeyCode); |
|
1046 if (index != KErrNotFound) |
|
1047 { |
|
1048 keyExists = ETrue; |
|
1049 } |
|
1050 return keyExists; |
|
1051 } |
|
1052 |
|
1053 // --------------------------------------------------------------------------- |
|
1054 // Sets icon for a mark sign. |
|
1055 // --------------------------------------------------------------------------- |
|
1056 // |
|
1057 void CFsTreeVisualizerBase::SetMarkIcon(CAlfTexture& aMarkIcon) |
|
1058 { |
|
1059 FUNC_LOG; |
|
1060 iMarkIcon = &aMarkIcon; |
|
1061 } |
|
1062 |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // Returns icon used to mark items. |
|
1065 // --------------------------------------------------------------------------- |
|
1066 // |
|
1067 CAlfTexture* CFsTreeVisualizerBase::MarkIcon() |
|
1068 { |
|
1069 FUNC_LOG; |
|
1070 return iMarkIcon; |
|
1071 } |
|
1072 |
|
1073 // --------------------------------------------------------------------------- |
|
1074 // |
|
1075 // --------------------------------------------------------------------------- |
|
1076 // |
|
1077 TBool CFsTreeVisualizerBase::IsMarked(const TFsTreeItemId aItemId) const |
|
1078 { |
|
1079 FUNC_LOG; |
|
1080 MFsTreeItemVisualizer* vis = NULL; |
|
1081 vis = iTreeData->ItemVisualizer(aItemId); |
|
1082 return vis->IsMarked(); |
|
1083 } |
|
1084 |
|
1085 // --------------------------------------------------------------------------- |
|
1086 // |
|
1087 // --------------------------------------------------------------------------- |
|
1088 // |
|
1089 void CFsTreeVisualizerBase::MarkItemL(const TFsTreeItemId aItemId, |
|
1090 TBool aMarked) |
|
1091 { |
|
1092 FUNC_LOG; |
|
1093 MFsTreeItemVisualizer* vis = NULL; |
|
1094 vis = iTreeData->ItemVisualizer(aItemId); |
|
1095 vis->SetMarked(aMarked); |
|
1096 if (iVisibleItems.Find(aItemId) != KErrNotFound) |
|
1097 { |
|
1098 MFsTreeItemData* data = NULL; |
|
1099 data = &(iTreeData->ItemData(aItemId)); |
|
1100 |
|
1101 vis->UpdateL(*data, IsItemFocused(aItemId) && IsFocusShown(), |
|
1102 iTreeData->Level(aItemId), iMarkIcon, iMenuIcon); |
|
1103 } |
|
1104 } |
|
1105 |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // |
|
1110 void CFsTreeVisualizerBase::GetMarkedItemsL(RFsTreeItemIdList& aMarkedItems) const |
|
1111 { |
|
1112 FUNC_LOG; |
|
1113 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, |
|
1114 KFsTreeRootID); |
|
1115 TFsTreeItemId itemId; |
|
1116 MFsTreeItemVisualizer* vis = NULL; |
|
1117 while (treeIter.HasNext()) |
|
1118 { |
|
1119 itemId = treeIter.Next(); |
|
1120 vis = iTreeData->ItemVisualizer(itemId); |
|
1121 if (vis->IsMarked()) |
|
1122 { |
|
1123 aMarkedItems.AppendL(itemId); |
|
1124 } |
|
1125 } |
|
1126 } |
|
1127 |
|
1128 // --------------------------------------------------------------------------- |
|
1129 // Function marks/unmarks all items in the list. |
|
1130 // --------------------------------------------------------------------------- |
|
1131 // |
|
1132 void CFsTreeVisualizerBase::MarkAllItemsL(TBool aMarkAll) |
|
1133 { |
|
1134 FUNC_LOG; |
|
1135 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, |
|
1136 KFsTreeRootID); |
|
1137 TFsTreeItemId itemId; |
|
1138 MFsTreeItemVisualizer* vis = NULL; |
|
1139 while (treeIter.HasNext()) |
|
1140 { |
|
1141 itemId = treeIter.Next(); |
|
1142 vis = iTreeData->ItemVisualizer(itemId); |
|
1143 vis->SetMarked(aMarkAll); |
|
1144 } |
|
1145 RefreshListViewL(); |
|
1146 } |
|
1147 |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // Sets item indentation per hierarchy level. |
|
1150 // --------------------------------------------------------------------------- |
|
1151 void CFsTreeVisualizerBase::SetIndentationL(TInt aIndentation) |
|
1152 { |
|
1153 FUNC_LOG; |
|
1154 iLevelIndentation = aIndentation; |
|
1155 |
|
1156 MFsTreeItemVisualizer* vis = NULL; |
|
1157 TFsTreeItemId itemId = KFsTreeNoneID; |
|
1158 //loop through the list and set items to always-extended state. |
|
1159 TFsTreeIterator iter = iTreeData->Iterator(KFsTreeRootID, KFsTreeRootID); |
|
1160 while (iter.HasNext()) |
|
1161 { |
|
1162 itemId = iter.Next(); |
|
1163 //get item's visualizer |
|
1164 vis = iTreeData->ItemVisualizer(itemId); |
|
1165 //set indentation in pixels |
|
1166 vis->SetIndentation(iLevelIndentation); |
|
1167 } |
|
1168 |
|
1169 //refresh the list view |
|
1170 RefreshListViewL(); |
|
1171 } |
|
1172 |
|
1173 // --------------------------------------------------------------------------- |
|
1174 // Returns indentation per hierarchy level in pixels. |
|
1175 // --------------------------------------------------------------------------- |
|
1176 // |
|
1177 TInt CFsTreeVisualizerBase::Indentation() const |
|
1178 { |
|
1179 FUNC_LOG; |
|
1180 return iLevelIndentation; |
|
1181 } |
|
1182 |
|
1183 // --------------------------------------------------------------------------- |
|
1184 // Sets icon for a menu sign. |
|
1185 // --------------------------------------------------------------------------- |
|
1186 void CFsTreeVisualizerBase::SetMenuIcon(CAlfTexture& aMenuIcon) |
|
1187 { |
|
1188 FUNC_LOG; |
|
1189 iMenuIcon = &aMenuIcon; |
|
1190 } |
|
1191 |
|
1192 // --------------------------------------------------------------------------- |
|
1193 // Returns menu icon. |
|
1194 // --------------------------------------------------------------------------- |
|
1195 CAlfTexture* CFsTreeVisualizerBase::MenuIcon() const |
|
1196 { |
|
1197 FUNC_LOG; |
|
1198 return iMenuIcon; |
|
1199 } |
|
1200 |
|
1201 // --------------------------------------------------------------------------- |
|
1202 // Used internally by the list. To make the list focused/not focused use |
|
1203 // CFsTreeList::SetFocusedL() instead. |
|
1204 // --------------------------------------------------------------------------- |
|
1205 // |
|
1206 void CFsTreeVisualizerBase::SetFocusedL(const TBool aFocused) |
|
1207 { |
|
1208 FUNC_LOG; |
|
1209 if (iDragHandler && !aFocused) |
|
1210 { |
|
1211 iDragHandler->Reset(); |
|
1212 } |
|
1213 if (iFlags.IsSet(EListFocused) != aFocused) |
|
1214 { |
|
1215 iFlags.Assign(EListFocused, aFocused); |
|
1216 if (iTreeData->Count()) |
|
1217 { |
|
1218 if (iFlags.IsSet(EListFocused)) |
|
1219 { |
|
1220 //list will receive focus |
|
1221 if (iFocusedItem == KFsTreeNoneID) |
|
1222 { |
|
1223 TFsTreeIterator treeIter = iTreeData->Iterator( |
|
1224 KFsTreeRootID, KFsTreeRootID, |
|
1225 KFsTreeIteratorSkipCollapsedFlag |
|
1226 | KFsTreeIteratorSkipHiddenFlag); |
|
1227 |
|
1228 TFsTreeItemId id(KFsTreeNoneID); |
|
1229 MFsTreeItemVisualizer* visualizer(NULL); |
|
1230 id = treeIter.First(); |
|
1231 visualizer = iTreeData->ItemVisualizer(id); |
|
1232 if (visualizer) |
|
1233 { |
|
1234 if (visualizer->IsFocusable()) |
|
1235 { |
|
1236 iFocusedItem = id; |
|
1237 } |
|
1238 } |
|
1239 } |
|
1240 // a workaround to make SetFocusedItemL work with timeout |
|
1241 SetFocusedItemL(iFocusedItem); |
|
1242 MakeSelectorVisibleL(ETrue); |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 if (iFocusedItem != KFsTreeNoneID) |
|
1247 { |
|
1248 //list will loose focus |
|
1249 MFsTreeItemVisualizer* visualizer = |
|
1250 iTreeData->ItemVisualizer(iFocusedItem); |
|
1251 if (visualizer) |
|
1252 { |
|
1253 TInt index(iListLayout->FindVisual( |
|
1254 &visualizer->Layout())); |
|
1255 if (index != KErrNotFound) |
|
1256 { |
|
1257 MFsTreeItemData* data = &iTreeData->ItemData( |
|
1258 iFocusedItem); |
|
1259 MakeSelectorVisibleL(EFalse); |
|
1260 visualizer->UpdateL(*data, EFalse, |
|
1261 iTreeData->Level(iFocusedItem), |
|
1262 iMarkIcon, iMenuIcon, iCurrentScrollSpeed); |
|
1263 } |
|
1264 } |
|
1265 } |
|
1266 } |
|
1267 iListLayout->UpdateChildrenLayout(); |
|
1268 } |
|
1269 } |
|
1270 } |
|
1271 |
|
1272 // --------------------------------------------------------------------------- |
|
1273 // The function sets some properties of the selector like bitmap, type |
|
1274 // of movement. |
|
1275 // --------------------------------------------------------------------------- |
|
1276 // |
|
1277 void CFsTreeVisualizerBase::SetSelectorPropertiesL(CAlfTexture* aTexture, |
|
1278 TFsSelectorMovement aMovementType, TInt aLeftBorderWidth, |
|
1279 TInt aRightBorderWidth, TInt aTopBorderHeight, |
|
1280 TInt aBottomBorderHeight) |
|
1281 { |
|
1282 FUNC_LOG; |
|
1283 iSelectorTexture = aTexture; |
|
1284 iSelectorBrush = NULL; |
|
1285 iSelectorMovementType = aMovementType; |
|
1286 iSelectorOpacity = 1.0; |
|
1287 |
|
1288 iLeftSelectorBorderWidth = aLeftBorderWidth; |
|
1289 iRightSelectorBorderWidth = aRightBorderWidth; |
|
1290 iTopSelectorBorderHeight = aTopBorderHeight; |
|
1291 iBottomSelectorBorderHeight = aBottomBorderHeight; |
|
1292 |
|
1293 DestroySelectorVisualL(); |
|
1294 MakeSelectorVisibleL(ETrue); |
|
1295 } |
|
1296 |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // The function sets some properties of the selector. |
|
1299 // --------------------------------------------------------------------------- |
|
1300 // |
|
1301 void CFsTreeVisualizerBase::SetSelectorPropertiesL(CAlfBrush* aSelectorBrush, |
|
1302 TReal32 aOpacity, TFsSelectorMovement aMovementType) |
|
1303 { |
|
1304 FUNC_LOG; |
|
1305 iSelectorTexture = NULL; |
|
1306 iSelectorBrush = aSelectorBrush; |
|
1307 iSelectorMovementType = aMovementType; |
|
1308 //check value, selector cannot be fully transparent ( <= 0.0 ) |
|
1309 if (aOpacity <= 0.0 || aOpacity > 1.0) |
|
1310 { |
|
1311 iSelectorOpacity = 1.0; |
|
1312 } |
|
1313 else |
|
1314 { |
|
1315 iSelectorOpacity = aOpacity; |
|
1316 } |
|
1317 |
|
1318 iLeftSelectorBorderWidth = 0; |
|
1319 iRightSelectorBorderWidth = 0; |
|
1320 iTopSelectorBorderHeight = 0; |
|
1321 iBottomSelectorBorderHeight = 0; |
|
1322 |
|
1323 DestroySelectorVisualL(); |
|
1324 MakeSelectorVisibleL(ETrue); |
|
1325 } |
|
1326 |
|
1327 // --------------------------------------------------------------------------- |
|
1328 // The function returnes selector's properties. |
|
1329 // --------------------------------------------------------------------------- |
|
1330 // |
|
1331 void CFsTreeVisualizerBase::GetSelectorProperties(CAlfTexture*& aTexture, |
|
1332 TFsSelectorMovement& aMovementType, TInt& aLeftBorderWidth, |
|
1333 TInt& aRightBorderWidth, TInt& aTopBorderHeight, |
|
1334 TInt& aBottomBorderHeight) |
|
1335 { |
|
1336 FUNC_LOG; |
|
1337 aTexture = iSelectorTexture; |
|
1338 aMovementType = iSelectorMovementType; |
|
1339 |
|
1340 aLeftBorderWidth = iLeftSelectorBorderWidth; |
|
1341 aRightBorderWidth = iRightSelectorBorderWidth; |
|
1342 aTopBorderHeight = iTopSelectorBorderHeight; |
|
1343 aBottomBorderHeight = iBottomSelectorBorderHeight; |
|
1344 } |
|
1345 |
|
1346 // --------------------------------------------------------------------------- |
|
1347 // The function sets a text for empty list's view. |
|
1348 // --------------------------------------------------------------------------- |
|
1349 // |
|
1350 void CFsTreeVisualizerBase::SetEmptyListTextL(const TDesC& aText) |
|
1351 { |
|
1352 FUNC_LOG; |
|
1353 if (iRootData) |
|
1354 { |
|
1355 iRootData->SetDataL(aText); |
|
1356 } |
|
1357 } |
|
1358 |
|
1359 // --------------------------------------------------------------------------- |
|
1360 // The function returns a text for empty list's view. |
|
1361 // --------------------------------------------------------------------------- |
|
1362 // |
|
1363 TDesC& CFsTreeVisualizerBase::GetEmptyListText() const |
|
1364 { |
|
1365 FUNC_LOG; |
|
1366 return iRootData->Data(); |
|
1367 } |
|
1368 |
|
1369 // --------------------------------------------------------------------------- |
|
1370 // Handles key event forwarded by the controller. |
|
1371 // --------------------------------------------------------------------------- |
|
1372 // |
|
1373 TBool CFsTreeVisualizerBase::HandleKeyEventL(const TAlfEvent& aEvent) |
|
1374 { |
|
1375 //ignore KeyUp events |
|
1376 TBool eventHandled = aEvent.Code() == EEventKeyUp; |
|
1377 |
|
1378 if (iTreeData->Count() && (!eventHandled)) |
|
1379 { |
|
1380 TInt nowOffset = iListLayout->ScrollOffset().iY.ValueNow(); |
|
1381 TInt targetOffset = iListLayout->ScrollOffset().iY.Target(); |
|
1382 |
|
1383 if (!(iFlags.IsSet(EIsPageUpDownActive) |
|
1384 && (nowOffset != targetOffset))) |
|
1385 { |
|
1386 iFlags.Clear(EIsPageUpDownActive); |
|
1387 |
|
1388 switch (aEvent.KeyEvent().iScanCode) |
|
1389 { |
|
1390 case EStdKeyUpArrow: |
|
1391 { |
|
1392 if (iFocusedItem != KFsTreeNoneID) |
|
1393 { |
|
1394 SetCurrentScrollSpeed(aEvent.KeyEvent().iRepeats); |
|
1395 MoveSelectionL(EFsTreeVisualizerMoveLineUp); |
|
1396 //iCurrentScrollSpeed = iScrollSpeed; |
|
1397 } |
|
1398 eventHandled = ETrue; |
|
1399 break; |
|
1400 } |
|
1401 case EStdKeyDownArrow: |
|
1402 { |
|
1403 if (iFocusedItem != KFsTreeNoneID) |
|
1404 { |
|
1405 SetCurrentScrollSpeed(aEvent.KeyEvent().iRepeats); |
|
1406 MoveSelectionL(EFsTreeVisualizerMoveLineDown); |
|
1407 //iCurrentScrollSpeed = iScrollSpeed; |
|
1408 } |
|
1409 eventHandled = ETrue; |
|
1410 break; |
|
1411 } |
|
1412 case EStdKeyLeftArrow: |
|
1413 { |
|
1414 if (iVisualizerObserver) |
|
1415 { |
|
1416 // <cmail> Touch |
|
1417 iVisualizerObserver->TreeVisualizerEventL( |
|
1418 MFsTreeVisualizerObserver::EFsTreeKeyLeftArrow, |
|
1419 iFocusedItem); |
|
1420 // </cmail> |
|
1421 } |
|
1422 eventHandled = ETrue; |
|
1423 break; |
|
1424 } |
|
1425 case EStdKeyRightArrow: |
|
1426 { |
|
1427 if (iVisualizerObserver) |
|
1428 { |
|
1429 // <cmail> |
|
1430 iVisualizerObserver->TreeVisualizerEventL( |
|
1431 MFsTreeVisualizerObserver::EFsTreeKeyRightArrow, |
|
1432 iFocusedItem); |
|
1433 // </cmail> |
|
1434 } |
|
1435 eventHandled = ETrue; |
|
1436 break; |
|
1437 } |
|
1438 case EStdKeyDevice3: |
|
1439 { |
|
1440 if (iTreeData->IsNode(iFocusedItem)) |
|
1441 { |
|
1442 if (iTreeData->NodeVisualizer(iFocusedItem)->IsExpanded()) |
|
1443 { |
|
1444 CollapseNodeL(iFocusedItem); |
|
1445 } |
|
1446 else |
|
1447 { |
|
1448 ExpandNodeL(iFocusedItem); |
|
1449 } |
|
1450 } |
|
1451 else |
|
1452 { |
|
1453 if (iVisualizerObserver) |
|
1454 { |
|
1455 if (iTreeData->ItemVisualizer(iFocusedItem)->Menu()) |
|
1456 { |
|
1457 // <cmail> Touch |
|
1458 iVisualizerObserver->TreeVisualizerEventL( |
|
1459 MFsTreeVisualizerObserver::EFsTreeItemWithMenuSelected, |
|
1460 iFocusedItem); |
|
1461 } |
|
1462 else |
|
1463 { |
|
1464 iVisualizerObserver->TreeVisualizerEventL( |
|
1465 MFsTreeVisualizerObserver::EFsTreeItemSelected, |
|
1466 iFocusedItem); |
|
1467 // </cmail> |
|
1468 } |
|
1469 } |
|
1470 } |
|
1471 eventHandled = ETrue; |
|
1472 break; |
|
1473 } |
|
1474 default: |
|
1475 { |
|
1476 // the visualizer ignores all other events |
|
1477 break; |
|
1478 } |
|
1479 } |
|
1480 //page up/down |
|
1481 if (!eventHandled) |
|
1482 { |
|
1483 if (IsCustomPageUpKey(aEvent.KeyEvent().iScanCode)) |
|
1484 { |
|
1485 SetCurrentScrollSpeed(aEvent.KeyEvent().iRepeats); |
|
1486 MoveSelectionL(EFsTreeVisualizerMovePageUp); |
|
1487 iFlags.Set(EIsPageUpDownActive); |
|
1488 eventHandled = ETrue; |
|
1489 //iCurrentScrollSpeed = iScrollSpeed; |
|
1490 } |
|
1491 else if (IsCustomPageDownKey(aEvent.KeyEvent().iScanCode)) |
|
1492 { |
|
1493 SetCurrentScrollSpeed(aEvent.KeyEvent().iRepeats); |
|
1494 MoveSelectionL(EFsTreeVisualizerMovePageDown); |
|
1495 iFlags.Set(EIsPageUpDownActive); |
|
1496 eventHandled = ETrue; |
|
1497 //iCurrentScrollSpeed = iScrollSpeed; |
|
1498 } |
|
1499 } |
|
1500 } |
|
1501 else |
|
1502 { |
|
1503 eventHandled = EFalse; |
|
1504 } |
|
1505 } |
|
1506 else |
|
1507 { |
|
1508 eventHandled = EFalse; |
|
1509 } |
|
1510 |
|
1511 return eventHandled; |
|
1512 } |
|
1513 |
|
1514 // --------------------------------------------------------------------------- |
|
1515 // CFsTreeVisualizerBase::SetFlipState |
|
1516 // --------------------------------------------------------------------------- |
|
1517 // |
|
1518 void CFsTreeVisualizerBase::SetFlipState( TBool aOpen ) |
|
1519 { |
|
1520 iFlipOpen = aOpen; |
|
1521 } |
|
1522 |
|
1523 // --------------------------------------------------------------------------- |
|
1524 // CFsTreeVisualizerBase::SetFocusVisibility |
|
1525 // --------------------------------------------------------------------------- |
|
1526 // |
|
1527 void CFsTreeVisualizerBase::SetFocusVisibility( TBool aShow ) |
|
1528 { |
|
1529 if( iFocusVisible != aShow ) |
|
1530 { |
|
1531 iFocusVisible = aShow; |
|
1532 TRAP_IGNORE( |
|
1533 MakeSelectorVisibleL(aShow); |
|
1534 UpdateItemL(iFocusedItem); ); |
|
1535 } |
|
1536 } |
|
1537 |
|
1538 // <cmail> "Base class modifications for using touch" |
|
1539 |
|
1540 // --------------------------------------------------------------------------- |
|
1541 // CFsTreeVisualizerBase::HandlePointerEventL |
|
1542 // |
|
1543 // --------------------------------------------------------------------------- |
|
1544 // |
|
1545 TBool CFsTreeVisualizerBase::HandlePointerEventL(const TAlfEvent& aEvent) |
|
1546 { |
|
1547 TBool eventHandled(EFalse); |
|
1548 if (iDragHandler && iOwnerControl->ControlGroup()->AcceptInput()) |
|
1549 { |
|
1550 TPointerEvent::TType type = aEvent.PointerEvent().iType; |
|
1551 const TInt id(EventItemId(aEvent)); |
|
1552 INFO_1("visual: $%x", aEvent.Visual()); |
|
1553 if (KErrNotFound != id || type == TPointerEvent::EDrag || |
|
1554 type == TPointerEvent::EButtonRepeat || |
|
1555 type == TPointerEvent::EButton1Up) |
|
1556 { |
|
1557 switch (type) |
|
1558 { |
|
1559 case TPointerEvent::EButton1Down: |
|
1560 { |
|
1561 eventHandled = ETrue; |
|
1562 iTouchPressed = ETrue; |
|
1563 const TPoint& pos(aEvent.PointerEvent().iParentPosition); |
|
1564 INFO_2("EButton1Down (%d, %d)", pos.iX, pos.iY); |
|
1565 if (!iFlags.IsSet(EPhysicsOn)) |
|
1566 { |
|
1567 iPhysics->StopPhysics(); |
|
1568 iPhysics->ResetFriction(); |
|
1569 UpdatePhysicsL(); |
|
1570 } |
|
1571 iDragHandler->PointerDown(aEvent.PointerEvent(), id); |
|
1572 break; |
|
1573 } |
|
1574 case TPointerEvent::EButton1Up: |
|
1575 { |
|
1576 const TPoint& pos(aEvent.PointerEvent().iParentPosition); |
|
1577 if( iTouchPressed ) |
|
1578 { |
|
1579 eventHandled = ETrue; |
|
1580 iTouchPressed = EFalse; |
|
1581 UpdateItemL( iFocusedItem ); |
|
1582 if( !IsFocusShown() ) |
|
1583 { |
|
1584 MakeSelectorVisibleL( EFalse ); |
|
1585 } |
|
1586 INFO_2( "EButton1Up (%d, %d)", pos.iX, pos.iY ); |
|
1587 if( !iDragHandler->IsFlicking() ) |
|
1588 { |
|
1589 iPhysics->StopPhysics(); |
|
1590 } |
|
1591 iDragHandler->PointerUp( aEvent.PointerEvent(), id ); |
|
1592 } |
|
1593 break; |
|
1594 } |
|
1595 case TPointerEvent::EDrag: |
|
1596 { |
|
1597 eventHandled = ETrue; |
|
1598 const TPoint& pos(aEvent.PointerEvent().iPosition); |
|
1599 INFO_2("EDrag (%d, %d)", pos.iX, pos.iY); |
|
1600 if (iDragHandler->IsFlicking() |
|
1601 || iDragHandler->DragDelta(aEvent.PointerEvent()) |
|
1602 >= iPhysics->DragThreshold()) |
|
1603 { |
|
1604 iDragHandler->PointerDrag(aEvent.PointerEvent(), id); |
|
1605 iDragHandler->EnableFlicking(); |
|
1606 } |
|
1607 break; |
|
1608 } |
|
1609 |
|
1610 case TPointerEvent::EButtonRepeat: |
|
1611 { |
|
1612 eventHandled = ETrue; |
|
1613 const TPoint& pos(aEvent.PointerEvent().iParentPosition); |
|
1614 INFO_2("EButtonRepeat (%d, %d)", pos.iX, pos.iY); |
|
1615 iDragHandler->PointerRepeat(aEvent.PointerEvent()); |
|
1616 break; |
|
1617 } |
|
1618 |
|
1619 default: |
|
1620 { |
|
1621 //Unknown event, ignore. |
|
1622 break; |
|
1623 } |
|
1624 } |
|
1625 } |
|
1626 } |
|
1627 return eventHandled; |
|
1628 } |
|
1629 // --------------------------------------------------------------------------- |
|
1630 // CFsTreeVisualizerBase::EventItemId |
|
1631 // --------------------------------------------------------------------------- |
|
1632 // |
|
1633 TFsTreeItemId CFsTreeVisualizerBase::EventItemId(const TAlfEvent& aEvent) const |
|
1634 { |
|
1635 FUNC_LOG; |
|
1636 if (aEvent.Type() == TPointerEvent::EDrag) |
|
1637 { |
|
1638 return VisualItemId(FindVisualUnderDrag( |
|
1639 aEvent.PointerEvent().iPosition)); |
|
1640 } |
|
1641 else |
|
1642 { |
|
1643 return VisualItemId(aEvent.Visual()); |
|
1644 } |
|
1645 } |
|
1646 |
|
1647 // --------------------------------------------------------------------------- |
|
1648 // CFsTreeVisualizerBase::FindVisualUnderDrag |
|
1649 // --------------------------------------------------------------------------- |
|
1650 // |
|
1651 const CAlfVisual* CFsTreeVisualizerBase::FindVisualUnderDrag( |
|
1652 const TPoint& aPosition) const |
|
1653 { |
|
1654 FUNC_LOG; |
|
1655 for (TInt i = 0; i < iListLayout->Count(); i++) |
|
1656 { |
|
1657 const TRect displayRect(iListLayout->Visual(i).DisplayRectTarget()); |
|
1658 if (displayRect.Contains(aPosition)) |
|
1659 { |
|
1660 return &iListLayout->Visual(i); |
|
1661 } |
|
1662 } |
|
1663 return NULL; |
|
1664 } |
|
1665 |
|
1666 // --------------------------------------------------------------------------- |
|
1667 // CFsTreeVisualizerBase::VisualItemId |
|
1668 // --------------------------------------------------------------------------- |
|
1669 // |
|
1670 TFsTreeItemId CFsTreeVisualizerBase::VisualItemId(const CAlfVisual* aVisual) const |
|
1671 { |
|
1672 FUNC_LOG; |
|
1673 TInt itemId(KErrNotFound); |
|
1674 if (aVisual) |
|
1675 { |
|
1676 aVisual->PropertyFindInteger(KPropertyItemId(), &itemId); |
|
1677 } |
|
1678 return itemId; |
|
1679 } |
|
1680 |
|
1681 // --------------------------------------------------------------------------- |
|
1682 // Sets the specified item as focused. |
|
1683 // --------------------------------------------------------------------------- |
|
1684 // |
|
1685 void CFsTreeVisualizerBase::SetFocusedItemL(const TFsTreeItemId aItemId, |
|
1686 TBool /*aCheckFocus*/) |
|
1687 { |
|
1688 FUNC_LOG; |
|
1689 MFsTreeItemVisualizer* visualizer = NULL; |
|
1690 if (aItemId != iFocusedItem) |
|
1691 { |
|
1692 visualizer = iTreeData->ItemVisualizer(iFocusedItem); |
|
1693 if (visualizer) |
|
1694 { |
|
1695 visualizer->UpdateL(iTreeData->ItemData(iFocusedItem), EFalse, |
|
1696 iTreeData->Level(iFocusedItem), iMarkIcon, iMenuIcon, 0); |
|
1697 } |
|
1698 iFocusedItem = aItemId; |
|
1699 } |
|
1700 visualizer = iTreeData->ItemVisualizer(iFocusedItem); |
|
1701 if (visualizer) |
|
1702 { |
|
1703 TBool focused = IsFocusShown(); |
|
1704 visualizer->UpdateL(iTreeData->ItemData(iFocusedItem), focused, |
|
1705 iTreeData->Level(iFocusedItem), iMarkIcon, iMenuIcon, 0); |
|
1706 } |
|
1707 if (iFocusedItem != KFsTreeNoneID) |
|
1708 { |
|
1709 UpdateSelectorVisualL(); |
|
1710 if (!iViewPort.ItemFullyVisible(iFocusedItem)) |
|
1711 { |
|
1712 iViewPort.ScrollItemToViewL(iFocusedItem); |
|
1713 } |
|
1714 } |
|
1715 } |
|
1716 |
|
1717 // --------------------------------------------------------------------------- |
|
1718 // Checks if the specified item is focused. |
|
1719 // --------------------------------------------------------------------------- |
|
1720 // |
|
1721 TFsTreeItemId CFsTreeVisualizerBase::FocusedItem() const |
|
1722 { |
|
1723 FUNC_LOG; |
|
1724 return iFocusedItem; |
|
1725 } |
|
1726 |
|
1727 // --------------------------------------------------------------------------- |
|
1728 // Checks if the specified item is focused. |
|
1729 // --------------------------------------------------------------------------- |
|
1730 // |
|
1731 TBool CFsTreeVisualizerBase::IsFocused(const TFsTreeItemId aItemId) const |
|
1732 { |
|
1733 FUNC_LOG; |
|
1734 return iFocusedItem == aItemId ? ETrue : EFalse; |
|
1735 } |
|
1736 |
|
1737 // --------------------------------------------------------------------------- |
|
1738 // Sets an item as first visible one in the list. |
|
1739 // --------------------------------------------------------------------------- |
|
1740 // |
|
1741 // <cmail> |
|
1742 void CFsTreeVisualizerBase::SetFirstVisibleItemL(const TFsTreeItemId /*aItemId*/) |
|
1743 { |
|
1744 FUNC_LOG; |
|
1745 } |
|
1746 |
|
1747 // --------------------------------------------------------------------------- |
|
1748 // Get an id of the first visible item. |
|
1749 // --------------------------------------------------------------------------- |
|
1750 // |
|
1751 TFsTreeItemId CFsTreeVisualizerBase::FirstVisibleItem() |
|
1752 { |
|
1753 FUNC_LOG; |
|
1754 TFsTreeItemId retId = KFsTreeNoneID; |
|
1755 if (iVisibleItems.Count()) |
|
1756 { |
|
1757 // <cmail> |
|
1758 // TRAP_IGNORE( ClearVisibleItemsListL(EFalse) ); |
|
1759 // </cmail> |
|
1760 retId = iVisibleItems[0]; |
|
1761 } |
|
1762 else |
|
1763 { |
|
1764 retId = KFsTreeNoneID; |
|
1765 } |
|
1766 return retId; |
|
1767 } |
|
1768 |
|
1769 // --------------------------------------------------------------------------- |
|
1770 // Gets a pointer to the root's item data object. |
|
1771 // --------------------------------------------------------------------------- |
|
1772 // |
|
1773 MFsTreeItemData* CFsTreeVisualizerBase::RootItemData() |
|
1774 { |
|
1775 FUNC_LOG; |
|
1776 return iRootData; |
|
1777 } |
|
1778 |
|
1779 // --------------------------------------------------------------------------- |
|
1780 // Gets a pointer to the root's item visualizer object. |
|
1781 // --------------------------------------------------------------------------- |
|
1782 // |
|
1783 MFsTreeNodeVisualizer* CFsTreeVisualizerBase::RootNodeVisualizer() |
|
1784 { |
|
1785 FUNC_LOG; |
|
1786 return iRootVisualizer; |
|
1787 } |
|
1788 |
|
1789 // --------------------------------------------------------------------------- |
|
1790 // Displays the list. |
|
1791 // --------------------------------------------------------------------------- |
|
1792 // |
|
1793 // <cmail> |
|
1794 void CFsTreeVisualizerBase::ShowListL(const TBool aFadeIn, |
|
1795 const TBool aSlideIn) |
|
1796 { |
|
1797 FUNC_LOG; |
|
1798 UpdateViewPortL(); |
|
1799 if (iTreeData->Count() == 0) |
|
1800 { |
|
1801 iRootVisualizer->ShowL(*iRootLayout); |
|
1802 iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon, iMenuIcon); |
|
1803 } |
|
1804 else |
|
1805 { |
|
1806 TBool showFocus = IsFocusShown(); |
|
1807 for (TUint i = 0; i < iVisibleItems.Count(); ++i) |
|
1808 { |
|
1809 TFsTreeItemId itemId(iVisibleItems[i]); |
|
1810 MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer( |
|
1811 itemId); |
|
1812 |
|
1813 TBool itemFocused( EFalse ); |
|
1814 if( showFocus ) |
|
1815 { |
|
1816 itemFocused = IsItemFocused(itemId); |
|
1817 } |
|
1818 visualizer->UpdateL(iTreeData->ItemData(itemId), itemFocused, |
|
1819 iTreeData->Level(itemId), iMarkIcon, iMenuIcon, |
|
1820 0); |
|
1821 } |
|
1822 } |
|
1823 |
|
1824 TInt fadeInTime(KZero), slideInTime(KZero); |
|
1825 CFsSlideEffect::TSlideEffectDirection slideInDir( |
|
1826 CFsSlideEffect::ESlideNone); |
|
1827 |
|
1828 iVisualizationState = EFsTreeVisible; |
|
1829 |
|
1830 if (aFadeIn) |
|
1831 { |
|
1832 fadeInTime = iFadeInEffectTime; |
|
1833 if (aSlideIn) |
|
1834 { |
|
1835 iVisualizationState = EFsTreeFadingInSlidingIn; |
|
1836 } |
|
1837 else |
|
1838 { |
|
1839 iVisualizationState = EFsTreeFadingIn; |
|
1840 } |
|
1841 } |
|
1842 else |
|
1843 { |
|
1844 fadeInTime = KZero; |
|
1845 } |
|
1846 |
|
1847 if (aSlideIn) |
|
1848 { |
|
1849 slideInTime = iSlideInDuration; |
|
1850 switch (iSlideInDirection) |
|
1851 { |
|
1852 case MFsTreeVisualizer::ESlideFromTop: |
|
1853 { |
|
1854 slideInDir = CFsSlideEffect::ESlideFromTop; |
|
1855 break; |
|
1856 } |
|
1857 case MFsTreeVisualizer::ESlideFromBottom: |
|
1858 { |
|
1859 slideInDir = CFsSlideEffect::ESlideFromBottom; |
|
1860 break; |
|
1861 } |
|
1862 case MFsTreeVisualizer::ESlideFromLeft: |
|
1863 { |
|
1864 slideInDir = CFsSlideEffect::ESlideFromLeft; |
|
1865 break; |
|
1866 } |
|
1867 case MFsTreeVisualizer::ESlideFromRight: |
|
1868 { |
|
1869 slideInDir = CFsSlideEffect::ESlideFromRight; |
|
1870 break; |
|
1871 } |
|
1872 case MFsTreeVisualizer::ESlideNone: |
|
1873 default: |
|
1874 { |
|
1875 slideInDir = CFsSlideEffect::ESlideNone; |
|
1876 break; |
|
1877 } |
|
1878 } |
|
1879 iVisualizationState = EFsTreeFadingInSlidingIn; |
|
1880 } |
|
1881 else |
|
1882 { |
|
1883 slideInTime = KZero; |
|
1884 slideInDir = CFsSlideEffect::ESlideNone; |
|
1885 } |
|
1886 |
|
1887 iFadeEffect->SetTime(fadeInTime); |
|
1888 iSlideEffect->SetTime(slideInTime); |
|
1889 |
|
1890 iFadeEffect->FadeIn(); |
|
1891 iSlideEffect->SlideIn(slideInDir); |
|
1892 |
|
1893 UpdateScrollBarL(); |
|
1894 } |
|
1895 // </cmail> |
|
1896 |
|
1897 // --------------------------------------------------------------------------- |
|
1898 // The function assures that the list view is correct. |
|
1899 // --------------------------------------------------------------------------- |
|
1900 // |
|
1901 void CFsTreeVisualizerBase::ValidateListLayoutL(TInt /*aTime*/) |
|
1902 { |
|
1903 FUNC_LOG; |
|
1904 } |
|
1905 |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // Hides the list. |
|
1908 // --------------------------------------------------------------------------- |
|
1909 // |
|
1910 void CFsTreeVisualizerBase::HideList(const TBool aFadeOut, |
|
1911 const TBool aSlideOut) |
|
1912 { |
|
1913 FUNC_LOG; |
|
1914 iScrollBar->MakeVisible(EFalse); |
|
1915 if (iDragHandler) |
|
1916 { |
|
1917 iDragHandler->Reset(); |
|
1918 } |
|
1919 |
|
1920 if (aFadeOut) |
|
1921 { |
|
1922 iFadeEffect->SetTime(iFadeOutEffectTime); |
|
1923 iVisualizationState = EFsTreeFadingOut; |
|
1924 iFadeEffect->FadeOut(); |
|
1925 } |
|
1926 |
|
1927 if (aSlideOut) |
|
1928 { |
|
1929 iSlideEffect->SetTime(iSlideOutDuration); |
|
1930 if (iVisualizationState == EFsTreeFadingOut) |
|
1931 { |
|
1932 iVisualizationState = EFsTreeFadingOutSlidingOut; |
|
1933 } |
|
1934 else |
|
1935 { |
|
1936 iVisualizationState = EFsTreeSlidingOut; |
|
1937 } |
|
1938 switch (iSlideOutDirection) |
|
1939 { |
|
1940 case MFsTreeVisualizer::ESlideFromTop: |
|
1941 { |
|
1942 iSlideEffect->SlideOut(CFsSlideEffect::ESlideFromTop); |
|
1943 break; |
|
1944 } |
|
1945 case MFsTreeVisualizer::ESlideFromBottom: |
|
1946 { |
|
1947 iSlideEffect->SlideOut(CFsSlideEffect::ESlideFromBottom); |
|
1948 break; |
|
1949 } |
|
1950 case MFsTreeVisualizer::ESlideFromLeft: |
|
1951 { |
|
1952 iSlideEffect->SlideOut(CFsSlideEffect::ESlideFromLeft); |
|
1953 break; |
|
1954 } |
|
1955 case MFsTreeVisualizer::ESlideFromRight: |
|
1956 { |
|
1957 iSlideEffect->SlideOut(CFsSlideEffect::ESlideFromRight); |
|
1958 break; |
|
1959 } |
|
1960 case MFsTreeVisualizer::ESlideNone: |
|
1961 default: |
|
1962 { |
|
1963 iSlideEffect->SlideOut(CFsSlideEffect::ESlideNone); |
|
1964 break; |
|
1965 } |
|
1966 } |
|
1967 } |
|
1968 |
|
1969 if (!aFadeOut && !aSlideOut) |
|
1970 { |
|
1971 iVisualizationState = EFsTreeFadingOut; |
|
1972 iFadeEffect->SetTime(KZero); |
|
1973 iFadeEffect->FadeOut(); |
|
1974 } |
|
1975 } |
|
1976 |
|
1977 // --------------------------------------------------------------------------- |
|
1978 // The function sets duration of the slide-in effect. |
|
1979 // --------------------------------------------------------------------------- |
|
1980 // |
|
1981 void CFsTreeVisualizerBase::SetSlideInDuration(TInt aTimeMiliseconds) |
|
1982 { |
|
1983 FUNC_LOG; |
|
1984 iSlideInDuration = aTimeMiliseconds; |
|
1985 if (iSlideInDuration < KZero) |
|
1986 { |
|
1987 iSlideInDuration = KZero; |
|
1988 } |
|
1989 } |
|
1990 |
|
1991 // --------------------------------------------------------------------------- |
|
1992 // The function returns slide in effect's duration. |
|
1993 // --------------------------------------------------------------------------- |
|
1994 // |
|
1995 TInt CFsTreeVisualizerBase::SlideInDuration() const |
|
1996 { |
|
1997 FUNC_LOG; |
|
1998 return iSlideInDuration; |
|
1999 } |
|
2000 |
|
2001 // --------------------------------------------------------------------------- |
|
2002 // The function sets direction of the slide in effect. |
|
2003 // --------------------------------------------------------------------------- |
|
2004 // |
|
2005 void CFsTreeVisualizerBase::SetSlideInDirection(TFsSlideEffect aDirection) |
|
2006 { |
|
2007 FUNC_LOG; |
|
2008 iSlideInDirection = aDirection; |
|
2009 } |
|
2010 |
|
2011 // --------------------------------------------------------------------------- |
|
2012 // The function returns direction of the slide in effect. |
|
2013 // --------------------------------------------------------------------------- |
|
2014 // |
|
2015 MFsTreeVisualizer::TFsSlideEffect CFsTreeVisualizerBase::SlideInDirection() const |
|
2016 { |
|
2017 FUNC_LOG; |
|
2018 return iSlideInDirection; |
|
2019 } |
|
2020 |
|
2021 // --------------------------------------------------------------------------- |
|
2022 // The function sets duration of the slide-out effect. |
|
2023 // --------------------------------------------------------------------------- |
|
2024 // |
|
2025 void CFsTreeVisualizerBase::SetSlideOutDuration(TInt aTimeMiliseconds) |
|
2026 { |
|
2027 FUNC_LOG; |
|
2028 iSlideOutDuration = aTimeMiliseconds; |
|
2029 if (iSlideOutDuration < 0) |
|
2030 { |
|
2031 iSlideOutDuration = 0; |
|
2032 } |
|
2033 } |
|
2034 |
|
2035 // --------------------------------------------------------------------------- |
|
2036 // The function returns slide out effect's duration. |
|
2037 // --------------------------------------------------------------------------- |
|
2038 // |
|
2039 TInt CFsTreeVisualizerBase::SlideOutDuration() const |
|
2040 { |
|
2041 FUNC_LOG; |
|
2042 return iSlideOutDuration; |
|
2043 } |
|
2044 |
|
2045 // --------------------------------------------------------------------------- |
|
2046 // The function sets direction of the slide out effect. |
|
2047 // --------------------------------------------------------------------------- |
|
2048 // |
|
2049 void CFsTreeVisualizerBase::SetSlideOutDirection(TFsSlideEffect aDirection) |
|
2050 { |
|
2051 FUNC_LOG; |
|
2052 iSlideOutDirection = aDirection; |
|
2053 } |
|
2054 |
|
2055 // --------------------------------------------------------------------------- |
|
2056 // The function returns direction of the slide out effect. |
|
2057 // --------------------------------------------------------------------------- |
|
2058 // |
|
2059 MFsTreeVisualizer::TFsSlideEffect CFsTreeVisualizerBase::SlideOutDirection() const |
|
2060 { |
|
2061 return iSlideOutDirection; |
|
2062 } |
|
2063 |
|
2064 // --------------------------------------------------------------------------- |
|
2065 // Returns information about looping type of the list. |
|
2066 // --------------------------------------------------------------------------- |
|
2067 // |
|
2068 TFsTreeListLoopingType CFsTreeVisualizerBase::LoopingType() const |
|
2069 { |
|
2070 FUNC_LOG; |
|
2071 return iLooping; |
|
2072 } |
|
2073 |
|
2074 // --------------------------------------------------------------------------- |
|
2075 // Sets type of list's looping. |
|
2076 // --------------------------------------------------------------------------- |
|
2077 // |
|
2078 void CFsTreeVisualizerBase::SetLoopingType( |
|
2079 const TFsTreeListLoopingType aLoopingType) |
|
2080 { |
|
2081 FUNC_LOG; |
|
2082 iLooping = aLoopingType; |
|
2083 } |
|
2084 |
|
2085 // --------------------------------------------------------------------------- |
|
2086 // Sets item expansion delay. |
|
2087 // --------------------------------------------------------------------------- |
|
2088 // |
|
2089 void CFsTreeVisualizerBase::SetItemExpansionDelay(const TInt aDelay) |
|
2090 { |
|
2091 FUNC_LOG; |
|
2092 iScrollSpeed = aDelay; |
|
2093 if (iScrollSpeed < 0) |
|
2094 { |
|
2095 iScrollSpeed = 0; |
|
2096 } |
|
2097 |
|
2098 iCurrentScrollSpeed = iScrollSpeed; |
|
2099 iScrollAccelerationRate = 0.5; |
|
2100 } |
|
2101 |
|
2102 // --------------------------------------------------------------------------- |
|
2103 // Sets an item separator color. |
|
2104 // --------------------------------------------------------------------------- |
|
2105 // |
|
2106 void CFsTreeVisualizerBase::SetItemSeparatorColor(const TRgb& aColor) |
|
2107 { |
|
2108 FUNC_LOG; |
|
2109 static_cast<CAlfBorderBrush*> (iBorderBrush)->SetColor(aColor); |
|
2110 } |
|
2111 |
|
2112 // --------------------------------------------------------------------------- |
|
2113 // Sets an item separator size. |
|
2114 // --------------------------------------------------------------------------- |
|
2115 // |
|
2116 void CFsTreeVisualizerBase::SetItemSeparatorSize(const TSize aSize) |
|
2117 { |
|
2118 FUNC_LOG; |
|
2119 static_cast<CAlfBorderBrush*> (iBorderBrush)->SetThickness( |
|
2120 TAlfTimedPoint(aSize.iWidth, aSize.iHeight)); |
|
2121 } |
|
2122 |
|
2123 // --------------------------------------------------------------------------- |
|
2124 // Sets an item separator size. |
|
2125 // --------------------------------------------------------------------------- |
|
2126 // |
|
2127 void CFsTreeVisualizerBase::SetItemSeparatorSize( |
|
2128 const TAlfTimedPoint& aThickness) |
|
2129 { |
|
2130 FUNC_LOG; |
|
2131 static_cast<CAlfBorderBrush*> (iBorderBrush)->SetThickness(aThickness); |
|
2132 } |
|
2133 |
|
2134 // --------------------------------------------------------------------------- |
|
2135 // The functions sets fade-in's effect duration. |
|
2136 // --------------------------------------------------------------------------- |
|
2137 // |
|
2138 void CFsTreeVisualizerBase::SetFadeInEffectTime(TInt aFadeTime) |
|
2139 { |
|
2140 FUNC_LOG; |
|
2141 if (aFadeTime < 0) |
|
2142 { |
|
2143 iFadeInEffectTime = 0; |
|
2144 } |
|
2145 else |
|
2146 { |
|
2147 iFadeInEffectTime = aFadeTime; |
|
2148 } |
|
2149 } |
|
2150 |
|
2151 // --------------------------------------------------------------------------- |
|
2152 // The functions returns fade-in's effect duration. |
|
2153 // --------------------------------------------------------------------------- |
|
2154 // |
|
2155 TInt CFsTreeVisualizerBase::FadeInEffectTime() |
|
2156 { |
|
2157 FUNC_LOG; |
|
2158 return iFadeInEffectTime; |
|
2159 } |
|
2160 |
|
2161 // --------------------------------------------------------------------------- |
|
2162 // The functions sets fade-out's effect duration. |
|
2163 // --------------------------------------------------------------------------- |
|
2164 // |
|
2165 void CFsTreeVisualizerBase::SetFadeOutEffectTime(TInt aFadeTime) |
|
2166 { |
|
2167 FUNC_LOG; |
|
2168 if (aFadeTime < 0) |
|
2169 { |
|
2170 iFadeOutEffectTime = 0; |
|
2171 } |
|
2172 else |
|
2173 { |
|
2174 iFadeOutEffectTime = aFadeTime; |
|
2175 } |
|
2176 } |
|
2177 |
|
2178 // --------------------------------------------------------------------------- |
|
2179 // The functions returns fade-out's effect duration. |
|
2180 // --------------------------------------------------------------------------- |
|
2181 // |
|
2182 TInt CFsTreeVisualizerBase::FadeOutEffectTime() |
|
2183 { |
|
2184 FUNC_LOG; |
|
2185 return iFadeOutEffectTime; |
|
2186 } |
|
2187 |
|
2188 // --------------------------------------------------------------------------- |
|
2189 // Function sets the time of list scroll per item and the scroll |
|
2190 // acceleration rate. |
|
2191 // --------------------------------------------------------------------------- |
|
2192 // |
|
2193 void CFsTreeVisualizerBase::SetScrollTime(TInt aScrollTime, |
|
2194 TReal aScrollAcceleration) |
|
2195 { |
|
2196 FUNC_LOG; |
|
2197 iScrollSpeed = aScrollTime; |
|
2198 if (iScrollSpeed < 0) |
|
2199 { |
|
2200 iScrollSpeed = 0; |
|
2201 } |
|
2202 |
|
2203 iCurrentScrollSpeed = iScrollSpeed; |
|
2204 iScrollAccelerationRate = aScrollAcceleration; |
|
2205 if (iScrollAccelerationRate < 0.0) |
|
2206 { |
|
2207 iScrollAccelerationRate = 0.0; |
|
2208 } |
|
2209 else if (iScrollAccelerationRate > 1.0) |
|
2210 { |
|
2211 iScrollAccelerationRate = 1.0; |
|
2212 } |
|
2213 } |
|
2214 |
|
2215 // --------------------------------------------------------------------------- |
|
2216 // Gets the item expansion delay. |
|
2217 // --------------------------------------------------------------------------- |
|
2218 // |
|
2219 TInt CFsTreeVisualizerBase::ItemExpansionDelay() const |
|
2220 { |
|
2221 FUNC_LOG; |
|
2222 return iScrollSpeed; |
|
2223 } |
|
2224 |
|
2225 // --------------------------------------------------------------------------- |
|
2226 // Function gets the values of scroll speed and its acceleration rate. |
|
2227 // --------------------------------------------------------------------------- |
|
2228 // |
|
2229 void CFsTreeVisualizerBase::GetScrollTime(TInt& aScrollTime, |
|
2230 TReal& aScrollAcceleration) |
|
2231 { |
|
2232 FUNC_LOG; |
|
2233 aScrollTime = iScrollSpeed; |
|
2234 aScrollAcceleration = iScrollAccelerationRate; |
|
2235 } |
|
2236 |
|
2237 // --------------------------------------------------------------------------- |
|
2238 // Expand the node. |
|
2239 // --------------------------------------------------------------------------- |
|
2240 // |
|
2241 void CFsTreeVisualizerBase::ExpandNodeL(const TFsTreeItemId aNodeId) |
|
2242 { |
|
2243 FUNC_LOG; |
|
2244 MFsTreeNodeVisualizer* nodeVisualizer = |
|
2245 iTreeData->NodeVisualizer(aNodeId); |
|
2246 TRect rc; |
|
2247 TUint index = iWorld.GetItemRect(aNodeId, rc); |
|
2248 if (!nodeVisualizer->IsExpanded()) |
|
2249 { |
|
2250 nodeVisualizer->SetExpanded(ETrue, &iTreeData->ItemData(aNodeId)); |
|
2251 |
|
2252 TFsTreeIterator treeIter = iTreeData->Iterator(aNodeId, aNodeId, |
|
2253 KFsTreeIteratorSkipHiddenFlag); |
|
2254 if (treeIter.HasNext()) |
|
2255 { |
|
2256 TPoint position; |
|
2257 if (iFocusedItem != KFsTreeNoneID) |
|
2258 { |
|
2259 position = iViewPort.ItemRect(iFocusedItem).iTl; |
|
2260 } |
|
2261 iWorld.BeginUpdate(); |
|
2262 TFsTreeItemId itemId; |
|
2263 TSize size; |
|
2264 do |
|
2265 { |
|
2266 itemId = treeIter.Next(); |
|
2267 ++index; |
|
2268 MFsTreeItemVisualizer* itemviz = |
|
2269 iTreeData->ItemVisualizer(itemId); |
|
2270 ApplyListSpecificValuesToItem(itemviz); |
|
2271 size = itemviz->Size(); |
|
2272 iWorld.InsertL(itemId, size, index); |
|
2273 } while (treeIter.HasNext()); |
|
2274 if (iFocusedItem != KFsTreeNoneID) |
|
2275 { |
|
2276 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse, |
|
2277 TViewPort::EPositionAfterExpand); |
|
2278 } |
|
2279 iWorld.EndUpdateL(); |
|
2280 |
|
2281 if ( iVisualizerObserver ) |
|
2282 { |
|
2283 iVisualizerObserver->TreeVisualizerEventL( |
|
2284 MFsTreeVisualizerObserver::EFsTreeListItemExpanded, |
|
2285 aNodeId ); |
|
2286 } |
|
2287 } |
|
2288 } |
|
2289 } |
|
2290 |
|
2291 // --------------------------------------------------------------------------- |
|
2292 // Collapse the node. |
|
2293 // --------------------------------------------------------------------------- |
|
2294 // |
|
2295 void CFsTreeVisualizerBase::CollapseNodeL(const TFsTreeItemId aNodeId) |
|
2296 { |
|
2297 FUNC_LOG; |
|
2298 MFsTreeNodeVisualizer* nodeVisualizer = |
|
2299 iTreeData->NodeVisualizer(aNodeId); |
|
2300 if (nodeVisualizer->IsExpanded()) |
|
2301 { |
|
2302 TFsTreeIterator treeIter = iTreeData->Iterator(aNodeId, aNodeId, |
|
2303 KFsTreeIteratorSkipHiddenFlag); |
|
2304 nodeVisualizer->SetExpanded(EFalse, &iTreeData->ItemData(aNodeId)); |
|
2305 if (treeIter.HasNext()) |
|
2306 { |
|
2307 iWorld.BeginUpdate(); |
|
2308 TFsTreeItemId itemId; |
|
2309 TSize size; |
|
2310 do |
|
2311 { |
|
2312 itemId = treeIter.Next(); |
|
2313 if (itemId != KFsTreeNoneID) |
|
2314 { |
|
2315 iWorld.RemoveL(itemId); |
|
2316 } |
|
2317 } while (treeIter.HasNext()); |
|
2318 iWorld.EndUpdateL(); |
|
2319 |
|
2320 if ( iVisualizerObserver ) |
|
2321 { |
|
2322 iVisualizerObserver->TreeVisualizerEventL( |
|
2323 MFsTreeVisualizerObserver::EFsTreeListItemCollapsed, |
|
2324 aNodeId ); |
|
2325 } |
|
2326 } |
|
2327 } |
|
2328 } |
|
2329 |
|
2330 // --------------------------------------------------------------------------- |
|
2331 // Expand all nodes in the tree. |
|
2332 // --------------------------------------------------------------------------- |
|
2333 // |
|
2334 void CFsTreeVisualizerBase::ExpandAllL() |
|
2335 { |
|
2336 FUNC_LOG; |
|
2337 iWorld.BeginUpdate(); |
|
2338 TPoint position; |
|
2339 if (iFocusedItem != KFsTreeNoneID) |
|
2340 { |
|
2341 position = iViewPort.ItemRect(iFocusedItem).iTl; |
|
2342 } |
|
2343 iWorld.RemoveAllL(); |
|
2344 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, |
|
2345 KFsTreeRootID); |
|
2346 TFsTreeItemId itemId = KFsTreeNoneID; |
|
2347 TSize size; |
|
2348 while (treeIter.HasNext()) |
|
2349 { |
|
2350 itemId = treeIter.Next(); |
|
2351 if (itemId != KFsTreeNoneID) |
|
2352 { |
|
2353 if (iTreeData->IsNode(itemId)) |
|
2354 { |
|
2355 MFsTreeNodeVisualizer* nodeviz = iTreeData->NodeVisualizer( |
|
2356 itemId); |
|
2357 nodeviz->SetExpanded(ETrue, &iTreeData->ItemData(itemId)); |
|
2358 size = nodeviz->Size(); |
|
2359 } |
|
2360 else |
|
2361 { |
|
2362 MFsTreeItemVisualizer* itemviz = iTreeData->ItemVisualizer( |
|
2363 itemId); |
|
2364 size = itemviz->Size(); |
|
2365 } |
|
2366 iWorld.AppendL(itemId, size); |
|
2367 } |
|
2368 } |
|
2369 if (iFocusedItem != KFsTreeNoneID) |
|
2370 { |
|
2371 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse, |
|
2372 TViewPort::EPositionAfterExpand); |
|
2373 } |
|
2374 iWorld.EndUpdateL(); |
|
2375 // <cmail> |
|
2376 if ( iVisualizerObserver ) |
|
2377 { |
|
2378 iVisualizerObserver->TreeVisualizerEventL( |
|
2379 MFsTreeVisualizerObserver::EFsTreeListExpandedAll ); |
|
2380 } |
|
2381 // </cmail> |
|
2382 } |
|
2383 |
|
2384 // --------------------------------------------------------------------------- |
|
2385 // Collapse all nodes in the tree. |
|
2386 // --------------------------------------------------------------------------- |
|
2387 // |
|
2388 void CFsTreeVisualizerBase::CollapseAllL() |
|
2389 { |
|
2390 FUNC_LOG; |
|
2391 iWorld.BeginUpdate(); |
|
2392 TPoint position; |
|
2393 if (iFocusedItem != KFsTreeNoneID) |
|
2394 { |
|
2395 position = iViewPort.ItemRect(iFocusedItem).iTl; |
|
2396 } |
|
2397 iWorld.RemoveAllL(); |
|
2398 if (iTreeData->Count() > 0) |
|
2399 { |
|
2400 TUint childcount = iTreeData->CountChildren(KFsTreeRootID); |
|
2401 for (TUint i = 0; i < childcount; ++i) |
|
2402 { |
|
2403 TFsTreeItemId itemId = iTreeData->Child(KFsTreeRootID, i); |
|
2404 TSize itemSize; |
|
2405 if (iTreeData->IsNode(itemId)) |
|
2406 { |
|
2407 MFsTreeNodeVisualizer* nodeVis(iTreeData->NodeVisualizer( |
|
2408 itemId)); |
|
2409 nodeVis->SetExpanded(EFalse, &iTreeData->ItemData(itemId)); |
|
2410 itemSize = nodeVis->Size(); |
|
2411 } |
|
2412 else |
|
2413 { |
|
2414 itemSize = iTreeData->ItemVisualizer(itemId)->Size(); |
|
2415 } |
|
2416 iWorld.AppendL(itemId, itemSize); |
|
2417 } |
|
2418 } |
|
2419 if (iFocusedItem != KFsTreeNoneID) |
|
2420 { |
|
2421 iViewPort.ItemToPositionL(iFocusedItem, position, EFalse); |
|
2422 } |
|
2423 iWorld.EndUpdateL(); |
|
2424 // <cmail> |
|
2425 if ( iVisualizerObserver ) |
|
2426 { |
|
2427 iVisualizerObserver->TreeVisualizerEventL( |
|
2428 MFsTreeVisualizerObserver::EFsTreeListCollapsedAll ); |
|
2429 } |
|
2430 // </cmail> |
|
2431 } |
|
2432 |
|
2433 // --------------------------------------------------------------------------- |
|
2434 // |
|
2435 // |
|
2436 // --------------------------------------------------------------------------- |
|
2437 // |
|
2438 TBool CFsTreeVisualizerBase::AllNodesCollapsed() const |
|
2439 { |
|
2440 FUNC_LOG; |
|
2441 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, |
|
2442 KFsTreeRootID, KFsTreeIteratorSkipCollapsedFlag |
|
2443 | KFsTreeIteratorSkipHiddenFlag); |
|
2444 TFsTreeItemId itemId = KFsTreeNoneID; |
|
2445 while (treeIter.HasNext()) |
|
2446 { |
|
2447 itemId = treeIter.Next(); |
|
2448 if (!iTreeData->IsNode(itemId)) |
|
2449 { |
|
2450 return EFalse; |
|
2451 } |
|
2452 } |
|
2453 return ETrue; |
|
2454 } |
|
2455 |
|
2456 // --------------------------------------------------------------------------- |
|
2457 // |
|
2458 // |
|
2459 // --------------------------------------------------------------------------- |
|
2460 // |
|
2461 TBool CFsTreeVisualizerBase::AllNodesExpanded() const |
|
2462 { |
|
2463 FUNC_LOG; |
|
2464 return iWorld.ItemCount() == iTreeData->Count(); |
|
2465 } |
|
2466 |
|
2467 // --------------------------------------------------------------------------- |
|
2468 // Update visual of the item given by id. |
|
2469 // --------------------------------------------------------------------------- |
|
2470 // |
|
2471 void CFsTreeVisualizerBase::UpdateItemL(const TFsTreeItemId aItemId) |
|
2472 { |
|
2473 FUNC_LOG; |
|
2474 TInt i = iVisibleItems.Find(aItemId); |
|
2475 if (i != KErrNotFound) |
|
2476 { |
|
2477 MFsTreeItemVisualizer* vis = iTreeData->ItemVisualizer(aItemId); |
|
2478 if (vis) |
|
2479 { |
|
2480 vis->UpdateL(iTreeData->ItemData(aItemId), |
|
2481 IsItemFocused(aItemId) && IsFocusShown(), |
|
2482 iTreeData->Level(aItemId), |
|
2483 iMarkIcon, iMenuIcon, 0); |
|
2484 } |
|
2485 } |
|
2486 } |
|
2487 |
|
2488 // --------------------------------------------------------------------------- |
|
2489 // The functions sets wether all item in the list should be always in |
|
2490 // extended state or in normal state. |
|
2491 // --------------------------------------------------------------------------- |
|
2492 // |
|
2493 void CFsTreeVisualizerBase::SetItemsAlwaysExtendedL(TBool aAlwaysExtended) |
|
2494 { |
|
2495 FUNC_LOG; |
|
2496 iFlags.Assign(EItemsAlwaysExtended, aAlwaysExtended); |
|
2497 TFsTreeIterator treeIter( |
|
2498 iTreeData->Iterator(KFsTreeRootID, KFsTreeRootID)); |
|
2499 while (treeIter.HasNext()) |
|
2500 { |
|
2501 TFsTreeItemId itemId(treeIter.Next()); |
|
2502 if (itemId != KFsTreeNoneID && !iTreeData->IsNode(itemId)) |
|
2503 { |
|
2504 MFsTreeItemVisualizer* itemviz(iTreeData->ItemVisualizer(itemId)); |
|
2505 ApplyListSpecificValuesToItem(itemviz); |
|
2506 } |
|
2507 } |
|
2508 iWorld.BeginUpdate(); |
|
2509 iWorld.RemoveAllL(); |
|
2510 treeIter = iTreeData->Iterator(KFsTreeRootID, KFsTreeRootID, |
|
2511 KFsTreeIteratorSkipCollapsedFlag); |
|
2512 while (treeIter.HasNext()) |
|
2513 { |
|
2514 TFsTreeItemId itemId(treeIter.Next()); |
|
2515 if (itemId != KFsTreeNoneID) |
|
2516 { |
|
2517 MFsTreeItemVisualizer* itemviz(iTreeData->ItemVisualizer(itemId)); |
|
2518 iWorld.AppendL(itemId, itemviz->Size()); |
|
2519 } |
|
2520 } |
|
2521 iViewPort.SetPositionL(TPoint(), EFalse); |
|
2522 iViewPort.ClearCache(); |
|
2523 iWorld.EndUpdateL(); |
|
2524 } |
|
2525 |
|
2526 // --------------------------------------------------------------------------- |
|
2527 // The function returns if items are always in extended state or in normal. |
|
2528 // --------------------------------------------------------------------------- |
|
2529 // |
|
2530 TBool CFsTreeVisualizerBase::IsItemsAlwaysExtended() |
|
2531 { |
|
2532 FUNC_LOG; |
|
2533 return iFlags.IsSet(EItemsAlwaysExtended); |
|
2534 } |
|
2535 |
|
2536 // --------------------------------------------------------------------------- |
|
2537 // Set the background texture, clears the background color. |
|
2538 // --------------------------------------------------------------------------- |
|
2539 // |
|
2540 EXPORT_C void CFsTreeVisualizerBase::SetBackgroundTextureL(CAlfTexture& /*aBgTexture*/) |
|
2541 { |
|
2542 FUNC_LOG; |
|
2543 } |
|
2544 |
|
2545 // --------------------------------------------------------------------------- |
|
2546 // Sets the background color, clears the background texture. |
|
2547 // --------------------------------------------------------------------------- |
|
2548 // |
|
2549 EXPORT_C void CFsTreeVisualizerBase::SetBackgroundColorL(TRgb aColor) |
|
2550 { |
|
2551 FUNC_LOG; |
|
2552 if (iWatermarkLayout && iWatermarkLayout->Brushes()) |
|
2553 { |
|
2554 TInt count = iWatermarkLayout->Brushes()->Count(); |
|
2555 if (count > 0) |
|
2556 {//there is only background brush attached to this layout |
|
2557 iWatermarkLayout->Brushes()->Remove(KZero); |
|
2558 iWatermarkLayout->Brushes()->Reset(); |
|
2559 iWatermarkLayout->SetFlag(EAlfVisualChanged); |
|
2560 } |
|
2561 } |
|
2562 |
|
2563 CAlfGradientBrush* backgroundBrush = CAlfGradientBrush::NewL( |
|
2564 iOwnerControl->Env()); |
|
2565 backgroundBrush->SetLayer(EAlfBrushLayerBackground); |
|
2566 backgroundBrush->SetColor(aColor); |
|
2567 |
|
2568 iWatermarkLayout->Brushes()->AppendL(backgroundBrush, EAlfHasOwnership); |
|
2569 } |
|
2570 |
|
2571 // --------------------------------------------------------------------------- |
|
2572 // Sets a given brush as a list background. |
|
2573 // --------------------------------------------------------------------------- |
|
2574 // |
|
2575 EXPORT_C void CFsTreeVisualizerBase::SetBackgroundBrushL(CAlfBrush* aBrush) |
|
2576 { |
|
2577 FUNC_LOG; |
|
2578 |
|
2579 if (iWatermarkLayout && iWatermarkLayout->Brushes()) |
|
2580 { |
|
2581 TInt count = iWatermarkLayout->Brushes()->Count(); |
|
2582 if (count > 0) |
|
2583 {//there is only background brush attached to this layout |
|
2584 iWatermarkLayout->Brushes()->Remove(KZero); |
|
2585 iWatermarkLayout->Brushes()->Reset(); |
|
2586 iWatermarkLayout->SetFlag(EAlfVisualChanged); |
|
2587 } |
|
2588 } |
|
2589 |
|
2590 aBrush->SetLayer(EAlfBrushLayerBackground); |
|
2591 iWatermarkLayout->Brushes()->AppendL(aBrush, EAlfHasOwnership); |
|
2592 } |
|
2593 |
|
2594 // --------------------------------------------------------------------------- |
|
2595 // The function clears list's background. |
|
2596 // --------------------------------------------------------------------------- |
|
2597 // |
|
2598 EXPORT_C void CFsTreeVisualizerBase::ClearBackground() |
|
2599 { |
|
2600 FUNC_LOG; |
|
2601 if (iWatermarkLayout && iWatermarkLayout->Brushes()) |
|
2602 { |
|
2603 TInt count = iWatermarkLayout->Brushes()->Count(); |
|
2604 if (count > 0) |
|
2605 {//there is only background brush attached to this layout |
|
2606 iWatermarkLayout->Brushes()->Remove(KZero); |
|
2607 iWatermarkLayout->Brushes()->Reset(); |
|
2608 iWatermarkLayout->SetFlag(EAlfVisualChanged); |
|
2609 } |
|
2610 } |
|
2611 } |
|
2612 |
|
2613 // --------------------------------------------------------------------------- |
|
2614 // Sets watermark position. |
|
2615 // --------------------------------------------------------------------------- |
|
2616 // |
|
2617 EXPORT_C void CFsTreeVisualizerBase::SetWatermarkPos(const TPoint& aPosition) |
|
2618 { |
|
2619 FUNC_LOG; |
|
2620 if (iWatermark) |
|
2621 { |
|
2622 TAlfTimedPoint position; |
|
2623 position.SetTarget(TAlfRealPoint(aPosition)); |
|
2624 iWatermark->SetPos(position); |
|
2625 } |
|
2626 } |
|
2627 |
|
2628 // --------------------------------------------------------------------------- |
|
2629 // Sets watermark's size. |
|
2630 // --------------------------------------------------------------------------- |
|
2631 // |
|
2632 EXPORT_C void CFsTreeVisualizerBase::SetWatermarkSize(const TSize& aSize) |
|
2633 { |
|
2634 FUNC_LOG; |
|
2635 if (iWatermark) |
|
2636 { |
|
2637 TAlfTimedPoint size; |
|
2638 size.SetTarget(TAlfRealPoint(aSize.AsPoint())); |
|
2639 iWatermark->SetSize(size); |
|
2640 } |
|
2641 } |
|
2642 |
|
2643 // --------------------------------------------------------------------------- |
|
2644 // Sets watermark opacity. |
|
2645 // --------------------------------------------------------------------------- |
|
2646 // |
|
2647 EXPORT_C void CFsTreeVisualizerBase::SetWatermarkOpacity(const float aOpacity) |
|
2648 { |
|
2649 FUNC_LOG; |
|
2650 if (iWatermark) |
|
2651 { |
|
2652 TAlfTimedValue opacity; |
|
2653 opacity.SetTarget(aOpacity, 0); |
|
2654 iWatermark->SetOpacity(opacity); |
|
2655 } |
|
2656 } |
|
2657 |
|
2658 // --------------------------------------------------------------------------- |
|
2659 // Sets watermark texture. |
|
2660 // --------------------------------------------------------------------------- |
|
2661 // |
|
2662 EXPORT_C void CFsTreeVisualizerBase::SetWatermarkL(CAlfTexture* aTexture) |
|
2663 { |
|
2664 FUNC_LOG; |
|
2665 if (aTexture) |
|
2666 { |
|
2667 if (!iWatermark) |
|
2668 { |
|
2669 iWatermark |
|
2670 = CFsWatermark::NewL(*iOwnerControl, *iWatermarkLayout); |
|
2671 } |
|
2672 // <cmail> |
|
2673 iWatermark->SetWatermarkTextureL(*aTexture); |
|
2674 // </cmail> |
|
2675 } |
|
2676 else |
|
2677 { |
|
2678 delete iWatermark; |
|
2679 iWatermark = NULL; |
|
2680 } |
|
2681 } |
|
2682 |
|
2683 // --------------------------------------------------------------------------- |
|
2684 // |
|
2685 // --------------------------------------------------------------------------- |
|
2686 // |
|
2687 void CFsTreeVisualizerBase::TreeEventL( |
|
2688 const TFsTreeEvent aEvent, |
|
2689 const MFsTreeObserver::TFsTreeEventParams& aParams) |
|
2690 { |
|
2691 FUNC_LOG; |
|
2692 switch (aEvent) |
|
2693 { |
|
2694 case EFsTreeItemAdded: |
|
2695 case EFsTreeNodeAdded: |
|
2696 { |
|
2697 MFsTreeItemVisualizer* itemVisualizer(iTreeData->ItemVisualizer( |
|
2698 aParams.iItemId)); |
|
2699 const TBool isHidden(itemVisualizer->IsHidden()); |
|
2700 if (!isHidden) |
|
2701 { |
|
2702 if (!iListLayout->Count()) |
|
2703 { |
|
2704 // Hide empty list marker |
|
2705 iRootVisualizer->Hide(); |
|
2706 iComponentLayout->UpdateChildrenLayout(); |
|
2707 iListLayout->UpdateChildrenLayout(); |
|
2708 } |
|
2709 if (aParams.iTargetNodeId != KFsTreeRootID) |
|
2710 { |
|
2711 MFsTreeNodeVisualizer* nodeVisualizer = |
|
2712 iTreeData->NodeVisualizer(aParams.iTargetNodeId); |
|
2713 if (nodeVisualizer->IsExpanded()) |
|
2714 { |
|
2715 // look for parent's index |
|
2716 TInt indexAdd = 0; |
|
2717 while (iWorld.Item(indexAdd) != aParams.iTargetNodeId) |
|
2718 { |
|
2719 indexAdd++; |
|
2720 } |
|
2721 |
|
2722 // look for how many children parent already has in |
|
2723 // the tree model |
|
2724 TInt childCount( 0 ); |
|
2725 if ( aParams.iIndex >= 0 ) |
|
2726 { |
|
2727 childCount = aParams.iIndex; |
|
2728 } |
|
2729 else |
|
2730 { |
|
2731 // -1 is for excluding the item that is now being |
|
2732 // inserted to visualiser |
|
2733 // (it has already been inserted to the tree model) |
|
2734 childCount = iTreeData->CountChildrenRecursively( |
|
2735 aParams.iTargetNodeId ) - 1; |
|
2736 } |
|
2737 |
|
2738 InsertItemL( aParams.iItemId, indexAdd + 1 + childCount ); |
|
2739 } |
|
2740 } |
|
2741 else if (iWorld.ItemCount() > 0) |
|
2742 { |
|
2743 if (aParams.iIndex >= 0) |
|
2744 { |
|
2745 TInt indexAdd = 0; |
|
2746 TInt nodeCount = 0; |
|
2747 while (indexAdd < iWorld.ItemCount() - 1 && nodeCount |
|
2748 != aParams.iIndex) |
|
2749 { |
|
2750 indexAdd++; |
|
2751 if (iTreeData->Parent(iWorld.Item(indexAdd)) |
|
2752 == KFsTreeRootID) |
|
2753 { |
|
2754 nodeCount++; |
|
2755 } |
|
2756 } |
|
2757 InsertItemL(aParams.iItemId, indexAdd); |
|
2758 } |
|
2759 else |
|
2760 { |
|
2761 InsertItemL(aParams.iItemId, KErrNotFound); |
|
2762 } |
|
2763 } |
|
2764 else |
|
2765 { |
|
2766 InsertItemL(aParams.iItemId, aParams.iIndex); |
|
2767 } |
|
2768 } |
|
2769 } |
|
2770 break; |
|
2771 case EFsTreeItemRemoved: |
|
2772 case EFsTreeNodeRemoved: |
|
2773 { |
|
2774 RemoveItemL(aParams.iItemId); |
|
2775 } |
|
2776 break; |
|
2777 case EFsTreeRemovedAll: |
|
2778 { |
|
2779 iRootVisualizer->ShowL(*iRootLayout); |
|
2780 iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon, |
|
2781 iMenuIcon); |
|
2782 //iListLayout->RemoveAndDestroyAllD(); |
|
2783 iWorld.RemoveAllL(); |
|
2784 iFocusedItem = KFsTreeNoneID; |
|
2785 } |
|
2786 break; |
|
2787 case EFsTreeItemVisualizerChanged: |
|
2788 //the selector visual will be destroyed only when changing visualizer |
|
2789 if (aParams.iItemId == iFocusedItem) |
|
2790 { |
|
2791 iSelectorVisual = NULL; |
|
2792 } |
|
2793 case EFsTreeItemDataChanged: |
|
2794 { |
|
2795 const TFsTreeItemId itemId(aParams.iItemId); |
|
2796 MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer( |
|
2797 itemId); |
|
2798 if (visualizer) |
|
2799 { |
|
2800 visualizer->UpdateL(iTreeData->ItemData(itemId), |
|
2801 IsItemFocused(itemId), iTreeData->Level(itemId), |
|
2802 iMarkIcon, iMenuIcon, 0); |
|
2803 } |
|
2804 } |
|
2805 break; |
|
2806 |
|
2807 default: |
|
2808 break; |
|
2809 } |
|
2810 } |
|
2811 |
|
2812 // --------------------------------------------------------------------------- |
|
2813 // The function implements tree observer's reaction to removing a list item |
|
2814 // from the model. If the item was visible then it's removed from the visible |
|
2815 // area. If the focused item was removed then the focus is moved to the next |
|
2816 // item in the tree hierarchy (if the next item is not present, then the focus |
|
2817 // is moved to the previous one). |
|
2818 // --------------------------------------------------------------------------- |
|
2819 // |
|
2820 void CFsTreeVisualizerBase::RemoveItemL(TFsTreeItemId aItemId) |
|
2821 { |
|
2822 FUNC_LOG; |
|
2823 TInt removedindex = iWorld.IndexOfItem(aItemId); |
|
2824 iWorld.RemoveL(aItemId); |
|
2825 if (iFocusedItem == aItemId) |
|
2826 { |
|
2827 if (iWorld.ItemCount() > removedindex) |
|
2828 { |
|
2829 SetFocusedItemL(iWorld.Item(removedindex), EFalse); |
|
2830 } |
|
2831 else if (iWorld.ItemCount() > 0) |
|
2832 { |
|
2833 SetFocusedItemL(iWorld.Item(removedindex - 1), EFalse); |
|
2834 } |
|
2835 else |
|
2836 { |
|
2837 iFocusedItem = KFsTreeNoneID; |
|
2838 } |
|
2839 } |
|
2840 } |
|
2841 |
|
2842 // --------------------------------------------------------------------------- |
|
2843 // The function checks whether the focused item is not outside the visible |
|
2844 // area and if needed scrolls the list so that selected item is fully visible. |
|
2845 // --------------------------------------------------------------------------- |
|
2846 // |
|
2847 void CFsTreeVisualizerBase::MakeFocusedItemFullyVisible() |
|
2848 { |
|
2849 FUNC_LOG; |
|
2850 } |
|
2851 |
|
2852 // --------------------------------------------------------------------------- |
|
2853 // |
|
2854 // --------------------------------------------------------------------------- |
|
2855 // |
|
2856 void CFsTreeVisualizerBase::RefreshListViewL() |
|
2857 { |
|
2858 FUNC_LOG; |
|
2859 if (iTreeData->Count() == 0) |
|
2860 { |
|
2861 iRootVisualizer->ShowL(*iRootLayout); |
|
2862 iRootVisualizer->UpdateL(*iRootData, EFalse, 0, iMarkIcon, iMenuIcon); |
|
2863 } |
|
2864 else |
|
2865 { |
|
2866 } |
|
2867 } |
|
2868 |
|
2869 // --------------------------------------------------------------------------- |
|
2870 // Hides item. |
|
2871 // --------------------------------------------------------------------------- |
|
2872 // |
|
2873 void CFsTreeVisualizerBase::HideItemL(const TFsTreeItemId /*aItemId*/) |
|
2874 |
|
2875 { |
|
2876 FUNC_LOG; |
|
2877 } |
|
2878 |
|
2879 // --------------------------------------------------------------------------- |
|
2880 // Unhides item. |
|
2881 // --------------------------------------------------------------------------- |
|
2882 // |
|
2883 void CFsTreeVisualizerBase::UnhideItemL(const TFsTreeItemId /*aItemId*/) |
|
2884 { |
|
2885 FUNC_LOG; |
|
2886 |
|
2887 } |
|
2888 |
|
2889 // --------------------------------------------------------------------------- |
|
2890 // |
|
2891 // --------------------------------------------------------------------------- |
|
2892 // |
|
2893 void CFsTreeVisualizerBase::SetPadding(const TAlfBoxMetric& aPadding) |
|
2894 { |
|
2895 FUNC_LOG; |
|
2896 |
|
2897 iWatermarkLayout->SetPadding(aPadding); |
|
2898 |
|
2899 } |
|
2900 |
|
2901 // --------------------------------------------------------------------------- |
|
2902 // List pane's padding taken from Layout Manager or switched off. |
|
2903 // --------------------------------------------------------------------------- |
|
2904 // |
|
2905 void CFsTreeVisualizerBase::EnableListPanePadding(TBool aEnable) |
|
2906 { |
|
2907 FUNC_LOG; |
|
2908 if (aEnable) |
|
2909 { |
|
2910 TRect listPane; |
|
2911 CFsLayoutManager::LayoutMetricsRect(TRect( |
|
2912 iComponentLayout->Size().Target().AsSize()), |
|
2913 CFsLayoutManager::EFsLmMainSpFsListPane, listPane); |
|
2914 |
|
2915 if (CFsLayoutManager::IsMirrored()) |
|
2916 { |
|
2917 iListLayout->SetPadding(TPoint( |
|
2918 iComponentLayout->Size().Target().AsSize().iWidth |
|
2919 - listPane.iBr.iX, 0)); |
|
2920 iListItemBackgroundLayout->SetPadding(TPoint( |
|
2921 iComponentLayout->Size().Target().AsSize().iWidth |
|
2922 - listPane.iBr.iX, 0)); |
|
2923 } |
|
2924 else |
|
2925 { |
|
2926 TInt xPadd; |
|
2927 xPadd = listPane.iTl.iX; |
|
2928 iListLayout->SetPadding(TPoint(xPadd, 0)); |
|
2929 iListItemBackgroundLayout->SetPadding(TPoint(xPadd, 0)); |
|
2930 } |
|
2931 } |
|
2932 else |
|
2933 { |
|
2934 //no padding |
|
2935 TInt padd(0); |
|
2936 iListLayout->SetPadding(TPoint(padd, padd)); |
|
2937 iListItemBackgroundLayout->SetPadding(TPoint(padd, padd)); |
|
2938 } |
|
2939 } |
|
2940 |
|
2941 // --------------------------------------------------------------------------- |
|
2942 // Sets the type of text marquee. |
|
2943 // --------------------------------------------------------------------------- |
|
2944 // |
|
2945 void CFsTreeVisualizerBase::SetTextMarqueeType( |
|
2946 const TFsTextMarqueeType aMarqueeType) |
|
2947 { |
|
2948 FUNC_LOG; |
|
2949 iMarqueeType = aMarqueeType; |
|
2950 } |
|
2951 |
|
2952 // --------------------------------------------------------------------------- |
|
2953 // Gets the type of text marquee. |
|
2954 // --------------------------------------------------------------------------- |
|
2955 // |
|
2956 TFsTextMarqueeType CFsTreeVisualizerBase::TextMarqueeType() const |
|
2957 { |
|
2958 FUNC_LOG; |
|
2959 return iMarqueeType; |
|
2960 } |
|
2961 |
|
2962 // --------------------------------------------------------------------------- |
|
2963 // Sets the speed of marquee. |
|
2964 // --------------------------------------------------------------------------- |
|
2965 // |
|
2966 void CFsTreeVisualizerBase::SetTextMarqueeSpeed(const TInt aPixelsPerSec) |
|
2967 { |
|
2968 FUNC_LOG; |
|
2969 iMarqueeSpeed = aPixelsPerSec; |
|
2970 } |
|
2971 |
|
2972 // --------------------------------------------------------------------------- |
|
2973 // Gets the speed of marquee. |
|
2974 // --------------------------------------------------------------------------- |
|
2975 // |
|
2976 TInt CFsTreeVisualizerBase::TextMarqueeSpeed() const |
|
2977 { |
|
2978 FUNC_LOG; |
|
2979 return iMarqueeSpeed; |
|
2980 } |
|
2981 |
|
2982 // --------------------------------------------------------------------------- |
|
2983 // Sets delay for text marquee start. |
|
2984 // --------------------------------------------------------------------------- |
|
2985 // |
|
2986 void CFsTreeVisualizerBase::SetTextMarqueeStartDelay(const TInt aStartDelay) |
|
2987 { |
|
2988 FUNC_LOG; |
|
2989 iMarqueStartDelay = aStartDelay; |
|
2990 } |
|
2991 |
|
2992 // --------------------------------------------------------------------------- |
|
2993 // Gets delay for text marquee. |
|
2994 // --------------------------------------------------------------------------- |
|
2995 // |
|
2996 TInt CFsTreeVisualizerBase::TextMarqueeStartDelay() const |
|
2997 { |
|
2998 FUNC_LOG; |
|
2999 return iMarqueStartDelay; |
|
3000 } |
|
3001 |
|
3002 // --------------------------------------------------------------------------- |
|
3003 // Sets a delay for each cycle start. |
|
3004 // --------------------------------------------------------------------------- |
|
3005 // |
|
3006 void CFsTreeVisualizerBase::SetTextMarqueeCycleStartDelay( |
|
3007 const TInt aCycleStartDelay) |
|
3008 { |
|
3009 FUNC_LOG; |
|
3010 iMarqueCycleStartDelay = aCycleStartDelay; |
|
3011 } |
|
3012 |
|
3013 // --------------------------------------------------------------------------- |
|
3014 // Returns a delay for each cycle start. |
|
3015 // --------------------------------------------------------------------------- |
|
3016 // |
|
3017 TInt CFsTreeVisualizerBase::TextMarqueeCycleStartDelay() const |
|
3018 { |
|
3019 FUNC_LOG; |
|
3020 return iMarqueCycleStartDelay; |
|
3021 } |
|
3022 |
|
3023 // --------------------------------------------------------------------------- |
|
3024 // Sets number of marquee cycles. |
|
3025 // --------------------------------------------------------------------------- |
|
3026 // |
|
3027 void CFsTreeVisualizerBase::SetTextMarqueeRepetitions( |
|
3028 const TInt aMarqueeRepetitions) |
|
3029 { |
|
3030 FUNC_LOG; |
|
3031 iMarqueeRepetitions = aMarqueeRepetitions; |
|
3032 } |
|
3033 |
|
3034 // --------------------------------------------------------------------------- |
|
3035 // Gets number of marquee cycles. |
|
3036 // --------------------------------------------------------------------------- |
|
3037 // |
|
3038 TInt CFsTreeVisualizerBase::TextMarqueeRepetitions() const |
|
3039 { |
|
3040 FUNC_LOG; |
|
3041 return iMarqueeRepetitions; |
|
3042 } |
|
3043 |
|
3044 // --------------------------------------------------------------------------- |
|
3045 // |
|
3046 // --------------------------------------------------------------------------- |
|
3047 // |
|
3048 TInt CFsTreeVisualizerBase::GetItemDisplayRectTarget( |
|
3049 const TFsTreeItemId aItemId, TAlfRealRect& aRect) |
|
3050 { |
|
3051 FUNC_LOG; |
|
3052 TInt retVal(KErrNotFound); |
|
3053 MFsTreeItemVisualizer* itemVis(NULL); |
|
3054 CAlfLayout* lay(NULL); |
|
3055 |
|
3056 aRect.iTl = TAlfRealPoint(0.0, 0.0); |
|
3057 aRect.iBr = TAlfRealPoint(0.0, 0.0); |
|
3058 |
|
3059 retVal = iVisibleItems.Find(aItemId); |
|
3060 if (retVal != KErrNotFound) |
|
3061 {//item visible |
|
3062 itemVis = iTreeData->ItemVisualizer(aItemId); |
|
3063 if (itemVis) |
|
3064 { |
|
3065 lay = &itemVis->Layout(); |
|
3066 if (lay) |
|
3067 { |
|
3068 aRect = lay->DisplayRectTarget(); |
|
3069 retVal = KErrNone; |
|
3070 } |
|
3071 else |
|
3072 { |
|
3073 retVal = KErrNotFound; |
|
3074 } |
|
3075 } |
|
3076 else |
|
3077 { |
|
3078 retVal = KErrNotFound; |
|
3079 } |
|
3080 } |
|
3081 else |
|
3082 { |
|
3083 retVal = KErrNotFound; |
|
3084 } |
|
3085 |
|
3086 return retVal; |
|
3087 } |
|
3088 |
|
3089 // --------------------------------------------------------------------------- |
|
3090 // Internall to TreeList. Do not use directly. |
|
3091 // Used to block update during addition of many items/nodes. Currently only |
|
3092 // scrollbar is blocked from beign updated.Gets number of marquee cycles. |
|
3093 // --------------------------------------------------------------------------- |
|
3094 // |
|
3095 void CFsTreeVisualizerBase::SetAutoRefreshAtInsert(TBool aAllowRefresh) |
|
3096 { |
|
3097 FUNC_LOG; |
|
3098 if (!aAllowRefresh && iFlags.IsSet(EAutoRefresh)) |
|
3099 { |
|
3100 iWorld.BeginUpdate(); |
|
3101 } |
|
3102 else if (aAllowRefresh && !iFlags.IsSet(EAutoRefresh)) |
|
3103 { |
|
3104 TInt error( KErrNone ); |
|
3105 TRAP( error, iWorld.EndUpdateL() ); |
|
3106 ERROR_1( error, "iWorld.EndUpdateL failed with error: %d", error ); |
|
3107 } |
|
3108 iFlags.Assign(EAutoRefresh, aAllowRefresh); |
|
3109 } |
|
3110 |
|
3111 // --------------------------------------------------------------------------- |
|
3112 // Internall to TreeList. Do not use directly. |
|
3113 // Used to block update during addition of many items/nodes. Currently only |
|
3114 // scrollbar is blocked from beign updated.Gets number of marquee cycles. |
|
3115 // --------------------------------------------------------------------------- |
|
3116 // |
|
3117 TBool CFsTreeVisualizerBase::IsAutoRefreshAtInsert() |
|
3118 { |
|
3119 FUNC_LOG; |
|
3120 return iFlags.IsSet(EAutoRefresh); |
|
3121 } |
|
3122 |
|
3123 // --------------------------------------------------------------------------- |
|
3124 // CFsTreeVisualizerBase::SetDirectTouchMode |
|
3125 // --------------------------------------------------------------------------- |
|
3126 // |
|
3127 void CFsTreeVisualizerBase::SetDirectTouchMode(const TBool aDirectTouchMode) |
|
3128 { |
|
3129 FUNC_LOG; |
|
3130 iFlags.Assign(EDirectTouchMode, aDirectTouchMode); |
|
3131 } |
|
3132 |
|
3133 // --------------------------------------------------------------------------- |
|
3134 // CFsTreeVisualizerBase::SetExpandCollapseAllOnLongTap |
|
3135 // --------------------------------------------------------------------------- |
|
3136 // |
|
3137 void CFsTreeVisualizerBase::SetExpandCollapseAllOnLongTap( TBool aExpandCollapse ) |
|
3138 { |
|
3139 FUNC_LOG; |
|
3140 iFlags.Assign( EExpandCollapseOnLongTap, aExpandCollapse ); |
|
3141 } |
|
3142 |
|
3143 // --------------------------------------------------------------------------- |
|
3144 // CFsTreeVisualizerBase::IsExpandCollapseAllOnLongTap |
|
3145 // --------------------------------------------------------------------------- |
|
3146 // |
|
3147 TBool CFsTreeVisualizerBase::IsExpandCollapseAllOnLongTap() |
|
3148 { |
|
3149 FUNC_LOG; |
|
3150 return iFlags.IsSet( EExpandCollapseOnLongTap ); |
|
3151 } |
|
3152 |
|
3153 // --------------------------------------------------------------------------- |
|
3154 // From MFsFadeEffectObserver |
|
3155 // Function which will receive notifications about fade effect state changes. |
|
3156 // --------------------------------------------------------------------------- |
|
3157 // |
|
3158 void CFsTreeVisualizerBase::FadeEffectEvent( |
|
3159 MFsFadeEffectObserver::TFadeEffectState aState) |
|
3160 { |
|
3161 FUNC_LOG; |
|
3162 switch (aState) |
|
3163 { |
|
3164 case MFsFadeEffectObserver::EFadeInFinished: |
|
3165 { |
|
3166 if (iVisualizationState == EFsTreeFadingInSlidingIn) |
|
3167 {//slide in effect still on |
|
3168 iVisualizationState = EFsTreeSlidingIn; |
|
3169 } |
|
3170 else if (iVisualizationState == EFsTreeFadingIn) |
|
3171 { |
|
3172 iVisualizationState = EFsTreeVisible; |
|
3173 UpdateScrollBar(); |
|
3174 } |
|
3175 break; |
|
3176 } |
|
3177 case MFsFadeEffectObserver::EFadeOutFinished: |
|
3178 { |
|
3179 if (iVisualizationState == EFsTreeFadingOutSlidingOut) |
|
3180 {//slide out effect still on |
|
3181 iVisualizationState = EFsTreeSlidingOut; |
|
3182 } |
|
3183 else if (iVisualizationState == EFsTreeFadingOut) |
|
3184 { |
|
3185 iScrollBar->MakeVisible(EFalse); |
|
3186 iVisualizationState = EFsTreeHidden; |
|
3187 } |
|
3188 break; |
|
3189 } |
|
3190 default: |
|
3191 { |
|
3192 break; |
|
3193 } |
|
3194 } |
|
3195 |
|
3196 if (iVisualizationState == EFsTreeVisible && iVisualizerObserver) |
|
3197 { |
|
3198 // <cmail> Touch |
|
3199 TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL( |
|
3200 MFsTreeVisualizerObserver::EFsTreeListVisualizerShown, |
|
3201 KFsTreeNoneID )); |
|
3202 // </cmail> |
|
3203 } |
|
3204 |
|
3205 if (iVisualizationState == EFsTreeHidden && iVisualizerObserver) |
|
3206 { |
|
3207 // <cmail> Touch |
|
3208 TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL( |
|
3209 MFsTreeVisualizerObserver::EFsTreeListVisualizerHidden, |
|
3210 KFsTreeNoneID )); |
|
3211 // </cmail> |
|
3212 } |
|
3213 } |
|
3214 |
|
3215 // --------------------------------------------------------------------------- |
|
3216 // From MFsSlideEffectObserver |
|
3217 // Function which will receive notifications about slide effect state changes. |
|
3218 // --------------------------------------------------------------------------- |
|
3219 // |
|
3220 void CFsTreeVisualizerBase::SlideEffectEvent( |
|
3221 MFsSlideEffectObserver::TSlideEffectState aState) |
|
3222 { |
|
3223 FUNC_LOG; |
|
3224 switch (aState) |
|
3225 { |
|
3226 case MFsSlideEffectObserver::ESlideInFinished: |
|
3227 { |
|
3228 if (iVisualizationState == EFsTreeFadingInSlidingIn) |
|
3229 {//fade in effect still on |
|
3230 iVisualizationState = EFsTreeFadingIn; |
|
3231 } |
|
3232 else if (iVisualizationState == EFsTreeSlidingIn) |
|
3233 { |
|
3234 iVisualizationState = EFsTreeVisible; |
|
3235 UpdateScrollBar(); |
|
3236 } |
|
3237 break; |
|
3238 } |
|
3239 case MFsSlideEffectObserver::ESlideOutFinished: |
|
3240 { |
|
3241 if (iVisualizationState == EFsTreeFadingOutSlidingOut) |
|
3242 {//fade out effect still on |
|
3243 iVisualizationState = EFsTreeFadingOut; |
|
3244 } |
|
3245 else if (iVisualizationState == EFsTreeSlidingOut) |
|
3246 { |
|
3247 iScrollBar->MakeVisible(EFalse); |
|
3248 iVisualizationState = EFsTreeHidden; |
|
3249 } |
|
3250 break; |
|
3251 } |
|
3252 default: |
|
3253 { |
|
3254 break; |
|
3255 } |
|
3256 } |
|
3257 |
|
3258 if (iVisualizationState == EFsTreeVisible && iVisualizerObserver) |
|
3259 { |
|
3260 // <cmail> Touch |
|
3261 TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL( |
|
3262 MFsTreeVisualizerObserver::EFsTreeListVisualizerShown, |
|
3263 KFsTreeNoneID )); |
|
3264 |
|
3265 } |
|
3266 |
|
3267 if (iVisualizationState == EFsTreeHidden && iVisualizerObserver) |
|
3268 { |
|
3269 TRAP_IGNORE(iVisualizerObserver->TreeVisualizerEventL( |
|
3270 MFsTreeVisualizerObserver::EFsTreeListVisualizerHidden, |
|
3271 KFsTreeNoneID )); |
|
3272 // </cmail> |
|
3273 } |
|
3274 } |
|
3275 |
|
3276 // --------------------------------------------------------------------------- |
|
3277 // From MAlfActionObserver |
|
3278 // Called by the server when an action command is executed. |
|
3279 // --------------------------------------------------------------------------- |
|
3280 // |
|
3281 void CFsTreeVisualizerBase::HandleActionL( |
|
3282 const TAlfActionCommand& aActionCommand) |
|
3283 { |
|
3284 // <cmail> Change scrollbar to avkon (to support skinning & touch) |
|
3285 if (KAknsMessageSkinChange == aActionCommand.Id()) |
|
3286 {//layoout has changed |
|
3287 // HideList(EFalse, EFalse); |
|
3288 // ShowListL(ETrue, EFalse); |
|
3289 iScrollBar->HandleResourceChange(KAknsMessageSkinChange); |
|
3290 } |
|
3291 // </cmail> |
|
3292 } |
|
3293 |
|
3294 // --------------------------------------------------------------------------- |
|
3295 // Hides visible list items. Clears the visible items table. |
|
3296 // --------------------------------------------------------------------------- |
|
3297 // |
|
3298 // <cmail> |
|
3299 void CFsTreeVisualizerBase::ClearVisibleItemsListL(TBool /*aRemoveAll*/, |
|
3300 TBool /*aScrollList*/) |
|
3301 // </cmail> |
|
3302 { |
|
3303 FUNC_LOG; |
|
3304 } |
|
3305 |
|
3306 // --------------------------------------------------------------------------- |
|
3307 // Applies focus brush to the selected item. |
|
3308 // --------------------------------------------------------------------------- |
|
3309 // |
|
3310 void CFsTreeVisualizerBase::ChangeFocusL(const TFsTreeItemId /*aPrevious*/) |
|
3311 { |
|
3312 FUNC_LOG; |
|
3313 |
|
3314 } |
|
3315 |
|
3316 // --------------------------------------------------------------------------- |
|
3317 // CFsTreeVisualizerBase::AdjustVisibleItemsL |
|
3318 // --------------------------------------------------------------------------- |
|
3319 // |
|
3320 void CFsTreeVisualizerBase::AdjustVisibleItemsL() |
|
3321 { |
|
3322 FUNC_LOG; |
|
3323 |
|
3324 } |
|
3325 |
|
3326 // --------------------------------------------------------------------------- |
|
3327 // CFsTreeVisualizerBase::InsertItemL |
|
3328 // --------------------------------------------------------------------------- |
|
3329 // |
|
3330 void CFsTreeVisualizerBase::InsertItemL(TFsTreeItemId aItemId, |
|
3331 const TInt aSlot) |
|
3332 { |
|
3333 MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer(aItemId); |
|
3334 ApplyListSpecificValuesToItem(visualizer); |
|
3335 //TUint32 oldflags = visualizer->Flags(); |
|
3336 //visualizer->SetFlags(oldflags | KFsTreeListItemManagedLayout); |
|
3337 const TSize size(visualizer->Size()); |
|
3338 //visualizer->SetFlags(oldflags); |
|
3339 if (aSlot != KErrNotFound) |
|
3340 { |
|
3341 iWorld.InsertL(aItemId, size, aSlot); |
|
3342 } |
|
3343 else |
|
3344 { |
|
3345 iWorld.AppendL(aItemId, size); |
|
3346 } |
|
3347 } |
|
3348 |
|
3349 // --------------------------------------------------------------------------- |
|
3350 // Move selection in the list. |
|
3351 // --------------------------------------------------------------------------- |
|
3352 // |
|
3353 void CFsTreeVisualizerBase::MoveSelectionL( |
|
3354 const TFsTreeVisualizerMove aMoveType) |
|
3355 { |
|
3356 FUNC_LOG; |
|
3357 TInt focusedIndex = iWorld.IndexOfItem(iFocusedItem); |
|
3358 switch (aMoveType) |
|
3359 { |
|
3360 case EFsTreeVisualizerMoveLineUp: |
|
3361 { |
|
3362 while (focusedIndex > 0) |
|
3363 { |
|
3364 focusedIndex -= 1; |
|
3365 if (iTreeData->ItemData(iWorld.Item(focusedIndex)).Type() |
|
3366 != KFsSeparatorDataType) |
|
3367 { |
|
3368 SetFocusedItemL(iWorld.Item(focusedIndex)); |
|
3369 break; |
|
3370 } |
|
3371 } |
|
3372 break; |
|
3373 } |
|
3374 case EFsTreeVisualizerMoveLineDown: |
|
3375 { |
|
3376 while (focusedIndex < iWorld.ItemCount() - 1) |
|
3377 { |
|
3378 focusedIndex += 1; |
|
3379 if (iTreeData->ItemData(iWorld.Item(focusedIndex)).Type() |
|
3380 != KFsSeparatorDataType) |
|
3381 { |
|
3382 SetFocusedItemL(iWorld.Item(focusedIndex)); |
|
3383 break; |
|
3384 } |
|
3385 } |
|
3386 break; |
|
3387 } |
|
3388 case EFsTreeVisualizerMovePageUp: |
|
3389 { |
|
3390 focusedIndex -= iVisibleItems.Count() - 2; |
|
3391 while (focusedIndex > 0) |
|
3392 { |
|
3393 if (iTreeData->ItemData(iWorld.Item(focusedIndex)).Type() |
|
3394 != KFsSeparatorDataType) |
|
3395 { |
|
3396 break; |
|
3397 } |
|
3398 else |
|
3399 { |
|
3400 focusedIndex--; |
|
3401 } |
|
3402 } |
|
3403 if (focusedIndex < 0) |
|
3404 { |
|
3405 focusedIndex = 0; |
|
3406 } |
|
3407 if (iWorld.ItemCount() > 0) |
|
3408 { |
|
3409 SetFocusedItemL(iWorld.Item(focusedIndex)); |
|
3410 } |
|
3411 break; |
|
3412 } |
|
3413 case EFsTreeVisualizerMovePageDown: |
|
3414 { |
|
3415 focusedIndex += iVisibleItems.Count() - 2; |
|
3416 while (focusedIndex < iWorld.ItemCount() - 1) |
|
3417 { |
|
3418 if (iTreeData->ItemData(iWorld.Item(focusedIndex)).Type() |
|
3419 != KFsSeparatorDataType) |
|
3420 { |
|
3421 break; |
|
3422 } |
|
3423 else |
|
3424 { |
|
3425 focusedIndex++; |
|
3426 } |
|
3427 } |
|
3428 if (focusedIndex > iWorld.ItemCount() - 1) |
|
3429 { |
|
3430 focusedIndex = iWorld.ItemCount() - 1; |
|
3431 } |
|
3432 if (iWorld.ItemCount() > 0) |
|
3433 { |
|
3434 SetFocusedItemL(iWorld.Item(focusedIndex)); |
|
3435 } |
|
3436 break; |
|
3437 } |
|
3438 } |
|
3439 iViewPort.ScrollItemToViewL(iFocusedItem, ETrue); |
|
3440 } |
|
3441 |
|
3442 // --------------------------------------------------------------------------- |
|
3443 // Moves selection in the list by one item upwards. |
|
3444 // --------------------------------------------------------------------------- |
|
3445 // |
|
3446 TInt CFsTreeVisualizerBase::MoveSelectionByLineUpL(const TBool /*aChangeFocus*/) |
|
3447 { |
|
3448 FUNC_LOG; |
|
3449 return 0; |
|
3450 } |
|
3451 |
|
3452 // --------------------------------------------------------------------------- |
|
3453 // Moves selection in the list by one item downwards. |
|
3454 // --------------------------------------------------------------------------- |
|
3455 // |
|
3456 TInt CFsTreeVisualizerBase::MoveSelectionByLineDownL(const TBool /*aChangeFocus*/) |
|
3457 { |
|
3458 FUNC_LOG; |
|
3459 return 0; |
|
3460 } |
|
3461 |
|
3462 // --------------------------------------------------------------------------- |
|
3463 // Scrolling |
|
3464 // --------------------------------------------------------------------------- |
|
3465 // |
|
3466 void CFsTreeVisualizerBase::Scroll(const TFsTreeItemId aPrevious, |
|
3467 TBool aAlignTop) |
|
3468 { |
|
3469 FUNC_LOG; |
|
3470 TInt currScrollOffset = iListLayout->ScrollOffset().iY.Target(); |
|
3471 TInt listItemsHeight = 0; |
|
3472 TInt visibleHeight = iComponentLayout->Size().iY.Target(); |
|
3473 TInt scrollOffset = 0; |
|
3474 |
|
3475 listItemsHeight = VisibleItemsHeight(aPrevious); |
|
3476 |
|
3477 if (aAlignTop) |
|
3478 { |
|
3479 scrollOffset = 0; |
|
3480 } |
|
3481 else |
|
3482 { |
|
3483 if (listItemsHeight > visibleHeight) |
|
3484 { |
|
3485 scrollOffset = listItemsHeight - visibleHeight; |
|
3486 } |
|
3487 else |
|
3488 { |
|
3489 scrollOffset = currScrollOffset; |
|
3490 } |
|
3491 } |
|
3492 |
|
3493 ScrollListLayouts(scrollOffset, iCurrentScrollSpeed); |
|
3494 } |
|
3495 |
|
3496 // --------------------------------------------------------------------------- |
|
3497 // Counts height items from iVisibleItems array which will |
|
3498 // be drawn on the screen |
|
3499 // --------------------------------------------------------------------------- |
|
3500 // |
|
3501 TInt CFsTreeVisualizerBase::VisibleItemsHeight(const TFsTreeItemId aPrevious) |
|
3502 { |
|
3503 FUNC_LOG; |
|
3504 TInt listItemsHeight = 0; |
|
3505 MFsTreeItemVisualizer* vis = 0; |
|
3506 TFsTreeItemId itemId; |
|
3507 TInt itemCount = iVisibleItems.Count(); |
|
3508 |
|
3509 for (TInt index = 0; index < itemCount; ++index) |
|
3510 { |
|
3511 itemId = iVisibleItems[index]; |
|
3512 vis = iTreeData->ItemVisualizer(itemId); |
|
3513 |
|
3514 if (itemId == iFocusedItem) |
|
3515 { |
|
3516 if (vis->IsExtendable()) |
|
3517 { |
|
3518 listItemsHeight += vis->ExtendedSize().iHeight; |
|
3519 } |
|
3520 else |
|
3521 { |
|
3522 listItemsHeight += vis->Size().iHeight; |
|
3523 } |
|
3524 } |
|
3525 else if (itemId == aPrevious && iFocusedItem != aPrevious) |
|
3526 { |
|
3527 listItemsHeight += vis->Size().iHeight; |
|
3528 } |
|
3529 else if (vis->IsExtended() && vis->IsExtendable()) |
|
3530 { |
|
3531 listItemsHeight += vis->ExtendedSize().iHeight; |
|
3532 } |
|
3533 else |
|
3534 { |
|
3535 listItemsHeight += vis->Size().iHeight; |
|
3536 } |
|
3537 } |
|
3538 |
|
3539 return listItemsHeight; |
|
3540 } |
|
3541 |
|
3542 // --------------------------------------------------------------------------- |
|
3543 // Check if item is in expanded node |
|
3544 // --------------------------------------------------------------------------- |
|
3545 TBool CFsTreeVisualizerBase::IsInExpanded(TFsTreeItemId aItemId) |
|
3546 { |
|
3547 FUNC_LOG; |
|
3548 TBool result(ETrue); |
|
3549 TFsTreeItemId parentId = iTreeData->Parent(aItemId); |
|
3550 while (parentId != KFsTreeRootID && parentId != KFsTreeNoneID) |
|
3551 { |
|
3552 if (iTreeData->IsNode(parentId)) |
|
3553 { |
|
3554 if (iTreeData->NodeVisualizer(parentId)->IsExpanded()) |
|
3555 { |
|
3556 result = ETrue; |
|
3557 parentId = iTreeData->Parent(parentId); |
|
3558 } |
|
3559 else |
|
3560 { |
|
3561 result = EFalse; |
|
3562 break; |
|
3563 } |
|
3564 } |
|
3565 else |
|
3566 { |
|
3567 parentId = iTreeData->Parent(parentId); |
|
3568 } |
|
3569 } |
|
3570 |
|
3571 return result; |
|
3572 } |
|
3573 |
|
3574 // --------------------------------------------------------------------------- |
|
3575 // CFsTreeVisualizerBase::UpdateViewPortL |
|
3576 // --------------------------------------------------------------------------- |
|
3577 // |
|
3578 void CFsTreeVisualizerBase::UpdateViewPortL() |
|
3579 { |
|
3580 FUNC_LOG; |
|
3581 TRect mainPaneRect; |
|
3582 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
3583 TRect listRect(iRootLayout->DisplayRectTarget()); |
|
3584 listRect.Move(mainPaneRect.iTl); |
|
3585 TRect listPane; |
|
3586 CFsLayoutManager::LayoutMetricsRect(listRect, |
|
3587 CFsLayoutManager::EFsLmMainSpFsListPane, listPane); |
|
3588 iWorld.BeginUpdate(); |
|
3589 TBool keepFocusedItemInView(EFalse); |
|
3590 if (iFocusedItem != KFsTreeNoneID) |
|
3591 { |
|
3592 keepFocusedItemInView = iViewPort.ItemRect(iFocusedItem).Height() > 0; |
|
3593 } |
|
3594 iViewPort.SetSizeL(listPane.Size()); |
|
3595 iWorld.Recalculate(*iTreeData); |
|
3596 if (keepFocusedItemInView) |
|
3597 { |
|
3598 iViewPort.ScrollItemToViewL(iFocusedItem, EFalse); |
|
3599 } |
|
3600 else |
|
3601 { |
|
3602 iViewPort.MakeViewFullyOccupiedL(); |
|
3603 } |
|
3604 iViewPort.ClearCache(); |
|
3605 iWorld.EndUpdateL(); |
|
3606 } |
|
3607 |
|
3608 // --------------------------------------------------------------------------- |
|
3609 // Updates scrollbar, only if update is needed. |
|
3610 // --------------------------------------------------------------------------- |
|
3611 // |
|
3612 void CFsTreeVisualizerBase::UpdateScrollBarIfNeededL() |
|
3613 { |
|
3614 FUNC_LOG; |
|
3615 if (iScrollBar->ThumbPosition() != iViewPort.Position().iY) |
|
3616 { |
|
3617 iScrollbarModel.SetFocusPosition(iViewPort.Position().iY); |
|
3618 iScrollBar->SetModelL(&iScrollbarModel); |
|
3619 } |
|
3620 } |
|
3621 |
|
3622 // --------------------------------------------------------------------------- |
|
3623 // Updates scrollbar. |
|
3624 // --------------------------------------------------------------------------- |
|
3625 // |
|
3626 void CFsTreeVisualizerBase::UpdateScrollBarL(const TInt /*aTimeout*/) |
|
3627 { |
|
3628 FUNC_LOG; |
|
3629 |
|
3630 TRect mainPaneRect; |
|
3631 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
3632 TRect listRect(iRootLayout->DisplayRectTarget()); |
|
3633 listRect.Move(mainPaneRect.iTl); |
|
3634 TRect scrollPane, listPane; |
|
3635 CFsLayoutManager::LayoutMetricsRect(listRect, |
|
3636 CFsLayoutManager::EFsLmSpFsScrollPane, scrollPane); |
|
3637 CFsLayoutManager::LayoutMetricsRect(listRect, |
|
3638 CFsLayoutManager::EFsLmMainSpFsListPane, listPane); |
|
3639 |
|
3640 const TInt pageSize(iViewPort.Size().iHeight); |
|
3641 iScrollbarModel.SetScrollSpan(Max(iWorld.Height(), pageSize)); |
|
3642 iScrollbarModel.SetWindowSize(pageSize); |
|
3643 iScrollbarModel.SetFocusPosition(iViewPort.Position().iY); |
|
3644 iScrollBar->SetModelL(&iScrollbarModel); |
|
3645 |
|
3646 RArray<TInt> columns; |
|
3647 CleanupClosePushL(columns); |
|
3648 TBool updateLayouts(EFalse); |
|
3649 if (iViewPort.IsScrollBarNeeded() && iVisualizationState |
|
3650 == EFsTreeVisible) |
|
3651 { |
|
3652 iScrollBar->SetRect(scrollPane); |
|
3653 columns.AppendL(listPane.Width()); |
|
3654 columns.AppendL(scrollPane.Width()); |
|
3655 iComponentLayout->SetColumnsL(columns); |
|
3656 iScrollBar->MakeVisible(ETrue); |
|
3657 updateLayouts = ETrue; |
|
3658 } |
|
3659 else if (!iViewPort.IsScrollBarNeeded()) |
|
3660 { |
|
3661 columns.AppendL(listPane.Width()); |
|
3662 iComponentLayout->SetColumnsL(columns); |
|
3663 iScrollBar->MakeVisible(EFalse); |
|
3664 updateLayouts = ETrue; |
|
3665 } |
|
3666 CleanupStack::PopAndDestroy(); // columns.Close() |
|
3667 if (updateLayouts) |
|
3668 { |
|
3669 iComponentLayout->UpdateChildrenLayout(); |
|
3670 |
|
3671 for (TUint i = 0; i < iVisibleItems.Count(); ++i) |
|
3672 { |
|
3673 TFsTreeItemId itemId(iVisibleItems[i]); |
|
3674 MFsTreeItemVisualizer* viz = iTreeData->ItemVisualizer(itemId); |
|
3675 viz->UpdateL(iTreeData->ItemData(itemId), |
|
3676 IsItemFocused(itemId) && IsFocusShown(), |
|
3677 iTreeData->Level(itemId), iMarkIcon, iMenuIcon, 0, EFalse); |
|
3678 } |
|
3679 UpdateSelectorVisualL(); |
|
3680 } |
|
3681 |
|
3682 } |
|
3683 |
|
3684 // --------------------------------------------------------------------------- |
|
3685 // |
|
3686 // --------------------------------------------------------------------------- |
|
3687 // |
|
3688 TInt CFsTreeVisualizerBase::UpdateScrollBar(const TInt aTimeout) |
|
3689 { |
|
3690 FUNC_LOG; |
|
3691 TRAPD( error, UpdateScrollBarL( aTimeout ) ); |
|
3692 return error; |
|
3693 } |
|
3694 |
|
3695 // --------------------------------------------------------------------------- |
|
3696 // Old API to be removed. Turns on or off vertical scrollbar. |
|
3697 // --------------------------------------------------------------------------- |
|
3698 // |
|
3699 void CFsTreeVisualizerBase::SetVScrollBarL(TBool /*aSetOn*/) |
|
3700 { |
|
3701 FUNC_LOG; |
|
3702 UpdateScrollBarL(iCurrentScrollSpeed); |
|
3703 } |
|
3704 |
|
3705 // --------------------------------------------------------------------------- |
|
3706 // Turns on or off vertical scrollbar. |
|
3707 // --------------------------------------------------------------------------- |
|
3708 // |
|
3709 void CFsTreeVisualizerBase::SetScrollBarVisibilityL( |
|
3710 const TFsScrollbarVisibility aVisibility) |
|
3711 { |
|
3712 iScrollbarVisibility = aVisibility; |
|
3713 UpdateScrollBarL(iCurrentScrollSpeed); |
|
3714 } |
|
3715 |
|
3716 // --------------------------------------------------------------------------- |
|
3717 // Gets scrollbar visibility. |
|
3718 // --------------------------------------------------------------------------- |
|
3719 // |
|
3720 TFsScrollbarVisibility CFsTreeVisualizerBase::ScrollbarVisibility() const |
|
3721 { |
|
3722 FUNC_LOG; |
|
3723 return iScrollbarVisibility; |
|
3724 } |
|
3725 |
|
3726 // --------------------------------------------------------------------------- |
|
3727 // Sets border status |
|
3728 // --------------------------------------------------------------------------- |
|
3729 // |
|
3730 void CFsTreeVisualizerBase::SetBorderL(const TBool aVisible, |
|
3731 CAlfTexture* aBorderTexture) |
|
3732 { |
|
3733 FUNC_LOG; |
|
3734 if (!aBorderTexture) |
|
3735 { |
|
3736 FsGenericPanic(EFsListPanicBorderNotSet); |
|
3737 } |
|
3738 |
|
3739 if (aVisible) |
|
3740 { |
|
3741 CAlfImageBrush* border = CAlfImageBrush::NewL(iOwnerControl->Env(), |
|
3742 TAlfImage(*aBorderTexture)); |
|
3743 border->SetLayer(EAlfBrushLayerBackground); |
|
3744 |
|
3745 border->SetBorders(-8, -8, -8, -8); |
|
3746 //<cmail> |
|
3747 // layout values needed here (not: only used from FS action menu) |
|
3748 //</cmail> |
|
3749 iBorderLayout->SetPadding(TPoint(5, 5)); |
|
3750 |
|
3751 if (iBorderLayout->Brushes()->Count() > 0) |
|
3752 { |
|
3753 iBorderLayout->Brushes()->Remove(0); |
|
3754 iBorderLayout->Brushes()->Reset(); |
|
3755 } |
|
3756 |
|
3757 iBorderLayout->Brushes()->AppendL(border, EAlfHasOwnership); |
|
3758 } |
|
3759 else |
|
3760 { |
|
3761 if (iBorderLayout->Brushes()->Count() > 0) |
|
3762 { |
|
3763 iBorderLayout->Brushes()->Remove(0); |
|
3764 iBorderLayout->Brushes()->Reset(); |
|
3765 iBorderLayout->SetPadding(0); |
|
3766 } |
|
3767 } |
|
3768 |
|
3769 iBorderLayout->SetFlag(EAlfVisualChanged); |
|
3770 iBorderLayout->UpdateChildrenLayout(); |
|
3771 RefreshListViewL(); |
|
3772 } |
|
3773 |
|
3774 // --------------------------------------------------------------------------- |
|
3775 // Sets shadow status |
|
3776 // --------------------------------------------------------------------------- |
|
3777 // |
|
3778 void CFsTreeVisualizerBase::SetShadowL(const TBool aVisible) |
|
3779 { |
|
3780 FUNC_LOG; |
|
3781 if (aVisible) |
|
3782 { |
|
3783 //remove shadow if it's already set |
|
3784 if (iShadowLayout && iShadowLayout->Brushes()) |
|
3785 { |
|
3786 TInt count = iShadowLayout->Brushes()->Count(); |
|
3787 if (count > 0) |
|
3788 {//there is only a shadow brush attached to this layout |
|
3789 iShadowLayout->Brushes()->Remove(KZero); |
|
3790 iShadowLayout->Brushes()->Reset(); |
|
3791 iShadowLayout->SetFlag(EAlfVisualChanged); |
|
3792 } |
|
3793 } |
|
3794 //attach shadow brush to layout |
|
3795 CAlfShadowBorderBrush* shadow = CAlfShadowBorderBrush::NewLC( |
|
3796 iOwnerControl->Env(), KDefaultShadowWidth); |
|
3797 shadow->SetOpacity(.25f); |
|
3798 |
|
3799 //set paddind to root layout so the shadow can be visible |
|
3800 TAlfBoxMetric m; |
|
3801 m.iBottom.iMagnitude = KDefaultShadowWidth; |
|
3802 m.iLeft.iMagnitude = KZero; |
|
3803 m.iRight.iMagnitude = KDefaultShadowWidth; |
|
3804 m.iTop.iMagnitude = KZero; |
|
3805 iRootLayout->SetPadding(m); |
|
3806 |
|
3807 iShadowLayout->EnableBrushesL(ETrue); |
|
3808 iShadowLayout->Brushes()->AppendL(shadow, EAlfHasOwnership); |
|
3809 CleanupStack::Pop(shadow); |
|
3810 |
|
3811 iShadowLayout->SetFlag(EAlfVisualChanged); |
|
3812 iRootLayout->UpdateChildrenLayout(KZero); |
|
3813 } |
|
3814 else |
|
3815 { |
|
3816 //remove shadow if it's already set |
|
3817 if (iShadowLayout && iShadowLayout->Brushes()) |
|
3818 { |
|
3819 TInt count = iShadowLayout->Brushes()->Count(); |
|
3820 if (count > 0) |
|
3821 {//there is only a shadow brush attached to this layout |
|
3822 iShadowLayout->Brushes()->Remove(KZero); |
|
3823 iShadowLayout->Brushes()->Reset(); |
|
3824 iShadowLayout->SetFlag(EAlfVisualChanged); |
|
3825 |
|
3826 //remove paddind from root layout |
|
3827 TAlfBoxMetric m; |
|
3828 m.iBottom.iMagnitude = KZero; |
|
3829 m.iLeft.iMagnitude = KZero; |
|
3830 m.iRight.iMagnitude = KZero; |
|
3831 m.iTop.iMagnitude = KZero; |
|
3832 iRootLayout->SetPadding(m); |
|
3833 iRootLayout->UpdateChildrenLayout(KZero); |
|
3834 } |
|
3835 } |
|
3836 } |
|
3837 } |
|
3838 |
|
3839 // --------------------------------------------------------------------------- |
|
3840 // Sets visualizer observer |
|
3841 // --------------------------------------------------------------------------- |
|
3842 // |
|
3843 void CFsTreeVisualizerBase::SetVisualizerObserver( |
|
3844 MFsTreeVisualizerObserver* aObserver) |
|
3845 { |
|
3846 FUNC_LOG; |
|
3847 iVisualizerObserver = aObserver; |
|
3848 } |
|
3849 |
|
3850 // --------------------------------------------------------------------------- |
|
3851 // Returns parent layout. |
|
3852 // --------------------------------------------------------------------------- |
|
3853 // |
|
3854 CAlfLayout& CFsTreeVisualizerBase::ParentLayout() const |
|
3855 { |
|
3856 FUNC_LOG; |
|
3857 return iParentLayout; |
|
3858 } |
|
3859 |
|
3860 // --------------------------------------------------------------------------- |
|
3861 // Function shows selector or hides it. |
|
3862 // --------------------------------------------------------------------------- |
|
3863 // |
|
3864 EXPORT_C void CFsTreeVisualizerBase::MakeSelectorVisibleL(TBool aVisible) |
|
3865 { |
|
3866 MakeSelectorVisibleL( aVisible, 0 ); |
|
3867 } |
|
3868 |
|
3869 // --------------------------------------------------------------------------- |
|
3870 // Function shows selector or hides it. |
|
3871 // --------------------------------------------------------------------------- |
|
3872 // |
|
3873 void CFsTreeVisualizerBase::MakeSelectorVisibleL(TBool aVisible, TInt aDelay) |
|
3874 { |
|
3875 FUNC_LOG; |
|
3876 TAlfTimedValue opacity; |
|
3877 |
|
3878 if (aVisible) |
|
3879 { |
|
3880 if (!iSelectorVisual) |
|
3881 { |
|
3882 CreateSelectorVisualL(); |
|
3883 } |
|
3884 |
|
3885 TBool isFocused = IsItemFocused(iFocusedItem); |
|
3886 |
|
3887 if (iSelectorVisual) |
|
3888 { |
|
3889 if (isFocused && IsFocusShown()) |
|
3890 { |
|
3891 if( aDelay ) |
|
3892 opacity.SetTarget(iSelectorOpacity, aDelay); |
|
3893 else |
|
3894 opacity.SetValueNow(iSelectorOpacity); |
|
3895 } |
|
3896 else |
|
3897 { |
|
3898 if( aDelay ) |
|
3899 opacity.SetTarget(0.0, aDelay); |
|
3900 else |
|
3901 opacity.SetValueNow(0.0); |
|
3902 } |
|
3903 |
|
3904 iSelectorVisual->SetOpacity(opacity); |
|
3905 } |
|
3906 UpdateSelectorVisualL(); |
|
3907 } |
|
3908 else |
|
3909 { |
|
3910 if (iSelectorVisual) |
|
3911 { |
|
3912 opacity.SetValueNow(0); |
|
3913 iSelectorVisual->SetOpacity(opacity); |
|
3914 } |
|
3915 } |
|
3916 } |
|
3917 |
|
3918 // --------------------------------------------------------------------------- |
|
3919 // |
|
3920 // --------------------------------------------------------------------------- |
|
3921 // |
|
3922 void CFsTreeVisualizerBase::UpdateSelectorVisualL(TInt /*aTime*/) |
|
3923 { |
|
3924 FUNC_LOG; |
|
3925 if (iSelectorVisual) |
|
3926 { |
|
3927 if (iFocusedItem == KFsTreeNoneID || !iFlags.IsSet(EListFocused) || !IsFocusShown()) |
|
3928 { |
|
3929 TAlfTimedValue opacity; |
|
3930 opacity.SetValueNow(0.0f); |
|
3931 iSelectorVisual->SetOpacity(opacity); |
|
3932 } |
|
3933 else |
|
3934 { |
|
3935 //check if item is visible |
|
3936 MFsTreeItemVisualizer* vis(NULL); |
|
3937 |
|
3938 iListLayout->SetFlag(EAlfVisualFlagFreezeLayout); |
|
3939 iListItemBackgroundLayout->SetFlag(EAlfVisualFlagFreezeLayout); |
|
3940 |
|
3941 TRect itemRect(iViewPort.ItemRect(iFocusedItem)); |
|
3942 if (itemRect.Height()) |
|
3943 { |
|
3944 TSize currSize; |
|
3945 currSize.iWidth = iListLayout->Size().iX.Target() - 2 |
|
3946 * iListLayout->PaddingInPixels().iTl.iX; |
|
3947 currSize.iHeight = itemRect.Height(); |
|
3948 iSelectorVisual->SetSize(currSize, 0); |
|
3949 TAlfRealPoint pNow; |
|
3950 pNow.iY = itemRect.iTl.iY; |
|
3951 pNow.iX = iListLayout->PaddingInPixels().iTl.iX; |
|
3952 iSelectorVisual->SetPos(pNow, 0); |
|
3953 |
|
3954 TAlfTimedValue opacity(iSelectorOpacity, 0); |
|
3955 iSelectorVisual->SetOpacity(opacity); |
|
3956 if (iMarqueeType != EFsTextMarqueeNone) |
|
3957 { |
|
3958 vis = iTreeData->ItemVisualizer(iFocusedItem); |
|
3959 vis->MarqueeL(iMarqueeType, iMarqueeSpeed, |
|
3960 iMarqueStartDelay, iMarqueCycleStartDelay, |
|
3961 iMarqueeRepetitions); |
|
3962 } |
|
3963 } |
|
3964 else |
|
3965 { |
|
3966 TAlfTimedValue opacity; |
|
3967 opacity.SetValueNow(0.0f); |
|
3968 iSelectorVisual->SetOpacity(opacity); |
|
3969 } |
|
3970 |
|
3971 iListLayout->ClearFlag(EAlfVisualFlagFreezeLayout); |
|
3972 iListItemBackgroundLayout->ClearFlag(EAlfVisualFlagFreezeLayout); |
|
3973 } |
|
3974 } |
|
3975 else if (iFocusedItem != KFsTreeNoneID && iFlags.IsSet(EListFocused)) |
|
3976 { |
|
3977 MakeSelectorVisibleL(ETrue); |
|
3978 } |
|
3979 } |
|
3980 |
|
3981 // --------------------------------------------------------------------------- |
|
3982 // The function deletes selector visual. |
|
3983 // --------------------------------------------------------------------------- |
|
3984 // |
|
3985 void CFsTreeVisualizerBase::DestroySelectorVisualL() |
|
3986 { |
|
3987 FUNC_LOG; |
|
3988 |
|
3989 if (iSelectorVisual && iSelectorLayout) |
|
3990 { |
|
3991 iSelectorLayout->Remove(iSelectorVisual); |
|
3992 //destroy |
|
3993 iSelectorVisual->RemoveAndDestroyAllD(); |
|
3994 iSelectorVisual = NULL; |
|
3995 } |
|
3996 } |
|
3997 |
|
3998 // --------------------------------------------------------------------------- |
|
3999 // The function creates selector visual. |
|
4000 // --------------------------------------------------------------------------- |
|
4001 // |
|
4002 void CFsTreeVisualizerBase::CreateSelectorVisualL() |
|
4003 { |
|
4004 FUNC_LOG; |
|
4005 TAlfTimedValue opacity; |
|
4006 |
|
4007 if (!iSelectorVisual) |
|
4008 { |
|
4009 if (iFocusedItem != KFsTreeNoneID) |
|
4010 { |
|
4011 MFsTreeItemVisualizer* vis = |
|
4012 iTreeData->ItemVisualizer( iFocusedItem ); |
|
4013 MFsTreeItemData* data = &iTreeData->ItemData( iFocusedItem ); |
|
4014 |
|
4015 iListLayout->SetFlag( EAlfVisualFlagFreezeLayout ); |
|
4016 iListItemBackgroundLayout->SetFlag( EAlfVisualFlagFreezeLayout ); |
|
4017 |
|
4018 iSelectorVisual = CAlfImageVisual::AddNewL(*iOwnerControl, iSelectorLayout); |
|
4019 opacity.SetValueNow(0.0f); |
|
4020 iSelectorVisual->SetOpacity(opacity); |
|
4021 iSelectorVisual->SetScaleMode( CAlfImageVisual::EScaleFit); |
|
4022 iSelectorVisual->EnableBrushesL(); |
|
4023 |
|
4024 // Set the selector visual size and pos. |
|
4025 iSelectorVisual->SetFlags(EAlfVisualFlagManualLayout | |
|
4026 EAlfVisualFlagIgnorePointer); |
|
4027 |
|
4028 TRect itemRect(iViewPort.ItemRect(iFocusedItem)); |
|
4029 itemRect.SetWidth(iListLayout->Size().iX.Target() - 2 * iListLayout->PaddingInPixels().iTl.iX); |
|
4030 if ( itemRect.Height() ) |
|
4031 { |
|
4032 iSelectorVisual->SetPos(itemRect.iTl); |
|
4033 iSelectorVisual->SetSize(itemRect.Size()); |
|
4034 } |
|
4035 |
|
4036 //create a selector from skin or from a supplied bitmap |
|
4037 if ( iSelectorTexture ) |
|
4038 { |
|
4039 CAlfImageBrush* brush = CAlfImageBrush::NewLC( |
|
4040 iOwnerControl->Env(),TAlfImage(*iSelectorTexture)); |
|
4041 |
|
4042 brush->SetBorders(iLeftSelectorBorderWidth, |
|
4043 iRightSelectorBorderWidth, |
|
4044 iTopSelectorBorderHeight, |
|
4045 iBottomSelectorBorderHeight); |
|
4046 |
|
4047 iSelectorVisual->Brushes()->AppendL(brush, EAlfHasOwnership); |
|
4048 CleanupStack::Pop(brush); |
|
4049 } |
|
4050 else if ( iSelectorBrush ) |
|
4051 { |
|
4052 //append brush supplied by the user to the selector visual |
|
4053 iSelectorVisual->Brushes()->AppendL( |
|
4054 iSelectorBrush, EAlfDoesNotHaveOwnership); |
|
4055 |
|
4056 if ( iSelectorOpacity <= 0.0 || iSelectorOpacity > 1.0 ) |
|
4057 { |
|
4058 iSelectorOpacity = 1.0; |
|
4059 } |
|
4060 |
|
4061 opacity.SetValueNow(iSelectorOpacity); |
|
4062 iSelectorVisual->SetOpacity(opacity); |
|
4063 } |
|
4064 else //no bitmap/brush given - create selector from skin |
|
4065 { |
|
4066 // apply a image brush to the visual |
|
4067 CAlfFrameBrush* brush = CAlfFrameBrush::NewLC(iOwnerControl->Env(), |
|
4068 KAknsIIDQsnFrList); |
|
4069 |
|
4070 iSelectorVisual->Brushes()->AppendL(brush, EAlfHasOwnership); |
|
4071 CleanupStack::Pop(brush); |
|
4072 |
|
4073 CAlfBrush& skinbrush( iSelectorVisual->Brushes()->At( |
|
4074 iSelectorVisual->Brushes()->Count() - 1 ) ); |
|
4075 CAlfFrameBrush* |
|
4076 selectorBrush( static_cast<CAlfFrameBrush*>( &skinbrush ) ); |
|
4077 |
|
4078 const TRect outerRect( itemRect.Size() ); //outer rect has the size of item |
|
4079 TRect innerRect( outerRect ); |
|
4080 |
|
4081 innerRect.Shrink( 5, 5 ); |
|
4082 if ( outerRect.Width() > 0 && outerRect.Height() > 0 && |
|
4083 innerRect.Width() > 0 && innerRect.Height() > 0 ) |
|
4084 { |
|
4085 // aInnerRect, const TRect& aOuterRect |
|
4086 selectorBrush->SetFrameRectsL( innerRect, outerRect ); |
|
4087 } |
|
4088 } |
|
4089 |
|
4090 iListLayout->ClearFlag( EAlfVisualFlagFreezeLayout ); |
|
4091 iListItemBackgroundLayout->ClearFlag( EAlfVisualFlagFreezeLayout ); |
|
4092 } |
|
4093 } |
|
4094 } |
|
4095 |
|
4096 // --------------------------------------------------------------------------- |
|
4097 // |
|
4098 // --------------------------------------------------------------------------- |
|
4099 // |
|
4100 void CFsTreeVisualizerBase::UpdateListItemSizes() |
|
4101 { |
|
4102 FUNC_LOG; |
|
4103 TInt focused = iVisibleItems.Find(iFocusedItem); |
|
4104 if (focused == KErrNotFound) |
|
4105 { |
|
4106 return; |
|
4107 } |
|
4108 TInt count = iVisibleItemsBackground.Count(); |
|
4109 for (TInt i = 0; i < count; ++i) |
|
4110 { |
|
4111 if (i == focused) |
|
4112 {//focused item already updated |
|
4113 continue; |
|
4114 } |
|
4115 else |
|
4116 { |
|
4117 UpdateListItemSize(i); |
|
4118 } |
|
4119 } |
|
4120 } |
|
4121 |
|
4122 // --------------------------------------------------------------------------- |
|
4123 // |
|
4124 // --------------------------------------------------------------------------- |
|
4125 // |
|
4126 void CFsTreeVisualizerBase::UpdateListItemSize(TInt aIndex) |
|
4127 { |
|
4128 FUNC_LOG; |
|
4129 TSize size; |
|
4130 TReal32 diff(0); |
|
4131 TReal32 speed(0); |
|
4132 TAlfTimedPoint sizeTarg; |
|
4133 TAlfTimedPoint sizeNow; |
|
4134 CAlfDeckLayout* lay; |
|
4135 |
|
4136 lay = iVisibleItemsBackground[aIndex]; |
|
4137 |
|
4138 sizeNow.iY.SetTarget(lay->Size().iY.ValueNow(), 0); |
|
4139 sizeNow.iX.SetTarget(lay->Size().iX.ValueNow(), 0); |
|
4140 sizeTarg.iY.SetTarget(lay->Size().iY.Target(), 0); |
|
4141 sizeTarg.iX.SetTarget(lay->Size().iX.Target(), 0); |
|
4142 |
|
4143 if (sizeNow.iY.Target() != sizeTarg.iY.Target()) |
|
4144 { |
|
4145 diff = sizeNow.iY.Target() - sizeTarg.iY.Target(); |
|
4146 if (diff < 0) |
|
4147 { |
|
4148 diff *= -1; |
|
4149 } |
|
4150 |
|
4151 if (iCurrentScrollSpeed != 0) |
|
4152 { |
|
4153 speed = diff / iCurrentScrollSpeed * 1000; |
|
4154 } |
|
4155 |
|
4156 TAlfTimedPoint p; |
|
4157 p.iY.SetTargetWithSpeed(sizeTarg.iY.Target(), speed); |
|
4158 p.iX.SetTarget(sizeTarg.iX.Target(), 0); |
|
4159 p.SetStyle(EAlfTimedValueStyleLinear); |
|
4160 |
|
4161 lay->SetSize(p); |
|
4162 iListLayout->Visual(aIndex).SetSize(p); |
|
4163 |
|
4164 } |
|
4165 } |
|
4166 |
|
4167 // --------------------------------------------------------------------------- |
|
4168 // |
|
4169 // --------------------------------------------------------------------------- |
|
4170 // |
|
4171 void CFsTreeVisualizerBase::ScrollListLayoutsL(TInt aScrollOffset, TInt /*aScrollTime*/) |
|
4172 { |
|
4173 FUNC_LOG; |
|
4174 TPoint position(iViewPort.Position()); |
|
4175 if (position.iY != aScrollOffset) |
|
4176 { |
|
4177 position.iY = aScrollOffset; |
|
4178 iViewPort.SetPositionL(position); |
|
4179 } |
|
4180 } |
|
4181 |
|
4182 // --------------------------------------------------------------------------- |
|
4183 // |
|
4184 // --------------------------------------------------------------------------- |
|
4185 // |
|
4186 TInt CFsTreeVisualizerBase::ScrollListLayouts(TInt aScrollOffset, |
|
4187 TInt aScrollTime) |
|
4188 { |
|
4189 TRAPD( error, ScrollListLayoutsL(aScrollOffset, aScrollTime) ); |
|
4190 return error; |
|
4191 } |
|
4192 |
|
4193 // --------------------------------------------------------------------------- |
|
4194 // |
|
4195 // --------------------------------------------------------------------------- |
|
4196 // |
|
4197 TFsTreeItemId CFsTreeVisualizerBase::NextFocusableItem( |
|
4198 const TFsTreeItemId aItemId) |
|
4199 { |
|
4200 FUNC_LOG; |
|
4201 TFsTreeItemId treeItem = KFsTreeNoneID; |
|
4202 TFsTreeItemId foundItem = KFsTreeNoneID; |
|
4203 |
|
4204 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, aItemId, |
|
4205 KFsTreeIteratorSkipCollapsedFlag | KFsTreeIteratorSkipHiddenFlag); |
|
4206 |
|
4207 while (treeIter.HasNext()) |
|
4208 { |
|
4209 treeItem = treeIter.Next(); |
|
4210 if (iTreeData->ItemVisualizer(treeItem)->IsFocusable()) |
|
4211 { |
|
4212 foundItem = treeItem; |
|
4213 break; |
|
4214 } |
|
4215 } |
|
4216 |
|
4217 return foundItem; |
|
4218 } |
|
4219 |
|
4220 // --------------------------------------------------------------------------- |
|
4221 // |
|
4222 // --------------------------------------------------------------------------- |
|
4223 // |
|
4224 TFsTreeItemId CFsTreeVisualizerBase::PrevFocusableItem( |
|
4225 const TFsTreeItemId aItemId) |
|
4226 { |
|
4227 FUNC_LOG; |
|
4228 TFsTreeItemId treeItem = KFsTreeNoneID; |
|
4229 TFsTreeItemId foundItem = KFsTreeNoneID; |
|
4230 |
|
4231 TFsTreeIterator treeIter = iTreeData->Iterator(KFsTreeRootID, aItemId, |
|
4232 KFsTreeIteratorSkipCollapsedFlag | KFsTreeIteratorSkipHiddenFlag); |
|
4233 |
|
4234 while (treeIter.HasPrevious()) |
|
4235 { |
|
4236 treeItem = treeIter.Previous(); |
|
4237 if (iTreeData->ItemVisualizer(treeItem)->IsFocusable()) |
|
4238 { |
|
4239 foundItem = treeItem; |
|
4240 break; |
|
4241 } |
|
4242 } |
|
4243 |
|
4244 return foundItem; |
|
4245 } |
|
4246 |
|
4247 // --------------------------------------------------------------------------- |
|
4248 // Function sets current scroll speed based on the up/down key repeats. |
|
4249 // --------------------------------------------------------------------------- |
|
4250 // |
|
4251 void CFsTreeVisualizerBase::SetCurrentScrollSpeed(TInt aKeyRepeats) |
|
4252 { |
|
4253 FUNC_LOG; |
|
4254 TInt time(0); |
|
4255 if (iScrollSpeed > 0) |
|
4256 { |
|
4257 time = iIntx->Interval(iScrollSpeed); |
|
4258 if (time != iScrollSpeed) |
|
4259 { |
|
4260 iCurrentScrollSpeed = time; |
|
4261 if (aKeyRepeats > 0) |
|
4262 { |
|
4263 iCurrentScrollSpeed = iCurrentScrollSpeed * (1 - aKeyRepeats |
|
4264 * iScrollAccelerationRate); |
|
4265 if (iCurrentScrollSpeed < 0) |
|
4266 { |
|
4267 iCurrentScrollSpeed = 1; |
|
4268 } |
|
4269 } |
|
4270 } |
|
4271 else |
|
4272 { |
|
4273 iCurrentScrollSpeed = iScrollSpeed; |
|
4274 } |
|
4275 |
|
4276 if (iCurrentScrollSpeed < iScrollSpeed) |
|
4277 { |
|
4278 iCurrentScrollSpeed = KZero; |
|
4279 } |
|
4280 // TInt part(0); |
|
4281 // part = iScrollSpeed * 0.9; |
|
4282 |
|
4283 // if ( iCurrentScrollSpeed <= part ) |
|
4284 // { |
|
4285 // iCurrentScrollSpeed = 0; |
|
4286 // } |
|
4287 // if (iCurrentScrollSpeed < 200) |
|
4288 // { |
|
4289 // iCurrentScrollSpeed = 200; |
|
4290 // } |
|
4291 } |
|
4292 } |
|
4293 |
|
4294 // --------------------------------------------------------------------------- |
|
4295 // Gets default settings from Central Repository. |
|
4296 // --------------------------------------------------------------------------- |
|
4297 // |
|
4298 void CFsTreeVisualizerBase::ReadDefaultValuesFromCenRep() |
|
4299 { |
|
4300 FUNC_LOG; |
|
4301 CRepository *crep(NULL); |
|
4302 TRAP_IGNORE( crep = CRepository::NewL( KCRUidFSGenericUI ) ); |
|
4303 |
|
4304 //scroll time |
|
4305 if (!crep || crep->Get(KFSGenericUIDefScrollSpeed, iScrollSpeed) |
|
4306 != KErrNone) |
|
4307 { |
|
4308 iScrollSpeed = KFsListDefaultScrollSpeed; |
|
4309 } |
|
4310 if (iScrollSpeed < 0) |
|
4311 { |
|
4312 iScrollSpeed = 0; |
|
4313 } |
|
4314 |
|
4315 //duration of the fade-in effect |
|
4316 if (!crep || crep->Get(KFSGenericUIFadeIn, iFadeInEffectTime) != KErrNone) |
|
4317 { |
|
4318 iFadeInEffectTime = KFsListDefaultFadeInTime; |
|
4319 } |
|
4320 if (iFadeInEffectTime < 0) |
|
4321 { |
|
4322 iFadeInEffectTime = 0; |
|
4323 } |
|
4324 |
|
4325 //duration of the fade-out effect |
|
4326 if (!crep || crep->Get(KFSGenericUIFadeOut, iFadeOutEffectTime) |
|
4327 != KErrNone) |
|
4328 { |
|
4329 iFadeOutEffectTime = KFsListDefaultFadeOutTime; |
|
4330 } |
|
4331 if (iFadeOutEffectTime < 0) |
|
4332 { |
|
4333 iFadeOutEffectTime = 0; |
|
4334 } |
|
4335 |
|
4336 //duration of the slide-in effect |
|
4337 if (!crep || crep->Get(KFSGenericUISlideInTime, iSlideInDuration) |
|
4338 != KErrNone) |
|
4339 { |
|
4340 iSlideInDuration = KFsListDefaultSlideInTime; |
|
4341 } |
|
4342 if (iSlideInDuration < 0) |
|
4343 { |
|
4344 iSlideInDuration = KFsListDefaultSlideInTime; |
|
4345 } |
|
4346 |
|
4347 //duration of the slide-out effect |
|
4348 if (!crep || crep->Get(KFSGenericUISlideOutTime, iSlideOutDuration) |
|
4349 != KErrNone) |
|
4350 { |
|
4351 iSlideOutDuration = KFsListDefaultSlideOutTime; |
|
4352 } |
|
4353 if (iSlideOutDuration < 0) |
|
4354 { |
|
4355 iSlideOutDuration = 0; |
|
4356 } |
|
4357 |
|
4358 //direction of the slide-in effect |
|
4359 TInt slideInDir; |
|
4360 if (!crep || crep->Get(KFSGenericUISlideInDir, slideInDir) != KErrNone) |
|
4361 { |
|
4362 slideInDir = KFsListDefaultSlideInDir; |
|
4363 } |
|
4364 if (slideInDir < 0 || slideInDir > 4) |
|
4365 { |
|
4366 slideInDir = 0; |
|
4367 } |
|
4368 iSlideInDirection |
|
4369 = static_cast<MFsTreeVisualizer::TFsSlideEffect> (slideInDir); |
|
4370 |
|
4371 //direction of the slide-out effect |
|
4372 TInt slideOutDir; |
|
4373 if (!crep || crep->Get(KFSGenericUISlideOutDir, slideOutDir) != KErrNone) |
|
4374 { |
|
4375 slideOutDir = KFsListDefaultSlideOutDir; |
|
4376 } |
|
4377 if (slideOutDir < 0 || slideOutDir > 4) |
|
4378 { |
|
4379 slideOutDir = 0; |
|
4380 } |
|
4381 iSlideOutDirection = |
|
4382 static_cast<MFsTreeVisualizer::TFsSlideEffect>(slideOutDir); |
|
4383 |
|
4384 //item expansion time |
|
4385 if ( !crep || crep->Get( KFSGenericUIListExpTimeOut, iCurrentScrollSpeed ) != |
|
4386 KErrNone ) |
|
4387 { |
|
4388 iCurrentScrollSpeed = KFsListDefaultListExpTimeOut; |
|
4389 } |
|
4390 if (iCurrentScrollSpeed < 1) |
|
4391 { |
|
4392 iCurrentScrollSpeed = 1; |
|
4393 } |
|
4394 |
|
4395 //list looping type |
|
4396 TInt listLooping; |
|
4397 if ( !crep || crep->Get( KFSGenericUIListLooping, listLooping) != |
|
4398 KErrNone ) |
|
4399 { |
|
4400 listLooping = KFsListDefaultListLooping; |
|
4401 } |
|
4402 if (listLooping < 0 || listLooping > 2) |
|
4403 { |
|
4404 listLooping = 0; |
|
4405 } |
|
4406 iLooping = static_cast<TFsTreeListLoopingType> (listLooping); |
|
4407 |
|
4408 delete crep; |
|
4409 } |
|
4410 |
|
4411 // --------------------------------------------------------------------------- |
|
4412 // Sets values to an item which are default for the whole list (e.g. if |
|
4413 // items are always extended. |
|
4414 // --------------------------------------------------------------------------- |
|
4415 // |
|
4416 void CFsTreeVisualizerBase::ApplyListSpecificValuesToItem( |
|
4417 MFsTreeItemVisualizer *aItemVis) |
|
4418 { |
|
4419 FUNC_LOG; |
|
4420 //list can have all items in extended or in a normal state |
|
4421 aItemVis->SetAlwaysExtended(IsItemsAlwaysExtended()); |
|
4422 |
|
4423 //global indentation in pixels for a list component |
|
4424 aItemVis->SetIndentation(iLevelIndentation); |
|
4425 |
|
4426 //global indentation in pixels for a list component |
|
4427 aItemVis->SetTextStyleManager(*iTextStyleManager); |
|
4428 } |
|
4429 |
|
4430 // --------------------------------------------------------------------------- |
|
4431 // The function calculates tree height up to the specified item. |
|
4432 // --------------------------------------------------------------------------- |
|
4433 // |
|
4434 TInt CFsTreeVisualizerBase::CalculateTreeHeightUpToItem( |
|
4435 const TFsTreeItemId aItemId, TInt& aHeight) const |
|
4436 { |
|
4437 FUNC_LOG; |
|
4438 TFsTreeItemId tmpItem(KFsTreeNoneID); |
|
4439 TFsTreeItemId itemToFind(KFsTreeNoneID); |
|
4440 itemToFind = aItemId; |
|
4441 TInt retVal(KErrNone); |
|
4442 //validate given item id |
|
4443 if (!iTreeData->Contains(itemToFind)) |
|
4444 { |
|
4445 retVal = KErrNotFound; |
|
4446 } |
|
4447 if (retVal == KErrNone) |
|
4448 { |
|
4449 //create an iterator |
|
4450 TFsTreeIterator iter = iTreeData->Iterator(KFsTreeRootID, |
|
4451 KFsTreeRootID, KFsTreeIteratorSkipCollapsedFlag |
|
4452 | KFsTreeIteratorSkipHiddenFlag); |
|
4453 |
|
4454 TBool notFound(ETrue); |
|
4455 TInt height(0); |
|
4456 MFsTreeItemVisualizer* vis = NULL; |
|
4457 |
|
4458 //iterate up to the given item id and calculate the tree height |
|
4459 while (notFound && iter.HasNext()) |
|
4460 { |
|
4461 tmpItem = iter.Next(); |
|
4462 if (tmpItem == itemToFind) |
|
4463 { |
|
4464 notFound = EFalse; |
|
4465 continue; |
|
4466 } |
|
4467 else |
|
4468 {//add item's height |
|
4469 vis = iTreeData->ItemVisualizer(tmpItem); |
|
4470 if (vis->IsExtendable() && vis->IsExtended()) |
|
4471 { |
|
4472 height += vis->ExtendedSize().iHeight; |
|
4473 } |
|
4474 else |
|
4475 { |
|
4476 height += vis->Size().iHeight; |
|
4477 } |
|
4478 } |
|
4479 } |
|
4480 |
|
4481 if (notFound) |
|
4482 { |
|
4483 retVal = KErrNotFound; |
|
4484 } |
|
4485 else |
|
4486 { |
|
4487 retVal = KErrNone; |
|
4488 aHeight = height; |
|
4489 } |
|
4490 } |
|
4491 return retVal; |
|
4492 } |
|
4493 |
|
4494 // --------------------------------------------------------------------------- |
|
4495 // Update list's visual content by appending items into empty gap in list. |
|
4496 // --------------------------------------------------------------------------- |
|
4497 // |
|
4498 void CFsTreeVisualizerBase::FillGapWithItemsL(const TInt /*aHeight*/) |
|
4499 { |
|
4500 FUNC_LOG; |
|
4501 } |
|
4502 |
|
4503 // --------------------------------------------------------------------------- |
|
4504 // The function checks if the given item id matches the focused one. |
|
4505 // --------------------------------------------------------------------------- |
|
4506 // |
|
4507 TBool CFsTreeVisualizerBase::IsItemFocused(TFsTreeItemId aItemId) const |
|
4508 { |
|
4509 FUNC_LOG; |
|
4510 TBool isFocused(EFalse); |
|
4511 |
|
4512 if (iFocusedItem != KFsTreeNoneID) |
|
4513 { |
|
4514 if (iFlags.IsSet(EListFocused) && (aItemId == iFocusedItem)) |
|
4515 { |
|
4516 isFocused = ETrue; |
|
4517 } |
|
4518 } |
|
4519 return isFocused; |
|
4520 } |
|
4521 |
|
4522 // <cmail> "Base class modifications for using touch" |
|
4523 |
|
4524 // --------------------------------------------------------------------------- |
|
4525 // C++ constructor. |
|
4526 // --------------------------------------------------------------------------- |
|
4527 // |
|
4528 CFsTreeVisualizerBase::CFsTreeVisualizerBase( CAlfControl* aOwnerControl, |
|
4529 CAlfLayout& aParent, const TBool aDirectTouchMode ) |
|
4530 : iVisualizationState(EFsTreeHidden), |
|
4531 iOwnerControl ( aOwnerControl ), |
|
4532 iParentLayout ( aParent ), |
|
4533 iTreeData ( NULL ), |
|
4534 iFocusedItem ( KFsTreeNoneID ), |
|
4535 iListLayout ( NULL ), |
|
4536 iLooping ( EFsTreeListLoopingDisabled ), |
|
4537 iSelectorTexture(NULL), |
|
4538 iSelectorBrush(NULL), |
|
4539 iSelectorOpacity(1.0), |
|
4540 iLeftSelectorBorderWidth(KFSListDefaultSelectorBorderWidth), |
|
4541 iRightSelectorBorderWidth(KFSListDefaultSelectorBorderWidth), |
|
4542 iTopSelectorBorderHeight(KFSListDefaultSelectorBorderWidth), |
|
4543 iBottomSelectorBorderHeight(KFSListDefaultSelectorBorderWidth), |
|
4544 iSelectorMovementType(EFsSelectorMoveImmediately), |
|
4545 iMarqueeSpeed(30), |
|
4546 iScrollSpeed( 0 ), |
|
4547 iCurrentScrollSpeed(0), |
|
4548 iScrollAccelerationRate(0.4), |
|
4549 iFadeInEffectTime(0), |
|
4550 iFadeOutEffectTime(0), |
|
4551 iWatermark(NULL), |
|
4552 iLevelIndentation ( KFsDefaultIndentation ), |
|
4553 iSlideInDuration ( 0 ), |
|
4554 iSlideInDirection ( ESlideFromTop ), |
|
4555 iSlideOutDuration ( 0 ), |
|
4556 iSlideOutDirection ( ESlideFromTop ), |
|
4557 iScrollOffset(0), |
|
4558 iMarqueeType(EFsTextMarqueeForth), |
|
4559 iMarqueStartDelay( 1000 ), //one sec of delay |
|
4560 iMarqueCycleStartDelay ( 500 ), //half a sec cycle delay |
|
4561 iMarqueeRepetitions (-1), //infinite loop |
|
4562 iViewPort( *this, iWorld ) |
|
4563 { |
|
4564 FUNC_LOG; |
|
4565 iFlags.Set(EAutoRefresh); |
|
4566 iFlags.Assign(EDirectTouchMode, aDirectTouchMode); |
|
4567 iFlags.Set( EExpandCollapseOnLongTap ); |
|
4568 } |
|
4569 // </cmail> |
|
4570 |
|
4571 // --------------------------------------------------------------------------- |
|
4572 // Second phase constructor. |
|
4573 // --------------------------------------------------------------------------- |
|
4574 // |
|
4575 void CFsTreeVisualizerBase::ConstructL() |
|
4576 { |
|
4577 FUNC_LOG; |
|
4578 ReadDefaultValuesFromCenRep(); |
|
4579 |
|
4580 if (CAknPhysics::FeatureEnabled()) |
|
4581 { |
|
4582 iPhysics = CAknPhysics::NewL(*this, NULL ); |
|
4583 iDragHandler = CDragHandler::NewL(*this, |
|
4584 iPhysics->HighlightTimeout(), iFlags); |
|
4585 } |
|
4586 |
|
4587 iRootData = CFsTreePlainOneLineItemData::NewL(); |
|
4588 HBufC* empty = StringLoader::LoadL(R_AVKON_EMPTY_POPUP_LIST_TEXT); |
|
4589 CleanupStack::PushL(empty); |
|
4590 iRootData->SetDataL(*empty); |
|
4591 CleanupStack::PopAndDestroy(empty); |
|
4592 |
|
4593 iParentLayout.UpdateChildrenLayout(); |
|
4594 |
|
4595 iRootVisualizer = CFsTreePlainRootVisualizer::NewL(*iOwnerControl); |
|
4596 |
|
4597 iRootLayout = CAlfDeckLayout::AddNewL(*iOwnerControl, &iParentLayout); |
|
4598 iRootLayout->EnableBrushesL(); |
|
4599 iRootLayout->SetClipping(ETrue); |
|
4600 iRootLayout->UpdateChildrenLayout(); |
|
4601 |
|
4602 iTextStyleManager = CFsAlfTextStyleManager::NewL( |
|
4603 iRootLayout->Env().TextStyleManager()); |
|
4604 |
|
4605 iRootVisualizer->SetTextStyleManager(*iTextStyleManager); |
|
4606 |
|
4607 iShadowLayout = CAlfDeckLayout::AddNewL(*iOwnerControl, iRootLayout); |
|
4608 iShadowLayout->EnableBrushesL(); |
|
4609 iShadowLayout->UpdateChildrenLayout(); |
|
4610 |
|
4611 iBorderLayout = CAlfDeckLayout::AddNewL(*iOwnerControl, iShadowLayout); |
|
4612 iBorderLayout->EnableBrushesL(); |
|
4613 iBorderLayout->UpdateChildrenLayout(); |
|
4614 |
|
4615 iWatermarkLayout = CAlfDeckLayout::AddNewL(*iOwnerControl, iBorderLayout); |
|
4616 iWatermarkLayout->EnableBrushesL(); |
|
4617 iWatermarkLayout->UpdateChildrenLayout(); |
|
4618 |
|
4619 iComponentLayout = CAlfGridLayout::AddNewL(*iOwnerControl, 1, 1, |
|
4620 iWatermarkLayout); |
|
4621 iComponentLayout->SetClipping(ETrue); |
|
4622 iComponentLayout->EnableBrushesL(); |
|
4623 iComponentLayout->UpdateChildrenLayout(); |
|
4624 |
|
4625 iListDeck = CAlfDeckLayout::AddNewL(*iOwnerControl, iComponentLayout); |
|
4626 |
|
4627 iListItemBackgroundLayout = CAlfFlowLayout::AddNewL(*iOwnerControl, |
|
4628 iListDeck); |
|
4629 iListItemBackgroundLayout->SetFlowDirection(CAlfFlowLayout::EFlowVertical); |
|
4630 iListItemBackgroundLayout->SetClipping(ETrue); |
|
4631 iListItemBackgroundLayout->EnableScrollingL(ETrue); |
|
4632 TAlfTimedPoint tpListScrollOffset; |
|
4633 tpListScrollOffset.SetStyle(EAlfTimedValueStyleLinear); |
|
4634 iListItemBackgroundLayout->SetScrollOffset(tpListScrollOffset); |
|
4635 |
|
4636 iSelectorLayout = CAlfDeckLayout::AddNewL(*iOwnerControl, iListDeck); |
|
4637 iSelectorLayout->SetClipping(ETrue); |
|
4638 |
|
4639 iListLayout = CAlfFlowLayout::AddNewL(*iOwnerControl, iListDeck); |
|
4640 iListLayout->SetFlowDirection(CAlfFlowLayout::EFlowVertical); |
|
4641 |
|
4642 iListLayout->EnableBrushesL(); |
|
4643 iListLayout->EnableScrollingL(ETrue); |
|
4644 iListLayout->SetScrollOffset(tpListScrollOffset); |
|
4645 |
|
4646 //list pane's padding taken from layout manager |
|
4647 EnableListPanePadding(ETrue); |
|
4648 |
|
4649 iListLayout->UpdateChildrenLayout(); |
|
4650 iListItemBackgroundLayout->UpdateChildrenLayout(); |
|
4651 |
|
4652 iBorderBrush = CAlfBorderBrush::NewL(iOwnerControl->Env(), 0, 1, 0, 0); |
|
4653 static_cast<CAlfBorderBrush*> (iBorderBrush)->SetColor(KRgbGray); |
|
4654 static_cast<CAlfBorderBrush*> (iBorderBrush)->SetThickness( |
|
4655 TAlfTimedPoint(0.0f, 0.5f)); |
|
4656 iBorderBrush->SetLayer(EAlfBrushLayerForeground); |
|
4657 |
|
4658 iScrollbarVisibility = EFsScrollbarShowAlways; |
|
4659 |
|
4660 iScrollBar = new (ELeave) CAknDoubleSpanScrollBar(0); |
|
4661 iScrollBar->ConstructL(ETrue, this, 0, CEikScrollBar::EVertical, 1000); |
|
4662 |
|
4663 iScrollbarModel.SetScrollSpan(iComponentLayout->Size().Target().iY); |
|
4664 iScrollbarModel.SetFocusPosition(iViewPort.Position().iY); |
|
4665 iScrollbarModel.SetWindowSize(iListLayout->Size().iY.Target()); |
|
4666 |
|
4667 iScrollBar->MakeVisible(EFalse); |
|
4668 iScrollBar->SetModelL(&iScrollbarModel); |
|
4669 |
|
4670 iDummyScrollbar = CAlfImageVisual::AddNewL(*iOwnerControl); |
|
4671 iComponentLayout->Append(iDummyScrollbar); |
|
4672 |
|
4673 // </cmail> |
|
4674 |
|
4675 iFadeEffect = CFsFadeEffect::NewL(iOwnerControl, this, iRootLayout, 0); |
|
4676 iSlideEffect = CFsSlideEffect::NewL(iOwnerControl, this, iRootLayout, 0); |
|
4677 |
|
4678 iFadeInEffectTime = KFsListDefaultFadeInTime; |
|
4679 iFadeOutEffectTime = KFsListDefaultFadeOutTime; |
|
4680 |
|
4681 iIntx = new (ELeave) CFsInteractionInterval; |
|
4682 |
|
4683 iOwnerControl->Env().AddActionObserverL(this); |
|
4684 |
|
4685 iWorld.AddObserverL(iViewPort); |
|
4686 iWorld.AddObserverL(*this); |
|
4687 UpdateViewPortL(); |
|
4688 } |
|
4689 |
|
4690 // <cmail> Change scrollbar to avkon (to support skinning & touch) |
|
4691 // --------------------------------------------------------------------------- |
|
4692 // Handle scrollbar events |
|
4693 // --------------------------------------------------------------------------- |
|
4694 // |
|
4695 void CFsTreeVisualizerBase::HandleScrollEventL(CEikScrollBar* aScrollBar, |
|
4696 TEikScrollEvent aEventType) |
|
4697 { |
|
4698 FUNC_LOG; |
|
4699 |
|
4700 if (iPhysics) |
|
4701 { |
|
4702 iPhysics->StopPhysics(); |
|
4703 } |
|
4704 |
|
4705 if (aScrollBar == iScrollBar) |
|
4706 { |
|
4707 |
|
4708 switch (aEventType) |
|
4709 { |
|
4710 case EEikScrollHome: |
|
4711 //Jump to beginning |
|
4712 break; |
|
4713 case EEikScrollEnd: |
|
4714 //Jump to end |
|
4715 break; |
|
4716 default: |
|
4717 TPoint position(iViewPort.Position()); |
|
4718 position.iY = aScrollBar->ThumbPosition(); |
|
4719 iViewPort.SetPositionL(position); |
|
4720 break; |
|
4721 } |
|
4722 } |
|
4723 } |
|
4724 |
|
4725 // --------------------------------------------------------------------------- |
|
4726 // Handle visibility change |
|
4727 // --------------------------------------------------------------------------- |
|
4728 // |
|
4729 void CFsTreeVisualizerBase::NotifyControlVisibilityChange(TBool aIsVisible) |
|
4730 { |
|
4731 FUNC_LOG; |
|
4732 |
|
4733 if (aIsVisible && iVisualizationState == EFsTreeVisible) |
|
4734 { |
|
4735 UpdateScrollBar(); |
|
4736 } |
|
4737 else |
|
4738 { |
|
4739 iScrollBar->MakeVisible(EFalse); |
|
4740 } |
|
4741 } |
|
4742 |
|
4743 // --------------------------------------------------------------------------- |
|
4744 // |
|
4745 // --------------------------------------------------------------------------- |
|
4746 // |
|
4747 void CFsTreeVisualizerBase::DisableKineticScrolling( TBool aDisable ) |
|
4748 { |
|
4749 FUNC_LOG; |
|
4750 iKineticScrollingDisabled = aDisable; |
|
4751 } |
|
4752 |
|
4753 |
|
4754 // --------------------------------------------------------------------------- |
|
4755 // |
|
4756 // --------------------------------------------------------------------------- |
|
4757 // |
|
4758 TBool CFsTreeVisualizerBase::IsKineticScrollingDisabled() const |
|
4759 { |
|
4760 FUNC_LOG; |
|
4761 return iKineticScrollingDisabled; |
|
4762 } |
|
4763 |
|
4764 // --------------------------------------------------------------------------- |
|
4765 // World updated |
|
4766 // --------------------------------------------------------------------------- |
|
4767 // |
|
4768 void CFsTreeVisualizerBase::WorldUpdatedL(const TWorld& /*aWorld*/) |
|
4769 { |
|
4770 FUNC_LOG; |
|
4771 if (iFlags.IsSet(EPhysicsOn)) |
|
4772 { |
|
4773 iFlags.Set(EUpdatePhysicsAfterSimulationFinished); |
|
4774 } |
|
4775 else |
|
4776 { |
|
4777 UpdatePhysicsL(); |
|
4778 } |
|
4779 UpdateScrollBarL(); |
|
4780 } |
|
4781 |
|
4782 // --------------------------------------------------------------------------- |
|
4783 // ViewPort updated |
|
4784 // --------------------------------------------------------------------------- |
|
4785 // |
|
4786 void CFsTreeVisualizerBase::ViewPortUpdatedL(TViewPort& aViewPort) |
|
4787 { |
|
4788 FUNC_LOG; |
|
4789 RArray<TFsTreeItemId> visibleItems; |
|
4790 RArray<TFsTreeItemId> removableItems; |
|
4791 TInt scrollOffset; |
|
4792 TBool fullUpdate; |
|
4793 CleanupClosePushL(visibleItems); |
|
4794 CleanupClosePushL(removableItems); |
|
4795 aViewPort.GetVisibleItemsL(removableItems, visibleItems, scrollOffset, |
|
4796 fullUpdate); |
|
4797 TAlfRefreshMode rm(EAlfRefreshModeAutomatic); |
|
4798 rm = CAlfStatic::Env().RefreshMode(); |
|
4799 CAlfStatic::Env().SetRefreshMode(EAlfRefreshModeManual); |
|
4800 iListLayout->SetFlag(EAlfVisualFlagFreezeLayout); |
|
4801 // clear list |
|
4802 TInt removed(0); |
|
4803 if (fullUpdate) |
|
4804 { |
|
4805 removed += iListLayout->Count(); |
|
4806 for (TInt i = removed - 1; i >= 0; i--) |
|
4807 { |
|
4808 iTreeData->ItemVisualizer(VisualItemId(&iListLayout->Visual(i)))->Hide(); |
|
4809 } |
|
4810 iVisibleItems.Reset(); |
|
4811 } |
|
4812 else |
|
4813 { |
|
4814 for (TInt i = 0; i < removableItems.Count(); i++) |
|
4815 { |
|
4816 CAlfVisual* visual( |
|
4817 &iTreeData->ItemVisualizer(removableItems[i])->Layout()); |
|
4818 if (iListLayout->FindVisual(visual) != KErrNotFound) |
|
4819 { |
|
4820 removed++; |
|
4821 } |
|
4822 iTreeData->ItemVisualizer(removableItems[i])->Hide(); |
|
4823 iVisibleItems.Remove(iVisibleItems.Find(removableItems[i])); |
|
4824 } |
|
4825 } |
|
4826 |
|
4827 // update items to list |
|
4828 TInt added(0); |
|
4829 for (TInt i = 0; i < visibleItems.Count(); i++) |
|
4830 { |
|
4831 const TFsTreeItemId itemId(visibleItems[i]); |
|
4832 if (itemId != KFsTreeNoneID) |
|
4833 { |
|
4834 MFsTreeItemVisualizer* visualizer = iTreeData->ItemVisualizer( |
|
4835 itemId); |
|
4836 visualizer->ShowL(*iListLayout); |
|
4837 TSize size(visualizer->Size()); |
|
4838 TInt listInnerWidth(iListLayout->Size().IntTarget().iX); |
|
4839 TAlfTimedPoint tpItemSize(listInnerWidth, size.iHeight); |
|
4840 tpItemSize.SetTarget(TAlfRealPoint(listInnerWidth, size.iHeight), |
|
4841 0); |
|
4842 CAlfLayout& visualizerLayout(visualizer->Layout()); |
|
4843 visualizerLayout.SetSize(tpItemSize); |
|
4844 visualizerLayout.PropertySetIntegerL(KPropertyItemId(), itemId); |
|
4845 visualizer->UpdateL(iTreeData->ItemData(itemId), |
|
4846 IsItemFocused(itemId) && IsFocusShown(), |
|
4847 iTreeData->Level(itemId), iMarkIcon, iMenuIcon, |
|
4848 0); |
|
4849 visualizerLayout.Brushes()->AppendL(iBorderBrush, |
|
4850 EAlfDoesNotHaveOwnership); |
|
4851 CAlfBrush* bgBrush(NULL); |
|
4852 if (visualizer->GetBackgroundBrush(bgBrush)) |
|
4853 { |
|
4854 bgBrush->SetLayer(EAlfBrushLayerBackground); |
|
4855 visualizerLayout.Brushes()->AppendL(bgBrush, |
|
4856 EAlfDoesNotHaveOwnership); |
|
4857 } |
|
4858 const TInt orderPosition( |
|
4859 i < iListLayout->Count() ? i : iListLayout->Count() - 1); |
|
4860 iListLayout->Reorder(visualizerLayout, orderPosition); |
|
4861 iVisibleItems.AppendL(itemId); |
|
4862 added++; |
|
4863 } |
|
4864 } |
|
4865 |
|
4866 INFO_2("totalItems: %d, visibleItems: %d", iWorld.ItemCount(), visibleItems.Count()); |
|
4867 CleanupStack::PopAndDestroy(2); // visibleItems.Close(), removableItems.Close() |
|
4868 // scroll list layout by offset |
|
4869 TAlfTimedPoint alfOffset; |
|
4870 alfOffset.iY.SetTarget(scrollOffset, 0); |
|
4871 iListLayout->SetScrollOffset(alfOffset); |
|
4872 iListLayout->ClearFlag(EAlfVisualFlagFreezeLayout); |
|
4873 iListLayout->UpdateChildrenLayout(); |
|
4874 UpdateSelectorVisualL(); |
|
4875 UpdateScrollBarIfNeededL(); |
|
4876 CAlfStatic::Env().RefreshCallBack(&CAlfStatic::Env()); |
|
4877 CAlfStatic::Env().SetRefreshMode(rm); |
|
4878 } |
|
4879 |
|
4880 // --------------------------------------------------------------------------- |
|
4881 // Set panning position |
|
4882 // --------------------------------------------------------------------------- |
|
4883 // |
|
4884 void CFsTreeVisualizerBase::SetPanningPosition(const TPoint& aDelta) |
|
4885 { |
|
4886 FUNC_LOG; |
|
4887 iPhysics->RegisterPanningPosition(aDelta); |
|
4888 } |
|
4889 |
|
4890 // --------------------------------------------------------------------------- |
|
4891 // Starts flicking. |
|
4892 // --------------------------------------------------------------------------- |
|
4893 // |
|
4894 void CFsTreeVisualizerBase::StartPhysics(TPoint& aDrag, |
|
4895 const TTime& aStartTime) |
|
4896 { |
|
4897 FUNC_LOG; |
|
4898 TTime startTime( aStartTime ); |
|
4899 TTime now; |
|
4900 now.HomeTime(); |
|
4901 TInt moveTime( now.MicroSecondsFrom( aStartTime ).Int64() ); |
|
4902 if (moveTime > KFlickMaxDuration) |
|
4903 { |
|
4904 startTime = now - TTimeIntervalMicroSeconds( KFlickMaxDuration - 1 ); |
|
4905 aDrag.iY = aDrag.iY * KFlickMaxDuration / moveTime; |
|
4906 } |
|
4907 iPhysics->StartPhysics(aDrag, startTime); |
|
4908 iFlags.Set(EPhysicsOn); |
|
4909 } |
|
4910 |
|
4911 // --------------------------------------------------------------------------- |
|
4912 // Update physics |
|
4913 // --------------------------------------------------------------------------- |
|
4914 // |
|
4915 void CFsTreeVisualizerBase::UpdatePhysicsL() |
|
4916 { |
|
4917 FUNC_LOG; |
|
4918 if (iPhysics) |
|
4919 { |
|
4920 SafeDelete(iPhysics); |
|
4921 iPhysics = CAknPhysics::NewL(*this, NULL ); |
|
4922 const TSize viewSize(iViewPort.Size()); |
|
4923 const TSize worldSize(viewSize.iWidth, Max(iWorld.Height(), |
|
4924 viewSize.iHeight)); |
|
4925 iPhysics->InitPhysicsL(worldSize, viewSize, EFalse); |
|
4926 } |
|
4927 } |
|
4928 |
|
4929 // --------------------------------------------------------------------------- |
|
4930 // Physic updated view position |
|
4931 // --------------------------------------------------------------------------- |
|
4932 // |
|
4933 void CFsTreeVisualizerBase::ViewPositionChanged(const TPoint& aNewPosition, |
|
4934 TBool /*aDrawNow*/, TUint /*aFlags*/) |
|
4935 { |
|
4936 FUNC_LOG; |
|
4937 TInt error(KErrNone); |
|
4938 TRAP( error, iViewPort.SetCenterPositionL(aNewPosition) ); |
|
4939 ERROR_1( error, "iViewPort.SetCenterPositionL failed with error: %d", error ); |
|
4940 } |
|
4941 |
|
4942 // --------------------------------------------------------------------------- |
|
4943 // Physic emulation has finished |
|
4944 // --------------------------------------------------------------------------- |
|
4945 // |
|
4946 void CFsTreeVisualizerBase::PhysicEmulationEnded() |
|
4947 { |
|
4948 FUNC_LOG; |
|
4949 iFlags.Clear(EPhysicsOn); |
|
4950 if (iFlags.IsSet(EUpdatePhysicsAfterSimulationFinished)) |
|
4951 { |
|
4952 iFlags.Clear(EUpdatePhysicsAfterSimulationFinished); |
|
4953 TRAP_IGNORE( UpdatePhysicsL() ); |
|
4954 } |
|
4955 } |
|
4956 |
|
4957 // --------------------------------------------------------------------------- |
|
4958 // |
|
4959 // --------------------------------------------------------------------------- |
|
4960 // |
|
4961 TPoint CFsTreeVisualizerBase::ViewPosition() const |
|
4962 { |
|
4963 FUNC_LOG; |
|
4964 return iViewPort.CenterPosition(); |
|
4965 } |
|
4966 |
|
4967 // --------------------------------------------------------------------------- |
|
4968 // Wrapper for SetFocusedItemAndSendEventL to trap the error and return it |
|
4969 // instead of leaving. |
|
4970 // --------------------------------------------------------------------------- |
|
4971 // |
|
4972 TInt CFsTreeVisualizerBase::SetFocusedItemAndSendEvent( |
|
4973 const TFsTreeItemId aItemId, TPointerEventType aEventType ) |
|
4974 { |
|
4975 FUNC_LOG; |
|
4976 TRAPD(error, SetFocusedItemAndSendEventL( aItemId, aEventType ) ); |
|
4977 return error; |
|
4978 } |
|
4979 |
|
4980 // --------------------------------------------------------------------------- |
|
4981 // Sets the specified item as focused and sends event about touch focusing if |
|
4982 // the same item is already focused, action event will be sent instead. |
|
4983 // --------------------------------------------------------------------------- |
|
4984 // |
|
4985 void CFsTreeVisualizerBase::SetFocusedItemAndSendEventL( |
|
4986 const TFsTreeItemId aItemId, TPointerEventType aEventType ) |
|
4987 { |
|
4988 FUNC_LOG; |
|
4989 |
|
4990 // Handles all other than pointer up events. |
|
4991 // Focus is drawn when: |
|
4992 // - new item is selected (FocusedItem() != aItemId) |
|
4993 // - pointer is pressed down and focus is not visible by default |
|
4994 // (aEventType == EPointerDown ) && IsFocusShown()) |
|
4995 if( ( aEventType < EPointerUp ) && |
|
4996 ( !iFlags.IsSet( EListFocused ) || FocusedItem() != aItemId || |
|
4997 ( ( aEventType == EPointerDown ) && IsFocusShown() ) ) ) |
|
4998 { |
|
4999 SetFocusedItemL( aItemId ); |
|
5000 iVisualizerObserver->TreeVisualizerEventL( |
|
5001 MFsTreeVisualizerObserver::EFsTreeItemTouchFocused, |
|
5002 FocusedItem() ); |
|
5003 |
|
5004 // If DirectTouchMode (actions happens in pointer down events) |
|
5005 if( iFlags.IsSet( EDirectTouchMode ) && aEventType == EPointerDown ) |
|
5006 { |
|
5007 iTouchPressed = EFalse; |
|
5008 iVisualizerObserver->TreeVisualizerEventL( |
|
5009 MFsTreeVisualizerObserver::EFsTreeItemTouchAction, |
|
5010 aItemId ); |
|
5011 } |
|
5012 } |
|
5013 else if( aEventType == ELongTap ) |
|
5014 { |
|
5015 iVisualizerObserver->TreeVisualizerEventL( |
|
5016 MFsTreeVisualizerObserver::EFsTreeItemTouchLongTap, |
|
5017 aItemId ); |
|
5018 } |
|
5019 else if( aEventType == EPointerUp ) |
|
5020 { |
|
5021 iVisualizerObserver->TreeVisualizerEventL( |
|
5022 MFsTreeVisualizerObserver::EFsTreeItemTouchAction, aItemId ); |
|
5023 } |
|
5024 } |
|
5025 |
|
5026 // CFsTreeVisualizerBase::CDragHandler |
|
5027 |
|
5028 // --------------------------------------------------------------------------- |
|
5029 // |
|
5030 // --------------------------------------------------------------------------- |
|
5031 // |
|
5032 CFsTreeVisualizerBase::CDragHandler* CFsTreeVisualizerBase::CDragHandler::NewL( |
|
5033 CFsTreeVisualizerBase& aTree, const TInt aHighlightTimeout, |
|
5034 const TBitFlagsT<TUint>& aFlags) |
|
5035 { |
|
5036 FUNC_LOG; |
|
5037 CDragHandler* self = new (ELeave) CDragHandler(aTree, aHighlightTimeout, |
|
5038 aFlags); |
|
5039 CleanupStack::PushL(self); |
|
5040 self->ConstructL(); |
|
5041 CleanupStack::Pop(self); |
|
5042 return self; |
|
5043 } |
|
5044 |
|
5045 // --------------------------------------------------------------------------- |
|
5046 // |
|
5047 // --------------------------------------------------------------------------- |
|
5048 // |
|
5049 CFsTreeVisualizerBase::CDragHandler::~CDragHandler() |
|
5050 { |
|
5051 FUNC_LOG; |
|
5052 delete iHighlightTimer; |
|
5053 } |
|
5054 |
|
5055 // --------------------------------------------------------------------------- |
|
5056 // |
|
5057 // --------------------------------------------------------------------------- |
|
5058 // |
|
5059 void CFsTreeVisualizerBase::CDragHandler::Reset() |
|
5060 { |
|
5061 FUNC_LOG; |
|
5062 iFlags.ClearAll(); |
|
5063 iHighlightTimer->Cancel(); |
|
5064 iItemId = KFsTreeNoneID; |
|
5065 iDragDirection = EDraggingNone; |
|
5066 } |
|
5067 |
|
5068 // --------------------------------------------------------------------------- |
|
5069 // |
|
5070 // --------------------------------------------------------------------------- |
|
5071 // |
|
5072 CFsTreeVisualizerBase::CDragHandler::TDragDirection |
|
5073 CFsTreeVisualizerBase::CDragHandler::DragDirection( |
|
5074 const TPoint& aCurrent, const TPoint aPrevious ) const |
|
5075 { |
|
5076 FUNC_LOG; |
|
5077 if (aCurrent.iY > aPrevious.iY) |
|
5078 { |
|
5079 return EDraggingDown; |
|
5080 } |
|
5081 else if (aCurrent.iY < aPrevious.iY) |
|
5082 { |
|
5083 return EDraggingUp; |
|
5084 } |
|
5085 else |
|
5086 { |
|
5087 return iDragDirection; |
|
5088 } |
|
5089 } |
|
5090 |
|
5091 // --------------------------------------------------------------------------- |
|
5092 // |
|
5093 // --------------------------------------------------------------------------- |
|
5094 // |
|
5095 void CFsTreeVisualizerBase::CDragHandler::PointerDown( |
|
5096 const TPointerEvent& aEvent, const TFsTreeItemId aItemId) |
|
5097 { |
|
5098 FUNC_LOG; |
|
5099 Reset(); |
|
5100 iItemId = aItemId; |
|
5101 iPosition = aEvent.iParentPosition; |
|
5102 iLastPointerPosition = aEvent.iParentPosition; |
|
5103 iStartTime.HomeTime(); |
|
5104 iFlags.Set( EPointerDownReceived ); |
|
5105 |
|
5106 iTree.SetFocusedItemAndSendEvent( iItemId, EPointerDown ); |
|
5107 } |
|
5108 |
|
5109 // --------------------------------------------------------------------------- |
|
5110 // |
|
5111 // --------------------------------------------------------------------------- |
|
5112 // |
|
5113 void CFsTreeVisualizerBase::CDragHandler::PointerRepeat( |
|
5114 const TPointerEvent& /*aEvent*/ ) |
|
5115 { |
|
5116 if( iItemId != KFsTreeNoneID && !IsFlicking() ) |
|
5117 { |
|
5118 iFlags.Set( EWasRepeat ); |
|
5119 iTree.SetFocusedItemAndSendEvent( iItemId, ELongTap ); |
|
5120 } |
|
5121 } |
|
5122 |
|
5123 // --------------------------------------------------------------------------- |
|
5124 // |
|
5125 // --------------------------------------------------------------------------- |
|
5126 // |
|
5127 void CFsTreeVisualizerBase::CDragHandler::PointerUp( |
|
5128 const TPointerEvent& aEvent, const TFsTreeItemId aItemId ) |
|
5129 { |
|
5130 FUNC_LOG; |
|
5131 // If kinetic scrolling is disabled |
|
5132 if( iTree.IsKineticScrollingDisabled() ) |
|
5133 { |
|
5134 if( ( aItemId != KFsTreeNoneID ) && |
|
5135 ( iTree.FocusedItem() == aItemId ) ) |
|
5136 { |
|
5137 iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp ); |
|
5138 } |
|
5139 } |
|
5140 else if ( IsFlicking() ) |
|
5141 { |
|
5142 TPoint drag(iPosition - aEvent.iParentPosition); |
|
5143 iTree.StartPhysics( drag, iStartTime ); |
|
5144 } |
|
5145 else if( !iFlags.IsSet( EWasRepeat ) && iItemId != KFsTreeNoneID ) |
|
5146 { |
|
5147 iTree.SetFocusedItemAndSendEvent( iItemId, EPointerUp ); |
|
5148 } |
|
5149 iLastPointerPosition = iPosition = TPoint(); |
|
5150 iFlags.Clear( EPointerDownReceived ); |
|
5151 iDragDirection = EDraggingNone; |
|
5152 } |
|
5153 |
|
5154 // --------------------------------------------------------------------------- |
|
5155 // |
|
5156 // --------------------------------------------------------------------------- |
|
5157 // |
|
5158 TInt CFsTreeVisualizerBase::CDragHandler::DragDelta( |
|
5159 const TPointerEvent& aEvent) const |
|
5160 { |
|
5161 FUNC_LOG; |
|
5162 return Abs(iPosition.iY - aEvent.iPosition.iY); |
|
5163 } |
|
5164 |
|
5165 // --------------------------------------------------------------------------- |
|
5166 // |
|
5167 // --------------------------------------------------------------------------- |
|
5168 // |
|
5169 TPoint CFsTreeVisualizerBase::CDragHandler::PointerDrag( |
|
5170 const TPointerEvent& aEvent, const TFsTreeItemId /*aItemId*/) |
|
5171 { |
|
5172 FUNC_LOG; |
|
5173 // If kinetic scrolling is disabled |
|
5174 if( iTree.IsKineticScrollingDisabled() ) |
|
5175 { |
|
5176 iLastPointerPosition = iPosition; |
|
5177 return aEvent.iPosition; |
|
5178 } |
|
5179 |
|
5180 if (!iFlags.IsSet(EPointerDownReceived)) |
|
5181 { |
|
5182 iLastPointerPosition = iPosition = aEvent.iPosition; |
|
5183 iFlags.Set(EPointerDownReceived); |
|
5184 } |
|
5185 else |
|
5186 { |
|
5187 iHighlightTimer->Cancel(); |
|
5188 if (!iTreeVisualizerFlags.IsSet(EPhysicsOn)) |
|
5189 { |
|
5190 iTree.SetPanningPosition(TPoint(0, iLastPointerPosition.iY |
|
5191 - aEvent.iPosition.iY)); |
|
5192 } |
|
5193 TDragDirection dragDirection(DragDirection(aEvent.iPosition, iLastPointerPosition)); |
|
5194 const TBool dragDirectionChanged( |
|
5195 (dragDirection == EDraggingUp && iDragDirection == EDraggingDown ) || |
|
5196 (dragDirection == EDraggingDown && iDragDirection == EDraggingUp ) ); |
|
5197 if (dragDirectionChanged) |
|
5198 { |
|
5199 iPosition = aEvent.iPosition; |
|
5200 iStartTime.HomeTime(); |
|
5201 } |
|
5202 iDragDirection = dragDirection; |
|
5203 iLastPointerPosition = aEvent.iPosition; |
|
5204 } |
|
5205 return iPosition - aEvent.iPosition; |
|
5206 } |
|
5207 |
|
5208 // --------------------------------------------------------------------------- |
|
5209 // |
|
5210 // --------------------------------------------------------------------------- |
|
5211 // |
|
5212 void CFsTreeVisualizerBase::CDragHandler::EnableFlicking() |
|
5213 { |
|
5214 FUNC_LOG; |
|
5215 iFlags.Set(EFlicking); |
|
5216 } |
|
5217 |
|
5218 // --------------------------------------------------------------------------- |
|
5219 // |
|
5220 // --------------------------------------------------------------------------- |
|
5221 // |
|
5222 TBool CFsTreeVisualizerBase::CDragHandler::IsFlicking() const |
|
5223 { |
|
5224 FUNC_LOG; |
|
5225 return iFlags.IsSet(EFlicking); |
|
5226 } |
|
5227 |
|
5228 // --------------------------------------------------------------------------- |
|
5229 // |
|
5230 // --------------------------------------------------------------------------- |
|
5231 // |
|
5232 CFsTreeVisualizerBase::CDragHandler::CDragHandler( |
|
5233 CFsTreeVisualizerBase& aTree, const TInt aHighlightTimeout, |
|
5234 const TBitFlagsT<TUint>& aFlags) : |
|
5235 iTree(aTree), iHighlightTimeout(aHighlightTimeout * 1000), |
|
5236 iTreeVisualizerFlags(aFlags) |
|
5237 { |
|
5238 FUNC_LOG; |
|
5239 } |
|
5240 |
|
5241 // --------------------------------------------------------------------------- |
|
5242 // |
|
5243 // --------------------------------------------------------------------------- |
|
5244 // |
|
5245 void CFsTreeVisualizerBase::CDragHandler::ConstructL() |
|
5246 { |
|
5247 FUNC_LOG; |
|
5248 iHighlightTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
|
5249 } |
|
5250 |
|
5251 // --------------------------------------------------------------------------- |
|
5252 // |
|
5253 // --------------------------------------------------------------------------- |
|
5254 // |
|
5255 TInt CFsTreeVisualizerBase::CDragHandler::HighlightTimerCallback( TAny* aPtr ) |
|
5256 { |
|
5257 FUNC_LOG; |
|
5258 CDragHandler* self = reinterpret_cast<CDragHandler*>( aPtr ); |
|
5259 self->iHighlightTimer->Cancel(); |
|
5260 return self->iTree.SetFocusedItemAndSendEvent( self->iItemId, ELongTap ); |
|
5261 } |
|
5262 |
|
5263 // --------------------------------------------------------------------------- |
|
5264 // CFsTreeVisualizerBase::IsFocusShown |
|
5265 // --------------------------------------------------------------------------- |
|
5266 // |
|
5267 TBool CFsTreeVisualizerBase::IsFocusShown() |
|
5268 { |
|
5269 if( iTouchPressed || iFocusVisible ) |
|
5270 { |
|
5271 return ETrue; |
|
5272 } |
|
5273 return EFalse; |
|
5274 } |
|
5275 |
|
5276 |
|
5277 // </cmail> |