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