internetradio2.0/uicontrolssrc/iradvertisinglistbox.cpp
changeset 0 09774dfdd46b
equal deleted inserted replaced
-1:000000000000 0:09774dfdd46b
       
     1 /*
       
     2 * Copyright (c) 2008-2008 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:  Listbox implementation supporting bitmap advertisement.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <gulicon.h>
       
    20 #include <stringloader.h>
       
    21 #include <internetradio.rsg>
       
    22 #include <aknbiditextutils.h> 
       
    23 #include <aknlayoutscalable_avkon.cdl.h>
       
    24 #include <aknutils.h> 
       
    25 
       
    26 #include "irui.h"
       
    27 #include "irdebug.h"
       
    28 #include "irfavoritesdb.h"
       
    29 #include "irmainview.h"
       
    30 #include "irmaincontainer.h"
       
    31 #include "iradvertisinglistbox.h"
       
    32 
       
    33 const TInt KThree = 3;
       
    34 const TInt KFour = 4;
       
    35 const TInt KSix = 6;
       
    36 const TInt KTen = 10;
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CIRAdvertisingListBoxData::NewL
       
    40 // ---------------------------------------------------------------------------
       
    41 //
       
    42 CIRAdvertisingListBoxData* CIRAdvertisingListBoxData::NewL()
       
    43     {
       
    44     CIRAdvertisingListBoxData* self = new (ELeave) CIRAdvertisingListBoxData();
       
    45     CleanupStack::PushL( self );
       
    46     self->ConstructLD();
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CIRAdvertisingListBoxData::SetAdvertisementIcon
       
    53 // ---------------------------------------------------------------------------
       
    54 //
       
    55 void CIRAdvertisingListBoxData::SetAdvertisementIcon( CGulIcon* aIcon )
       
    56     {
       
    57     delete iIcon;
       
    58     iIcon = aIcon;
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 // CIRAdvertisingListBoxData::AdvertisementIcon
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CGulIcon* CIRAdvertisingListBoxData::AdvertisementIcon()
       
    66     {
       
    67     return iIcon;
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------------------------
       
    71 // CIRAdvertisingListBoxData::SetControlFlag
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CIRAdvertisingListBoxData::SetControlFlag(TBool aControlFlag)
       
    75     {
       
    76     iControlFlag = aControlFlag;
       
    77     }
       
    78 // ---------------------------------------------------------------------------
       
    79 // CIRAdvertisingListBoxData::GetControlFlag
       
    80 // ---------------------------------------------------------------------------
       
    81 //
       
    82 TBool CIRAdvertisingListBoxData::GetControlFlag()
       
    83     {
       
    84     return iControlFlag;
       
    85     }
       
    86 // ---------------------------------------------------------------------------
       
    87 // CIRAdvertisingListBoxData::CIRAdvertisingListBoxData
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CIRAdvertisingListBoxData::CIRAdvertisingListBoxData()
       
    91     {
       
    92     }
       
    93 // ---------------------------------------------------------
       
    94 // CIRAdvertisingListBoxData::DrawNoMatchesText
       
    95 // Draws the NoMatches Text on the view
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CIRAdvertisingListBoxData::DrawEmptyListL(CWindowGc &aGc,
       
    99 											   TPtrC aText,
       
   100 											   TRect aParentRect) const 
       
   101 	{
       
   102     IRLOG_DEBUG( "CIRAdvertisingListBoxData::DrawEmptyListL - Entering" );
       
   103     
       
   104 	MAknsSkinInstance* skin = AknsUtils::SkinInstance () ;
       
   105 
       
   106 
       
   107     TRgb color( KRgbBlack );
       
   108     if ( AknsUtils::AvkonSkinEnabled() )
       
   109         {
       
   110         TRgb c;
       
   111         MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   112         TInt err = AknsUtils::GetCachedColor( skin,
       
   113                                               c,
       
   114                                               KAknsIIDQsnTextColors,
       
   115                                               EAknsCIQsnTextColorsCG6 );
       
   116         if ( !err )
       
   117             {
       
   118             color = c;
       
   119             }
       
   120         }
       
   121 
       
   122 	
       
   123     if ( !aText.Length() )
       
   124         {
       
   125         return;
       
   126         }
       
   127 
       
   128     HBufC* hbuf = HBufC::New( aText.Size() + 3 * ( KAknBidiExtraSpacePerLine  +1 )
       
   129                               + KTen );  // reserve space for newlines
       
   130     if ( !hbuf )
       
   131         { // can't really do anything
       
   132         return;
       
   133         }
       
   134 
       
   135     TPtr buffer(hbuf->Des());
       
   136     
       
   137 
       
   138     /*
       
   139     * input text can be either
       
   140     * - "line1"
       
   141     * - "line1 which will be wrapped to 2 lines and truncated with..."
       
   142     * - "line1\nline2"
       
   143     * - "line1\nMany other lines which will be wrapped to several lines"
       
   144     *
       
   145     * there are 3 layouts
       
   146     * - 1 line with big font,
       
   147     * - 2 lines with big font
       
   148     * - 1 line with big font + 1..3 lines with small font (not for popup lists)
       
   149     *
       
   150     *  so first we need to check if given text has a newline,
       
   151     *  if so, then we need to check if given text fits to 2 lines or
       
   152     *  should it be split to several small font lines
       
   153     */
       
   154 
       
   155     TInt i, n;
       
   156     n = 0;
       
   157     for (i = 0; i < aText.Length(); i ++)
       
   158         {
       
   159         if ( aText[i] == '\n' )
       
   160             {
       
   161             n++;
       
   162             }
       
   163         }
       
   164 
       
   165     
       
   166     TAknTextComponentLayout layout1( AknLayoutScalable_Avkon::main_pane_empty_t1( 0 ) );
       
   167     TAknTextComponentLayout layout2( AknLayoutScalable_Avkon::main_pane_empty_t2( 0 ) );
       
   168     TAknLayoutText line1;
       
   169     TAknLayoutText line2;
       
   170 
       
   171     line1.LayoutText( aParentRect, layout1 );
       
   172     TInt line1length = line1.TextRect().Size().iWidth;
       
   173 
       
   174     line2.LayoutText( aParentRect, layout2 ); 
       
   175     TInt line2length = line2.TextRect().Size().iWidth;
       
   176 
       
   177     const CFont *font = line1.Font();
       
   178 
       
   179     if ( n == 0 )
       
   180         { // one line, or one line which will be wrapped to two
       
   181         DrawEmptyListDrawUpToTwoLinesL( aGc,aText, line1, line2,
       
   182                                                  line1length, line2length,
       
   183                                                  font, color, buffer,
       
   184                                                  aParentRect );
       
   185 
       
   186         delete hbuf;
       
   187         return;
       
   188         }
       
   189     
       
   190     CArrayFix<TInt>* wrapWidthArray = new( ELeave ) CArrayFixFlat<TInt>(KTen);
       
   191     CleanupStack::PushL( wrapWidthArray );
       
   192 
       
   193     wrapWidthArray->AppendL( line1length );
       
   194     wrapWidthArray->AppendL( line2length );
       
   195     wrapWidthArray->AppendL( line2length ); // allow wrap to 3 lines
       
   196     
       
   197     TRAPD( error,AknBidiTextUtils::ConvertToVisualAndWrapToStringL(
       
   198         aText, *wrapWidthArray, *font, buffer, ETrue ));
       
   199 
       
   200     CleanupStack::PopAndDestroy(wrapWidthArray); 
       
   201 
       
   202 
       
   203     n = 0;
       
   204     for ( i = 0; i < buffer.Length(); i ++)
       
   205         {
       
   206         if (buffer[i] == '\n')
       
   207             {
       
   208             n++;
       
   209             }
       
   210         }
       
   211 
       
   212     // wrapping adds a \n to end of each line --> n < 3
       
   213     
       
   214     if ( error != KErrNone || n < KThree)
       
   215         { // 2 lines which fit to 2 line space
       
   216         DrawEmptyListDrawUpToTwoLinesL( aGc,aText, line1, line2,
       
   217                                                  line1length, line2length,
       
   218                                                  font, color, buffer,
       
   219                                                  aParentRect );
       
   220 
       
   221         }
       
   222     else
       
   223         { // 1 line with big font + 1..3 lines with small font
       
   224         DrawEmptyListDrawMoreThanTwoLinesL( aGc,aParentRect, aText,
       
   225         											 color, buffer );
       
   226 
       
   227         }
       
   228 
       
   229     delete hbuf;
       
   230    
       
   231     IRLOG_DEBUG( "CIRAdvertisingListBoxData::DrawEmptyListL - Exiting" );
       
   232 	}   
       
   233 // ---------------------------------------------------------
       
   234 // CIRAdvertisingListBoxData::DrawEmptyListDrawUpToTwoLines
       
   235 // 
       
   236 // ---------------------------------------------------------
       
   237 //
       
   238 void CIRAdvertisingListBoxData::DrawEmptyListDrawUpToTwoLinesL(CWindowGc &aGc,
       
   239 											  TPtrC aText,
       
   240                                               TAknLayoutText &aLine1,
       
   241                                               TAknLayoutText &aLine2,
       
   242                                               TInt aLine1length,
       
   243                                               TInt aLine2length,
       
   244                                               const CFont* aFont,
       
   245                                               TRgb aColor,
       
   246                                               TDes& aBuffer,
       
   247                                               TRect aParentRect) const 
       
   248     {
       
   249     IRLOG_DEBUG("CIRAdvertisingListBoxData::DrawEmptyListDrawUpToTwoLinesL-Entering" );
       
   250     CArrayFix<TInt>* wrapWidthArray = new( ELeave ) CArrayFixFlat<TInt>(KTen);
       
   251     CleanupStack::PushL( wrapWidthArray );
       
   252 
       
   253     wrapWidthArray->AppendL( aLine1length );
       
   254     wrapWidthArray->AppendL( aLine2length );
       
   255     
       
   256     TRAPD( error,AknBidiTextUtils::ConvertToVisualAndWrapToStringL( 
       
   257         aText, *wrapWidthArray, *aFont, aBuffer, ETrue ));
       
   258     
       
   259     CleanupStack::PopAndDestroy(wrapWidthArray); 
       
   260     
       
   261     if ( error != KErrNone )
       
   262         {
       
   263         aBuffer = aText;
       
   264         }
       
   265     
       
   266     // Drawing text
       
   267     aGc.Reset();
       
   268     TBool oneline( EFalse );
       
   269     TPtrC ptr = aBuffer;
       
   270     TPtrC top = ptr;
       
   271     TInt off = ptr.Locate('\n');
       
   272     if ( off >= 0 )
       
   273         {
       
   274         top.Set(ptr.Left(off));
       
   275         ptr.Set(ptr.Mid(off+1));
       
   276 
       
   277         TInt off1 = ptr.Locate('\n');
       
   278         if ( off1 >= 0 )
       
   279             {
       
   280             ptr.Set(ptr.Left(off1));
       
   281             }
       
   282         else
       
   283             {
       
   284             oneline = ETrue;
       
   285             }
       
   286         }
       
   287     
       
   288     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   289     aGc.SetOpaque( ETrue ); // transparency off
       
   290 
       
   291     // no layout exist for popup list - mainpane layout is ok for X
       
   292     // coords, center vertically.  Also need to calculate vertical
       
   293     // position for mainpane lists, since laf is broken as designed.
       
   294     // If you don't believe this, try using laf values in phonebook.
       
   295     aGc.UseFont( aFont );
       
   296     aGc.SetPenColor( aColor );
       
   297     
       
   298     // center horizontally
       
   299     CGraphicsContext::TTextAlign textAlign( CGraphicsContext::ECenter );
       
   300     
       
   301     // center vertically
       
   302     TInt h = aParentRect.Height();
       
   303     TInt lineh = aLine1.TextRect().Height();
       
   304     TRect r1( aLine1.TextRect() );
       
   305     TRect r2( aLine2.TextRect() );
       
   306 
       
   307     // gap between lines - must be calculated this way, since no other
       
   308     // way really exists. Could be calculated from layout data, but
       
   309     // data is wrong, as 1st line is calculated from top of parent
       
   310     // rect, and 2nd line is calculated from bottom of the parent
       
   311     // rect. iAvkonAppUi->ClientRect() as parent rect would otherwise
       
   312     // be ok and give nice results, but in phonebook ClientRect() is
       
   313     // not what it should be - it is some strange amount too large.
       
   314     // This can not be fixed unless layout data is fixed to use only
       
   315     // top marginals.
       
   316     TInt lineGap( lineh / KSix );
       
   317 
       
   318     TInt m;  // // middle point of texts
       
   319     m = aParentRect.iTl.iY + h / 2;// + lineh + lineGap / 2;
       
   320     if ( oneline )
       
   321         {
       
   322         m += lineh / 2;
       
   323         }
       
   324     TInt b1( m - lineGap / 2 );           // bottom of 1st line
       
   325     TInt b2( m + lineh + lineGap / 2 );   // botton of 2nd line
       
   326     
       
   327     
       
   328     // rects of texts
       
   329     r1.iTl.iY = b1 - lineh;
       
   330     r1.iBr.iY = b1;
       
   331         
       
   332     r2.iTl.iY = b2 - lineh;
       
   333     r2.iBr.iY = b2;
       
   334         
       
   335 	TInt baseLineOffset = ((r1.iBr.iY - r1.iTl.iY - aFont->HeightInPixels())/2
       
   336 				+ aFont->AscentInPixels());
       
   337 
       
   338     aGc.DrawText( top, r1, baseLineOffset, textAlign );
       
   339     if ( !oneline )
       
   340         {
       
   341         aGc.DrawText( ptr, r2, baseLineOffset, textAlign );
       
   342         }
       
   343     
       
   344     
       
   345     aGc.DiscardFont();
       
   346     aGc.SetOpaque( EFalse ); // transparency back on
       
   347     IRLOG_DEBUG("CIRAdvertisingListBoxData::DrawEmptyListDrawUpToTwoLinesL-Exiting" );
       
   348     }    
       
   349 // ---------------------------------------------------------
       
   350 // CIRAdvertisingListBoxData::DrawEmptyListDrawMoreThanTwoLines
       
   351 // Draws the NoMatches Text on the view
       
   352 // ---------------------------------------------------------
       
   353 //
       
   354 void CIRAdvertisingListBoxData::DrawEmptyListDrawMoreThanTwoLinesL(CWindowGc &aGc,
       
   355 												  TRect &aParentRect,
       
   356                                                   TPtrC aText,
       
   357                                                   TRgb aColor,
       
   358                                                   TDes& buffer ) const
       
   359 
       
   360     {
       
   361     IRLOG_DEBUG("CIRAdvertisingListBoxData::DrawEmptyListDrawMoreThanTwoLinesL-Entering" );
       
   362     // fetch layouts
       
   363     TAknLayoutText line[KFour];
       
   364     
       
   365     line[0].LayoutText( aParentRect, AknLayoutScalable_Avkon::main_pane_empty_t1(2) );
       
   366     line[1].LayoutText( aParentRect, AknLayoutScalable_Avkon::main_pane_empty_t3(0) );
       
   367     line[2].LayoutText( aParentRect, AknLayoutScalable_Avkon::main_pane_empty_t4(0) );
       
   368     line[3].LayoutText( aParentRect, AknLayoutScalable_Avkon::main_pane_empty_t5(0) );
       
   369 
       
   370     TInt lineLength[KFour];
       
   371     TInt i;
       
   372     for ( i = 0; i < KFour; i++ )
       
   373         {
       
   374         lineLength[i] = line[i].TextRect().Width();
       
   375         }
       
   376     
       
   377     const CFont *bigFont = line[0].Font();
       
   378     const CFont *smallFont = line[1].Font(); 
       
   379 
       
   380     // wrap text
       
   381     TInt off = aText.Locate('\n');
       
   382     TPtrC rest( aText );
       
   383     rest.Set( aText.Right(aText.Length() - off - 1 ));
       
   384 
       
   385     HBufC* firstLine = NULL;
       
   386     
       
   387     TRAPD( error1, 
       
   388             {
       
   389             firstLine = HBufC::NewL(
       
   390                 aText.Left(off).Length() + KAknBidiExtraSpacePerLine );
       
   391             });
       
   392 
       
   393     if (error1 == KErrNone)
       
   394         {
       
   395         TPtr firstLinePtr = firstLine->Des();
       
   396         AknBidiTextUtils::ConvertToVisualAndClip(
       
   397                                 aText.Left(off),
       
   398                                 firstLinePtr,
       
   399                                 *bigFont,
       
   400                                 lineLength[0],
       
   401                                 lineLength[0] );
       
   402         }
       
   403     
       
   404     CArrayFix<TInt>* wrapWidthArray = new( ELeave ) CArrayFixFlat<TInt>(KTen);
       
   405     CleanupStack::PushL( wrapWidthArray );
       
   406     
       
   407     // wrap small font lines
       
   408     wrapWidthArray->Reset();
       
   409     for ( i = 1; i < KFour; i++ )
       
   410         {
       
   411 		TInt temp = lineLength[i];
       
   412 		if(wrapWidthArray->Count() >= 0  && wrapWidthArray->Count() < KTen)
       
   413 			{
       
   414 			wrapWidthArray->AppendL( temp );
       
   415 			}
       
   416         }
       
   417     
       
   418     TRAPD( error2,AknBidiTextUtils::ConvertToVisualAndWrapToStringL( 
       
   419         rest, *wrapWidthArray, *smallFont, buffer, ETrue ));
       
   420     
       
   421     CleanupStack::PopAndDestroy(wrapWidthArray);
       
   422     
       
   423     
       
   424     TPtrC ptr[KFour];
       
   425     TInt n = 0;
       
   426     
       
   427     if (error1 == KErrNone)
       
   428         {
       
   429         ptr[0].Set( firstLine->Des() );
       
   430         }
       
   431     if ( error1 != KErrNone || error2 != KErrNone )
       
   432         {
       
   433         ptr[0].Set(aText.Left(off));
       
   434         }
       
   435     else
       
   436         {
       
   437         TInt newlines[KThree];
       
   438         n = 0;
       
   439         for ( i = 0; i < buffer.Length(); i++ )
       
   440             {
       
   441             if ( buffer[i] != '\n' )
       
   442                 {
       
   443                 continue;
       
   444                 }
       
   445             newlines[n] = i;
       
   446             
       
   447             n++;
       
   448             if ( n >= KThree )
       
   449                 {
       
   450                 break;
       
   451                 }
       
   452             }
       
   453         
       
   454         if ( n >= 1 )
       
   455             {
       
   456             ptr[1].Set( buffer.Left( newlines[0] ) );
       
   457             }
       
   458         if ( n >= 2 )
       
   459             {
       
   460             ptr[2].Set( buffer.Mid( newlines[0] + 1, newlines[1] - newlines[0] - 1 ) );
       
   461             }
       
   462         if ( n >= KThree )
       
   463             {
       
   464             ptr[3].Set( buffer.Mid( newlines[1] + 1, newlines[2] - newlines[1] - 1 ) );
       
   465             }
       
   466         }
       
   467     
       
   468     // draw texts
       
   469     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   470     aGc.SetOpaque( ETrue ); // transparency off
       
   471     
       
   472     for ( i = 0; i < KFour; i++ )
       
   473         {
       
   474         line[i].DrawText( aGc,ptr[i], EFalse, aColor );
       
   475         }
       
   476  
       
   477     aGc.SetOpaque( EFalse ); // transparency back on  
       
   478     delete firstLine;
       
   479     IRLOG_DEBUG("CIRAdvertisingListBoxData::DrawEmptyListDrawMoreThanTwoLinesL-Exiting" );
       
   480 
       
   481     }
       
   482 
       
   483 // ---------------------------------------------------------------------------
       
   484 // CIRAdvertisingListBoxData::~CIRAdvertisingListBoxData
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 CIRAdvertisingListBoxData::~CIRAdvertisingListBoxData()
       
   488     {
       
   489     delete iIcon;
       
   490     }
       
   491 
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // CIRAdvertisingListBoxDrawer::CIRAdvertisingListBoxDrawer
       
   495 // ---------------------------------------------------------------------------
       
   496 //
       
   497 CIRAdvertisingListBoxDrawer::CIRAdvertisingListBoxDrawer( MTextListBoxModel* aTextListBoxModel,
       
   498                                                           const CFont* aFont,
       
   499                                                           CIRAdvertisingListBoxData* 
       
   500                                                           aFormattedCellData,
       
   501                                                           CIRAdvertisingListBox* aListBox,
       
   502                       									  CIRCategoryAdvertisingListBox* aCatListBox) 
       
   503     : CFormattedCellListBoxItemDrawer( aTextListBoxModel, aFont, aFormattedCellData ),
       
   504       iListBox(aListBox),
       
   505       iCatListBox(aCatListBox)
       
   506 
       
   507     {
       
   508     }
       
   509 // ---------------------------------------------------------------------------
       
   510 // CIRAdvertisingListBoxDrawer::DrawActualItem
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 void CIRAdvertisingListBoxDrawer::DrawActualItem( TInt aItemIndex, 
       
   514                                                   const TRect& aActualItemRect, 
       
   515                                                   TBool aItemIsCurrent, 
       
   516                                                   TBool aViewIsEmphasized, 
       
   517                                                   TBool aViewIsDimmed,
       
   518                                                   TBool aItemIsSelected) const
       
   519 	{
       
   520 	IRLOG_DEBUG( "CIRAdvertisingListBox::DrawActualItem - Entering" );
       
   521 	CIRAdvertisingListBoxData* formattedCellData = static_cast<CIRAdvertisingListBoxData*>
       
   522 														( FormattedCellData() );
       
   523 	if (aItemIndex == 0)
       
   524 		{
       
   525 		TBool flag(EFalse);
       
   526 		if (iListBox)
       
   527 			{
       
   528 			flag = iListBox->GetLastPlayed();
       
   529 			}
       
   530 		TBool selectedItem =aItemIsSelected;
       
   531 		if(flag)	
       
   532 			{
       
   533 			selectedItem = EFalse;	
       
   534 			}
       
   535 		CFormattedCellListBoxItemDrawer::DrawActualItem( aItemIndex, 
       
   536 		                                                 aActualItemRect, 
       
   537 		                                                 aItemIsCurrent, 
       
   538 		                                                 aViewIsEmphasized, 
       
   539 		                                                 aViewIsDimmed,
       
   540 		                                                 selectedItem);
       
   541 
       
   542 
       
   543 		// For MainView the folowing code is executed for hacking to make the
       
   544 		// (NoMatches) string to be visible. The icon used for drawing in main
       
   545 		// view is totally transparent, which makes it invisible.
       
   546 		if (aItemIndex == 0 && formattedCellData->AdvertisementIcon() )
       
   547 		    {
       
   548 		    const CFbsBitmap* bitmap = formattedCellData->AdvertisementIcon()->Bitmap();
       
   549 		    const CFbsBitmap* mask = formattedCellData->AdvertisementIcon()->Mask();
       
   550 		    TSize bitmapSize = bitmap->SizeInPixels();
       
   551 		    TRect maskRect;
       
   552 		    if ( mask )
       
   553 		        {
       
   554 		        maskRect.SetSize( mask->SizeInPixels() );
       
   555 		        }
       
   556 		    
       
   557 		    TPoint bitmapPos( aActualItemRect.iTl.iX + 
       
   558 		    				 (aActualItemRect.Width() - bitmapSize.iWidth)/2,
       
   559 		                      aActualItemRect.iTl.iY + 
       
   560 		                      (aActualItemRect.Height() - bitmapSize.iHeight)/2 );
       
   561 
       
   562 		    Gc()->BitBltMasked( bitmapPos, bitmap, maskRect, mask, EFalse );
       
   563 		    }
       
   564 
       
   565 		}
       
   566 	else
       
   567 		{
       
   568 		CFormattedCellListBoxItemDrawer::DrawActualItem( aItemIndex, 
       
   569 		                                                 aActualItemRect, 
       
   570 		                                                 aItemIsCurrent, 
       
   571 		                                                 aViewIsEmphasized, 
       
   572 		                                                 aViewIsDimmed,
       
   573 		                                                 aItemIsSelected);
       
   574 		}
       
   575 
       
   576 	IRLOG_DEBUG( "CIRAdvertisingListBox::DrawActualItem - Exiting" );
       
   577 	}
       
   578         
       
   579 // ---------------------------------------------------------------------------
       
   580 // CIRAdvertisingListBox::CIRAdvertisingListBox
       
   581 // ---------------------------------------------------------------------------
       
   582 //
       
   583 CIRAdvertisingListBox::CIRAdvertisingListBox()
       
   584     {
       
   585     }
       
   586 
       
   587 // ---------------------------------------------------------------------------
       
   588 // CIRAdvertisingListBox::SetGC
       
   589 // ---------------------------------------------------------------------------
       
   590 //
       
   591 void CIRAdvertisingListBox::SetGC(CWindowGc& aGc)
       
   592 	{
       
   593 	iGc = &aGc;	
       
   594 	}
       
   595 // ---------------------------------------------------------------------------
       
   596 // CIRAdvertisingListBox::SetControlFlag
       
   597 // ---------------------------------------------------------------------------
       
   598 //
       
   599 void CIRAdvertisingListBox::SetControlFlag(TBool aControlFlag)
       
   600 	{
       
   601     CIRAdvertisingListBoxData* irListBoxData = 
       
   602         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   603 	irListBoxData->SetControlFlag(aControlFlag);	
       
   604 	}
       
   605 // ---------------------------------------------------------------------------
       
   606 // CIRAdvertisingListBox::Draw
       
   607 // ---------------------------------------------------------------------------
       
   608 //
       
   609 void CIRAdvertisingListBox::Draw(const TRect& aRect) const 
       
   610 	{
       
   611     IRLOG_DEBUG( "CIRAdvertisingListBox::Draw - Entering" );
       
   612 	CAknDoubleLargeStyleListBox::Draw(aRect);
       
   613 	
       
   614     TInt count = Model()->NumberOfItems();
       
   615     CIRAdvertisingListBoxData* irListBoxData = 
       
   616         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   617 	if(irListBoxData->GetControlFlag())
       
   618 		{
       
   619 		if(GetActiveView())
       
   620 			{	
       
   621 			if(GetFavouritesCount() != 0)
       
   622 				{
       
   623 				if(count == 0 && !GetLastPlayed())
       
   624 					{
       
   625 					TRAP_IGNORE(View()->SetListEmptyTextL(*iNoMatchesTextResource));
       
   626 					}
       
   627 				else if(count == 1 && GetLastPlayed())
       
   628 					{
       
   629 					TRAP_IGNORE(irListBoxData->DrawEmptyListL(*iGc,*iNoMatchesTextResource,Rect()));	
       
   630 					}
       
   631 				}
       
   632 			else
       
   633 				{
       
   634 				if(GetLastPlayed())
       
   635 					{
       
   636 					TRAP_IGNORE(irListBoxData->DrawEmptyListL(*iGc,*iFindStationsTextResource,Rect()));	
       
   637 					}
       
   638 				else
       
   639 					{
       
   640 					TRAP_IGNORE(View()->SetListEmptyTextL(*iFindStationsTextResource));	
       
   641 					}
       
   642 				}
       
   643 			}
       
   644 		else
       
   645 			{
       
   646 			if(count == 1 && irListBoxData->AdvertisementIcon())
       
   647 				{
       
   648 				TRAP_IGNORE(irListBoxData->DrawEmptyListL(*iGc,*iNoMatchesTextResource,Rect()));	
       
   649 				}
       
   650 			else
       
   651 				{
       
   652 				TRAP_IGNORE(View()->SetListEmptyTextL(*iNoMatchesTextResource));
       
   653 				}
       
   654 			}
       
   655 		irListBoxData->SetControlFlag(EFalse);
       
   656 		}
       
   657 
       
   658     IRLOG_DEBUG( "CIRAdvertisingListBox::Draw - Exiting" );
       
   659     }
       
   660 // ---------------------------------------------------------------------------
       
   661 // CIRAdvertisingListBox::~CIRAdvertisingListBox
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 CIRAdvertisingListBox::~CIRAdvertisingListBox()
       
   665 	{
       
   666 	IRLOG_DEBUG( "CIRAdvertisingListBox::~CIRAdvertisingListBox - Entering" );
       
   667 	if(iFindStationsTextResource)
       
   668 		{
       
   669 		delete iFindStationsTextResource;
       
   670 		iFindStationsTextResource = NULL;
       
   671 		}
       
   672 	if(iNoMatchesTextResource)
       
   673 		{
       
   674 		delete iNoMatchesTextResource;
       
   675 		iNoMatchesTextResource = NULL;	
       
   676 		}
       
   677 	IRLOG_DEBUG( "CIRAdvertisingListBox::~CIRAdvertisingListBox - Exiting" );
       
   678 	}
       
   679 
       
   680 // ---------------------------------------------------------------------------
       
   681 // CIRAdvertisingListBox::SetListItemFormat
       
   682 // ---------------------------------------------------------------------------
       
   683 //
       
   684 void CIRAdvertisingListBox::SetListItemFormat(  HBufC* aItemFormat)
       
   685     {
       
   686     IRLOG_DEBUG( "CIRAdvertisingListBox::SetListItemFormat - Entering" );
       
   687 	iItemFormat = aItemFormat;
       
   688     }
       
   689 
       
   690 // ---------------------------------------------------------------------------
       
   691 // CIRAdvertisingListBox::SetAdvertisementIconL
       
   692 // ---------------------------------------------------------------------------
       
   693 //
       
   694 void CIRAdvertisingListBox::SetAdvertisementIconL( CGulIcon* aIcon,TBool aMainView )
       
   695     {
       
   696     IRLOG_DEBUG( "CIRAdvertisingListBox::SetAdvertisementIconL - Entering" );
       
   697     
       
   698     CIRAdvertisingListBoxData* irListBoxData = 
       
   699         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   700     
       
   701     // add listitem only, if it doesn't exist yet.
       
   702     if ( !aMainView && !irListBoxData->AdvertisementIcon() )
       
   703         {
       
   704         TInt currentItemIndex = CurrentItemIndex();
       
   705         TInt topItemIndex = TopItemIndex();
       
   706 
       
   707         
       
   708         CAknFilteredTextListBoxModel* listBoxModel = static_cast<CAknFilteredTextListBoxModel*>
       
   709         												( Model() );
       
   710         CDesCArraySeg* items = static_cast<CDesCArraySeg*>( listBoxModel->ItemTextArray() );
       
   711         items->InsertL( 0, *iItemFormat );
       
   712         
       
   713         HandleItemAdditionL();
       
   714         if ( currentItemIndex >= 0 )
       
   715             {
       
   716             SetCurrentItemIndex( currentItemIndex + 1 );
       
   717             }
       
   718         if ( topItemIndex > 0 )
       
   719             {
       
   720             SetTopItemIndex( topItemIndex + 1 );
       
   721             }
       
   722         }
       
   723     // always replace the existing image.
       
   724     irListBoxData->SetAdvertisementIcon( aIcon );
       
   725     
       
   726     DrawDeferred();     
       
   727     IRLOG_DEBUG( "CIRAdvertisingListBox::SetAdvertisementIconL - Exiting" );
       
   728     }
       
   729 
       
   730 // ---------------------------------------------------------------------------
       
   731 // CIRAdvertisingListBox::ClearAdvertisementIcon
       
   732 // ---------------------------------------------------------------------------
       
   733 //
       
   734 void CIRAdvertisingListBox::ClearAdvertisementIcon()
       
   735     {
       
   736     IRLOG_DEBUG( "CIRAdvertisingListBox::ClearAdvertisementIcon - Entering" );
       
   737    CIRAdvertisingListBoxData* irListBoxData = 
       
   738         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   739     irListBoxData->SetAdvertisementIcon( NULL );
       
   740     IRLOG_DEBUG( "CIRAdvertisingListBox::ClearAdvertisementIcon - Exiting" );
       
   741     }
       
   742 
       
   743 // ---------------------------------------------------------------------------
       
   744 // CIRAdvertisingListBox::AdvertisementIcon
       
   745 // ---------------------------------------------------------------------------
       
   746 //
       
   747 CGulIcon* CIRAdvertisingListBox::AdvertisementIcon()
       
   748     {
       
   749     IRLOG_DEBUG( "CIRAdvertisingListBox::AdvertisementIcon - Entering" );
       
   750   	CIRAdvertisingListBoxData* irListBoxData = 
       
   751         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   752     IRLOG_DEBUG( "CIRAdvertisingListBox::AdvertisementIcon - Exiting" );
       
   753     return irListBoxData->AdvertisementIcon();
       
   754     }
       
   755 
       
   756 // ---------------------------------------------------------------------------
       
   757 // CIRAdvertisingListBox::CreateItemDrawerL
       
   758 // ---------------------------------------------------------------------------
       
   759 //
       
   760 void CIRAdvertisingListBox::CreateItemDrawerL()
       
   761     {
       
   762     IRLOG_DEBUG( "CIRAdvertisingListBox::CreateItemDrawerL - Entering" );
       
   763     CIRAdvertisingListBoxData* formattedCellListBoxData = CIRAdvertisingListBoxData::NewL();
       
   764     CleanupStack::PushL( formattedCellListBoxData );
       
   765     const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimaryFont );
       
   766     
       
   767     iItemDrawer = new (ELeave) CIRAdvertisingListBoxDrawer( Model(), font,
       
   768                                                             formattedCellListBoxData,this, NULL );
       
   769     CleanupStack::Pop( formattedCellListBoxData );
       
   770     IRLOG_DEBUG( "CIRAdvertisingListBox::CreateItemDrawerL - Exiting" );
       
   771     }
       
   772 // --------------------------------------------------------------------------
       
   773 // CIRAdvertisingListBox::ConstructL()
       
   774 // 
       
   775 // --------------------------------------------------------------------------
       
   776 void CIRAdvertisingListBox::ConstructL(const CCoeControl* aParent, 
       
   777                     TInt aFlags,CAknFilteredTextListBoxModel* aFilteredmodel)
       
   778     {
       
   779     IRLOG_DEBUG( "CIRAdvertisingListBox::ConstructL - Entering" );
       
   780     iModel=aFilteredmodel;
       
   781     CreateItemDrawerL();
       
   782 
       
   783     EnableExtendedDrawingL();
       
   784     iItemDrawer->SetDrawMark(EFalse);
       
   785     
       
   786 	if(iFindStationsTextResource)
       
   787 		{
       
   788 		delete iFindStationsTextResource;
       
   789 		iFindStationsTextResource = NULL;
       
   790 		}
       
   791 	HBufC* findStationsTextResource = StringLoader::LoadLC(R_IRAPP_FAVOURITES_LIST_EMPTY);
       
   792 	iFindStationsTextResource = HBufC::NewL(findStationsTextResource->Length());
       
   793 	iFindStationsTextResource->Des().Append(findStationsTextResource->Des());
       
   794 	CleanupStack::PopAndDestroy( findStationsTextResource );
       
   795 	
       
   796 	if(iNoMatchesTextResource)
       
   797 		{
       
   798 		delete iNoMatchesTextResource;
       
   799 		iNoMatchesTextResource = NULL;	
       
   800 		}
       
   801 	HBufC* noMatchesTextResource = StringLoader::LoadLC(R_IRAPP_STATIONLIST_NOMATCHES);
       
   802 	iNoMatchesTextResource = HBufC::NewL(noMatchesTextResource->Length());
       
   803 	iNoMatchesTextResource->Des().Append(noMatchesTextResource->Des());
       
   804 	CleanupStack::PopAndDestroy( noMatchesTextResource );
       
   805 
       
   806     CEikListBox::ConstructL(aParent,aFlags);
       
   807     IRLOG_DEBUG( "CIRAdvertisingListBox::ConstructL - Exiting" );
       
   808     }
       
   809 // --------------------------------------------------------------------------
       
   810 // CIRAdvertisingListBox::SetLastPlayed()
       
   811 // sets the status of lastplayed
       
   812 // --------------------------------------------------------------------------
       
   813 void CIRAdvertisingListBox::SetLastPlayed(TBool aLastPlayed)
       
   814 	{
       
   815     IRLOG_DEBUG( "CIRAdvertisingListBox::SetLastPlayed " );
       
   816 	iLastPlayed = aLastPlayed;	
       
   817 	}
       
   818 
       
   819 // --------------------------------------------------------------------------
       
   820 // CIRAdvertisingListBox::GetLastPlayed()
       
   821 // return the status of lastplayed
       
   822 // --------------------------------------------------------------------------
       
   823 TBool  CIRAdvertisingListBox::GetLastPlayed() const
       
   824 	{
       
   825     IRLOG_DEBUG( "CIRAdvertisingListBox::GetLastPlayed " );
       
   826 	return iLastPlayed;	
       
   827 	}
       
   828 // --------------------------------------------------------------------------
       
   829 // CIRAdvertisingListBox::GetFavouritesCount()
       
   830 // returns the number of favourates present.
       
   831 // --------------------------------------------------------------------------
       
   832 TInt CIRAdvertisingListBox::GetFavouritesCount() const
       
   833 	{
       
   834     IRLOG_DEBUG( "CIRAdvertisingListBox::GetFavouritesCount " );
       
   835 	CIRUi* appUi = static_cast<CIRUi*>( iCoeEnv->AppUi() );
       
   836 	TInt favCount = appUi->iFavPresets->iFavPresetList.Count();
       
   837     IRLOG_DEBUG( "CIRAdvertisingListBox::GetFavouritesCount - Exiting" );
       
   838     return favCount;
       
   839 	}
       
   840 // --------------------------------------------------------------------------
       
   841 // CIRAdvertisingListBox::GetFavouritesCount()
       
   842 // returns the number of favourates present.
       
   843 // --------------------------------------------------------------------------
       
   844 TBool CIRAdvertisingListBox::GetFilteredFlag() const
       
   845 	{
       
   846     IRLOG_DEBUG( "CIRAdvertisingListBox::GetFavouritesCount " );
       
   847 	CIRUi* appUi = static_cast<CIRUi*>( iCoeEnv->AppUi() );
       
   848 	TBool flag = appUi->iMainView->GetMainContainer()->GetFilteredFlag();
       
   849     IRLOG_DEBUG( "CIRAdvertisingListBox::GetFavouritesCount - Exiting" );
       
   850     return flag;
       
   851 	}
       
   852 // --------------------------------------------------------------------------
       
   853 // CIRAdvertisingListBox::GetActiveView()
       
   854 // returns whether the active view is mainView or not.
       
   855 // --------------------------------------------------------------------------
       
   856 TBool CIRAdvertisingListBox::GetActiveView() const
       
   857 	{
       
   858     IRLOG_DEBUG( "CIRAdvertisingListBox::GetActiveView " );
       
   859 	CIRUi* appUi = static_cast<CIRUi*>( iCoeEnv->AppUi() );
       
   860     IRLOG_DEBUG( "CIRAdvertisingListBox::GetActiveView - Exiting" );
       
   861 	if(appUi->iMainView->GetMainContainer())
       
   862 		{
       
   863 		return ETrue;	
       
   864 		}
       
   865 	else
       
   866 		{
       
   867 		return EFalse;	
       
   868 		}
       
   869 	}
       
   870 /******************************Advertisement Listbox for Category View************/
       
   871 
       
   872 
       
   873 // ---------------------------------------------------------------------------
       
   874 // CIRCategoryAdvertisingListBox::CIRCategoryAdvertisingListBox
       
   875 // ---------------------------------------------------------------------------
       
   876 //
       
   877 CIRCategoryAdvertisingListBox::CIRCategoryAdvertisingListBox()
       
   878     {
       
   879     }
       
   880 
       
   881 // ---------------------------------------------------------------------------
       
   882 // CIRCategoryAdvertisingListBox::SetGC
       
   883 // ---------------------------------------------------------------------------
       
   884 //
       
   885 void CIRCategoryAdvertisingListBox::SetGC(CWindowGc& aGc)
       
   886 	{
       
   887 	iGc = &aGc;	
       
   888 	}
       
   889 // ---------------------------------------------------------------------------
       
   890 // CIRCategoryAdvertisingListBox::SetControlFlag
       
   891 // ---------------------------------------------------------------------------
       
   892 //
       
   893 void CIRCategoryAdvertisingListBox::SetControlFlag(TBool aControlFlag)
       
   894 	{
       
   895     CIRAdvertisingListBoxData* irListBoxData = 
       
   896         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   897 	irListBoxData->SetControlFlag(aControlFlag);	
       
   898 	}
       
   899 // ---------------------------------------------------------------------------
       
   900 // CIRCategoryAdvertisingListBox::Draw
       
   901 // ---------------------------------------------------------------------------
       
   902 //
       
   903 void CIRCategoryAdvertisingListBox::Draw(const TRect& aRect) const 
       
   904 	{
       
   905     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::Draw - Entering" );
       
   906 	CAknDoubleStyleListBox::Draw(aRect);
       
   907 
       
   908     TInt count = Model()->NumberOfItems();
       
   909     CIRAdvertisingListBoxData* irListBoxData = 
       
   910         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   911     if(irListBoxData->GetControlFlag())
       
   912 	    {
       
   913 	    if(count == 1 && irListBoxData->AdvertisementIcon())
       
   914 		    {
       
   915 			TRAP_IGNORE(irListBoxData->DrawEmptyListL(*iGc,*iTextResource,Rect()));	
       
   916 			}
       
   917 	    else if(count == 0)
       
   918 		    {
       
   919 			TRAP_IGNORE(View()->SetListEmptyTextL(*iTextResource));
       
   920 		    }
       
   921 		irListBoxData->SetControlFlag(EFalse);
       
   922 	    }
       
   923     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::Draw - Exiting" );
       
   924     }
       
   925 // ---------------------------------------------------------------------------
       
   926 // CIRCategoryAdvertisingListBox::~CIRCategoryAdvertisingListBox
       
   927 // ---------------------------------------------------------------------------
       
   928 //
       
   929 CIRCategoryAdvertisingListBox::~CIRCategoryAdvertisingListBox()
       
   930 	{
       
   931 	IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::~CIRCategoryAdvertisingListBox - Entering" );
       
   932 	if(iTextResource)
       
   933 		{
       
   934 		delete iTextResource;
       
   935 		iTextResource = NULL;
       
   936 		}
       
   937 	IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::~CIRCategoryAdvertisingListBox - Exiting" );
       
   938 	}
       
   939 
       
   940 // ---------------------------------------------------------------------------
       
   941 // CIRCategoryAdvertisingListBox::SetListItemFormat
       
   942 // ---------------------------------------------------------------------------
       
   943 //
       
   944 void CIRCategoryAdvertisingListBox::SetListItemFormat(  HBufC* aItemFormat )
       
   945     {
       
   946     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::SetListItemFormat - Entering" );
       
   947 	__ASSERT_ALWAYS( !iItemFormat, User::Panic( KNullDesC, KErrCorrupt ) );
       
   948     iItemFormat = aItemFormat;
       
   949     }
       
   950 
       
   951 // ---------------------------------------------------------------------------
       
   952 // CIRCategoryAdvertisingListBox::SetAdvertisementIconL
       
   953 // ---------------------------------------------------------------------------
       
   954 //
       
   955 void CIRCategoryAdvertisingListBox::SetAdvertisementIconL( CGulIcon* aIcon )
       
   956     {
       
   957     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::SetAdvertisementIconL - Entering" );
       
   958 	__ASSERT_ALWAYS( iItemFormat, User::Panic( KNullDesC, KErrCorrupt  ) );
       
   959     
       
   960     CIRAdvertisingListBoxData* irListBoxData = 
       
   961         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
   962     
       
   963     // add listitem only, if it doesn't exist yet.
       
   964     if ( !irListBoxData->AdvertisementIcon() )
       
   965         {
       
   966         TInt currentItemIndex = CurrentItemIndex();
       
   967         TInt topItemIndex = TopItemIndex();
       
   968 
       
   969      
       
   970         CAknFilteredTextListBoxModel* listBoxModel = static_cast<CAknFilteredTextListBoxModel*>
       
   971         											( Model() );
       
   972         CDesCArraySeg* items = static_cast<CDesCArraySeg*>( listBoxModel->ItemTextArray() );
       
   973         items->InsertL( 0, *iItemFormat );
       
   974         
       
   975         HandleItemAdditionL();
       
   976         if ( currentItemIndex >= 0 )
       
   977             {
       
   978             SetCurrentItemIndex( currentItemIndex + 1 );
       
   979             }
       
   980         if ( topItemIndex > 0 )
       
   981             {
       
   982             SetTopItemIndex( topItemIndex + 1 );
       
   983             }
       
   984         }
       
   985     // always replace the existing image.
       
   986     irListBoxData->SetAdvertisementIcon( aIcon );
       
   987     
       
   988     DrawDeferred();     
       
   989     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::SetAdvertisementIconL - Exiting" );
       
   990     }
       
   991 
       
   992 // ---------------------------------------------------------------------------
       
   993 // CIRCategoryAdvertisingListBox::ClearAdvertisementIcon
       
   994 // ---------------------------------------------------------------------------
       
   995 //
       
   996 void CIRCategoryAdvertisingListBox::ClearAdvertisementIcon()
       
   997     {
       
   998     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::ClearAdvertisementIcon - Entering" );
       
   999    CIRAdvertisingListBoxData* irListBoxData = 
       
  1000         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
  1001     irListBoxData->SetAdvertisementIcon( NULL );
       
  1002     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::ClearAdvertisementIcon - Exiting" );
       
  1003     }
       
  1004 
       
  1005 // ---------------------------------------------------------------------------
       
  1006 // CIRCategoryAdvertisingListBox::AdvertisementIcon
       
  1007 // ---------------------------------------------------------------------------
       
  1008 //
       
  1009 CGulIcon* CIRCategoryAdvertisingListBox::AdvertisementIcon()
       
  1010     {
       
  1011      IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::AdvertisementIcon - Entering" );
       
  1012   CIRAdvertisingListBoxData* irListBoxData = 
       
  1013         static_cast<CIRAdvertisingListBoxData*>( ItemDrawer()->FormattedCellData() );
       
  1014     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::AdvertisementIcon - Exiting" );
       
  1015     return irListBoxData->AdvertisementIcon();
       
  1016     }
       
  1017 
       
  1018 // ---------------------------------------------------------------------------
       
  1019 // CIRCategoryAdvertisingListBox::CreateItemDrawerL
       
  1020 // ---------------------------------------------------------------------------
       
  1021 //
       
  1022 void CIRCategoryAdvertisingListBox::CreateItemDrawerL()
       
  1023     {
       
  1024     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::CreateItemDrawerL - Entering" );
       
  1025     CIRAdvertisingListBoxData* formattedCellListBoxData = CIRAdvertisingListBoxData::NewL();
       
  1026     CleanupStack::PushL( formattedCellListBoxData );
       
  1027     const CFont* font = AknLayoutUtils::FontFromId( EAknLogicalFontPrimaryFont );
       
  1028     
       
  1029     iItemDrawer = new (ELeave) CIRAdvertisingListBoxDrawer( Model(), font,
       
  1030                                                             formattedCellListBoxData,NULL, this );
       
  1031     CleanupStack::Pop( formattedCellListBoxData );
       
  1032     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::CreateItemDrawerL - Exiting" );
       
  1033     }
       
  1034 // --------------------------------------------------------------------------
       
  1035 // CIRCategoryAdvertisingListBox::ConstructL()
       
  1036 // 
       
  1037 // --------------------------------------------------------------------------
       
  1038 void CIRCategoryAdvertisingListBox::ConstructL(const CCoeControl* aParent, 
       
  1039                     TInt aFlags,CAknFilteredTextListBoxModel* aFilteredmodel)
       
  1040     {
       
  1041     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::ConstructL - Entering" );
       
  1042     iModel=aFilteredmodel;
       
  1043     CreateItemDrawerL();
       
  1044 
       
  1045     EnableExtendedDrawingL();
       
  1046     iItemDrawer->SetDrawMark(EFalse);
       
  1047 
       
  1048 	if(iTextResource)
       
  1049 		{
       
  1050 		delete iTextResource;
       
  1051 		iTextResource = NULL;
       
  1052 		}
       
  1053 	HBufC* textResource = StringLoader::LoadLC(R_IRAPP_STATIONLIST_NOMATCHES);
       
  1054 	iTextResource = HBufC::NewL(textResource->Length());
       
  1055 	iTextResource->Des().Append(textResource->Des());
       
  1056 	CleanupStack::PopAndDestroy( textResource );
       
  1057 
       
  1058     CEikListBox::ConstructL(aParent,aFlags);
       
  1059     IRLOG_DEBUG( "CIRCategoryAdvertisingListBox::ConstructL - Exiting" );
       
  1060     }