uifw/ganes/src/HgDoubleTextList.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/HgDoubleTextList.h>
       
    20 #include <ganes/HgItem.h>
       
    21 
       
    22 #include "HgMarquee.h"
       
    23 #include "HgLayoutData.h"
       
    24 #include "HgIndicatorManager.h"
       
    25 #include "HgDrawUtils.h"
       
    26 #include "HgConstants.h"
       
    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 // CHgDoubleTextList::NewL()
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 EXPORT_C CHgDoubleTextList* CHgDoubleTextList::NewL(
       
    43         const TRect& aRect, 
       
    44         TInt aItemCount, 
       
    45         CGulIcon* aDefaultIcon,
       
    46         RWsSession* aSession)
       
    47     {
       
    48     CHgDoubleTextList* self = new ( ELeave ) CHgDoubleTextList( 
       
    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 // CHgDoubleTextList::~CHgDoubleTextList()
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C CHgDoubleTextList::~CHgDoubleTextList( )
       
    63     {
       
    64     
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CHgDoubleTextList::PreferredImageSize()
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 EXPORT_C TSize CHgDoubleTextList::PreferredImageSize()
       
    72     {
       
    73     return TSize(0,0);
       
    74     }
       
    75 
       
    76 // -----------------------------------------------------------------------------
       
    77 // CHgDoubleTextList::HandleSizeChanged()
       
    78 // -----------------------------------------------------------------------------
       
    79 //
       
    80 void CHgDoubleTextList::HandleSizeChanged()
       
    81     {
       
    82     // Call base implementation
       
    83     CHgList::HandleSizeChanged();
       
    84 
       
    85     iLayoutData->SetItemLayout(list_double_pane( 0 ));
       
    86     for(TInt i = 0; i <= KMaxNumberOfTitleIndicators; ++i)
       
    87         iLayoutData->SetTitleLayout(i, list_double_pane_t1( i ));
       
    88     iLayoutData->SetTextLayout(list_double_pane_t2( 2 ));
       
    89     iLayoutData->SetFirstIndicatorLayout(list_double_pane_g2(0));
       
    90     iLayoutData->SetSecondIndicatorLayout(list_double_pane_g1(1));
       
    91     
       
    92     // Get the Row rect.
       
    93     TAknLayoutRect layout;
       
    94     layout.LayoutRect(ListRect(), iLayoutData->ItemLayout());
       
    95     iRowHeight = layout.Rect().Height();
       
    96 
       
    97     // Indicator Rect.
       
    98     TAknLayoutRect indicator;
       
    99     indicator.LayoutRect(layout.Rect(), iLayoutData->FirstIndicatorLayout() );
       
   100     iIndicatorSize = indicator.Rect().Size();
       
   101     
       
   102     // Calculate the items on the screen.
       
   103     iItemsOnScreen = iHeight / iRowHeight;
       
   104     iHeight = iItemsOnScreen * iRowHeight;
       
   105 
       
   106     if( iCurrentRow != KErrNotFound )
       
   107         FitTopItemToView( iCurrentRow );    
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CHgDoubleTextList::DrawItem()
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 void CHgDoubleTextList::DrawItem( TInt aIndex, const TRect& aRect ) const
       
   115     {
       
   116     // Get the Icon
       
   117     CHgItem* item = iItems[aIndex];
       
   118     TInt indicators = CHgIndicatorManager::CountIndicators(item->Flags());
       
   119     
       
   120     CWindowGc& gc = SystemGc();
       
   121     
       
   122     // Highlight the row if it's selected
       
   123     TRgb color = iColor;
       
   124     if( aIndex == iSelectedIndex )
       
   125         {
       
   126         DrawHighlight( aRect, color );
       
   127 
       
   128         // Draw first line text
       
   129         iDrawUtils->DrawTextMarquee(
       
   130                 gc,
       
   131                 aRect, 
       
   132                 iLayoutData->TitleLayout(indicators),
       
   133                 item->Title(),
       
   134                 color, 0);
       
   135 
       
   136         // Draw second line text
       
   137         iDrawUtils->DrawTextMarquee(
       
   138                 gc,
       
   139                 aRect, 
       
   140                 iLayoutData->TextLayout(),
       
   141                 item->Text(),
       
   142                 color, 1);
       
   143 
       
   144         ResetClippingRect( gc );
       
   145         }
       
   146     else
       
   147         {
       
   148         // Draw first line text
       
   149         iDrawUtils->DrawText(
       
   150                 gc,
       
   151                 aRect, 
       
   152                 iLayoutData->TitleLayout(indicators),
       
   153                 item->Title(),
       
   154                 color);
       
   155         
       
   156         // Draw second line text
       
   157         iDrawUtils->DrawText(
       
   158                 gc,
       
   159                 aRect, 
       
   160                 iLayoutData->TextLayout(),
       
   161                 item->Text(),
       
   162                 color);
       
   163         
       
   164         }
       
   165     
       
   166     // Draw the indicators.
       
   167     iIndicatorManager->DrawIndicators(
       
   168             gc,
       
   169             aRect, 
       
   170             item->Flags(), 
       
   171             iLayoutData->FirstIndicatorLayout(), 
       
   172             iLayoutData->SecondIndicatorLayout() );            
       
   173     }
       
   174 
       
   175 // -----------------------------------------------------------------------------
       
   176 // CHgDoubleTextList::CHgDoubleTextList()
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 CHgDoubleTextList::CHgDoubleTextList( TInt aItemCount, 
       
   180                                             CGulIcon* aDefaultIcon )
       
   181 : CHgList( aItemCount, aDefaultIcon )
       
   182     {
       
   183     
       
   184     }
       
   185