uifw/eikctl/src/EIKCLBD.CPP
branchRCL_3
changeset 25 941195f2d488
parent 23 3d340a0166ff
child 29 a8834a2e9a96
equal deleted inserted replaced
23:3d340a0166ff 25:941195f2d488
    51 
    51 
    52 // colored tick marks support
    52 // colored tick marks support
    53 const TInt KColorIconFlag = -1;
    53 const TInt KColorIconFlag = -1;
    54 const TInt KColorIconIdx  =  0;
    54 const TInt KColorIconIdx  =  0;
    55 
    55 
       
    56 // Number of icons in marking mode icon array
       
    57 const TInt KMarkingModeIconArraySize = 2;
    56 
    58 
    57 /**
    59 /**
    58 * About animation usage:
    60 * About animation usage:
    59 * All animation usage is implemented in this class. Animation is eye candy and
    61 * All animation usage is implemented in this class. Animation is eye candy and
    60 * low priority when it comes to resources -> on resource failures animation
    62 * low priority when it comes to resources -> on resource failures animation
  1146 //
  1148 //
  1147 void CColumnListBoxDataExtension::LoadMarkingIconsL()
  1149 void CColumnListBoxDataExtension::LoadMarkingIconsL()
  1148     {
  1150     {
  1149     if ( !iMarkingIconArray )
  1151     if ( !iMarkingIconArray )
  1150         {
  1152         {
  1151         iMarkingIconArray = new ( ELeave ) CAknIconArray( 2 );
  1153         iMarkingIconArray = new ( ELeave ) CAknIconArray( 
       
  1154                 KMarkingModeIconArraySize );
  1152         }
  1155         }
  1153     else
  1156     else
  1154         {
  1157         {
  1155         iMarkingIconArray->ResetAndDestroy();
  1158         iMarkingIconArray->ResetAndDestroy();
  1156         }
  1159         }
  2028     TPtrC text;
  2031     TPtrC text;
  2029     TPtrC tempText;
  2032     TPtrC tempText;
  2030 
  2033 
  2031     TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText;
  2034     TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText;
  2032     
  2035     
  2033     TBool markingMode = EFalse;
       
  2034     TRect itemRect( aRect );
       
  2035     
       
  2036     if ( listbox->View() && listbox->View()->ItemDrawer() )
       
  2037         {
       
  2038         if ( listbox->View()->ItemDrawer()->Flags() 
       
  2039                 & CListItemDrawer::EMarkingModeEnabled
       
  2040                 && iExtension->iMarkingIconArray
       
  2041                 &&  iExtension->iMarkingIconArray->Count() == 2 )
       
  2042             {
       
  2043             markingMode = ETrue;
       
  2044             itemRect.iTl.iX += 
       
  2045                     AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).LayoutLine().il;
       
  2046             }
       
  2047         }
       
  2048 
       
  2049     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
  2036     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
  2050     MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() );
  2037     MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() );
  2051     if ( !cc )
  2038     if ( !cc )
  2052         {
  2039         {
  2053         cc = SkinBackgroundContext();
  2040         cc = SkinBackgroundContext();
  2055 
  2042 
  2056     TAknTextLineLayout textLines[KMaxColumn];
  2043     TAknTextLineLayout textLines[KMaxColumn];
  2057     TBool rectClipped[KMaxColumn];
  2044     TBool rectClipped[KMaxColumn];
  2058     
  2045     
  2059     Mem::FillZ( &rectClipped[0], KMaxColumn * sizeof( TBool ) );
  2046     Mem::FillZ( &rectClipped[0], KMaxColumn * sizeof( TBool ) );
  2060     
       
  2061     if ( iExtension->iSubCellsMightIntersect )
       
  2062         {
       
  2063         CheckIfSubCellsIntersect( &textLines[0], &rectClipped[0], *aText, itemRect );
       
  2064         }
       
  2065 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2047 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2066     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
  2048     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
  2067 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2049 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2068 
  2050 
  2069     if ( !listbox || !listbox->BackgroundDrawingSuppressed() )
  2051     if ( !listbox || !listbox->BackgroundDrawingSuppressed() )
  2093             transApi->StopDrawing();
  2075             transApi->StopDrawing();
  2094             }
  2076             }
  2095 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2077 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2096         }
  2078         }
  2097  
  2079  
       
  2080     TRect itemRect( aRect );
       
  2081     DrawMarkingModeIcons( aItemProperties, aGc, itemRect );
       
  2082     if ( iExtension->iSubCellsMightIntersect )
       
  2083         {
       
  2084         CheckIfSubCellsIntersect( &textLines[0], &rectClipped[0], *aText, itemRect );
       
  2085         }
  2098     if ( iExtension->iCurrentRow < listbox->BottomItemIndex() )
  2086     if ( iExtension->iCurrentRow < listbox->BottomItemIndex() )
  2099         {
  2087         {
  2100         AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin );
  2088         AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin );
  2101         }
  2089         }
  2102     DrawHighLight( aGc, aRect, aHighlight, skin );
  2090     DrawHighLight( aGc, aRect, aHighlight, skin );
  2103     
  2091     
  2104     if ( markingMode && !aItemProperties.IsSelectionHidden() )
       
  2105         {
       
  2106         TAknLayoutRect layoutRect;
       
  2107         layoutRect.LayoutRect( aRect, 
       
  2108                 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
       
  2109         
       
  2110         aGc.SetPenColor( aColors.iText );
       
  2111         aGc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  2112 
       
  2113         CGulIcon* icon = (*iExtension->iMarkingIconArray)[1]; // unchecked
       
  2114 
       
  2115         if ( listbox->View()->ItemIsSelected( iExtension->iCurrentRow ) )
       
  2116             {
       
  2117             icon = (*iExtension->iMarkingIconArray)[0];
       
  2118             }
       
  2119         
       
  2120         CFbsBitmap* bitmap = icon->Bitmap();
       
  2121 
       
  2122         if ( bitmap )
       
  2123             {
       
  2124             TSize size( bitmap->SizeInPixels() ); // set size if not already
       
  2125             TSize targetSize( layoutRect.Rect().Size() );
       
  2126             
       
  2127             if ( size.iWidth != targetSize.iWidth && size.iHeight != targetSize.iHeight )
       
  2128                 {
       
  2129                 AknIconUtils::SetSize( bitmap, targetSize,
       
  2130                         EAspectRatioPreservedAndUnusedSpaceRemoved ); 
       
  2131                 }
       
  2132 
       
  2133             aGc.BitBltMasked( layoutRect.Rect().iTl, bitmap, TRect( layoutRect.Rect().Size() ), icon->Mask(), EFalse );
       
  2134             }
       
  2135         
       
  2136         }
       
  2137     
  2092     
  2138     // The column draw loop
  2093     // The column draw loop
  2139     column = 0;
  2094     column = 0;
  2140     TInt subCellIndex = 0;
  2095     TInt subCellIndex = 0;
  2141     
  2096     
  2151     for( column = 0; column <= lastColumn; column++ )
  2106     for( column = 0; column <= lastColumn; column++ )
  2152         {
  2107         {
  2153         TextUtils::ColumnText( text, column, aText );
  2108         TextUtils::ColumnText( text, column, aText );
  2154         if ( text == KNullDesC ) { continue; }
  2109         if ( text == KNullDesC ) { continue; }
  2155 
  2110 
  2156         if ( iExtension->FindSLSubCellIndex( subCellIndex, column )!=0 ) { continue; }
  2111         if ( iExtension->FindSLSubCellIndex( subCellIndex, column )!=0 ) 
       
  2112             { 
       
  2113             continue; 
       
  2114             }
  2157         
  2115         
  2158         CGraphicsContext::TTextAlign align=ColumnAlignment(column);
  2116         CGraphicsContext::TTextAlign align=ColumnAlignment(column);
  2159         TBool isLayoutAlignment = iExtension->ColumnLayoutAlignment(column);
  2117         TBool isLayoutAlignment = iExtension->ColumnLayoutAlignment(column);
  2160         
  2118         
  2161         if ( iExtension->AtSL(subCellIndex).iSubCellType == CColumnListBoxDataExtension::EEikSLText )
  2119         if ( iExtension->AtSL(subCellIndex).iSubCellType == CColumnListBoxDataExtension::EEikSLText )
  2458             }
  2416             }
  2459         return;
  2417         return;
  2460         }
  2418         }
  2461 
  2419 
  2462     CEikListBox* listbox = static_cast<CEikListBox*>( iExtension->iControl );
  2420     CEikListBox* listbox = static_cast<CEikListBox*>( iExtension->iControl );
  2463     TBool markingMode = EFalse;
       
  2464     TRect itemRect( aRect );
  2421     TRect itemRect( aRect );
  2465     
       
  2466     if ( listbox->View() && listbox->View()->ItemDrawer() )
       
  2467         {
       
  2468         if ( listbox->View()->ItemDrawer()->Flags() 
       
  2469                 & CListItemDrawer::EMarkingModeEnabled &&
       
  2470              iExtension->iMarkingIconArray && 
       
  2471              iExtension->iMarkingIconArray->Count() == 2 )
       
  2472             {
       
  2473             markingMode = ETrue;
       
  2474             itemRect.iTl.iX += 
       
  2475                 AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 0 ).LayoutLine().il;
       
  2476             }
       
  2477         }
       
  2478     
  2422     
  2479     TInt extraVerticalSpace=(aRect.Height()-font->HeightInPixels());
  2423     TInt extraVerticalSpace=(aRect.Height()-font->HeightInPixels());
  2480     TInt baseLineOffset=extraVerticalSpace/2+font->AscentInPixels();
  2424     TInt baseLineOffset=extraVerticalSpace/2+font->AscentInPixels();
       
  2425     // SERIES60 Background drawing.
       
  2426     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
  2427     MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() );
       
  2428     if (!cc)
       
  2429         {
       
  2430         cc = SkinBackgroundContext();
       
  2431         }
       
  2432 
       
  2433 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2434 
       
  2435     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
       
  2436 
       
  2437 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2438 
       
  2439     if ( !listbox || !listbox->BackgroundDrawingSuppressed() )
       
  2440         {
       
  2441 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2442         if ( transApi )
       
  2443             {
       
  2444             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
  2445             }
       
  2446 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2447 
       
  2448         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2449         aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  2450 
       
  2451         if ( listbox )
       
  2452             {
       
  2453             AknsDrawUtils::Background( skin, cc, listbox, aGc, aRect );
       
  2454             }
       
  2455         else
       
  2456             {
       
  2457             aGc.Clear(aRect);
       
  2458             }
       
  2459 
       
  2460 #ifdef RD_UI_TRANSITION_EFFECTS_LIST   
       
  2461         if ( transApi )
       
  2462             {
       
  2463             transApi->StopDrawing();
       
  2464             }
       
  2465 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2466         }
       
  2467     
       
  2468     DrawMarkingModeIcons( aItemProperties, aGc, itemRect );
  2481     TRect textRect( itemRect );
  2469     TRect textRect( itemRect );
       
  2470     textRect.iBr.iX = itemRect.iTl.iX;    
  2482     TRect textMRect; // textrect with margins.
  2471     TRect textMRect; // textrect with margins.
  2483     textRect.iBr.iX = itemRect.iTl.iX;
       
  2484     TInt column=0;
  2472     TInt column=0;
  2485     TPtrC text;
  2473     TPtrC text;
  2486 
  2474 
  2487     TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText;
  2475     TRgb aTextColor = aHighlight ? aColors.iHighlightedText : aColors.iText;
  2488 
  2476 
  2557         column++;
  2545         column++;
  2558         }
  2546         }
  2559 
  2547 
  2560     // pass 3 drawing
  2548     // pass 3 drawing
  2561 
  2549 
  2562     // SERIES60 Background drawing.
       
  2563     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
  2564     MAknsControlContext *cc = AknsDrawUtils::ControlContext( Control() );
       
  2565     if (!cc)
       
  2566         {
       
  2567         cc = SkinBackgroundContext();
       
  2568         }
       
  2569 
       
  2570 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2571 
       
  2572     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
       
  2573 
       
  2574 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2575 
       
  2576     if ( !listbox || !listbox->BackgroundDrawingSuppressed() )
       
  2577         {
       
  2578 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  2579         if ( transApi )
       
  2580             {
       
  2581             transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
  2582             }
       
  2583 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2584 
       
  2585         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
  2586         aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
  2587 
       
  2588         if ( listbox )
       
  2589             {
       
  2590             AknsDrawUtils::Background( skin, cc, listbox, aGc, aRect );
       
  2591             }
       
  2592         else
       
  2593             {
       
  2594             aGc.Clear(aRect);
       
  2595             }
       
  2596 
       
  2597 #ifdef RD_UI_TRANSITION_EFFECTS_LIST   
       
  2598         if ( transApi )
       
  2599             {
       
  2600             transApi->StopDrawing();
       
  2601             }
       
  2602 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  2603         }
       
  2604 
  2550 
  2605     if ( iExtension->iCurrentRow < listbox->BottomItemIndex() )
  2551     if ( iExtension->iCurrentRow < listbox->BottomItemIndex() )
  2606         {
  2552         {
  2607         AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin );
  2553         AknListUtils::DrawSeparator( aGc, aRect, aColors.iText, skin );
  2608         }
  2554         }
  2616         transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  2562         transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
  2617         CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View();
  2563         CListBoxView* view = static_cast<CEikListBox*>( iExtension->iControl )->View();
  2618         aGc.SetClippingRect( view->ViewRect() );
  2564         aGc.SetClippingRect( view->ViewRect() );
  2619         }
  2565         }
  2620 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2566 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2621 
       
  2622     if ( markingMode && !aItemProperties.IsSelectionHidden() )
       
  2623         {
       
  2624         TAknLayoutRect layoutRect;
       
  2625         layoutRect.LayoutRect(
       
  2626             aRect, 
       
  2627             AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
       
  2628         
       
  2629         aGc.SetPenColor( aColors.iText );
       
  2630         aGc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  2631 
       
  2632         CGulIcon* icon = (*iExtension->iMarkingIconArray)[1]; // unchecked
       
  2633 
       
  2634         if ( listbox->View()->ItemIsSelected( iExtension->iCurrentRow ) )
       
  2635             {
       
  2636             icon = (*iExtension->iMarkingIconArray)[0];
       
  2637             }
       
  2638         
       
  2639         CFbsBitmap* bitmap = icon->Bitmap();
       
  2640 
       
  2641         if ( bitmap )
       
  2642             {
       
  2643             TSize size( bitmap->SizeInPixels() ); // set size if not already
       
  2644             TSize targetSize( layoutRect.Rect().Size() );
       
  2645             
       
  2646             if ( size.iWidth != targetSize.iWidth &&
       
  2647                  size.iHeight != targetSize.iHeight )
       
  2648                 {
       
  2649                 AknIconUtils::SetSize(
       
  2650                     bitmap,
       
  2651                     targetSize,
       
  2652                     EAspectRatioPreservedAndUnusedSpaceRemoved ); 
       
  2653                 }
       
  2654 
       
  2655             aGc.BitBltMasked( layoutRect.Rect().iTl,
       
  2656                               bitmap,
       
  2657                               TRect( layoutRect.Rect().Size() ),
       
  2658                               icon->Mask(),
       
  2659                               EFalse );
       
  2660             }
       
  2661         }
       
  2662     
       
  2663     // The column draw loop
  2567     // The column draw loop
  2664     column = 0;
  2568     column = 0;
  2665     FOREVER
  2569     FOREVER
  2666         {
  2570         {
  2667         if (column > lastColumn) break;
  2571         if (column > lastColumn) break;
  2917         transApi->StopDrawing();
  2821         transApi->StopDrawing();
  2918         }
  2822         }
  2919 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2823 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  2920     }
  2824     }
  2921 
  2825 
       
  2826 // -----------------------------------------------------------------------------
       
  2827 // CColumnListBoxData::DrawMarkingModeIcons
       
  2828 // -----------------------------------------------------------------------------
       
  2829 //
       
  2830 void CColumnListBoxData::DrawMarkingModeIcons( 
       
  2831                 const TListItemProperties& aProperties,
       
  2832                 CWindowGc& aGc,
       
  2833                 TRect& aItemRect ) const
       
  2834     {
       
  2835     CEikListBox* listbox = static_cast<CEikListBox*>( iExtension->iControl );
       
  2836     TRect textRect( aItemRect );
       
  2837     
       
  2838     if ( listbox->View() && listbox->View()->ItemDrawer() )
       
  2839         {
       
  2840         if ( listbox->View()->ItemDrawer()->Flags() 
       
  2841                 & CListItemDrawer::EMarkingModeEnabled &&
       
  2842                 !aProperties.IsSelectionHidden() &&
       
  2843                 iExtension->iMarkingIconArray &&
       
  2844 #ifdef RD_TOUCH2_MARKING
       
  2845                 iExtension->iMarkingIconArray->Count() == 
       
  2846                         KMarkingModeIconArraySize )
       
  2847 #else
       
  2848                 iExtension->iMarkingIconArray->Count() == 2 )
       
  2849 #endif // RD_TOUCH2_MARKING            
       
  2850             {
       
  2851             textRect.iTl.iX += 
       
  2852                 AknLayoutScalable_Avkon::list_single_graphic_pane_t1( 
       
  2853                         0 ).LayoutLine().il;
       
  2854             TAknLayoutRect layoutRect;
       
  2855             layoutRect.LayoutRect( aItemRect, 
       
  2856                 AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ) );
       
  2857             
       
  2858             // unchecked icon
       
  2859             CGulIcon* icon = (*iExtension->iMarkingIconArray)[1];
       
  2860             
       
  2861             if ( listbox->View()->ItemIsSelected( iExtension->iCurrentRow ) )
       
  2862                 {
       
  2863                 icon = (*iExtension->iMarkingIconArray)[0];
       
  2864                 }
       
  2865             CFbsBitmap* bitmap = icon->Bitmap();
       
  2866             
       
  2867             if ( bitmap )
       
  2868                 {
       
  2869                 TSize size( bitmap->SizeInPixels() ); // set size if not already
       
  2870                 TSize targetSize( layoutRect.Rect().Size() );
       
  2871                 
       
  2872                 if ( size.iWidth != targetSize.iWidth &&
       
  2873                      size.iHeight != targetSize.iHeight )
       
  2874                     {
       
  2875                     AknIconUtils::SetSize(
       
  2876                         bitmap,
       
  2877                         targetSize,
       
  2878                         EAspectRatioPreservedAndUnusedSpaceRemoved ); 
       
  2879                     }
       
  2880 
       
  2881                 aGc.BitBltMasked( layoutRect.Rect().iTl,
       
  2882                                   bitmap,
       
  2883                                   TRect( layoutRect.Rect().Size() ),
       
  2884                                   icon->Mask(),
       
  2885                                   EFalse );
       
  2886                 }   
       
  2887             aItemRect = textRect;
       
  2888             }
       
  2889         }
       
  2890     }
  2922 
  2891 
  2923 void CColumnListBoxData::AddColumnL(TInt aColumn)
  2892 void CColumnListBoxData::AddColumnL(TInt aColumn)
  2924 //
  2893 //
  2925 //    Add a column's worth of data
  2894 //    Add a column's worth of data
  2926 //
  2895 //