idlehomescreen/widgetmanager/src/wmlistbox.cpp
changeset 1 5315654608de
child 2 08c6ee43b396
equal deleted inserted replaced
0:f72a12da539e 1:5315654608de
       
     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 * Implementation of the widget listbox for WidgetManager
       
    16 *
       
    17 */
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <coemain.h>
       
    21 #include <StringLoader.h>
       
    22 #include <aknstyluspopupmenu.h> 
       
    23 #include <AknsDrawUtils.h>
       
    24 #include <AknsFrameBackgroundControlContext.h>
       
    25 #include <AknsListBoxBackgroundControlContext.h>
       
    26 #include <aknlayout.cdl.h>
       
    27 #include <layoutmetadata.cdl.h>
       
    28 #include <aknlayoutscalable_avkon.cdl.h>
       
    29 #include <aknlayoutscalable_apps.cdl.h>
       
    30 #include <AknLayout.lag>
       
    31 #include <widgetmanagerview.rsg>
       
    32 #include <widgetmanager.mbg>
       
    33 #include "wmcommon.h"
       
    34 #include "wmplugin.h"
       
    35 #include "wmresourceloader.h"
       
    36 #include "wmlistbox.h"
       
    37 #include "wmwidgetdata.h"
       
    38 
       
    39 // CONSTANTS
       
    40 
       
    41 // MEMBER FUNCTIONS
       
    42 
       
    43 // ---------------------------------------------------------
       
    44 // CWmListItemDrawer::NewL
       
    45 // ---------------------------------------------------------
       
    46 //
       
    47 CWmListItemDrawer* CWmListItemDrawer::NewL(
       
    48         CWmPlugin& aWmPlugin,
       
    49         MTextListBoxModel* aTextListBoxModel,  
       
    50         const CFont* aFont,  
       
    51         CFormattedCellListBoxData* aFormattedCellData,
       
    52         CWmListBox* aListBox  )
       
    53     {
       
    54     CWmListItemDrawer* self = new ( ELeave ) CWmListItemDrawer(
       
    55             aWmPlugin,
       
    56             aTextListBoxModel,
       
    57             aFont,
       
    58             aFormattedCellData,
       
    59             aListBox );
       
    60     CleanupStack::PushL(self);   
       
    61     self->ConstructL();
       
    62     CleanupStack::Pop(self);
       
    63     return self;
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------
       
    67 // CWmListItemDrawer::CWmListItemDrawer
       
    68 // ---------------------------------------------------------
       
    69 //
       
    70 CWmListItemDrawer::CWmListItemDrawer(
       
    71         CWmPlugin& aWmPlugin,
       
    72         MTextListBoxModel* aTextListBoxModel,  
       
    73         const CFont* aFont,  
       
    74         CFormattedCellListBoxData* aFormattedCellData,
       
    75         CWmListBox* aListBox )
       
    76     : CFormattedCellListBoxItemDrawer( aTextListBoxModel,aFont,aFormattedCellData ),
       
    77     iWmPlugin( aWmPlugin )
       
    78 	{    
       
    79     iCellData = aFormattedCellData;
       
    80     iListBox = aListBox;
       
    81     iFont = aFont;
       
    82 	}
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CWmListItemDrawer::ConstructL
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 void CWmListItemDrawer::ConstructL()
       
    89     {
       
    90     SetSkinEnabledL( ETrue );
       
    91     
       
    92     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    93     AknsUtils::CreateIconL(
       
    94             skin,
       
    95             KAknsIIDQgnMenuHswidget,
       
    96             iDefaultLogoImage,
       
    97             iDefaultLogoImageMask,
       
    98             iWmPlugin.ResourceLoader().IconFilePath(),
       
    99             EMbmWidgetmanagerQgn_menu_hswidget,
       
   100             EMbmWidgetmanagerQgn_menu_hswidget_mask
       
   101             );
       
   102 	
       
   103     AknsUtils::CreateColorIconL(
       
   104             skin,
       
   105             KAknsIIDQgnIndiWmAdd,
       
   106             KAknsIIDQsnTextColors,
       
   107             EAknsCIQsnTextColorsCG6,
       
   108             iAddWidgetBtnImage,
       
   109             iAddWidgetBtnMask,
       
   110             iWmPlugin.ResourceLoader().IconFilePath(),
       
   111             EMbmWidgetmanagerAdd_widget_button,
       
   112             EMbmWidgetmanagerAdd_widget_button_mask,
       
   113             KRgbBlack );
       
   114 
       
   115     AknsUtils::CreateColorIconL(
       
   116             skin,
       
   117             KAknsIIDQgnIndiWmAdd,
       
   118             KAknsIIDQsnTextColors,
       
   119             EAknsCIQsnTextColorsCG10,
       
   120             iAddWidgetBtnHighlightImage,
       
   121             iAddWidgetBtnHighlightMask,
       
   122             iWmPlugin.ResourceLoader().IconFilePath(),
       
   123             EMbmWidgetmanagerAdd_widget_button,
       
   124             EMbmWidgetmanagerAdd_widget_button_mask,
       
   125             KRgbWhite );
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------
       
   129 // CWmListItemDrawer::~CWmListItemDrawer
       
   130 // ---------------------------------------------------------
       
   131 //
       
   132 CWmListItemDrawer::~CWmListItemDrawer()
       
   133 	{
       
   134     iCellData = NULL;
       
   135     iListBox = NULL;
       
   136 
       
   137     // dispose icons
       
   138     delete iDefaultLogoImage;
       
   139     delete iDefaultLogoImageMask;
       
   140     delete iAddWidgetBtnImage;
       
   141     delete iAddWidgetBtnMask;
       
   142     delete iAddWidgetBtnHighlightImage;
       
   143     delete iAddWidgetBtnHighlightMask;
       
   144 	}
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // CWmListItemDrawer::ResizeDefaultBitmaps
       
   148 // ---------------------------------------------------------
       
   149 //
       
   150 void CWmListItemDrawer::ResizeDefaultBitmaps()
       
   151     {
       
   152 	TAknWindowLineLayout logoPane = 
       
   153 	          AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine();
       
   154     TAknWindowLineLayout addPane = 
       
   155               AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine();
       
   156     TAknLayoutRect layoutRect;
       
   157     TRect rect = TRect( ItemCellSize() );
       
   158     layoutRect.LayoutRect( rect, logoPane );
       
   159     
       
   160     // RESIZE DEFAULT LOGO BITMAPS ACCORDING TO LAYOUT
       
   161     TSize size = layoutRect.Rect().Size();
       
   162     AknIconUtils::SetSize( 
       
   163         iDefaultLogoImage, size, EAspectRatioPreserved );
       
   164     AknIconUtils::SetSize( 
       
   165         iDefaultLogoImageMask, size, EAspectRatioPreserved );
       
   166     
       
   167     // RESIZE ADD BTN BITMAPS ACCORDING TO LAYOUT
       
   168     layoutRect.LayoutRect( rect, addPane );
       
   169     size = layoutRect.Rect().Size();
       
   170     AknIconUtils::SetSize( 
       
   171         iAddWidgetBtnImage, size, EAspectRatioPreserved );
       
   172     AknIconUtils::SetSize( 
       
   173         iAddWidgetBtnMask, size, EAspectRatioPreserved );
       
   174     AknIconUtils::SetSize( 
       
   175         iAddWidgetBtnHighlightImage, size, EAspectRatioPreserved );
       
   176     AknIconUtils::SetSize( 
       
   177         iAddWidgetBtnHighlightMask, size, EAspectRatioPreserved );
       
   178     }
       
   179 	
       
   180 // ---------------------------------------------------------
       
   181 // CWmListItemDrawer::DrawItem
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CWmListItemDrawer::DrawItem( TInt aItemIndex, TPoint aItemRectPos, 
       
   185                             TBool aItemIsSelected, TBool aItemIsCurrent, 
       
   186                             TBool aViewIsEmphasized, TBool aViewIsDimmed ) const
       
   187     {
       
   188     TSize cellSize = ItemCellSize();
       
   189     
       
   190     CWmWidgetData& wData = iListBox->WidgetData( aItemIndex );
       
   191     // Get graphics context which is used for drawing.
       
   192     CWindowGc& gc = *Gc();
       
   193     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   194     TInt selectedIndex = iListBox->CurrentItemIndex();
       
   195     TBool isInFocus = ( selectedIndex == aItemIndex );
       
   196     TBool listFocused = iListBox->IsFocused();
       
   197     TRect itemRect = TRect( aItemRectPos, cellSize );
       
   198 
       
   199     if ( isInFocus && listFocused )
       
   200         {
       
   201         // force baseclass to draw highlight and animation for this item
       
   202         CFormattedCellListBoxItemDrawer::DrawItemText( 
       
   203                 aItemIndex, itemRect,
       
   204                 aItemIsCurrent, aViewIsEmphasized,
       
   205                 ( isInFocus || aItemIsSelected ) );
       
   206 		
       
   207 		if ( iListBox->PressedDown() )
       
   208 			{
       
   209 			TRect innerRect( itemRect );
       
   210     	    const TInt highlightOffset = 3;
       
   211 	        innerRect.Shrink( highlightOffset, highlightOffset );
       
   212 			AknsDrawUtils::DrawFrame( skin,
       
   213                                       gc,
       
   214                                       itemRect,
       
   215                                       innerRect,
       
   216                                       KAknsIIDQsnFrListPressed,
       
   217                                       KAknsIIDQsnFrListCenterPressed );
       
   218 			}
       
   219         }
       
   220     else
       
   221         {
       
   222         // to prevent item staying highlighted when list isn't focused.
       
   223         CFormattedCellListBoxItemDrawer::DrawEmptyItem( 
       
   224                                 aItemIndex, aItemRectPos, aViewIsDimmed );
       
   225         }
       
   226 
       
   227     
       
   228     // DRAW LOGO
       
   229     CFbsBitmap* bitmap = const_cast<CFbsBitmap*>(wData.LogoImage());
       
   230     CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask());
       
   231     TAknLayoutRect logoLayout;
       
   232     logoLayout.LayoutRect( itemRect,
       
   233              AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
       
   234 
       
   235     if ( !bitmap )
       
   236         {
       
   237         logoLayout.DrawImage( gc, iDefaultLogoImage, iDefaultLogoImageMask );
       
   238         }
       
   239     else
       
   240         {
       
   241         logoLayout.DrawImage( gc, bitmap, mask );
       
   242         }
       
   243 
       
   244     TRgb textColor;
       
   245     TAknsQsnTextColorsIndex index = ( isInFocus && listFocused )? 
       
   246                 EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6;
       
   247 
       
   248     AknsUtils::GetCachedColor( 
       
   249                     skin, textColor, KAknsIIDQsnTextColors, index );
       
   250 
       
   251     // DRAW TEXT
       
   252     gc.UseFont( iFont );
       
   253     gc.SetPenColor( textColor );
       
   254     gc.SetPenSize( TSize(2,2) );
       
   255 
       
   256     TAknTextLineLayout titleTextLayout = 
       
   257               AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine();
       
   258     TAknTextLineLayout descTextLayout =
       
   259             AknLayoutScalable_Apps::listrow_wgtman_pane_t2().LayoutLine();
       
   260 
       
   261     TAknLayoutText textLayout;
       
   262     textLayout.LayoutText( itemRect, titleTextLayout );
       
   263     textLayout.DrawText( gc, wData.Name(), ETrue, textColor );
       
   264     
       
   265     if ( wData.HsContentInfo().CanBeAdded() )
       
   266         {
       
   267         // DRAW ADD BUTTON
       
   268         TAknLayoutRect addButtonLayout;
       
   269         addButtonLayout.LayoutRect( itemRect,
       
   270                 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() );
       
   271         if ( isInFocus && listFocused )
       
   272             {
       
   273             addButtonLayout.DrawImage( gc,                    
       
   274                     iAddWidgetBtnHighlightImage, iAddWidgetBtnHighlightMask );
       
   275             }
       
   276         else
       
   277             {
       
   278             addButtonLayout.DrawImage( gc, 
       
   279                     iAddWidgetBtnImage, iAddWidgetBtnMask );
       
   280             }        
       
   281         }
       
   282 
       
   283     gc.SetPenSize(TSize(1,1));
       
   284 
       
   285     // DRAW DESCRIPTION TEXT
       
   286     textLayout.LayoutText( itemRect, descTextLayout );
       
   287     textLayout.DrawText( gc, wData.Description(), ETrue, textColor );
       
   288     gc.DiscardFont();
       
   289     }
       
   290 
       
   291 // ---------------------------------------------------------
       
   292 // CWmListItemDrawer::DefaultLogoImage()
       
   293 // ---------------------------------------------------------
       
   294 //
       
   295 const CFbsBitmap* CWmListItemDrawer::DefaultLogoImage()
       
   296     {
       
   297     return iDefaultLogoImage;
       
   298     }
       
   299 
       
   300 // ---------------------------------------------------------
       
   301 // CWmListItemDrawer::DefaultLogoMask()
       
   302 // ---------------------------------------------------------
       
   303 //
       
   304 const CFbsBitmap* CWmListItemDrawer::DefaultLogoMask()
       
   305     {
       
   306     return iDefaultLogoImageMask;
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------
       
   310 // CWmListItemDrawer::HandleSkinChanged
       
   311 // ---------------------------------------------------------
       
   312 //
       
   313 void CWmListItemDrawer::HandleSkinChanged()
       
   314     {
       
   315     CFbsBitmap* addWidgetBtnImage( NULL );
       
   316     CFbsBitmap* addWidgetBtnMask( NULL );
       
   317     CFbsBitmap* addWidgetBtnHighlightImage( NULL );
       
   318     CFbsBitmap* addWidgetBtnHighlightMask( NULL );
       
   319     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   320     
       
   321     TRAPD( err, 
       
   322         AknsUtils::CreateColorIconLC(
       
   323                 skin,
       
   324                 KAknsIIDQgnIndiWmAdd,
       
   325                 KAknsIIDQsnTextColors,
       
   326                 EAknsCIQsnTextColorsCG6,
       
   327                 addWidgetBtnImage,
       
   328                 addWidgetBtnMask,
       
   329                 iWmPlugin.ResourceLoader().IconFilePath(),
       
   330                 EMbmWidgetmanagerAdd_widget_button,
       
   331                 EMbmWidgetmanagerAdd_widget_button_mask,
       
   332                 KRgbBlack );
       
   333         
       
   334         AknsUtils::CreateColorIconLC(
       
   335                 skin,
       
   336                 KAknsIIDQgnIndiWmAdd,
       
   337                 KAknsIIDQsnTextColors,
       
   338                 EAknsCIQsnTextColorsCG10,
       
   339                 addWidgetBtnHighlightImage,
       
   340                 addWidgetBtnHighlightMask,
       
   341                 iWmPlugin.ResourceLoader().IconFilePath(),
       
   342                 EMbmWidgetmanagerAdd_widget_button,
       
   343                 EMbmWidgetmanagerAdd_widget_button_mask,
       
   344                 KRgbWhite );
       
   345         
       
   346         CleanupStack::Pop( 4 ); // pop icons
       
   347         );
       
   348     
       
   349     if ( KErrNone == err )
       
   350         {
       
   351         // delete old icons
       
   352         delete iAddWidgetBtnImage;
       
   353         iAddWidgetBtnImage = NULL;
       
   354         delete iAddWidgetBtnMask;
       
   355         iAddWidgetBtnMask = NULL;
       
   356         delete iAddWidgetBtnHighlightImage;
       
   357         iAddWidgetBtnHighlightImage = NULL;
       
   358         delete iAddWidgetBtnHighlightMask;
       
   359         iAddWidgetBtnHighlightMask = NULL;
       
   360         
       
   361         // transfer ownership
       
   362         iAddWidgetBtnImage = addWidgetBtnImage;
       
   363         addWidgetBtnImage = NULL;
       
   364         iAddWidgetBtnMask = addWidgetBtnMask;
       
   365         addWidgetBtnMask = NULL;
       
   366         iAddWidgetBtnHighlightImage = addWidgetBtnHighlightImage;
       
   367         addWidgetBtnHighlightImage = NULL;
       
   368         iAddWidgetBtnHighlightMask = addWidgetBtnHighlightMask;
       
   369         addWidgetBtnHighlightMask = NULL;
       
   370         
       
   371         // resize new created icons
       
   372         ResizeDefaultBitmaps();
       
   373         }
       
   374     }
       
   375 
       
   376 // ---------------------------------------------------------
       
   377 // CWmListBox::NewL
       
   378 // ---------------------------------------------------------
       
   379 //
       
   380 CWmListBox* CWmListBox::NewL(
       
   381         CWmPlugin& aWmPlugin,
       
   382         const TRect& aRect,
       
   383         const CCoeControl* aParent,
       
   384         TInt aFlags )
       
   385     {
       
   386     CWmListBox* self = new ( ELeave ) CWmListBox( aWmPlugin);
       
   387     CleanupStack::PushL( self );
       
   388     self->ConstructL( aRect, aParent, aFlags );
       
   389     CleanupStack::Pop( self );
       
   390     return self;
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------
       
   394 // CWmListBox::CWmListBox
       
   395 // ---------------------------------------------------------
       
   396 //
       
   397 CWmListBox::CWmListBox( CWmPlugin& aWmPlugin ):
       
   398     CAknDouble2LargeStyleListBox(),
       
   399     iWmPlugin( aWmPlugin )
       
   400     {
       
   401     iFindPaneIsVisible = EFalse;
       
   402 	iPressedDown = EFalse;
       
   403     }
       
   404 
       
   405 // ---------------------------------------------------------
       
   406 // CWmListBox::~CWmListBox
       
   407 // ---------------------------------------------------------
       
   408 //
       
   409 CWmListBox::~CWmListBox()
       
   410     {
       
   411     iWidgetDatas.ResetAndDestroy();
       
   412     }
       
   413 
       
   414 // ---------------------------------------------------------
       
   415 // CWmListBox::ConstructL
       
   416 // ---------------------------------------------------------
       
   417 //
       
   418 void CWmListBox::ConstructL(
       
   419         const TRect& aRect,
       
   420         const CCoeControl* aParent,
       
   421         TInt aFlags )
       
   422     {
       
   423     CEikFormattedCellListBox::ConstructL( aParent, aFlags );
       
   424     SetContainerWindowL( *aParent );    
       
   425 
       
   426     // set model point to the widgets array
       
   427     Model()->SetItemTextArray( &iWidgetDatas );
       
   428     Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   429 
       
   430     // set empty-text to null
       
   431     View()->SetListEmptyTextL( KNullDesC );
       
   432 
       
   433     SetRect( aRect );
       
   434     }
       
   435 
       
   436 // ---------------------------------------------------------
       
   437 // CWmListBox::WidgetData
       
   438 // ---------------------------------------------------------
       
   439 //
       
   440 CWmWidgetData* CWmListBox::WidgetData()
       
   441     {
       
   442     TInt index = CurrentListBoxItemIndex();
       
   443     return (index>=0 ? iWidgetDatas[index] : NULL);
       
   444     }
       
   445 
       
   446 // ---------------------------------------------------------
       
   447 // CWmListBox::WidgetData
       
   448 // ---------------------------------------------------------
       
   449 //
       
   450 CWmWidgetData& CWmListBox::WidgetData( TInt aItemIndex )
       
   451     {
       
   452     return *iWidgetDatas[ RealIndex( aItemIndex ) ];
       
   453     }
       
   454 
       
   455 // ---------------------------------------------------------
       
   456 // CWmListBox::AddWidgetDataL
       
   457 // ---------------------------------------------------------
       
   458 //
       
   459 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData )
       
   460     {
       
   461     aWidgetData->SetObserver( this );
       
   462     aWidgetData->SetLogoSize( LogoSize() );
       
   463     iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData,
       
   464             SortOrder(EStoredOrder) );
       
   465     HandleItemAdditionL();
       
   466     }
       
   467 
       
   468 // ---------------------------------------------------------
       
   469 // CWmListBox::RemoveWidgetData
       
   470 // ---------------------------------------------------------
       
   471 //
       
   472 void CWmListBox::RemoveWidgetData( TInt aItemIndex )
       
   473     {
       
   474     TInt realIndex = RealIndex( aItemIndex );
       
   475     TBool current = ( aItemIndex == CurrentItemIndex() );
       
   476     // remove widget data
       
   477     CWmWidgetData* data = iWidgetDatas[realIndex];
       
   478     iWidgetDatas.Remove( realIndex );
       
   479     delete data;
       
   480 
       
   481     // reorganise
       
   482     TRAP_IGNORE(
       
   483         AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
       
   484             this, realIndex, current ) );
       
   485     }
       
   486 
       
   487 // ---------------------------------------------------------
       
   488 // CWmListBox::RedrawItem
       
   489 // ---------------------------------------------------------
       
   490 //
       
   491 void CWmListBox::RedrawItem( TInt aItemIndex )
       
   492     {
       
   493     View()->DrawItem( aItemIndex );
       
   494     }
       
   495 
       
   496 // ---------------------------------------------------------
       
   497 // CWmListBox::SetSortOrderL
       
   498 // ---------------------------------------------------------
       
   499 //
       
   500 void CWmListBox::SetSortOrderL( TSortOrder aOrder )
       
   501     {
       
   502     // now sort the existing data
       
   503     iWidgetDatas.Sort( SortOrder( aOrder ) );
       
   504     DrawNow();
       
   505     }
       
   506 
       
   507 // ---------------------------------------------------------
       
   508 // CWmListBox::CreateItemDrawerL
       
   509 // ---------------------------------------------------------
       
   510 //
       
   511 void CWmListBox::CreateItemDrawerL()
       
   512     {
       
   513     CFormattedCellListBoxData* cellData = CFormattedCellListBoxData::NewL();
       
   514     CleanupStack::PushL( cellData );
       
   515     iItemDrawer = CWmListItemDrawer::NewL(
       
   516             iWmPlugin,
       
   517             Model(),
       
   518             iEikonEnv->DenseFont(),
       
   519             cellData,
       
   520             this );
       
   521     CleanupStack::Pop(); // cellData
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------
       
   525 // CWmListBox::HandleLayoutChanged
       
   526 // ---------------------------------------------------------
       
   527 //
       
   528 void CWmListBox::HandleLayoutChanged()
       
   529     {
       
   530 	TSize ls = LogoSize();
       
   531     for ( TInt i=0; i<iWidgetDatas.Count(); i++)
       
   532         {
       
   533         iWidgetDatas[i]->ReCreateLogo( ls );
       
   534         }
       
   535     }
       
   536 
       
   537 // ---------------------------------------------------------
       
   538 // CWmListBox::HandleSkinChanged
       
   539 // ---------------------------------------------------------
       
   540 //
       
   541 void CWmListBox::HandleSkinChanged()
       
   542     {
       
   543     CWmListItemDrawer* itemDrawer = 
       
   544                         static_cast <CWmListItemDrawer*>( iItemDrawer );
       
   545     if ( itemDrawer )
       
   546         {
       
   547         itemDrawer->HandleSkinChanged();
       
   548         }
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------
       
   552 // CWmListBox::HandleWidgetDataChanged
       
   553 // ---------------------------------------------------------
       
   554 //
       
   555 void CWmListBox::HandleWidgetDataChanged( CWmWidgetData* aWidgetData )
       
   556     {
       
   557     if ( !iFindPaneIsVisible )
       
   558         {
       
   559         // spontaneous change in the model. Cause table to redraw
       
   560         TInt index = iWidgetDatas.Find( aWidgetData );
       
   561         if ( index >= 0 )
       
   562             {
       
   563             // redraw item.
       
   564             RedrawItem( RealIndex( index ) );			
       
   565             }
       
   566         }
       
   567     else
       
   568         {
       
   569         // redraw everything
       
   570         Parent()->DrawDeferred();
       
   571         }
       
   572     }
       
   573 
       
   574 // ---------------------------------------------------------
       
   575 // CWmListBox::SortOrder
       
   576 // ---------------------------------------------------------
       
   577 //
       
   578 TLinearOrder<CWmWidgetData> CWmListBox::SortOrder( TSortOrder aOrder )
       
   579     {
       
   580     if ( aOrder == EStoredOrder )
       
   581         {
       
   582         return TLinearOrder<CWmWidgetData>(
       
   583                 CWmWidgetData::CompareByPersistentWidgetOrder );
       
   584         }
       
   585     else
       
   586         {
       
   587         return TLinearOrder<CWmWidgetData>(
       
   588                 CWmWidgetData::CompareByName );
       
   589         }
       
   590     }
       
   591 
       
   592 // ---------------------------------------------------------
       
   593 // CWmListBox::CurrentListBoxItemIndex
       
   594 // ---------------------------------------------------------
       
   595 //
       
   596 TInt CWmListBox::CurrentListBoxItemIndex()
       
   597     {
       
   598     TInt index( KErrNotFound );
       
   599     if ( Model()->NumberOfItems() > 0 )
       
   600         {
       
   601         index = CurrentItemIndex();
       
   602         }
       
   603     return RealIndex( index );
       
   604     }
       
   605 
       
   606 // ---------------------------------------------------------
       
   607 // CWmListBox::RealIndex
       
   608 // ---------------------------------------------------------
       
   609 //
       
   610 TInt CWmListBox::RealIndex( TInt aIndex )
       
   611     {
       
   612     TInt realIndex = aIndex;
       
   613     if ( iFindPaneIsVisible && aIndex >= 0 )
       
   614         {
       
   615         realIndex = static_cast<CAknFilteredTextListBoxModel*>(Model())->Filter()
       
   616                 ->FilteredItemIndex( aIndex );
       
   617         }
       
   618     return realIndex;    
       
   619     }
       
   620 
       
   621 // ---------------------------------------------------------
       
   622 // CWmListBox::SizeChanged
       
   623 // ---------------------------------------------------------
       
   624 //
       
   625 void CWmListBox::SizeChanged()
       
   626     {
       
   627     CAknDouble2LargeStyleListBox::SizeChanged();
       
   628     
       
   629     CWmListItemDrawer* itemDrawer = 
       
   630                     static_cast <CWmListItemDrawer*>( iItemDrawer );
       
   631     if ( itemDrawer )
       
   632         {
       
   633         return itemDrawer->ResizeDefaultBitmaps();
       
   634         }
       
   635     }
       
   636 
       
   637 // ---------------------------------------------------------
       
   638 // CWmListBox::Draw
       
   639 // ---------------------------------------------------------
       
   640 //
       
   641 void CWmListBox::Draw( const TRect& aRect ) const
       
   642     {
       
   643     CWindowGc& gc = SystemGc(); 
       
   644     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   645     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   646     AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
   647     CAknDouble2LargeStyleListBox::Draw( aRect );
       
   648     }
       
   649 
       
   650 // ---------------------------------------------------------
       
   651 // CWmListBox::HandlePointerEventL
       
   652 // ---------------------------------------------------------
       
   653 //
       
   654 void CWmListBox::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   655     {
       
   656 	// Check if pointer is down ( needed for drawing correct hightlight frame )
       
   657 	if ( Rect().Contains( aPointerEvent.iPosition ) )
       
   658 		{
       
   659 		if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
   660 			{
       
   661 			iPressedDown = ETrue;
       
   662 			RedrawItem( CurrentListBoxItemIndex() );
       
   663 			}
       
   664 		else if( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
   665 			{
       
   666 			iPressedDown = EFalse;
       
   667 			RedrawItem( CurrentListBoxItemIndex() );
       
   668 			}
       
   669 		}
       
   670 
       
   671 	CAknDouble2LargeStyleListBox::HandlePointerEventL( aPointerEvent );	
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------
       
   675 // CWmListBox::LogoSize
       
   676 // ---------------------------------------------------------
       
   677 //
       
   678 TSize CWmListBox::LogoSize()
       
   679     {
       
   680     TAknLayoutRect rowLayoutRect;
       
   681     rowLayoutRect.LayoutRect( Rect(),
       
   682             AknLayoutScalable_Apps::listrow_wgtman_pane().LayoutLine() );
       
   683     TAknLayoutRect logoLayoutRect;
       
   684     logoLayoutRect.LayoutRect( rowLayoutRect.Rect(),
       
   685             AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
       
   686     return logoLayoutRect.Rect().Size();
       
   687     }
       
   688 
       
   689 // ---------------------------------------------------------
       
   690 // CWmListBox::DefaultLogo
       
   691 // ---------------------------------------------------------
       
   692 //
       
   693 const CFbsBitmap* CWmListBox::DefaultLogo()
       
   694     {
       
   695     CWmListItemDrawer* itemDrawer = 
       
   696                     static_cast <CWmListItemDrawer*>( iItemDrawer );
       
   697     if ( itemDrawer )
       
   698         {
       
   699         return itemDrawer->DefaultLogoImage();
       
   700         }
       
   701     return NULL;
       
   702     }
       
   703 
       
   704 // ---------------------------------------------------------
       
   705 // CWmListBox::DefaultMask
       
   706 // ---------------------------------------------------------
       
   707 //
       
   708 const CFbsBitmap* CWmListBox::DefaultMask()
       
   709     {
       
   710     CWmListItemDrawer* itemDrawer = 
       
   711                     static_cast <CWmListItemDrawer*>( iItemDrawer );
       
   712     if ( itemDrawer )
       
   713         {
       
   714         return itemDrawer->DefaultLogoMask();
       
   715         }
       
   716     return NULL;
       
   717     }
       
   718 
       
   719 // End of File
       
   720