uifw/ganes/src/HgSingleTextListWithIcon.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 #include <ganes/HgSingleTextListWithIcon.h>
       
    19 #include <ganes/HgItem.h>
       
    20 #include "HgMarquee.h"
       
    21 #include "HgLayoutData.h"
       
    22 #include "HgIndicatorManager.h"
       
    23 #include "HgDrawUtils.h"
       
    24 
       
    25 #include <AknsUtils.h>
       
    26 #include <AknUtils.h>
       
    27 #include <AknsDrawUtils.h>
       
    28 
       
    29 #include <layoutmetadata.cdl.h>
       
    30 #include <aknlayoutscalable_avkon.cdl.h>
       
    31 #include <gulicon.h>
       
    32 
       
    33 using namespace AknLayoutScalable_Avkon;
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // CHgSingleTextList::NewL()
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 EXPORT_C CHgSingleTextListWithIcon* CHgSingleTextListWithIcon::NewL(
       
    40         const TRect& aRect, 
       
    41         TInt aItemCount, 
       
    42         CGulIcon* aDefaultIcon,
       
    43         RWsSession* aSession)
       
    44     {
       
    45     CHgSingleTextListWithIcon* self = new ( ELeave ) CHgSingleTextListWithIcon( 
       
    46             aItemCount, 
       
    47             aDefaultIcon );
       
    48 
       
    49     CleanupStack::PushL (self );
       
    50     self->ConstructL( aRect, aSession );
       
    51     CleanupStack::Pop (self );
       
    52     return self;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // CHgSingleTextListWithIcon::~CHgSingleTextListWithIcon()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C CHgSingleTextListWithIcon::~CHgSingleTextListWithIcon( )
       
    60     {
       
    61     delete iGraphicLayoutData;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CHgSingleTextList::HandleSizeChanged()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 void CHgSingleTextListWithIcon::HandleSizeChanged()
       
    69     {
       
    70     // Init layout for the graphic item
       
    71     iGraphicLayoutData->SetItemLayout(list_single_graphic_pane( 0 ));
       
    72     iGraphicLayoutData->SetIconLayout(list_single_graphic_pane_g1( 2 ));
       
    73     for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i)
       
    74         iGraphicLayoutData->SetTitleLayout( i, list_single_graphic_pane_t1( i ));
       
    75     iGraphicLayoutData->SetFirstIndicatorLayout(list_single_graphic_pane_g3(0));
       
    76     iGraphicLayoutData->SetSecondIndicatorLayout(list_single_graphic_pane_g2(1));
       
    77 
       
    78     // Get the Row rect.
       
    79     TAknLayoutRect layout;
       
    80     layout.LayoutRect(ListRect(), iGraphicLayoutData->ItemLayout());
       
    81 
       
    82     // Icon rect.
       
    83     TAknLayoutRect image;
       
    84     image.LayoutRect(layout.Rect(), iLayoutData->IconLayout());
       
    85     iImageSize = image.Rect().Size();
       
    86 
       
    87     // Call base implementation
       
    88     CHgSingleTextList::HandleSizeChanged();    
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CHgSingleTextList::DrawItem()
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CHgSingleTextListWithIcon::DrawItem( TInt aIndex, const TRect& aRect ) const
       
    96     {
       
    97     // Get the Icon
       
    98     CHgItem* item = iItems[aIndex];
       
    99     if( !item->Icon() )
       
   100         {
       
   101         // Let single text list handle the normal item drawing.
       
   102         CHgSingleTextList::DrawItem( aIndex, aRect );
       
   103         return;
       
   104         }
       
   105             
       
   106     // Highlight the row if it's selected
       
   107     TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags());
       
   108     
       
   109     CWindowGc& gc = SystemGc();
       
   110     
       
   111     TRgb color = iColor;
       
   112     if( aIndex == iSelectedIndex )
       
   113         {
       
   114         DrawHighlight( aRect, color );
       
   115         
       
   116         // Draw first line text
       
   117         iDrawUtils->DrawTextMarquee(
       
   118                 gc,
       
   119                 aRect, 
       
   120                 iGraphicLayoutData->TitleLayout(indicators),
       
   121                 item->Title(),
       
   122                 color, 0);
       
   123         
       
   124         ResetClippingRect( gc );
       
   125         }
       
   126     else
       
   127         {
       
   128         // Draw first line text
       
   129         iDrawUtils->DrawText(
       
   130                 gc,
       
   131                 aRect, 
       
   132                 iGraphicLayoutData->TitleLayout(indicators),
       
   133                 item->Title(),
       
   134                 color);
       
   135         }
       
   136 
       
   137     iDrawUtils->DrawImage(gc, aRect, iGraphicLayoutData->IconLayout(), *item->Icon() );
       
   138     
       
   139     // Draw the indicators.
       
   140     iIndicatorManager->DrawIndicators(
       
   141             gc,
       
   142             aRect, 
       
   143             item->Flags(), 
       
   144             iGraphicLayoutData->FirstIndicatorLayout(), 
       
   145             iGraphicLayoutData->SecondIndicatorLayout() );  
       
   146    }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CHgSingleTextList::CHgSingleTextList()
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 CHgSingleTextListWithIcon::CHgSingleTextListWithIcon( TInt aItemCount, 
       
   153                                       CGulIcon* aDefaultIcon )
       
   154 : CHgSingleTextList( aItemCount, aDefaultIcon )
       
   155     {
       
   156     SetFlags( EHgScrollerFlatStatusPane ); // Set Flat status pane on
       
   157     }
       
   158 
       
   159 void CHgSingleTextListWithIcon::ConstructL( const TRect& aRect, RWsSession* aSession )
       
   160     {
       
   161     iGraphicLayoutData = CHgListLayoutData::NewL();
       
   162     CHgList::ConstructL( aRect, aSession );
       
   163     }
       
   164 
       
   165 
       
   166 // EOF