phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/src/ccappstatuscontrol.cpp
branchRCL_3
changeset 3 04ab22b956c2
parent 0 e686773b3f54
child 14 81f8547efd4f
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
    20 #include "MVPbkContactLink.h"
    20 #include "MVPbkContactLink.h"
    21 #include "TPbk2IconId.h"
    21 #include "TPbk2IconId.h"
    22 #include <eikimage.h>
    22 #include <eikimage.h>
    23 #include <eiklabel.h>
    23 #include <eiklabel.h>
    24 #include <AknIconUtils.h>
    24 #include <AknIconUtils.h>
    25 #include <aknutils.h>
    25 #include <AknUtils.h>
    26 #include <avkon.mbg>
    26 #include <avkon.mbg>
    27 #include <gulicon.h>
    27 #include <gulicon.h>
    28 #include <stringloader.h>
    28 #include <StringLoader.h>
    29 #include <aknsframebackgroundcontrolcontext.h>
    29 #include <AknsFrameBackgroundControlContext.h>
    30 #include <aknlayoutscalable_avkon.cdl.h>
    30 #include <aknlayoutscalable_avkon.cdl.h>
    31 #include <AknsUtils.h>
    31 #include <AknsUtils.h>
    32 #include <AknsDrawUtils.h>
    32 #include <AknsDrawUtils.h>
    33 #include <touchfeedback.h>
    33 #include <touchfeedback.h>
    34 #include <aknlayoutscalable_apps.cdl.h>
    34 #include <aknlayoutscalable_apps.cdl.h>
    91 //
    91 //
    92 CCCAppStatusControl::CCCAppStatusControl( 
    92 CCCAppStatusControl::CCCAppStatusControl( 
    93     CSpbContentProvider& aContentProvider, MCCAStatusControlObserver& aObserver ) : 
    93     CSpbContentProvider& aContentProvider, MCCAStatusControlObserver& aObserver ) : 
    94     iContentProvider( aContentProvider ),
    94     iContentProvider( aContentProvider ),
    95     iObserver( aObserver ),
    95     iObserver( aObserver ),
    96     iDefaultResource( KErrNotFound )
    96     iState( EStateUndefined )
    97     {		
    97     {		
    98     } 
    98     } 
    99 
    99 
   100 // ---------------------------------------------------------------------------
   100 // ---------------------------------------------------------------------------
   101 // CCCAppStatusControl::ConstructL
   101 // CCCAppStatusControl::ConstructL
   153     delete iStatusLabel1;    
   153     delete iStatusLabel1;    
   154     delete iStatusLabel2;    
   154     delete iStatusLabel2;    
   155     delete iStatusText;    
   155     delete iStatusText;    
   156 	delete iDefaultIcon;
   156 	delete iDefaultIcon;
   157     delete iBgContext; 
   157     delete iBgContext; 
       
   158     delete iDefaultStatusText;
   158     delete iLink;
   159     delete iLink;
   159     }
   160     }
   160 
   161 
   161 // ---------------------------------------------------------------------------
   162 // ---------------------------------------------------------------------------
   162 // CCCAppStatusControl::SetPressed
   163 // CCCAppStatusControl::SetPressed
   210     CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; 
   211     CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; 
   211 	iContentProvider.GetContentL( *iLink, iStatusText, iconId, type );			
   212 	iContentProvider.GetContentL( *iLink, iStatusText, iconId, type );			
   212 	}
   213 	}
   213 
   214 
   214 // ---------------------------------------------------------------------------
   215 // ---------------------------------------------------------------------------
   215 // CCCAppStatusControl::SetDefaultStatusL
   216 // CCCAppStatusControl::SetDefaultStatusIconL
   216 // ---------------------------------------------------------------------------
   217 // ---------------------------------------------------------------------------
   217 //
   218 //
   218 EXPORT_C void CCCAppStatusControl::SetDefaultStatusL( TInt aDefaultResource, 
   219 EXPORT_C void CCCAppStatusControl::SetDefaultStatusIconL( CGulIcon* aDefaultStatusIcon )
   219 		CGulIcon* aDefaultStatusIcon )
       
   220 	{
   220 	{
   221 	iDefaultResource = aDefaultResource;
   221 	delete iDefaultIcon;
   222 	delete iDefaultIcon;	
   222 	iDefaultIcon = aDefaultStatusIcon;
   223 	iDefaultIcon = aDefaultStatusIcon;					
   223 
       
   224 	if( iStatusIconSize != TSize() && iState == EStateDefaultContent )
       
   225         {
       
   226         ShowDefaultContentL();
       
   227         }
       
   228 	}
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // CCCAppStatusControl::SetDefaultStatusTextL
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C void CCCAppStatusControl::SetDefaultStatusTextL( HBufC* aDefaultStatusText ) 		
       
   235 	{
       
   236 	delete iDefaultStatusText;
       
   237 	iDefaultStatusText = aDefaultStatusText;
       
   238 	
       
   239 	if( iState == EStateDefaultContent )
       
   240 	    {
       
   241         ShowDefaultContentL();
       
   242 	    }
   224 	}
   243 	}
   225 
   244 
   226 // ---------------------------------------------------------------------------
   245 // ---------------------------------------------------------------------------
   227 // CCCAppStatusControl::CountComponentControls
   246 // CCCAppStatusControl::CountComponentControls
   228 // ---------------------------------------------------------------------------
   247 // ---------------------------------------------------------------------------
   288             rect, 
   307             rect, 
   289             AknLayoutScalable_Apps::phob2_cc_button_pane_t1( aOption ) ); 
   308             AknLayoutScalable_Apps::phob2_cc_button_pane_t1( aOption ) ); 
   290 
   309 
   291     // resize images for new resolution
   310     // resize images for new resolution
   292     ReSizeIcon( iStatusIcon, iStatusIconSize );
   311     ReSizeIcon( iStatusIcon, iStatusIconSize );
       
   312     ReSizeIcon( iDefaultIcon, iStatusIconSize );
   293     }
   313     }
   294 
   314 
   295 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   296 // CCCAppStatusControl::SizeChanged
   316 // CCCAppStatusControl::SizeChanged
   297 // ---------------------------------------------------------------------------
   317 // ---------------------------------------------------------------------------
   408 void CCCAppStatusControl::DoStatusUpdateL( MVPbkContactLink& aLink,
   428 void CCCAppStatusControl::DoStatusUpdateL( MVPbkContactLink& aLink,
   409     MSpbContentProviderObserver::TSpbContentEvent aEvent )
   429     MSpbContentProviderObserver::TSpbContentEvent aEvent )
   410     {
   430     {
   411     if( aEvent == EContentNotAvailable )
   431     if( aEvent == EContentNotAvailable )
   412         {
   432         {
   413         DefaultStatusL();
   433 		ShowDefaultContentL();
   414         return;
   434         }
   415         }
   435     else if( iLink && iLink->IsSame( aLink ) )
   416     
   436         {
   417     if( iLink && iLink->IsSame( aLink ) )
   437         iState = EStateStatusContent;
   418         {
       
   419         delete iStatusText;
   438         delete iStatusText;
   420         iStatusText = NULL;
   439         iStatusText = NULL;
   421         
   440         
   422         TPbk2IconId iconId;
   441         TPbk2IconId iconId;
   423         CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; 
   442         CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; 
   538             }
   557             }
   539         
   558         
   540         iStatusLabel1->SetTextL( label1 );
   559         iStatusLabel1->SetTextL( label1 );
   541         iStatusLabel2->SetTextL( label2 );
   560         iStatusLabel2->SetTextL( label2 );
   542         CleanupStack::PopAndDestroy( 2, statusTxtBuffer ); // txtArray
   561         CleanupStack::PopAndDestroy( 2, statusTxtBuffer ); // txtArray
       
   562         iStatusImage->MakeVisible( ETrue );
   543         DrawDeferred();
   563         DrawDeferred();
   544         }
   564         }
   545     return txtCount;
   565     return txtCount;
   546     }
   566     }
   547 
   567 
   565         gc.DrawRect( rect );
   585         gc.DrawRect( rect );
   566         }    
   586         }    
   567     }
   587     }
   568 
   588 
   569 // ---------------------------------------------------------------------------
   589 // ---------------------------------------------------------------------------
   570 // CCCAppStatusControl::DefaultStatusL
   590 // CCCAppStatusControl::ShowDefaultContentL
   571 // ---------------------------------------------------------------------------
   591 // ---------------------------------------------------------------------------
   572 //
   592 //
   573 void CCCAppStatusControl::DefaultStatusL()
   593 void CCCAppStatusControl::ShowDefaultContentL()
   574 	{
   594 	{
   575 	if( iDefaultResource != KErrNotFound )
   595     iState = EStateDefaultContent;
       
   596     
       
   597 	if( iDefaultIcon && ( iDefaultIcon->Bitmap() != iStatusImage->Bitmap() ) )
   576 		{
   598 		{
   577 		delete iStatusText;
   599         ReSizeIcon( iDefaultIcon, iStatusIconSize );
   578 		iStatusText = NULL;
   600         iStatusImage->SetPicture( iDefaultIcon->Bitmap(), iDefaultIcon->Mask() );
   579 		iStatusText = StringLoader::LoadL( iDefaultResource );
   601         iStatusImage->DrawDeferred();
   580         
       
   581 		const TInt count( RewrapStatusTextL() );
       
   582         TInt option( 1 );
       
   583         if( count > 1 )
       
   584             {
       
   585             option = 0;
       
   586             }
       
   587         SetVariableLayouts( option );
       
   588 		}
   602 		}
   589 	
   603 	
   590 	if( iDefaultIcon )
   604 	if( iDefaultStatusText )
   591 		{
   605 		{
   592         delete iStatusIcon;
   606         if( !iStatusText || iDefaultStatusText->CompareC( *iStatusText ) != 0 )
   593         iStatusIcon = NULL;
   607             {
   594         iStatusIcon = CGulIcon::NewL( iDefaultIcon->Bitmap(), iDefaultIcon->Mask() );
   608             // update text
   595         iStatusIcon->SetBitmapsOwnedExternally( ETrue ); // iDefaultIcon owns bitmaps
   609             HBufC* txt = iDefaultStatusText->AllocL();
   596         ReSizeIcon( iStatusIcon, iStatusIconSize );
   610             delete iStatusText;
   597 
   611             iStatusText = txt;
   598         iStatusImage->SetPicture( iDefaultIcon->Bitmap(), iDefaultIcon->Mask() );
   612             RewrapStatusTextL();
   599         iStatusImage->MakeVisible( ETrue );
   613             }
   600         DrawDeferred();
       
   601 		}
   614 		}
   602 	}
   615 	}
   603 
   616 
   604 // End of file
   617 // End of file