uifw/ganes/src/HgDoubleGraphicList.cpp
branchRCL_3
changeset 20 d48ab3b357f1
child 21 978afdc0236f
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
       
     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 #include "HgScrollbar.h"
       
    27 
       
    28 
       
    29 #include <AknsUtils.h>
       
    30 #include <AknUtils.h>
       
    31 #include <AknsDrawUtils.h>
       
    32 
       
    33 #include <layoutmetadata.cdl.h>
       
    34 #include <aknlayoutscalable_avkon.cdl.h>
       
    35 #include <gulicon.h>
       
    36 
       
    37 using namespace AknLayoutScalable_Avkon;
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // CHgDoubleGraphicList::NewL()
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 EXPORT_C CHgDoubleGraphicList* CHgDoubleGraphicList::NewL(
       
    44         const TRect& aRect, 
       
    45         TInt aItemCount, 
       
    46         CGulIcon* aDefaultIcon,
       
    47         RWsSession* aSession)
       
    48     {
       
    49     CHgDoubleGraphicList* self = new ( ELeave ) CHgDoubleGraphicList( 
       
    50             aItemCount, 
       
    51             aDefaultIcon );
       
    52 
       
    53     CleanupStack::PushL (self );
       
    54     self->ConstructL( aRect, aSession );
       
    55     CleanupStack::Pop (self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CHgDoubleGraphicList::~CHgDoubleGraphicList()
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CHgDoubleGraphicList::~CHgDoubleGraphicList( )
       
    64     {
       
    65     delete iIconOverlayIndicator;
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CHgDoubleGraphicList::PreferredImageSize()
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C TSize CHgDoubleGraphicList::PreferredImageSize()
       
    73     {
       
    74     TAknLayoutRect image;
       
    75     image.LayoutRect(TRect(), AknLayoutScalable_Avkon::list_double_large_graphic_pane_g1( 0 ));
       
    76     return image.Rect().Size();
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // CHgDoubleGraphicList::PreferredImageSize()
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C void CHgDoubleGraphicList::SetIconOverlayIndicator( CGulIcon* aIndicator )
       
    84     {
       
    85     delete iIconOverlayIndicator; 
       
    86     iIconOverlayIndicator = aIndicator;
       
    87     InitOverlayIcon();
       
    88     }
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // CHgDoubleGraphicList::HandleSizeChanged()
       
    92 // -----------------------------------------------------------------------------
       
    93 //
       
    94 void CHgDoubleGraphicList::HandleSizeChanged()
       
    95     {
       
    96     // Call base implementation
       
    97     CHgList::HandleSizeChanged();
       
    98     
       
    99     iLayoutData->SetItemLayout(list_double_large_graphic_pane( 0 ));
       
   100     iLayoutData->SetIconLayout(list_double_large_graphic_pane_g1( 2 ));
       
   101     for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i)
       
   102         iLayoutData->SetTitleLayout(i, list_double_large_graphic_pane_t1( i ));
       
   103     iLayoutData->SetTextLayout(list_double_large_graphic_pane_t2( 2 ));
       
   104     iLayoutData->SetFirstIndicatorLayout(list_double_large_graphic_pane_g3(0));
       
   105     TInt variety = iScrollbar && !iScrollbar->IsStatic() ? 1 : 0;
       
   106     iLayoutData->SetSecondIndicatorLayout(list_double_large_graphic_pane_g2(variety));
       
   107     
       
   108     // Get the Row rect.
       
   109     TAknLayoutRect layout;
       
   110     layout.LayoutRect(ListRect(), iLayoutData->ItemLayout());
       
   111     iRowHeight = layout.Rect().Height();
       
   112 
       
   113     // Icon rect.
       
   114     TAknLayoutRect image;
       
   115     image.LayoutRect(layout.Rect(), iLayoutData->IconLayout());
       
   116     iImageSize = image.Rect().Size();
       
   117 
       
   118     InitOverlayIcon();
       
   119     
       
   120     // Indicator Rect.
       
   121     TAknLayoutRect indicator;
       
   122     indicator.LayoutRect(layout.Rect(), iLayoutData->FirstIndicatorLayout());
       
   123     iIndicatorSize = indicator.Rect().Size();
       
   124     
       
   125     // Calculate the items on the screen.
       
   126     iItemsOnScreen = iHeight / iRowHeight;
       
   127     iHeight = iItemsOnScreen * iRowHeight;
       
   128 
       
   129     if( iCurrentRow != KErrNotFound )
       
   130         FitTopItemToView( iCurrentRow );
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CHgDoubleGraphicList::DrawItem()
       
   135 // -----------------------------------------------------------------------------
       
   136 //
       
   137 void CHgDoubleGraphicList::DrawItem( TInt aIndex, const TRect& aRect ) const
       
   138     {
       
   139     // Get the Icon
       
   140     CHgItem* item = iItems[aIndex];
       
   141     CGulIcon* icon = item->Icon() ? item->Icon() : iDefaultIcon;
       
   142     TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags());
       
   143 
       
   144     CWindowGc& gc = SystemGc();
       
   145     
       
   146     // Highlight the row if it's selected
       
   147     TRgb color = iColor;
       
   148     if( aIndex == iSelectedIndex )
       
   149         {
       
   150         DrawHighlight( aRect, color );
       
   151 
       
   152         // Draw first line text
       
   153         iDrawUtils->DrawTextMarquee(
       
   154                 gc,
       
   155                 aRect, 
       
   156                 iLayoutData->TitleLayout(indicators),
       
   157                 item->Title(),
       
   158                 color, 0);
       
   159 
       
   160         // Draw second line text
       
   161         iDrawUtils->DrawTextMarquee(
       
   162                 gc,
       
   163                 aRect, 
       
   164                 iLayoutData->TextLayout(),
       
   165                 item->Text(),
       
   166                 color, 1);
       
   167         
       
   168         ResetClippingRect( gc );
       
   169         }
       
   170     else
       
   171         {
       
   172         // Draw first line text
       
   173         iDrawUtils->DrawText(
       
   174                 gc,
       
   175                 aRect, 
       
   176                 iLayoutData->TitleLayout(indicators),
       
   177                 item->Title(),
       
   178                 color);
       
   179 
       
   180         // Draw second line text
       
   181         iDrawUtils->DrawText(
       
   182                 gc,
       
   183                 aRect, 
       
   184                 iLayoutData->TextLayout(),
       
   185                 item->Text(),
       
   186                 color);
       
   187         }
       
   188     
       
   189     // Draw the icon
       
   190     iDrawUtils->DrawImage(gc, aRect, iLayoutData->IconLayout(), *icon);
       
   191     
       
   192     // Draw the icon overlay indicator if applicable
       
   193     if( item->Flags() & CHgItem::EHgItemFlagsIconOverlayIndicator
       
   194             && iIconOverlayIndicator )
       
   195         {
       
   196         iDrawUtils->DrawImage(
       
   197                 gc, 
       
   198                 aRect, 
       
   199                 iLayoutData->IconLayout(), 
       
   200                 *iIconOverlayIndicator);
       
   201         }
       
   202     
       
   203     // Draw the indicators.
       
   204     iIndicatorManager->DrawIndicators(
       
   205             gc,
       
   206             aRect, 
       
   207             item->Flags(), 
       
   208             iLayoutData->FirstIndicatorLayout(), 
       
   209             iLayoutData->SecondIndicatorLayout() );            
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CHgDoubleGraphicList::CHgDoubleGraphicList()
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 CHgDoubleGraphicList::CHgDoubleGraphicList( TInt aItemCount, 
       
   217                                             CGulIcon* aDefaultIcon )
       
   218 : CHgList( aItemCount, aDefaultIcon )
       
   219     {
       
   220     
       
   221     }
       
   222 
       
   223 // -----------------------------------------------------------------------------
       
   224 // CHgDoubleGraphicList::InitOverlayIcon()
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 void CHgDoubleGraphicList::InitOverlayIcon()
       
   228     {
       
   229     if( iIconOverlayIndicator && iIconOverlayIndicator->Bitmap() )
       
   230         {
       
   231         AknIconUtils::SetSize(iIconOverlayIndicator->Bitmap(), iImageSize);
       
   232         }
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CHgDoubleGraphicList::HandleScrollbarVisibilityChange()
       
   237 // -----------------------------------------------------------------------------
       
   238 //
       
   239 void CHgDoubleGraphicList::HandleScrollbarVisibilityChange( TBool aVisible )
       
   240     {
       
   241     TInt variety = aVisible ? 1 : 0;
       
   242     iLayoutData->SetSecondIndicatorLayout(list_double_large_graphic_pane_g2(variety));
       
   243     }
       
   244 
       
   245 // End of file