uifw/ganes/src/HgSingleGraphicList.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/HgSingleGraphicList.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 #include <AknsUtils.h>
       
    28 #include <AknUtils.h>
       
    29 #include <AknsDrawUtils.h>
       
    30 
       
    31 #include <layoutmetadata.cdl.h>
       
    32 #include <aknlayoutscalable_avkon.cdl.h>
       
    33 #include <gulicon.h>
       
    34 
       
    35 using namespace AknLayoutScalable_Avkon;
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CHgSingleGraphicList::NewL()
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CHgSingleGraphicList* CHgSingleGraphicList::NewL(
       
    42         const TRect& aRect, 
       
    43         TInt aItemCount, 
       
    44         CGulIcon* aDefaultIcon,
       
    45         RWsSession* aSession)
       
    46     {
       
    47     CHgSingleGraphicList* self = new ( ELeave ) CHgSingleGraphicList( 
       
    48             aItemCount, 
       
    49             aDefaultIcon );
       
    50 
       
    51     CleanupStack::PushL (self );
       
    52     self->ConstructL( aRect, aSession );
       
    53     CleanupStack::Pop (self );
       
    54     return self;
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // CHgSingleGraphicList::~CHgSingleGraphicList()
       
    59 // -----------------------------------------------------------------------------
       
    60 //
       
    61 EXPORT_C CHgSingleGraphicList::~CHgSingleGraphicList( )
       
    62     {
       
    63     
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CHgSingleGraphicList::PreferredImageSize()
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 EXPORT_C TSize CHgSingleGraphicList::PreferredImageSize()
       
    71     {
       
    72     TAknLayoutRect image;
       
    73     image.LayoutRect(TRect(), AknLayoutScalable_Avkon::list_single_graphic_pane_g1( 0 ));
       
    74     return image.Rect().Size();
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CHgSingleGraphicList::HandleSizeChanged()
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 void CHgSingleGraphicList::HandleSizeChanged()
       
    82     {
       
    83     CHgList::HandleSizeChanged();
       
    84     
       
    85     iLayoutData->SetItemLayout(list_single_graphic_pane( 0 ));
       
    86     iLayoutData->SetIconLayout(list_single_graphic_pane_g1( 2 ));
       
    87     for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i)
       
    88         iLayoutData->SetTitleLayout( i, list_single_graphic_pane_t1( i ));
       
    89     iLayoutData->SetFirstIndicatorLayout(list_single_graphic_pane_g3(0));
       
    90     iLayoutData->SetSecondIndicatorLayout(list_single_graphic_pane_g2(1));
       
    91 
       
    92     // Get the Row rect.
       
    93     TAknLayoutRect layout;
       
    94     layout.LayoutRect(ListRect(), iLayoutData->ItemLayout());
       
    95     iRowHeight = layout.Rect().Height();
       
    96 
       
    97     // Icon rect.
       
    98     TAknLayoutRect image;
       
    99     image.LayoutRect(layout.Rect(), iLayoutData->IconLayout());
       
   100     iImageSize = image.Rect().Size();
       
   101 
       
   102     // Indicator Rect.
       
   103     TAknLayoutRect indicator;
       
   104     indicator.LayoutRect(layout.Rect(), iLayoutData->FirstIndicatorLayout());
       
   105     iIndicatorSize = indicator.Rect().Size();
       
   106 
       
   107     iItemsOnScreen = iHeight / iRowHeight;
       
   108     iHeight = iItemsOnScreen * iRowHeight;
       
   109     
       
   110     if( iCurrentRow != KErrNotFound )
       
   111         FitTopItemToView( iCurrentRow );
       
   112     }
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // CHgDoubleGraphicList::DrawItem()
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CHgSingleGraphicList::DrawItem( TInt aIndex, const TRect& aRect ) const
       
   119     {
       
   120     // Get the Icon
       
   121     CHgItem* item = iItems[aIndex];
       
   122     CGulIcon* icon = item->Icon() ? item->Icon() : iDefaultIcon;
       
   123     // Highlight the row if it's selected
       
   124     TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags());
       
   125     
       
   126     CWindowGc& gc = SystemGc();
       
   127     
       
   128     TRgb color = iColor;
       
   129     if( aIndex == iSelectedIndex )
       
   130         {
       
   131         DrawHighlight( aRect, color );
       
   132 
       
   133         // Draw first line text
       
   134         iDrawUtils->DrawTextMarquee(
       
   135                 gc,
       
   136                 aRect, 
       
   137                 iLayoutData->TitleLayout(indicators),
       
   138                 item->Title(),
       
   139                 color, 0);
       
   140 
       
   141         ResetClippingRect( gc );
       
   142         }
       
   143     else
       
   144         {
       
   145         // Draw first line text
       
   146         iDrawUtils->DrawText(
       
   147                 gc,
       
   148                 aRect, 
       
   149                 iLayoutData->TitleLayout(indicators),
       
   150                 item->Title(),
       
   151                 color);
       
   152         }
       
   153     
       
   154     // Draw the icon
       
   155     iDrawUtils->DrawImage(gc, aRect, iLayoutData->IconLayout(), *icon);
       
   156     
       
   157     // Draw the indicators.
       
   158     iIndicatorManager->DrawIndicators(
       
   159             gc,
       
   160             aRect, 
       
   161             item->Flags(), 
       
   162             iLayoutData->FirstIndicatorLayout(), 
       
   163             iLayoutData->SecondIndicatorLayout() );            
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CHgSingleGraphicList::CHgSingleGraphicList()
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 CHgSingleGraphicList::CHgSingleGraphicList( TInt aItemCount, 
       
   171         CGulIcon* aDefaultIcon )
       
   172 : CHgList( aItemCount, aDefaultIcon )
       
   173     {
       
   174     
       
   175     }
       
   176 
       
   177 // End of file