48 }; |
48 }; |
49 |
49 |
50 /** Number of closable applications, to show "close all" option. */ |
50 /** Number of closable applications, to show "close all" option. */ |
51 const TInt KTsMaxClosableApps = 2; |
51 const TInt KTsMaxClosableApps = 2; |
52 |
52 |
53 /** Uid of Active Idle application. |
|
54 Used when movind Ai to specified position.*/ |
|
55 const TUid KAiUid = TUid::Uid( 0x102750F0 ); |
|
56 |
|
57 /** Position of Ai in fsw grid.*/ |
|
58 const TInt KAiPosition = 0; |
|
59 |
|
60 /** Default grid item to highlight.*/ |
53 /** Default grid item to highlight.*/ |
61 const TInt KItemToHighlight = 3; |
54 const TInt KItemToHighlight = 2; |
62 |
55 |
63 const TInt KAppKeyTypeShort = 1; |
56 const TInt KAppKeyTypeShort = 1; |
64 const TInt KAppKeyTypeLong = 2; |
57 const TInt KAppKeyTypeLong = 2; |
65 |
58 |
66 const TInt KLayoutItemCount = 4; |
59 const TInt KLayoutItemCount = 4; |
108 // |
101 // |
109 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent, |
102 CTsFastSwapArea::CTsFastSwapArea(CCoeControl& aParent, |
110 CTsDeviceState& aDeviceState, |
103 CTsDeviceState& aDeviceState, |
111 CTsEventControler& aEventHandler) : |
104 CTsEventControler& aEventHandler) : |
112 iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), |
105 iParent(aParent), iDeviceState(aDeviceState), iEvtHandler(aEventHandler), |
113 iPreviousNoOfItems(0), iIgnoreLayoutSwitch(EFalse) |
106 iIgnoreLayoutSwitch(EFalse) |
114 { |
107 { |
115 // no implementation required |
108 // no implementation required |
116 } |
109 } |
117 |
110 |
118 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
222 empty, empty); |
215 empty, empty); |
223 |
216 |
224 // Text colors |
217 // Text colors |
225 TRgb textColor; |
218 TRgb textColor; |
226 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, |
219 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, |
227 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6 ); |
220 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
228 TRgb highlightTextColor; |
221 TRgb highlightTextColor; |
229 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, |
222 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, |
230 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); |
223 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); |
231 CFormattedCellListBoxData::TColors colors; |
224 CFormattedCellListBoxData::TColors colors; |
232 colors.iText = textColor; |
225 colors.iText = textColor; |
233 colors.iBack = iGrid->ItemDrawer()->BackColor(); |
226 colors.iBack = iGrid->ItemDrawer()->BackColor(); |
234 colors.iHighlightedText = highlightTextColor; |
227 colors.iHighlightedText = highlightTextColor; |
235 colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); |
228 colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); |
236 iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); |
229 iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); |
|
230 iGrid->SetStrokeColors(textColor, highlightTextColor); |
237 |
231 |
238 // Setup grid observers |
232 // Setup grid observers |
239 if ( obs ) |
233 if ( obs ) |
240 { |
234 { |
241 iGrid->SetObserver( obs ); |
235 iGrid->SetObserver( obs ); |
430 // not fully correct but the app will then reappear on the next |
426 // not fully correct but the app will then reappear on the next |
431 // content-changed notification anyway. |
427 // content-changed notification anyway. |
432 delete iArray[aIndex]; |
428 delete iArray[aIndex]; |
433 iArray.Remove( aIndex ); |
429 iArray.Remove( aIndex ); |
434 NotifyChange(); |
430 NotifyChange(); |
435 if ( !aSuppressRendering ) |
431 |
436 { |
432 // Hide highlight |
437 RenderContentL( ETrue ); |
433 if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
438 } |
434 { |
439 // Update item selection on the screen if last item was deleted |
435 iGrid->HideHighlight(); |
440 TInt newItemCount = GridItemCount(); |
436 } |
|
437 // Update selection |
|
438 TInt newItemCount = GridItemCount() - 1; |
441 if ( aIndex == newItemCount ) |
439 if ( aIndex == newItemCount ) |
442 { |
440 { |
443 newItemCount--; |
441 newItemCount--; |
444 iGrid->SetCurrentDataIndex(newItemCount); |
442 iGrid->SetCurrentDataIndex(newItemCount); |
445 } |
443 } |
446 else |
444 else |
447 { |
445 { |
448 DrawDeferred(); |
|
449 iGrid->SetCurrentDataIndex(selIdx); |
446 iGrid->SetCurrentDataIndex(selIdx); |
|
447 } |
|
448 // Render contect |
|
449 if ( !aSuppressRendering ) |
|
450 { |
|
451 RenderContentL( ETrue ); |
450 } |
452 } |
451 |
453 |
452 // Orientation update |
454 // Orientation update |
453 iPrevScreenOrientation = GetCurrentScreenOrientation(); |
455 iPrevScreenOrientation = GetCurrentScreenOrientation(); |
454 iOrientationSignalTimer->Cancel(); |
456 iOrientationSignalTimer->Cancel(); |
542 TSLOG_CONTEXT( HandleFswContentChangedL, TSLOG_LOCAL ); |
544 TSLOG_CONTEXT( HandleFswContentChangedL, TSLOG_LOCAL ); |
543 TSLOG_IN(); |
545 TSLOG_IN(); |
544 |
546 |
545 // get current content from fastswap server |
547 // get current content from fastswap server |
546 iFSClient->GetContentL( iArray ); |
548 iFSClient->GetContentL( iArray ); |
547 SwapApplicationOrder( iArray ); |
|
548 |
549 |
549 #ifdef _DEBUG |
550 #ifdef _DEBUG |
550 for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
551 for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
551 { |
552 { |
552 CTsFswEntry* e = iArray[i]; |
553 CTsFswEntry* e = iArray[i]; |
579 CleanupStack::PushL( iconArray ); |
580 CleanupStack::PushL( iconArray ); |
580 CDesCArrayFlat* textArray = new ( ELeave ) CDesCArrayFlat( KMaxGranularity ); |
581 CDesCArrayFlat* textArray = new ( ELeave ) CDesCArrayFlat( KMaxGranularity ); |
581 CleanupStack::PushL( textArray ); |
582 CleanupStack::PushL( textArray ); |
582 RArray<TInt> closeItemArray; |
583 RArray<TInt> closeItemArray; |
583 CleanupClosePushL(closeItemArray); |
584 CleanupClosePushL(closeItemArray); |
|
585 RArray<TInt> strokeItemArray; |
|
586 CleanupClosePushL(strokeItemArray); |
584 |
587 |
585 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
588 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
586 RArray<TAknLayoutRect> rects; |
589 RArray<TAknLayoutRect> rects; |
587 CleanupClosePushL(rects); |
590 CleanupClosePushL(rects); |
588 rects.ReserveL(KLayoutItemCount); |
591 rects.ReserveL(KLayoutItemCount); |
589 GetFastSwapAreaRects(rects); |
592 GetFastSwapAreaRects(rects); |
590 TAknLayoutRect gridItem = rects[1]; |
593 TAknLayoutRect gridItem = rects[1]; |
591 CleanupStack::PopAndDestroy(&rects); |
594 CleanupStack::PopAndDestroy(&rects); |
592 if ( iArray.Count() ) |
595 if ( iArray.Count() ) |
593 { |
596 { |
|
597 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); |
|
598 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(ETrue); |
594 if ( AknLayoutUtils::LayoutMirrored() ) |
599 if ( AknLayoutUtils::LayoutMirrored() ) |
595 { |
600 { |
596 iGrid->SetLayoutL( EFalse, EFalse, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
601 iGrid->SetLayoutL( EFalse, EFalse, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
597 } |
602 } |
598 else |
603 else |
599 { |
604 { |
600 iGrid->SetLayoutL( EFalse, ETrue, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
605 iGrid->SetLayoutL( EFalse, ETrue, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
601 } |
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
|
611 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
602 } |
612 } |
603 |
613 |
604 for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
614 for ( TInt i = 0, ie = iArray.Count(); i != ie; ++i ) |
605 { |
615 { |
606 const TDesC& appName( iArray[i]->AppName() ); |
616 const TDesC& appName( iArray[i]->AppName() ); |
621 TSLOG2( TSLOG_INFO, "'%S' screenshot handle %d", &appName, h ); |
631 TSLOG2( TSLOG_INFO, "'%S' screenshot handle %d", &appName, h ); |
622 TInt maskh = 0; |
632 TInt maskh = 0; |
623 CFbsBitmap* mask = 0; |
633 CFbsBitmap* mask = 0; |
624 if ( !h ) |
634 if ( !h ) |
625 { |
635 { |
|
636 // No screenshot, take app icon |
626 h = iArray[i]->AppIconBitmapHandle(); |
637 h = iArray[i]->AppIconBitmapHandle(); |
627 maskh = iArray[i]->AppIconMaskHandle(); |
638 maskh = iArray[i]->AppIconMaskHandle(); |
628 TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); |
639 TSLOG1( TSLOG_INFO, "using appicon, handle = %d", h ); |
|
640 } |
|
641 else |
|
642 { |
|
643 // Screenshot exists, mark it for stroke |
|
644 strokeItemArray.AppendL(i); |
629 } |
645 } |
630 __ASSERT_DEBUG( h, User::Invariant() ); |
646 __ASSERT_DEBUG( h, User::Invariant() ); |
631 bitmap = CopyBitmapL( h, sz ); |
647 bitmap = CopyBitmapL( h, sz ); |
632 CleanupStack::PushL( bitmap ); |
648 CleanupStack::PushL( bitmap ); |
633 if ( maskh ) |
649 if ( maskh ) |
656 delete oldIconArray; |
672 delete oldIconArray; |
657 oldIconArray = NULL; |
673 oldIconArray = NULL; |
658 } |
674 } |
659 iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
675 iGrid->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
660 iGrid->SetCloseItemsL(closeItemArray); |
676 iGrid->SetCloseItemsL(closeItemArray); |
|
677 iGrid->SetStrokeItemsL(strokeItemArray); |
661 |
678 |
662 // Cleanup |
679 // Cleanup |
|
680 CleanupStack::PopAndDestroy(&strokeItemArray); |
663 CleanupStack::PopAndDestroy(&closeItemArray); |
681 CleanupStack::PopAndDestroy(&closeItemArray); |
664 CleanupStack::Pop(textArray); |
682 CleanupStack::Pop(textArray); |
665 CleanupStack::Pop(iconArray); |
683 CleanupStack::Pop(iconArray); |
666 |
684 |
667 if( iGrid->ScrollBarFrame() ) |
685 if( iGrid->ScrollBarFrame() ) |
669 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
687 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
670 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
688 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
671 } |
689 } |
672 |
690 |
673 // refresh the items in the grid |
691 // refresh the items in the grid |
674 if(iPreviousNoOfItems < iArray.Count()) |
692 iGrid->HandleItemAdditionL(); |
675 { |
|
676 iGrid->HandleItemAdditionL(); |
|
677 } |
|
678 else if(iPreviousNoOfItems > iArray.Count()) |
|
679 { |
|
680 iGrid->HandleItemRemovalL(); |
|
681 } |
|
682 iPreviousNoOfItems = iArray.Count(); |
|
683 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
693 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
684 UpdateGrid( ETrue, !aSuppressAnimation ); |
694 UpdateGrid( ETrue, !aSuppressAnimation ); |
685 |
695 |
686 TSLOG_OUT(); |
696 TSLOG_OUT(); |
687 } |
697 } |
701 User::LeaveIfError( bmp->Duplicate( aFbsHandle ) ); |
711 User::LeaveIfError( bmp->Duplicate( aFbsHandle ) ); |
702 |
712 |
703 // do not always use aSize, preserving the aspect ratio is quite |
713 // do not always use aSize, preserving the aspect ratio is quite |
704 // important when showing app icons instead of screenshots |
714 // important when showing app icons instead of screenshots |
705 TSize sz = CalculateSizePreserveRatio( aSize, bmp->SizeInPixels() ); |
715 TSize sz = CalculateSizePreserveRatio( aSize, bmp->SizeInPixels() ); |
706 |
|
707 User::LeaveIfError( ret->Create( sz, bmp->DisplayMode() ) ); |
716 User::LeaveIfError( ret->Create( sz, bmp->DisplayMode() ) ); |
708 |
717 |
709 AknIconUtils::ScaleBitmapL( sz, ret, bmp ); |
718 AknIconUtils::ScaleBitmapL( sz, ret, bmp ); |
710 |
719 |
711 CleanupStack::PopAndDestroy( bmp ); |
720 CleanupStack::PopAndDestroy( bmp ); |
755 TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
764 TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
756 TSLOG_IN(); |
765 TSLOG_IN(); |
757 |
766 |
758 // Reset grid |
767 // Reset grid |
759 TRAP_IGNORE( ReCreateGridL() ); |
768 TRAP_IGNORE( ReCreateGridL() ); |
|
769 if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) |
|
770 { |
|
771 iGrid->HideHighlight(); |
|
772 } |
|
773 else |
|
774 { |
|
775 iGrid->ShowHighlight(); |
|
776 } |
760 |
777 |
761 // get the current task list |
778 // get the current task list |
762 HandleFswContentChanged(); |
779 HandleFswContentChanged(); |
763 // and then start listening for changes |
780 // and then start listening for changes |
764 iFSClient->Subscribe( *this ); |
781 iFSClient->Subscribe( *this ); |
765 |
782 |
766 if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) |
|
767 { |
|
768 iGrid->HideHighlight(); |
|
769 } |
|
770 else |
|
771 { |
|
772 iGrid->ShowHighlight(); |
|
773 } |
|
774 |
|
775 RestoreSelectedIndex(); |
783 RestoreSelectedIndex(); |
776 UpdateGrid(EFalse, EFalse); |
784 UpdateGrid(EFalse, EFalse); |
777 |
785 |
778 iRedrawTimer->Cancel(); |
786 iRedrawTimer->Cancel(); |
779 iRedrawTimer->After(KRedrawTime); |
787 iRedrawTimer->After(KRedrawTime); |
814 TKeyResponse CTsFastSwapArea::OfferKeyEventL( |
822 TKeyResponse CTsFastSwapArea::OfferKeyEventL( |
815 const TKeyEvent& aKeyEvent, |
823 const TKeyEvent& aKeyEvent, |
816 TEventCode aType ) |
824 TEventCode aType ) |
817 { |
825 { |
818 iKeyEvent = ETrue; |
826 iKeyEvent = ETrue; |
819 iGrid->SetTactileFeedbackSupport(EFalse); |
|
820 // handle the 'clear' key |
827 // handle the 'clear' key |
821 if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
828 if ( aType == EEventKey && aKeyEvent.iCode == EKeyBackspace ) |
822 { |
829 { |
823 TInt idx = SelectedIndex(); |
830 TInt idx = SelectedIndex(); |
824 if ( idx >= 0 ) |
831 if ( idx >= 0 ) |
945 void CTsFastSwapArea::RestoreSelectedIndex() |
951 void CTsFastSwapArea::RestoreSelectedIndex() |
946 { |
952 { |
947 iSavedSelectedIndex = KErrNotFound; |
953 iSavedSelectedIndex = KErrNotFound; |
948 if ( GridItemCount() ) |
954 if ( GridItemCount() ) |
949 { |
955 { |
950 // highlight second recent item (that has index 2) if possible |
956 // highlight second recent item (that has index 1) if possible |
951 TInt highlightItem = 0; |
957 TInt highlightItem = 0; |
952 TInt count = GridItemCount(); |
958 TInt count = GridItemCount(); |
953 while( highlightItem < count |
959 while( highlightItem < count |
954 && highlightItem < KItemToHighlight ) |
960 && highlightItem < KItemToHighlight ) |
955 { |
961 { |
1131 void CTsFastSwapArea::NotifyChange() |
1137 void CTsFastSwapArea::NotifyChange() |
1132 { |
1138 { |
1133 if ( iDcObserver ) |
1139 if ( iDcObserver ) |
1134 { |
1140 { |
1135 iDcObserver->DataChanged( this, Count() ); |
1141 iDcObserver->DataChanged( this, Count() ); |
1136 } |
|
1137 } |
|
1138 |
|
1139 // ----------------------------------------------------------------------------- |
|
1140 // CTsFastSwapArea::SwapApplicationOrder |
|
1141 // ----------------------------------------------------------------------------- |
|
1142 // |
|
1143 void CTsFastSwapArea::SwapApplicationOrder( |
|
1144 RPointerArray<CTsFswEntry>& aArray ) |
|
1145 { |
|
1146 for ( TInt i = 0; i < aArray.Count(); ++i ) |
|
1147 { |
|
1148 if( aArray[i]->AppUid() == KAiUid ) |
|
1149 { |
|
1150 CTsFswEntry* homescreenEntry(0); |
|
1151 homescreenEntry = aArray[i]; |
|
1152 aArray.Remove(i); |
|
1153 aArray.Insert(homescreenEntry, KAiPosition); |
|
1154 break; |
|
1155 } |
|
1156 } |
1142 } |
1157 } |
1143 } |
1158 |
1144 |
1159 // ----------------------------------------------------------------------------- |
1145 // ----------------------------------------------------------------------------- |
1160 // CTsFastSwapArea::PreferredImageSize |
1146 // CTsFastSwapArea::PreferredImageSize |
1217 // |
1203 // |
1218 TSize CTsFastSwapArea::CalculateSizePreserveRatio( |
1204 TSize CTsFastSwapArea::CalculateSizePreserveRatio( |
1219 const TSize& aTargetAreaSize, |
1205 const TSize& aTargetAreaSize, |
1220 const TSize& aSourceSize ) |
1206 const TSize& aSourceSize ) |
1221 { |
1207 { |
1222 TSize sz; |
1208 const TReal |
1223 if ( aSourceSize.iWidth > aSourceSize.iHeight ) |
1209 resizedAspectRatio(aTargetAreaSize.iWidth/(TReal)aTargetAreaSize.iHeight); |
1224 { |
1210 const TReal |
1225 sz.iWidth = aTargetAreaSize.iWidth; |
1211 orginalAspectRatio(aSourceSize.iWidth/(TReal)aSourceSize.iHeight); |
1226 TReal ratio = aSourceSize.iWidth / (TReal) aSourceSize.iHeight; |
1212 //this condition avoid empty margins ( bigger output ). to realy fit area change it |
1227 sz.iHeight = sz.iWidth / ratio; |
1213 const TReal scaleFactor = |
1228 } |
1214 ( orginalAspectRatio > resizedAspectRatio ) ? |
1229 else |
1215 (aTargetAreaSize.iHeight /(TReal)aSourceSize.iHeight) ://scale by height |
1230 { |
1216 (aTargetAreaSize.iWidth /(TReal)aSourceSize.iWidth) ;//scale by width |
1231 sz.iHeight = aTargetAreaSize.iHeight; |
1217 return TSize(aSourceSize.iWidth * scaleFactor, aSourceSize.iHeight * scaleFactor); |
1232 TReal ratio = aSourceSize.iHeight / (TReal) aSourceSize.iWidth; |
|
1233 sz.iWidth = sz.iHeight / ratio; |
|
1234 } |
|
1235 return sz; |
|
1236 } |
1218 } |
1237 |
1219 |
1238 // -------------------------------------------------------------------------- |
1220 // -------------------------------------------------------------------------- |
1239 // CTsFastSwapArea::SelectNextItem |
1221 // CTsFastSwapArea::SelectNextItem |
1240 // -------------------------------------------------------------------------- |
1222 // -------------------------------------------------------------------------- |
1241 // |
1223 // |
1242 void CTsFastSwapArea::SelectNextItem() |
1224 void CTsFastSwapArea::SelectNextItem() |
1243 { |
1225 { |
1244 iKeyEvent = ETrue; |
1226 iKeyEvent = ETrue; |
1245 iGrid->SetTactileFeedbackSupport(EFalse); |
|
1246 TBool forceRedraw(ETrue); |
1227 TBool forceRedraw(ETrue); |
1247 TBool animate(ETrue); |
1228 TBool animate(ETrue); |
1248 TInt selectedItem = SelectedIndex(); |
1229 TInt selectedItem = SelectedIndex(); |
1249 selectedItem++; |
1230 selectedItem++; |
1250 if ( selectedItem == GridItemCount() ) |
1231 if ( selectedItem == GridItemCount() ) |
1280 |
1261 |
1281 // Check if view is outside of grid world |
1262 // Check if view is outside of grid world |
1282 TPoint absViewPos = ViewPos(); |
1263 TPoint absViewPos = ViewPos(); |
1283 absViewPos.iX -= Rect().Width() / 2; |
1264 absViewPos.iX -= Rect().Width() / 2; |
1284 if( !iEvtHandler.IsPhysicsRunning() && |
1265 if( !iEvtHandler.IsPhysicsRunning() && |
1285 ( absViewPos.iX < 0 || absViewPos.iX + Rect().Width() > GridWorldSize().iWidth ) |
1266 ( absViewPos.iX < 0 ||( absViewPos.iX + Rect().Width() > GridWorldSize().iWidth && GridItemCount() ) ) |
1286 ) |
1267 ) |
1287 { |
1268 { |
1288 // View is outside of grid world - update view |
1269 // View is outside of grid world - update view |
1289 iUpdateGridTimer->Cancel(); |
1270 iUpdateGridTimer->Cancel(); |
1290 iUpdateGridTimer->After(aRedrawDelay); |
1271 iUpdateGridTimer->After(aRedrawDelay); |
1329 // CTsFastSwapArea::HandleAppKey |
1311 // CTsFastSwapArea::HandleAppKey |
1330 // -------------------------------------------------------------------------- |
1312 // -------------------------------------------------------------------------- |
1331 // |
1313 // |
1332 void CTsFastSwapArea::HandleAppKey(TInt aType) |
1314 void CTsFastSwapArea::HandleAppKey(TInt aType) |
1333 { |
1315 { |
1334 if( aType == KAppKeyTypeShort ) |
1316 if ( iArray.Count() ) |
1335 { |
1317 { |
1336 if(iGrid->IsHighlightVisible()) |
1318 if( aType == KAppKeyTypeShort ) |
1337 { |
1319 { |
1338 SelectNextItem(); |
1320 if(iGrid->IsHighlightVisible()) |
1339 } |
1321 { |
1340 else |
1322 SelectNextItem(); |
1341 { |
1323 } |
1342 iGrid->ShowHighlight(); |
1324 else |
1343 } |
1325 { |
1344 } |
1326 iGrid->ShowHighlight(); |
1345 else if( aType == KAppKeyTypeLong ) |
1327 } |
1346 { |
1328 } |
1347 SwitchToApp( SelectedIndex() ); |
1329 else if( aType == KAppKeyTypeLong ) |
|
1330 { |
|
1331 SwitchToApp( SelectedIndex() ); |
|
1332 } |
|
1333 } |
|
1334 else |
|
1335 { |
|
1336 TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
1348 } |
1337 } |
1349 } |
1338 } |
1350 |
1339 |
1351 // -------------------------------------------------------------------------- |
1340 // -------------------------------------------------------------------------- |
1352 // CTsFastSwapArea::MoveOffset |
1341 // CTsFastSwapArea::MoveOffset |
1372 currentXPos -= Rect().Width() / 2; |
1361 currentXPos -= Rect().Width() / 2; |
1373 TRect gridViewRect = Rect(); |
1362 TRect gridViewRect = Rect(); |
1374 gridViewRect.iTl.iX = -currentXPos; |
1363 gridViewRect.iTl.iX = -currentXPos; |
1375 // Take edge offset into account |
1364 // Take edge offset into account |
1376 gridViewRect.iTl.iX += Rect().iTl.iX; |
1365 gridViewRect.iTl.iX += Rect().iTl.iX; |
1377 if(GridItemCount() <= iMaxItemsOnScreen) |
1366 if(GridItemCount() && GridItemCount() <= iMaxItemsOnScreen) |
1378 { |
1367 { |
1379 // Center view |
1368 // Center view |
1380 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1369 gridViewRect.iTl.iX += ( Rect().Width() - GridItemCount() * iGridItemWidth ) / 2; |
1381 } |
1370 } |
|
1371 DrawDeferred(); |
1382 iGrid->SetRect( gridViewRect ); |
1372 iGrid->SetRect( gridViewRect ); |
1383 DrawDeferred(); |
|
1384 iLogicalViewPosOffset = 0; |
1373 iLogicalViewPosOffset = 0; |
1385 } |
1374 } |
1386 else |
1375 else |
1387 { |
1376 { |
1388 // Update logical view position |
1377 // Update logical view position |
1394 // CTsFastSwapArea::Tap |
1383 // CTsFastSwapArea::Tap |
1395 // -------------------------------------------------------------------------- |
1384 // -------------------------------------------------------------------------- |
1396 // |
1385 // |
1397 void CTsFastSwapArea::TapL(const TPoint& aPoint) |
1386 void CTsFastSwapArea::TapL(const TPoint& aPoint) |
1398 { |
1387 { |
1399 if(Rect().Contains(aPoint)) |
1388 if(Rect().Contains(aPoint) && iArray.Count()) |
1400 { |
1389 { |
1401 //provide tap pointer event to grid |
1390 //provide tap pointer event to grid |
1402 iGrid->HandlePointerEventL(iTapEvent); |
1391 iGrid->HandlePointerEventL(iTapEvent); |
1403 iHighlightTimer->Cancel(); |
1392 iHighlightTimer->Cancel(); |
1404 iHighlightTimer->After(KHighlighActivationTime); |
1393 iHighlightTimer->After(KHighlighActivationTime); |
1415 // -------------------------------------------------------------------------- |
1404 // -------------------------------------------------------------------------- |
1416 // |
1405 // |
1417 void CTsFastSwapArea::LongTapL(const TPoint& aPoint) |
1406 void CTsFastSwapArea::LongTapL(const TPoint& aPoint) |
1418 { |
1407 { |
1419 TInt index(KErrNotFound); |
1408 TInt index(KErrNotFound); |
1420 if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) ) |
1409 if( iGrid->GridView()->XYPosToItemIndex(aPoint,index) && iArray.Count() ) |
1421 { |
1410 { |
1422 iGrid->SetCurrentItemIndex(index); |
1411 iGrid->SetCurrentItemIndex(index); |
1423 SaveSelectedIndex(); |
1412 SaveSelectedIndex(); |
1424 if ( !ShowPopupL(iSavedSelectedIndex, aPoint) ) |
1413 if ( !ShowPopupL(iSavedSelectedIndex, aPoint) ) |
1425 { |
1414 { |
1480 { |
1468 { |
1481 TPoint retVal; |
1469 TPoint retVal; |
1482 retVal.iY = iGrid->Rect().iTl.iY + Rect().Height() / 2; |
1470 retVal.iY = iGrid->Rect().iTl.iY + Rect().Height() / 2; |
1483 retVal.iX = - (iGrid->Rect().iTl.iX - Rect().iTl.iX) + Rect().Width() / 2 ; |
1471 retVal.iX = - (iGrid->Rect().iTl.iX - Rect().iTl.iX) + Rect().Width() / 2 ; |
1484 TInt gridItemCount = iGrid->Model()->ItemTextArray()->MdcaCount(); |
1472 TInt gridItemCount = iGrid->Model()->ItemTextArray()->MdcaCount(); |
1485 if( gridItemCount <= iMaxItemsOnScreen) |
1473 if(gridItemCount && gridItemCount <= iMaxItemsOnScreen) |
1486 { |
1474 { |
1487 // View centered |
1475 // View centered |
1488 retVal.iX += ( Rect().Width() - gridItemCount * iGridItemWidth ) / 2; |
1476 retVal.iX += ( Rect().Width() - gridItemCount * iGridItemWidth ) / 2; |
1489 } |
1477 } |
1490 retVal.iX += iLogicalViewPosOffset; |
1478 retVal.iX += iLogicalViewPosOffset; |
1496 // ----------------------------------------------------------------------------- |
1484 // ----------------------------------------------------------------------------- |
1497 // |
1485 // |
1498 TPoint CTsFastSwapArea::ItemViewPosition( TInt aItemIdx ) |
1486 TPoint CTsFastSwapArea::ItemViewPosition( TInt aItemIdx ) |
1499 { |
1487 { |
1500 TPoint retVal = Rect().iTl; |
1488 TPoint retVal = Rect().iTl; |
1501 if ( aItemIdx == 0 ) |
1489 if ( aItemIdx < 0 ) |
|
1490 { |
|
1491 // No items |
|
1492 retVal.iX = 0; |
|
1493 } |
|
1494 else if ( aItemIdx == 0 ) |
1502 { |
1495 { |
1503 // First item |
1496 // First item |
1504 if( AknLayoutUtils::LayoutMirrored() ) |
1497 if( AknLayoutUtils::LayoutMirrored() ) |
1505 { |
1498 { |
1506 if ( GridItemCount() > iMaxItemsOnScreen ) |
1499 if ( GridItemCount() > iMaxItemsOnScreen ) |