idlehomescreen/widgetmanager/src/wmlistbox.cpp
changeset 2 08c6ee43b396
parent 1 5315654608de
child 4 4d54b72983ae
equal deleted inserted replaced
1:5315654608de 2:08c6ee43b396
    97             iDefaultLogoImageMask,
    97             iDefaultLogoImageMask,
    98             iWmPlugin.ResourceLoader().IconFilePath(),
    98             iWmPlugin.ResourceLoader().IconFilePath(),
    99             EMbmWidgetmanagerQgn_menu_hswidget,
    99             EMbmWidgetmanagerQgn_menu_hswidget,
   100             EMbmWidgetmanagerQgn_menu_hswidget_mask
   100             EMbmWidgetmanagerQgn_menu_hswidget_mask
   101             );
   101             );
   102 	
   102 
   103     AknsUtils::CreateColorIconL(
   103     AknsUtils::CreateColorIconL(
   104             skin,
   104             skin,
   105             KAknsIIDQgnIndiWmAdd,
   105             KAknsIIDQgnIndiWmAdd,
   106             KAknsIIDQsnTextColors,
   106             KAknsIIDQsnTextColors,
   107             EAknsCIQsnTextColorsCG6,
   107             EAknsCIQsnTextColorsCG6,
   230     CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask());
   230     CFbsBitmap* mask = const_cast<CFbsBitmap*>(wData.LogoImageMask());
   231     TAknLayoutRect logoLayout;
   231     TAknLayoutRect logoLayout;
   232     logoLayout.LayoutRect( itemRect,
   232     logoLayout.LayoutRect( itemRect,
   233              AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
   233              AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
   234 
   234 
   235     if ( !bitmap )
   235     if ( !bitmap && !wData.IsPrepairingLogo() )
   236         {
   236         {
   237         logoLayout.DrawImage( gc, iDefaultLogoImage, iDefaultLogoImageMask );
   237         logoLayout.DrawImage( gc, iDefaultLogoImage, iDefaultLogoImageMask );
   238         }
   238         }
   239     else
   239     else if( bitmap && mask )
   240         {
   240         {
   241         logoLayout.DrawImage( gc, bitmap, mask );
   241         logoLayout.DrawImage( gc, bitmap, mask );
   242         }
   242         }
   243 
   243 
   244     TRgb textColor;
   244     TRgb textColor;
   253     gc.SetPenColor( textColor );
   253     gc.SetPenColor( textColor );
   254     gc.SetPenSize( TSize(2,2) );
   254     gc.SetPenSize( TSize(2,2) );
   255 
   255 
   256     TAknTextLineLayout titleTextLayout = 
   256     TAknTextLineLayout titleTextLayout = 
   257               AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine();
   257               AknLayoutScalable_Apps::listrow_wgtman_pane_t1().LayoutLine();
   258     TAknTextLineLayout descTextLayout =
       
   259             AknLayoutScalable_Apps::listrow_wgtman_pane_t2().LayoutLine();
       
   260 
   258 
   261     TAknLayoutText textLayout;
   259     TAknLayoutText textLayout;
   262     textLayout.LayoutText( itemRect, titleTextLayout );
   260     textLayout.LayoutText( itemRect, titleTextLayout );
   263     textLayout.DrawText( gc, wData.Name(), ETrue, textColor );
   261     textLayout.DrawText( gc, wData.Name(), ETrue, textColor );
   264     
   262     
   265     if ( wData.HsContentInfo().CanBeAdded() )
   263     if ( !wData.IsUninstalling() &&
       
   264         wData.HsContentInfo().CanBeAdded() )
   266         {
   265         {
   267         // DRAW ADD BUTTON
   266         // DRAW ADD BUTTON
   268         TAknLayoutRect addButtonLayout;
   267         TAknLayoutRect addButtonLayout;
   269         addButtonLayout.LayoutRect( itemRect,
   268         addButtonLayout.LayoutRect( itemRect,
   270                 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() );
   269                 AknLayoutScalable_Apps::listrow_wgtman_pane_g2().LayoutLine() );
   278             addButtonLayout.DrawImage( gc, 
   277             addButtonLayout.DrawImage( gc, 
   279                     iAddWidgetBtnImage, iAddWidgetBtnMask );
   278                     iAddWidgetBtnImage, iAddWidgetBtnMask );
   280             }        
   279             }        
   281         }
   280         }
   282 
   281 
   283     gc.SetPenSize(TSize(1,1));
   282     if ( !wData.IsUninstalling() )
   284 
   283         {
   285     // DRAW DESCRIPTION TEXT
   284         TAknTextLineLayout descTextLayout =
   286     textLayout.LayoutText( itemRect, descTextLayout );
   285             AknLayoutScalable_Apps::listrow_wgtman_pane_t2().LayoutLine();
   287     textLayout.DrawText( gc, wData.Description(), ETrue, textColor );
   286         gc.SetPenSize(TSize(1,1));
       
   287         // DRAW DESCRIPTION TEXT
       
   288         textLayout.LayoutText( itemRect, descTextLayout );
       
   289         textLayout.DrawText( gc, wData.Description(), ETrue, textColor );
       
   290         }
       
   291     else
       
   292         {
       
   293         // draw animation
       
   294         TAknLayoutRect animationLayout;
       
   295         animationLayout.LayoutRect( itemRect,
       
   296              AknLayoutScalable_Apps::wait_bar_pane_cp09().LayoutLine() );
       
   297         TSize size = animationLayout.Rect().Size();
       
   298         CFbsBitmap* animBitmap = 
       
   299                 const_cast<CFbsBitmap*>(wData.AnimationBitmap( size ));
       
   300         CFbsBitmap* animMask = 
       
   301                 const_cast<CFbsBitmap*>(wData.AnimationMask( size ));
       
   302         if ( animBitmap && animMask )
       
   303             {
       
   304             animationLayout.DrawImage( gc, animBitmap, animMask );
       
   305             }
       
   306         }
   288     gc.DiscardFont();
   307     gc.DiscardFont();
   289     }
   308     }
   290 
   309 
   291 // ---------------------------------------------------------
   310 // ---------------------------------------------------------
   292 // CWmListItemDrawer::DefaultLogoImage()
   311 // CWmListItemDrawer::DefaultLogoImage()
   398     CAknDouble2LargeStyleListBox(),
   417     CAknDouble2LargeStyleListBox(),
   399     iWmPlugin( aWmPlugin )
   418     iWmPlugin( aWmPlugin )
   400     {
   419     {
   401     iFindPaneIsVisible = EFalse;
   420     iFindPaneIsVisible = EFalse;
   402 	iPressedDown = EFalse;
   421 	iPressedDown = EFalse;
       
   422 	iLogoSize = TSize( 0, 0);
   403     }
   423     }
   404 
   424 
   405 // ---------------------------------------------------------
   425 // ---------------------------------------------------------
   406 // CWmListBox::~CWmListBox
   426 // CWmListBox::~CWmListBox
   407 // ---------------------------------------------------------
   427 // ---------------------------------------------------------
   408 //
   428 //
   409 CWmListBox::~CWmListBox()
   429 CWmListBox::~CWmListBox()
   410     {
   430     {
   411     iWidgetDatas.ResetAndDestroy();
   431     iWidgetDatas.ResetAndDestroy();
       
   432     iTrashedData.ResetAndDestroy();
   412     }
   433     }
   413 
   434 
   414 // ---------------------------------------------------------
   435 // ---------------------------------------------------------
   415 // CWmListBox::ConstructL
   436 // CWmListBox::ConstructL
   416 // ---------------------------------------------------------
   437 // ---------------------------------------------------------
   454 
   475 
   455 // ---------------------------------------------------------
   476 // ---------------------------------------------------------
   456 // CWmListBox::AddWidgetDataL
   477 // CWmListBox::AddWidgetDataL
   457 // ---------------------------------------------------------
   478 // ---------------------------------------------------------
   458 //
   479 //
   459 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData )
   480 void CWmListBox::AddWidgetDataL( CWmWidgetData* aWidgetData,
       
   481         TBool aRedraw )
   460     {
   482     {
   461     aWidgetData->SetObserver( this );
   483     aWidgetData->SetObserver( this );
   462     aWidgetData->SetLogoSize( LogoSize() );
       
   463     iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData,
   484     iWidgetDatas.InsertInOrderAllowRepeatsL( aWidgetData,
   464             SortOrder(EStoredOrder) );
   485             SortOrder(EStoredOrder) );
   465     HandleItemAdditionL();
   486     if ( aRedraw ) { HandleItemAdditionL(); }
   466     }
   487     }
   467 
   488 
   468 // ---------------------------------------------------------
   489 // ---------------------------------------------------------
   469 // CWmListBox::RemoveWidgetData
   490 // CWmListBox::RemoveWidgetData
   470 // ---------------------------------------------------------
   491 // ---------------------------------------------------------
   474     TInt realIndex = RealIndex( aItemIndex );
   495     TInt realIndex = RealIndex( aItemIndex );
   475     TBool current = ( aItemIndex == CurrentItemIndex() );
   496     TBool current = ( aItemIndex == CurrentItemIndex() );
   476     // remove widget data
   497     // remove widget data
   477     CWmWidgetData* data = iWidgetDatas[realIndex];
   498     CWmWidgetData* data = iWidgetDatas[realIndex];
   478     iWidgetDatas.Remove( realIndex );
   499     iWidgetDatas.Remove( realIndex );
   479     delete data;
       
   480 
       
   481     // reorganise
   500     // reorganise
   482     TRAP_IGNORE(
   501     TRAP_IGNORE(
   483         AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
   502         AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
   484             this, realIndex, current ) );
   503             this, realIndex, current ) );
       
   504     
       
   505     // widgetlist changed notification comes too early before even
       
   506     // uninstall is completed. in wk04_2010 there is going to be fix 
       
   507     // available for this issue. add data object to trashed array so
       
   508     // that its not visible in list and is destroyed later.
       
   509     if ( data->IsUninstalling() && data->IsActive() )
       
   510         {
       
   511         iTrashedData.Append( data );
       
   512         }
       
   513     else
       
   514         {
       
   515         // delete now
       
   516         delete data;
       
   517         }
   485     }
   518     }
   486 
   519 
   487 // ---------------------------------------------------------
   520 // ---------------------------------------------------------
   488 // CWmListBox::RedrawItem
   521 // CWmListBox::RedrawItem
   489 // ---------------------------------------------------------
   522 // ---------------------------------------------------------
   517             Model(),
   550             Model(),
   518             iEikonEnv->DenseFont(),
   551             iEikonEnv->DenseFont(),
   519             cellData,
   552             cellData,
   520             this );
   553             this );
   521     CleanupStack::Pop(); // cellData
   554     CleanupStack::Pop(); // cellData
       
   555 
       
   556     // enable extended drawing
       
   557     EnableExtendedDrawingL();
   522     }
   558     }
   523 
   559 
   524 // ---------------------------------------------------------
   560 // ---------------------------------------------------------
   525 // CWmListBox::HandleLayoutChanged
   561 // CWmListBox::HandleLayoutChanged
   526 // ---------------------------------------------------------
   562 // ---------------------------------------------------------
   527 //
   563 //
   528 void CWmListBox::HandleLayoutChanged()
   564 void CWmListBox::HandleLayoutChanged()
   529     {
   565     {
   530 	TSize ls = LogoSize();
   566     iLogoSize = TSize( 0, 0);
       
   567 	iLogoSize = LogoSize();
   531     for ( TInt i=0; i<iWidgetDatas.Count(); i++)
   568     for ( TInt i=0; i<iWidgetDatas.Count(); i++)
   532         {
   569         {
   533         iWidgetDatas[i]->ReCreateLogo( ls );
   570         iWidgetDatas[i]->ReCreateLogo( iLogoSize );
   534         }
   571         }
   535     }
   572     }
   536 
   573 
   537 // ---------------------------------------------------------
   574 // ---------------------------------------------------------
   538 // CWmListBox::HandleSkinChanged
   575 // CWmListBox::HandleSkinChanged
   559         // spontaneous change in the model. Cause table to redraw
   596         // spontaneous change in the model. Cause table to redraw
   560         TInt index = iWidgetDatas.Find( aWidgetData );
   597         TInt index = iWidgetDatas.Find( aWidgetData );
   561         if ( index >= 0 )
   598         if ( index >= 0 )
   562             {
   599             {
   563             // redraw item.
   600             // redraw item.
   564             RedrawItem( RealIndex( index ) );			
   601             RedrawItem( RealIndex( index ) );
   565             }
   602             }
   566         }
   603         }
   567     else
   604     else
   568         {
   605         {
   569         // redraw everything
   606         // redraw everything
   675 // CWmListBox::LogoSize
   712 // CWmListBox::LogoSize
   676 // ---------------------------------------------------------
   713 // ---------------------------------------------------------
   677 //
   714 //
   678 TSize CWmListBox::LogoSize()
   715 TSize CWmListBox::LogoSize()
   679     {
   716     {
   680     TAknLayoutRect rowLayoutRect;
   717     TSize size( iLogoSize );    
   681     rowLayoutRect.LayoutRect( Rect(),
   718     if ( size.iWidth == 0 || size.iHeight == 0 )
   682             AknLayoutScalable_Apps::listrow_wgtman_pane().LayoutLine() );
   719         {
   683     TAknLayoutRect logoLayoutRect;
   720         TAknLayoutRect rowLayoutRect;
   684     logoLayoutRect.LayoutRect( rowLayoutRect.Rect(),
   721         rowLayoutRect.LayoutRect( Rect(),
   685             AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
   722                 AknLayoutScalable_Apps::listrow_wgtman_pane().LayoutLine() );
   686     return logoLayoutRect.Rect().Size();
   723         TAknLayoutRect logoLayoutRect;
   687     }
   724         logoLayoutRect.LayoutRect( rowLayoutRect.Rect(),
       
   725                 AknLayoutScalable_Apps::listrow_wgtman_pane_g1().LayoutLine() );
       
   726         size = logoLayoutRect.Rect().Size();
       
   727         iLogoSize = size;
       
   728         }
       
   729     return size;
       
   730     }
       
   731 
   688 
   732 
   689 // ---------------------------------------------------------
   733 // ---------------------------------------------------------
   690 // CWmListBox::DefaultLogo
   734 // CWmListBox::DefaultLogo
   691 // ---------------------------------------------------------
   735 // ---------------------------------------------------------
   692 //
   736 //