uifw/ganes/src/HgDoubleGraphicList.cpp
changeset 47 2f0c06423c72
parent 46 0e1e0022bd03
child 53 3c67ea82fafc
equal deleted inserted replaced
46:0e1e0022bd03 47:2f0c06423c72
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:     
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ganes/HgDoubleGraphicList.h>
       
    20 #include <ganes/HgItem.h>
       
    21 #include "HgMarquee.h"
       
    22 #include "HgLayoutData.h"
       
    23 #include "HgIndicatorManager.h"
       
    24 #include "HgDrawUtils.h"
       
    25 #include "HgConstants.h"
       
    26 
       
    27 
       
    28 #include <AknsUtils.h>
       
    29 #include <AknUtils.h>
       
    30 #include <AknsDrawUtils.h>
       
    31 
       
    32 #include <layoutmetadata.cdl.h>
       
    33 #include <aknlayoutscalable_avkon.cdl.h>
       
    34 #include <gulicon.h>
       
    35 
       
    36 using namespace AknLayoutScalable_Avkon;
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CHgDoubleGraphicList::NewL()
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CHgDoubleGraphicList* CHgDoubleGraphicList::NewL(
       
    43         const TRect& aRect, 
       
    44         TInt aItemCount, 
       
    45         CGulIcon* aDefaultIcon,
       
    46         RWsSession* aSession)
       
    47     {
       
    48     CHgDoubleGraphicList* self = new ( ELeave ) CHgDoubleGraphicList( 
       
    49             aItemCount, 
       
    50             aDefaultIcon );
       
    51 
       
    52     CleanupStack::PushL (self );
       
    53     self->ConstructL( aRect, aSession );
       
    54     CleanupStack::Pop (self );
       
    55     return self;
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CHgDoubleGraphicList::~CHgDoubleGraphicList()
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CHgDoubleGraphicList::~CHgDoubleGraphicList( )
       
    63     {
       
    64     delete iIconOverlayIndicator;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CHgDoubleGraphicList::PreferredImageSize()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TSize CHgDoubleGraphicList::PreferredImageSize()
       
    72     {
       
    73     TAknLayoutRect image;
       
    74     image.LayoutRect(TRect(), AknLayoutScalable_Avkon::list_double_large_graphic_pane_g1( 0 ));
       
    75     return image.Rect().Size();
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CHgDoubleGraphicList::PreferredImageSize()
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 EXPORT_C void CHgDoubleGraphicList::SetIconOverlayIndicator( CGulIcon* aIndicator )
       
    83     {
       
    84     delete iIconOverlayIndicator; 
       
    85     iIconOverlayIndicator = aIndicator;
       
    86     InitOverlayIcon();
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // CHgDoubleGraphicList::HandleSizeChanged()
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 void CHgDoubleGraphicList::HandleSizeChanged()
       
    94     {
       
    95     // Call base implementation
       
    96     CHgList::HandleSizeChanged();
       
    97     
       
    98     iLayoutData->SetItemLayout(list_double_large_graphic_pane( 0 ));
       
    99     iLayoutData->SetIconLayout(list_double_large_graphic_pane_g1( 2 ));
       
   100     for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i)
       
   101         iLayoutData->SetTitleLayout(i, list_double_large_graphic_pane_t1( i ));
       
   102     iLayoutData->SetTextLayout(list_double_large_graphic_pane_t2( 2 ));
       
   103     iLayoutData->SetFirstIndicatorLayout(list_double_large_graphic_pane_g3(0));
       
   104     iLayoutData->SetSecondIndicatorLayout(list_double_large_graphic_pane_g2(1));
       
   105     
       
   106     // Get the Row rect.
       
   107     TAknLayoutRect layout;
       
   108     layout.LayoutRect(ListRect(), iLayoutData->ItemLayout());
       
   109     iRowHeight = layout.Rect().Height();
       
   110 
       
   111     // Icon rect.
       
   112     TAknLayoutRect image;
       
   113     image.LayoutRect(layout.Rect(), iLayoutData->IconLayout());
       
   114     iImageSize = image.Rect().Size();
       
   115 
       
   116     InitOverlayIcon();
       
   117     
       
   118     // Indicator Rect.
       
   119     TAknLayoutRect indicator;
       
   120     indicator.LayoutRect(layout.Rect(), iLayoutData->FirstIndicatorLayout());
       
   121     iIndicatorSize = indicator.Rect().Size();
       
   122     
       
   123     // Calculate the items on the screen.
       
   124     iItemsOnScreen = iHeight / iRowHeight;
       
   125     iHeight = iItemsOnScreen * iRowHeight;
       
   126 
       
   127     if( iCurrentRow != KErrNotFound )
       
   128         FitTopItemToView( iCurrentRow );
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CHgDoubleGraphicList::DrawItem()
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 void CHgDoubleGraphicList::DrawItem( TInt aIndex, const TRect& aRect ) const
       
   136     {
       
   137     // Get the Icon
       
   138     CHgItem* item = iItems[aIndex];
       
   139     CGulIcon* icon = item->Icon() ? item->Icon() : iDefaultIcon;
       
   140     TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags());
       
   141 
       
   142     CWindowGc& gc = SystemGc();
       
   143     
       
   144     // Highlight the row if it's selected
       
   145     TRgb color = iColor;
       
   146     if( aIndex == iSelectedIndex )
       
   147         {
       
   148         DrawHighlight( aRect, color );
       
   149 
       
   150         // Draw first line text
       
   151         iDrawUtils->DrawTextMarquee(
       
   152                 gc,
       
   153                 aRect, 
       
   154                 iLayoutData->TitleLayout(indicators),
       
   155                 item->Title(),
       
   156                 color, 0);
       
   157 
       
   158         // Draw second line text
       
   159         iDrawUtils->DrawTextMarquee(
       
   160                 gc,
       
   161                 aRect, 
       
   162                 iLayoutData->TextLayout(),
       
   163                 item->Text(),
       
   164                 color, 1);
       
   165         
       
   166         ResetClippingRect( gc );
       
   167         }
       
   168     else
       
   169         {
       
   170         // Draw first line text
       
   171         iDrawUtils->DrawText(
       
   172                 gc,
       
   173                 aRect, 
       
   174                 iLayoutData->TitleLayout(indicators),
       
   175                 item->Title(),
       
   176                 color);
       
   177 
       
   178         // Draw second line text
       
   179         iDrawUtils->DrawText(
       
   180                 gc,
       
   181                 aRect, 
       
   182                 iLayoutData->TextLayout(),
       
   183                 item->Text(),
       
   184                 color);
       
   185         }
       
   186     
       
   187     // Draw the icon
       
   188     iDrawUtils->DrawImage(gc, aRect, iLayoutData->IconLayout(), *icon);
       
   189     
       
   190     // Draw the icon overlay indicator if applicable
       
   191     if( item->Flags() & CHgItem::EHgItemFlagsIconOverlayIndicator
       
   192             && iIconOverlayIndicator )
       
   193         {
       
   194         iDrawUtils->DrawImage(
       
   195                 gc, 
       
   196                 aRect, 
       
   197                 iLayoutData->IconLayout(), 
       
   198                 *iIconOverlayIndicator);
       
   199         }
       
   200     
       
   201     // Draw the indicators.
       
   202     iIndicatorManager->DrawIndicators(
       
   203             gc,
       
   204             aRect, 
       
   205             item->Flags(), 
       
   206             iLayoutData->FirstIndicatorLayout(), 
       
   207             iLayoutData->SecondIndicatorLayout() );            
       
   208     }
       
   209 
       
   210 // -----------------------------------------------------------------------------
       
   211 // CHgDoubleGraphicList::CHgDoubleGraphicList()
       
   212 // -----------------------------------------------------------------------------
       
   213 //
       
   214 CHgDoubleGraphicList::CHgDoubleGraphicList( TInt aItemCount, 
       
   215                                             CGulIcon* aDefaultIcon )
       
   216 : CHgList( aItemCount, aDefaultIcon )
       
   217     {
       
   218     
       
   219     }
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CHgDoubleGraphicList::InitOverlayIcon()
       
   223 // -----------------------------------------------------------------------------
       
   224 //
       
   225 void CHgDoubleGraphicList::InitOverlayIcon()
       
   226     {
       
   227     if( iIconOverlayIndicator && iIconOverlayIndicator->Bitmap() )
       
   228         {
       
   229         AknIconUtils::SetSize(iIconOverlayIndicator->Bitmap(), iImageSize);
       
   230         }
       
   231     }
       
   232