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