457 return retVal; |
460 return retVal; |
458 } |
461 } |
459 |
462 |
460 |
463 |
461 // ----------------------------------------------------------------------------- |
464 // ----------------------------------------------------------------------------- |
462 // CTsFastSwapGrid::LoadCloseIconL |
465 // CTsFastSwapGrid::LoadCloseIconAndStrokeParams |
463 // ----------------------------------------------------------------------------- |
466 // ----------------------------------------------------------------------------- |
464 // |
467 // |
465 void CTsFastSwapGrid::LoadCloseIcon() |
468 void CTsFastSwapGrid::LoadCloseIconAndStrokeParams() |
466 { |
469 { |
467 // Load and set close icon |
470 // Load and set close icon |
468 CFbsBitmap* icon = NULL; |
471 CFbsBitmap* icon = NULL; |
469 CFbsBitmap* mask = NULL; |
472 CFbsBitmap* iconMask = NULL; |
470 |
473 CFbsBitmap* iconPressed = NULL; |
471 TRAP_IGNORE(AknsUtils::CreateColorIconLC( AknsUtils::SkinInstance(), |
474 CFbsBitmap* iconPressedMask = NULL; |
472 KAknsIIDQgnIndiItutListCollapse, |
475 |
473 KAknsIIDQsnTextColors, // we use text color here, eventhough this is an icon |
476 TRAP_IGNORE(AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
474 EAknsCIQsnTextColorsCG13, // softkey text color |
477 KAknsIIDQgnIndiTsButtonClose, |
475 icon, |
478 icon, |
476 mask, |
479 iconMask, |
477 KAvkonBitmapFile, |
480 KAvkonBitmapFile, |
478 EMbmAvkonQgn_indi_button_preview_close, |
481 EMbmAvkonQgn_indi_button_preview_close, |
479 EMbmAvkonQgn_indi_button_preview_close_mask, |
482 EMbmAvkonQgn_indi_button_preview_close_mask |
480 KRgbWhite |
483 )); |
481 ); |
484 |
482 CleanupStack::Pop( 2 ); // codescanner::cleanup |
485 TRAP_IGNORE(AknsUtils::CreateIconL( AknsUtils::SkinInstance(), |
483 ); |
486 KAknsIIDQgnIndiTsButtonClosePressed, |
|
487 iconPressed, |
|
488 iconPressedMask, |
|
489 KAvkonBitmapFile, |
|
490 EMbmAvkonQgn_indi_button_preview_close, |
|
491 EMbmAvkonQgn_indi_button_preview_close_mask |
|
492 )); |
484 |
493 |
485 TAknLayoutRect gridAppPane; |
494 TAknLayoutRect gridAppPane; |
486 TAknLayoutRect gridItem; |
495 TAknLayoutRect gridItem; |
|
496 TAknLayoutRect gridImage; |
487 TAknLayoutRect gridCloseButton; |
497 TAknLayoutRect gridCloseButton; |
488 TAknLayoutRect gridCloseIcon; |
498 TAknLayoutRect gridCloseIcon; |
489 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
499 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
490 TRect source = iParent ? iParent->Rect() : Rect(); |
500 TRect source = iParent ? iParent->Rect() : Rect(); |
491 gridAppPane.LayoutRect( source, |
501 gridAppPane.LayoutRect( source, |
492 AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
502 AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
493 gridItem.LayoutRect( gridAppPane.Rect(), |
503 gridItem.LayoutRect( gridAppPane.Rect(), |
494 AknLayoutScalable_Apps::cell_tport_appsw_pane( variety, 0, 0 ) ); |
504 AknLayoutScalable_Apps::cell_tport_appsw_pane( variety, 0, 0 ) ); |
|
505 gridImage.LayoutRect( gridItem.Rect(), |
|
506 AknLayoutScalable_Apps::cell_tport_appsw_pane_g1( variety ) ); |
495 gridCloseButton.LayoutRect( gridItem.Rect(), |
507 gridCloseButton.LayoutRect( gridItem.Rect(), |
496 AknLayoutScalable_Apps::bg_button_pane_cp16( variety, 0, 0 )); |
508 AknLayoutScalable_Apps::bg_button_pane_cp16( variety, 0, 0 )); |
497 gridCloseIcon.LayoutRect( gridItem.Rect(), |
509 gridCloseIcon.LayoutRect( gridItem.Rect(), |
498 AknLayoutScalable_Apps::cell_tport_appsw_pane_g3( variety, 0, 0 )); |
510 AknLayoutScalable_Apps::cell_tport_appsw_pane_g3( variety, 0, 0 )); |
|
511 |
|
512 // Set icon size |
499 AknIconUtils::SetSize( icon, gridCloseIcon.Rect().Size(), EAspectRatioPreserved ); |
513 AknIconUtils::SetSize( icon, gridCloseIcon.Rect().Size(), EAspectRatioPreserved ); |
500 AknIconUtils::SetSize( mask, gridCloseIcon.Rect().Size(), EAspectRatioPreserved ); |
514 AknIconUtils::SetSize( iconPressed, gridCloseIcon.Rect().Size(), EAspectRatioPreserved ); |
501 CTsGridItemDrawer* itemDrawer = |
515 CTsGridItemDrawer* itemDrawer = |
502 static_cast<CTsGridItemDrawer*>(iItemDrawer); |
516 static_cast<CTsGridItemDrawer*>(iItemDrawer); |
503 itemDrawer->SetCloseIcon( icon, mask ); |
517 |
|
518 // Setup close parameters |
|
519 itemDrawer->SetCloseIcon( icon, iconMask, iconPressed, iconPressedMask ); |
504 TRect relGridCloseButton = TRect( TPoint( gridCloseButton.Rect().iTl.iX - gridItem.Rect().iTl.iX, |
520 TRect relGridCloseButton = TRect( TPoint( gridCloseButton.Rect().iTl.iX - gridItem.Rect().iTl.iX, |
505 gridCloseButton.Rect().iTl.iY - gridItem.Rect().iTl.iY), |
521 gridCloseButton.Rect().iTl.iY - gridItem.Rect().iTl.iY), |
506 gridCloseButton.Rect().Size() ); |
522 gridCloseButton.Rect().Size() ); |
507 TRect relGridCloseIconRect = TRect( TPoint( gridCloseIcon.Rect().iTl.iX - gridItem.Rect().iTl.iX, |
523 TRect relGridCloseIconRect = TRect( TPoint( gridCloseIcon.Rect().iTl.iX - gridItem.Rect().iTl.iX, |
508 gridCloseIcon.Rect().iTl.iY - gridItem.Rect().iTl.iY), |
524 gridCloseIcon.Rect().iTl.iY - gridItem.Rect().iTl.iY), |
509 gridCloseIcon.Rect().Size() ); |
525 gridCloseIcon.Rect().Size() ); |
510 itemDrawer->SetCloseIconRect( relGridCloseButton, relGridCloseIconRect ); |
526 itemDrawer->SetCloseIconRect( relGridCloseButton, relGridCloseIconRect ); |
|
527 |
|
528 // Setup stroke parameters |
|
529 TPoint strokeOffset; |
|
530 strokeOffset.iX = gridImage.Rect().iTl.iX - gridItem.Rect().iTl.iX - KStrokeThickness; |
|
531 strokeOffset.iY = gridImage.Rect().iTl.iY - gridItem.Rect().iTl.iY - KStrokeThickness; |
|
532 TSize strokeSize = gridImage.Rect().Size(); |
|
533 strokeSize.iHeight += KStrokeThickness * 2; |
|
534 strokeSize.iWidth += KStrokeThickness * 2; |
|
535 itemDrawer->SetStrokeOffset( strokeOffset, strokeSize ); |
511 } |
536 } |
512 |
537 |
513 |
538 |
514 // ----------------------------------------------------------------------------- |
539 // ----------------------------------------------------------------------------- |
515 // CTsFastSwapGrid::Redraw |
540 // CTsFastSwapGrid::Redraw |
528 ctrlToRedraw->DrawNow(); |
553 ctrlToRedraw->DrawNow(); |
529 } |
554 } |
530 } |
555 } |
531 } |
556 } |
532 |
557 |
533 // ----------------------------------------------------------------------------- |
558 |
534 // CTsFastSwapGrid::LaunchTactileFeedback |
559 |
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CTsFastSwapGrid::LaunchTactileFeedback() |
|
538 { |
|
539 if( !iTactileFeedbackSupport ) |
|
540 { |
|
541 return; |
|
542 } |
|
543 |
|
544 iFeedbackTimer->Cancel(); |
|
545 iFeedbackTimer->After(KFeedbackTime); |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // CTsFastSwapGrid::SetTactileFeedbackSupport |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CTsFastSwapGrid::SetTactileFeedbackSupport(TBool aSupport) |
|
553 { |
|
554 iTactileFeedbackSupport = aSupport; |
|
555 } |
|
556 |
|
557 |
|
558 // ----------------------------------------------------------------------------- |
|
559 // CTsFastSwapGrid::RemoveFromVisibleItems |
|
560 // ----------------------------------------------------------------------------- |
|
561 // |
|
562 TBool CTsFastSwapGrid::RemoveFromVisibleItems(TInt aItem) const |
|
563 { |
|
564 TBool retVal(EFalse); |
|
565 TInt idx(0); |
|
566 idx = iFullyVisibleItems.Find(aItem); |
|
567 if( idx >= 0) |
|
568 { |
|
569 iFullyVisibleItems.Remove(idx); |
|
570 retVal = ETrue; |
|
571 } |
|
572 idx = iPartialVisibleItems.Find( aItem ); |
|
573 if( idx >= 0) |
|
574 { |
|
575 iPartialVisibleItems.Remove(idx); |
|
576 retVal = ETrue; |
|
577 } |
|
578 return retVal; |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CTsFastSwapGrid::AddToFullyVisibleItems |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 TBool CTsFastSwapGrid::AddToFullyVisibleItems( TInt aItem ) const |
|
586 { |
|
587 TBool retVal(EFalse); |
|
588 TInt idx(0); |
|
589 |
|
590 idx = iPartialVisibleItems.Find(aItem); |
|
591 if( idx >= 0) |
|
592 { |
|
593 iPartialVisibleItems.Remove(idx); |
|
594 } |
|
595 idx = iFullyVisibleItems.Find( aItem ); |
|
596 if( idx == KErrNotFound ) |
|
597 { |
|
598 iFullyVisibleItems.Append(aItem); |
|
599 retVal = ETrue; |
|
600 } |
|
601 return retVal; |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // CTsFastSwapGrid::MoveToPartialVisibleItems |
|
606 // ----------------------------------------------------------------------------- |
|
607 // |
|
608 TBool CTsFastSwapGrid::MoveToPartialVisibleItems( TInt aItem ) const |
|
609 { |
|
610 TInt idx(0); |
|
611 idx = iFullyVisibleItems.Find(aItem); |
|
612 if( idx >= 0) |
|
613 { |
|
614 iFullyVisibleItems.Remove(idx); |
|
615 } |
|
616 idx = iPartialVisibleItems.Find( aItem ); |
|
617 if( idx == KErrNotFound ) |
|
618 { |
|
619 iPartialVisibleItems.Append(aItem); |
|
620 } |
|
621 return EFalse; |
|
622 } |
|
623 |
560 |
624 /* ================================================================================ |
561 /* ================================================================================ |
625 * CTsGridItemDrawer |
562 * CTsGridItemDrawer |
626 * ================================================================================ |
563 * ================================================================================ |
627 */ |
564 */ |
649 // |
588 // |
650 CTsGridItemDrawer::~CTsGridItemDrawer() |
589 CTsGridItemDrawer::~CTsGridItemDrawer() |
651 { |
590 { |
652 delete iCloseIcon; |
591 delete iCloseIcon; |
653 delete iCloseIconMask; |
592 delete iCloseIconMask; |
|
593 delete iCloseIconPressed; |
|
594 delete iCloseIconPressedMask; |
|
595 iStrokeItems.Close(); |
654 } |
596 } |
655 |
597 |
656 |
598 |
657 // ----------------------------------------------------------------------------- |
599 // ----------------------------------------------------------------------------- |
658 // CTsGridItemDrawer::SetCloseIcon |
600 // CTsGridItemDrawer::SetCloseIcon |
659 // ----------------------------------------------------------------------------- |
601 // ----------------------------------------------------------------------------- |
660 // |
602 // |
661 void CTsGridItemDrawer::SetCloseIcon( CFbsBitmap* aBmp, CFbsBitmap* aMask ) |
603 void CTsGridItemDrawer::SetCloseIcon( CFbsBitmap* aBmp, CFbsBitmap* aBmpMask, |
|
604 CFbsBitmap* aBmpPressed, CFbsBitmap* aBmpPressedMask ) |
662 { |
605 { |
663 delete iCloseIcon; |
606 delete iCloseIcon; |
664 iCloseIcon = aBmp; |
607 iCloseIcon = aBmp; |
665 delete iCloseIconMask; |
608 delete iCloseIconMask; |
666 iCloseIconMask = aMask; |
609 iCloseIconMask = aBmpMask; |
|
610 delete iCloseIconPressed; |
|
611 iCloseIconPressed = aBmpPressed; |
|
612 delete iCloseIconPressedMask; |
|
613 iCloseIconPressedMask = aBmpPressedMask; |
667 } |
614 } |
668 |
615 |
669 |
616 |
670 // ----------------------------------------------------------------------------- |
617 // ----------------------------------------------------------------------------- |
671 // CTsGridItemDrawer::SetCloseIconRect |
618 // CTsGridItemDrawer::SetCloseIconRect |
712 iRedrawBackground = aEnable; |
659 iRedrawBackground = aEnable; |
713 } |
660 } |
714 |
661 |
715 |
662 |
716 // ----------------------------------------------------------------------------- |
663 // ----------------------------------------------------------------------------- |
|
664 // CTsGridItemDrawer::SetStrokeColor |
|
665 // ----------------------------------------------------------------------------- |
|
666 // |
|
667 void CTsGridItemDrawer::SetStrokeColors( TRgb aColor, |
|
668 TRgb aHighlightedColor ) |
|
669 { |
|
670 iStrokeColor = aColor; |
|
671 iHighlightStrokeColor = aHighlightedColor; |
|
672 } |
|
673 |
|
674 |
|
675 // ----------------------------------------------------------------------------- |
|
676 // CTsGridItemDrawer::SetStrokeItemsL |
|
677 // ----------------------------------------------------------------------------- |
|
678 // |
|
679 void CTsGridItemDrawer::SetStrokeItemsL( RArray<TInt>& aItemIndex ) |
|
680 { |
|
681 iStrokeItems.Close(); |
|
682 for ( TInt i = 0; i < aItemIndex.Count(); i++ ) |
|
683 { |
|
684 iStrokeItems.AppendL( aItemIndex[i] ); |
|
685 } |
|
686 } |
|
687 |
|
688 |
|
689 // ----------------------------------------------------------------------------- |
|
690 // CTsGridItemDrawer::SetStrokeOffset |
|
691 // ----------------------------------------------------------------------------- |
|
692 // |
|
693 void CTsGridItemDrawer::SetStrokeOffset( TPoint aStrokeOffset, TSize aStrokeSize ) |
|
694 { |
|
695 iStrokeRect = TRect( aStrokeOffset, aStrokeSize ); |
|
696 } |
|
697 |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
717 // CTsGridItemDrawer::DrawActualItem |
700 // CTsGridItemDrawer::DrawActualItem |
718 // ----------------------------------------------------------------------------- |
701 // ----------------------------------------------------------------------------- |
719 // |
702 // |
720 void CTsGridItemDrawer::DrawActualItem( TInt aItemIndex, const TRect& aActualItemRect, |
703 void CTsGridItemDrawer::DrawActualItem( TInt aItemIndex, const TRect& aActualItemRect, |
721 TBool aItemIsCurrent, TBool aViewIsEmphasized, |
704 TBool aItemIsCurrent, TBool aViewIsEmphasized, |
722 TBool aViewIsDimmed, TBool aItemIsSelected ) const |
705 TBool aViewIsDimmed, TBool aItemIsSelected ) const |
723 { |
706 { |
724 TBool feedbackNeed(EFalse);//feedback when item disappear or fully appear |
|
725 |
|
726 if (IsItemRectVisible(aActualItemRect)) |
707 if (IsItemRectVisible(aActualItemRect)) |
727 { |
708 { |
728 // Calculate offset of the visible rectangle |
709 // Calculate offset of the visible rectangle |
729 TRect drawRect = aActualItemRect; |
710 TRect drawRect = aActualItemRect; |
730 if ( drawRect.iTl.iX < iLeftOffset ) |
711 if ( drawRect.iTl.iX < iLeftOffset ) |
767 |
739 |
768 // Draw item |
740 // Draw item |
769 CFormattedCellListBoxItemDrawer::DrawActualItem(aItemIndex, aActualItemRect, |
741 CFormattedCellListBoxItemDrawer::DrawActualItem(aItemIndex, aActualItemRect, |
770 itemIsCurrent, aViewIsEmphasized, aViewIsDimmed, aItemIsSelected ); |
742 itemIsCurrent, aViewIsEmphasized, aViewIsDimmed, aItemIsSelected ); |
771 |
743 |
772 if ( iGrid->CanCloseItem( aItemIndex ) && iCloseIcon && iCloseIconMask ) |
744 // Draw stroke |
|
745 if ( iStrokeItems.Find( aItemIndex ) != KErrNotFound ) |
|
746 { |
|
747 TRect strokeRect = iStrokeRect; |
|
748 strokeRect.Move( aActualItemRect.iTl ); |
|
749 if ( itemIsCurrent ) |
|
750 { |
|
751 iGc->SetPenColor( iHighlightStrokeColor ); |
|
752 } |
|
753 else |
|
754 { |
|
755 iGc->SetPenColor( iStrokeColor ); |
|
756 } |
|
757 // Thumbnail stroke |
|
758 iGc->DrawRect( strokeRect ); |
|
759 } |
|
760 |
|
761 // Draw close button |
|
762 if ( iGrid->CanCloseItem( aItemIndex ) && iCloseIcon && iCloseIconPressed ) |
773 { |
763 { |
774 TRect closeIconRect = GetCloseButtonRect( aActualItemRect ); |
764 TRect closeIconRect = GetCloseButtonRect( aActualItemRect ); |
775 // Draw frame |
765 // Draw frame |
776 TRect outerRect = closeIconRect; |
766 TRect outerRect = closeIconRect; |
777 TRect innerRect = CalculateInnerButtonRect( outerRect ); |
767 TRect innerRect = CalculateInnerButtonRect( outerRect ); |
778 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
768 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
779 if ( iGrid->IsItemCloseHit( aItemIndex ) ) |
769 if ( iGrid->IsItemCloseHit( aItemIndex ) ) |
780 { |
770 { |
781 AknsDrawUtils::DrawFrame(skin, *iGc, outerRect, innerRect, |
771 TRect sourceRect( TPoint(0,0), iCloseIconPressed->SizeInPixels() ); |
782 KAknsIIDQgnFrSctrlButtonPressed, KAknsIIDQgnFrSctrlButtonCenterPressed); |
772 iGc->DrawBitmapMasked( innerRect, |
|
773 iCloseIconPressed, |
|
774 sourceRect, |
|
775 iCloseIconPressedMask, |
|
776 ETrue ); |
783 } |
777 } |
784 else |
778 else |
785 { |
779 { |
786 AknsDrawUtils::DrawFrame(skin, *iGc, outerRect, innerRect, |
780 TRect sourceRect( TPoint(0,0), iCloseIcon->SizeInPixels() ); |
787 KAknsIIDQgnFrSctrlButton, KAknsIIDQgnFrSctrlButtonCenter); |
781 iGc->DrawBitmapMasked( innerRect, |
|
782 iCloseIcon, |
|
783 sourceRect, |
|
784 iCloseIconMask, |
|
785 ETrue ); |
788 } |
786 } |
789 // Draw close icon |
787 } |
790 TRect sourceRect( TPoint(0,0), iCloseIcon->SizeInPixels() ); |
|
791 iGc->DrawBitmapMasked( innerRect, iCloseIcon, sourceRect, iCloseIconMask, ETrue ); |
|
792 } |
|
793 } |
|
794 else |
|
795 { |
|
796 feedbackNeed = iGrid->RemoveFromVisibleItems(aItemIndex); |
|
797 } |
|
798 if(feedbackNeed) |
|
799 { |
|
800 iGrid->LaunchTactileFeedback(); |
|
801 } |
788 } |
802 } |
789 } |
803 |
790 |
804 // ----------------------------------------------------------------------------- |
791 // ----------------------------------------------------------------------------- |
805 // CTsGridItemDrawer::DrawActualItem |
792 // CTsGridItemDrawer::DrawActualItem |