778 #define ITEM_EXISTS(x) (((x) > -1) && ((x) < no_of_items__)) |
778 #define ITEM_EXISTS(x) (((x) > -1) && ((x) < no_of_items__)) |
779 |
779 |
780 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems())) |
780 #define ITEM_EXISTS_ONCE(x) (((x) > -1) && ((x) < iModel->NumberOfItems())) |
781 |
781 |
782 EXPORT_C void |
782 EXPORT_C void |
783 CFormattedCellListBoxView::Draw(const TRect* clipRect) const |
783 CFormattedCellListBoxView::Draw( const TRect* aClipRect ) const |
784 { |
784 { |
785 _AKNTRACE_FUNC_ENTER; |
785 _AKNTRACE_FUNC_ENTER; |
786 if ( RedrawDisabled() || !IsVisible() ) |
786 if ( RedrawDisabled() || !IsVisible() ) |
787 { |
787 { |
788 _AKNTRACE("CFormattedCellListBoxView::Draw return because redraw disabled or invisible"); |
788 _AKNTRACE("CFormattedCellListBoxView::Draw return because redraw disabled or invisible"); |
789 _AKNTRACE_FUNC_EXIT; |
789 _AKNTRACE_FUNC_EXIT; |
790 return; |
790 return; |
791 } |
791 } |
792 |
792 |
793 if(clipRect && clipRect->IsEmpty()) |
793 if( aClipRect && aClipRect->IsEmpty() ) |
794 { |
794 { |
795 _AKNTRACE("CFormattedCellListBoxView::Draw return because clip rect is empty"); |
795 _AKNTRACE("CFormattedCellListBoxView::Draw return because clip rect is empty"); |
796 _AKNTRACE_FUNC_EXIT; |
796 _AKNTRACE_FUNC_EXIT; |
797 return; |
797 return; |
798 } |
798 } |
799 |
799 |
800 TInt i = iTopItemIndex; |
800 TInt i = iTopItemIndex; |
801 CFormattedCellListBoxItemDrawer *itemDrawer = static_cast<CFormattedCellListBoxItemDrawer*>( iItemDrawer ); |
801 CFormattedCellListBoxItemDrawer* itemDrawer = |
802 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
802 static_cast<CFormattedCellListBoxItemDrawer*>( iItemDrawer ); |
|
803 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
803 CCoeControl* control = itemDrawer->FormattedCellData()->Control(); |
804 CCoeControl* control = itemDrawer->FormattedCellData()->Control(); |
804 MAknsControlContext *cc = AknsDrawUtils::ControlContext( control ); |
805 MAknsControlContext* cc = AknsDrawUtils::ControlContext( control ); |
|
806 CWindowGc* gc = itemDrawer->Gc(); |
805 |
807 |
806 if ( !cc ) |
808 if ( !cc ) |
807 { |
809 { |
808 cc = itemDrawer->FormattedCellData()->SkinBackgroundContext(); |
810 cc = itemDrawer->FormattedCellData()->SkinBackgroundContext(); |
809 } |
811 } |
810 |
812 |
811 itemDrawer->SetTopItemIndex( iTopItemIndex ); |
813 itemDrawer->SetTopItemIndex( iTopItemIndex ); |
812 |
814 |
813 if ( iModel->NumberOfItems() > 0 ) |
815 TBool transparencyEnabled = CAknEnv::Static()->TransparencyEnabled(); |
|
816 TInt numberOfItems = iModel->NumberOfItems(); |
|
817 |
|
818 if ( numberOfItems > 0 ) |
814 { |
819 { |
815 TBool drawingInitiated = ETrue; |
820 TBool drawingInitiated = ETrue; |
816 |
821 |
817 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
822 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
818 MAknListBoxTfxInternal* transApi = |
823 MAknListBoxTfxInternal* transApi = |
819 CAknListLoader::TfxApiInternal( itemDrawer->Gc() ); |
824 CAknListLoader::TfxApiInternal( gc ); |
820 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
825 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
821 |
826 |
822 if ( CAknEnv::Static()->TransparencyEnabled() ) |
827 if ( transparencyEnabled ) |
823 { |
828 { |
824 if ( iWin && iWin->GetDrawRect() == TRect::EUninitialized ) |
829 if ( iWin && iWin->GetDrawRect() == TRect::EUninitialized ) |
825 { |
830 { |
826 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
831 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
827 drawingInitiated = transApi && !transApi->EffectsDisabled(); |
832 drawingInitiated = transApi && !transApi->EffectsDisabled(); |
830 #endif |
835 #endif |
831 } |
836 } |
832 |
837 |
833 if ( !drawingInitiated ) |
838 if ( !drawingInitiated ) |
834 { |
839 { |
835 iWin->Invalidate( *clipRect ); |
840 iWin->Invalidate( *aClipRect ); |
836 iWin->BeginRedraw( *clipRect ); |
841 iWin->BeginRedraw( *aClipRect ); |
837 } |
842 } |
838 } |
843 } |
839 |
844 |
840 TInt lastPotentialItemIndex = Min( iModel->NumberOfItems(), iTopItemIndex + NumberOfItemsThatFitInRect( iViewRect ) ); |
845 TInt lastPotentialItemIndex = |
|
846 Min( numberOfItems, |
|
847 iTopItemIndex + NumberOfItemsThatFitInRect( iViewRect ) ); |
841 |
848 |
842 while ( i < lastPotentialItemIndex ) |
849 while ( i < lastPotentialItemIndex ) |
843 { |
850 { |
844 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
851 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
845 if ( transApi ) |
852 if ( transApi ) |
846 { |
853 { |
847 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
854 transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified ); |
848 } |
855 } |
849 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
856 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
850 |
857 |
851 itemDrawer->Gc()->SetClippingRect( iViewRect ); |
858 gc->SetClippingRect( iViewRect ); |
852 |
859 |
853 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
860 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
854 if ( transApi ) |
861 if ( transApi ) |
855 { |
862 { |
856 transApi->StopDrawing(); |
863 transApi->StopDrawing(); |
879 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
886 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
880 if ( transApi ) |
887 if ( transApi ) |
881 { |
888 { |
882 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
889 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
883 } |
890 } |
|
891 |
884 if ( i > iBottomItemIndex + 1 ) |
892 if ( i > iBottomItemIndex + 1 ) |
885 { |
893 { |
886 i = iBottomItemIndex + 1; |
894 i = iBottomItemIndex + 1; |
887 } |
895 } |
888 TRect usedPortionOfViewRect( iViewRect.iTl+TSize(0,iVerticalOffset), TSize( iViewRect.Width(), ( i - iTopItemIndex ) * iItemHeight ) ); |
896 |
|
897 TRect usedPortionOfViewRect( |
|
898 iViewRect.iTl + TSize( 0, iVerticalOffset ), |
|
899 TSize( iViewRect.Width(), ( i - iTopItemIndex ) * iItemHeight ) ); |
889 #else |
900 #else |
890 // clear the unused portion of the viewing area |
901 // clear the unused portion of the viewing area |
891 TRect usedPortionOfViewRect( iViewRect.iTl.iX, iViewRect.iTl.iY + iVerticalOffset, iViewRect.Width(), ItemPos( lastPotentialItemIndex ).iY ); |
902 TRect usedPortionOfViewRect( iViewRect.iTl.iX, |
|
903 iViewRect.iTl.iY + iVerticalOffset, |
|
904 iViewRect.Width(), |
|
905 ItemPos( lastPotentialItemIndex ).iY ); |
892 |
906 |
893 if ( clipRect ) |
907 if ( aClipRect ) |
894 { |
908 { |
895 usedPortionOfViewRect.iBr.iX = clipRect->iBr.iX; |
909 usedPortionOfViewRect.iBr.iX = aClipRect->iBr.iX; |
896 } |
910 } |
897 |
911 |
898 #endif |
912 #endif |
899 |
913 |
900 // also clear area behind scroll bar. |
914 // Also draw the area behind scroll bar. |
901 // this is a terrible hack, which is unfortunately needed since layouts |
915 TRect sbbg( iViewRect ); // whole area behind scroll bar |
902 // leave 2 pixel (in double res) wide margins to both sides of the |
|
903 // scroll bar, and there is no other way to do this. This hack is |
|
904 // only really valid for main pane lists, but it does not seem to |
|
905 // break popup lists, popup field lists or setting page radiobutton |
|
906 // lists. |
|
907 // See also: eikslb.cpp, eikclb.cpp |
|
908 TRect sbbg( iViewRect ); // whole area behind scroll bar |
|
909 TRect margin( iViewRect ); // it gets even worse in mirrored layouts |
|
910 |
916 |
911 if ( AknLayoutUtils::LayoutMirrored() ) |
917 if ( AknLayoutUtils::LayoutMirrored() ) |
912 { |
918 { |
913 _AKNTRACE("CFormattedCellListBoxView::Draw Layout mirrored"); |
919 _AKNTRACE("CFormattedCellListBoxView::Draw Layout mirrored"); |
914 sbbg.iBr.iX = iViewRect.iBr.iX - itemDrawer->LafItemSize().iWidth; |
920 sbbg.iBr.iX = iViewRect.iBr.iX - itemDrawer->LafItemSize().iWidth; |
915 |
|
916 // in mirrored layouts we also need to draw a margin slice in right |
|
917 TRect mainPane; |
|
918 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
919 mainPane ); |
|
920 TAknLayoutRect listscrollAppPane; |
|
921 listscrollAppPane.LayoutRect( mainPane, |
|
922 AknLayoutScalable_Avkon::listscroll_app_pane( 0 ) ); |
|
923 |
|
924 TInt rMargin = mainPane.iBr.iX - listscrollAppPane.Rect().iBr.iX; |
|
925 margin.iTl.iX = margin.iBr.iX - rMargin; |
|
926 } |
921 } |
927 else |
922 else |
928 { |
923 { |
929 sbbg.iTl.iX = iViewRect.iTl.iX + itemDrawer->LafItemSize().iWidth; |
924 sbbg.iTl.iX = iViewRect.iTl.iX + itemDrawer->LafItemSize().iWidth; |
930 } |
925 } |
931 |
926 |
932 // Unused portion will be cleared only if listbox background is drawn. |
927 // Unused portion will be cleared only if listbox background is drawn. |
933 if ( itemDrawer->ColumnData()->IsBackgroundDrawingEnabled() ) |
928 if ( itemDrawer->ColumnData()->IsBackgroundDrawingEnabled() ) |
934 { |
929 { |
935 if ( control ) |
930 if ( control ) |
936 { |
931 { |
937 if ( !control->FindBackground() ) |
932 if ( !control->FindBackground() ) |
938 { |
933 { |
939 AknsDrawUtils::BackgroundBetweenRects( skin, |
934 AknsDrawUtils::BackgroundBetweenRects( skin, |
940 cc, |
935 cc, |
941 control, |
936 control, |
942 *itemDrawer->Gc(), |
937 *gc, |
943 iViewRect, |
938 iViewRect, |
944 usedPortionOfViewRect ); |
939 usedPortionOfViewRect ); |
945 |
940 |
946 AknsDrawUtils::Background( skin, cc, control, *itemDrawer->Gc(), sbbg ); |
941 if ( !sbbg.IsEmpty() ) |
947 |
|
948 if ( AknLayoutUtils::LayoutMirrored() ) |
|
949 { |
942 { |
950 AknsDrawUtils::Background( skin, cc, control, *itemDrawer->Gc(), margin ); |
943 AknsDrawUtils::Background( skin, |
|
944 cc, |
|
945 control, |
|
946 *gc, |
|
947 sbbg ); |
951 } |
948 } |
952 } |
949 } |
953 } |
950 } |
954 else |
951 else |
955 { |
952 { |
956 itemDrawer->Gc()->SetBrushColor( BackColor() ); |
953 gc->SetBrushColor( BackColor() ); |
957 DrawUtils::ClearBetweenRects( *itemDrawer->Gc(), iViewRect, usedPortionOfViewRect ); |
954 DrawUtils::ClearBetweenRects( *gc, |
958 itemDrawer->Gc()->Clear( sbbg ); |
955 iViewRect, |
959 |
956 usedPortionOfViewRect ); |
960 if ( AknLayoutUtils::LayoutMirrored() ) |
957 gc->Clear( sbbg ); |
961 { |
|
962 itemDrawer->Gc()->Clear( margin ); |
|
963 } |
|
964 } |
958 } |
965 } |
959 } |
966 |
960 |
967 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
961 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
968 if ( transApi ) |
962 if ( transApi ) |