phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/src/ccappstatuscontrol.cpp
branchRCL_3
changeset 23 5586b4d2ec3e
parent 14 81f8547efd4f
child 39 a6539d1e8e43
equal deleted inserted replaced
21:b3431bff8c19 23:5586b4d2ec3e
    58         {
    58         {
    59         CFbsBitmap* bitmap = aIcon->Bitmap();
    59         CFbsBitmap* bitmap = aIcon->Bitmap();
    60         CFbsBitmap* mask = aIcon->Mask();
    60         CFbsBitmap* mask = aIcon->Mask();
    61         if( bitmap )
    61         if( bitmap )
    62             {
    62             {
    63             AknIconUtils::SetSize( bitmap, aSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
    63             AknIconUtils::SetSize( 
       
    64                     bitmap, aSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
    64             }
    65             }
    65         if( mask )
    66         if( mask )
    66             {
    67             {
    67             AknIconUtils::SetSize( mask, aSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
    68             AknIconUtils::SetSize( 
       
    69                     mask, aSize, EAspectRatioPreservedAndUnusedSpaceRemoved );
    68             }
    70             }
    69         }
    71         }
    70     }
    72     }
    71 
    73 
    72 }   // namespace
    74 }   // namespace
    74 // ---------------------------------------------------------------------------
    76 // ---------------------------------------------------------------------------
    75 // CCCAppStatusControl::NewL
    77 // CCCAppStatusControl::NewL
    76 // ---------------------------------------------------------------------------
    78 // ---------------------------------------------------------------------------
    77 //                            
    79 //                            
    78 EXPORT_C CCCAppStatusControl* CCCAppStatusControl::NewL( 
    80 EXPORT_C CCCAppStatusControl* CCCAppStatusControl::NewL( 
    79     CSpbContentProvider& aContentProvider, MCCAStatusControlObserver& aObserver )
    81     CSpbContentProvider& aContentProvider, 
    80     {
    82     MCCAStatusControlObserver& aObserver )
    81     CCCAppStatusControl* self= new(ELeave) CCCAppStatusControl( aContentProvider, aObserver );
    83     {
       
    84     CCCAppStatusControl* self= new(ELeave) CCCAppStatusControl( 
       
    85             aContentProvider, aObserver );
    82     CleanupStack::PushL(self);
    86     CleanupStack::PushL(self);
    83     self->ConstructL();
    87     self->ConstructL();
    84     CleanupStack::Pop(self);
    88     CleanupStack::Pop(self);
    85     return self;
    89     return self;
    86     }
    90     }
    88 // ---------------------------------------------------------------------------
    92 // ---------------------------------------------------------------------------
    89 // CCCAppStatusControl::CCCAppStatusControl
    93 // CCCAppStatusControl::CCCAppStatusControl
    90 // ---------------------------------------------------------------------------
    94 // ---------------------------------------------------------------------------
    91 //
    95 //
    92 CCCAppStatusControl::CCCAppStatusControl( 
    96 CCCAppStatusControl::CCCAppStatusControl( 
    93     CSpbContentProvider& aContentProvider, MCCAStatusControlObserver& aObserver ) : 
    97     CSpbContentProvider& aContentProvider, 
       
    98     MCCAStatusControlObserver& aObserver ) : 
    94     iContentProvider( aContentProvider ),
    99     iContentProvider( aContentProvider ),
    95     iObserver( aObserver ),
   100     iObserver( aObserver ),
    96     iState( EStateUndefined )
   101     iState( EStateUndefined )
    97     {		
   102     {		
    98     } 
   103     } 
   184             }
   189             }
   185         }
   190         }
   186     }
   191     }
   187 
   192 
   188 // ---------------------------------------------------------------------------
   193 // ---------------------------------------------------------------------------
   189 // CCCAppStatusControl::IsPressed
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 TBool CCCAppStatusControl::IsPressed()
       
   193     {
       
   194     return iPressed;
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------------------------
       
   198 // CCCAppStatusControl::CountComponentControls
   194 // CCCAppStatusControl::CountComponentControls
   199 // ---------------------------------------------------------------------------
   195 // ---------------------------------------------------------------------------
   200 //
   196 //
   201 EXPORT_C void CCCAppStatusControl::SetContactLinkL( MVPbkContactLink& aLink )
   197 EXPORT_C void CCCAppStatusControl::SetContactLinkL( MVPbkContactLink& aLink )
   202 	{
   198 	{
   214 
   210 
   215 // ---------------------------------------------------------------------------
   211 // ---------------------------------------------------------------------------
   216 // CCCAppStatusControl::SetDefaultStatusIconL
   212 // CCCAppStatusControl::SetDefaultStatusIconL
   217 // ---------------------------------------------------------------------------
   213 // ---------------------------------------------------------------------------
   218 //
   214 //
   219 EXPORT_C void CCCAppStatusControl::SetDefaultStatusIconL( CGulIcon* aDefaultStatusIcon )
   215 EXPORT_C void CCCAppStatusControl::SetDefaultStatusIconL( 
       
   216         CGulIcon* aDefaultStatusIcon )
   220 	{
   217 	{
   221 	delete iDefaultIcon;
   218 	delete iDefaultIcon;
   222 	iDefaultIcon = aDefaultStatusIcon;
   219 	iDefaultIcon = aDefaultStatusIcon;
   223 
   220 
   224 	if( iStatusIconSize != TSize() && iState == EStateDefaultContent )
   221 	if( iStatusIconSize != TSize() && iState == EStateDefaultContent )
   229 
   226 
   230 // ---------------------------------------------------------------------------
   227 // ---------------------------------------------------------------------------
   231 // CCCAppStatusControl::SetDefaultStatusTextL
   228 // CCCAppStatusControl::SetDefaultStatusTextL
   232 // ---------------------------------------------------------------------------
   229 // ---------------------------------------------------------------------------
   233 //
   230 //
   234 EXPORT_C void CCCAppStatusControl::SetDefaultStatusTextL( HBufC* aDefaultStatusText ) 		
   231 EXPORT_C void CCCAppStatusControl::SetDefaultStatusTextL( 
       
   232         HBufC* aDefaultStatusText ) 		
   235 	{
   233 	{
   236 	delete iDefaultStatusText;
   234 	delete iDefaultStatusText;
   237 	iDefaultStatusText = aDefaultStatusText;
   235 	iDefaultStatusText = aDefaultStatusText;
   238 	
   236 	
   239 	if( iState == EStateDefaultContent )
   237 	if( iState == EStateDefaultContent )
   281 //
   279 //
   282 void CCCAppStatusControl::SetVariableLayouts( TInt aOption )
   280 void CCCAppStatusControl::SetVariableLayouts( TInt aOption )
   283     {
   281     {
   284     const TRect rect(Rect());
   282     const TRect rect(Rect());
   285     // set background graphics layout
   283     // set background graphics layout
   286     TAknWindowComponentLayout innerLayout(
   284     const TAknWindowComponentLayout innerLayout(
   287             AknLayoutScalable_Apps::bg_button_pane_cp033( aOption ) );
   285             AknLayoutScalable_Apps::bg_button_pane_cp033( aOption ) );
   288     
   286     
   289     TAknLayoutRect innerLayoutRect;
   287     TAknLayoutRect innerLayoutRect;
   290     innerLayoutRect.LayoutRect( rect, innerLayout.LayoutLine() );
   288     innerLayoutRect.LayoutRect( rect, innerLayout.LayoutLine() );
   291     TRect innerRect( innerLayoutRect.Rect() );
   289     const TRect innerRect( innerLayoutRect.Rect() );
   292     iBgContext->SetFrameRects( rect, innerRect );      
   290     iBgContext->SetFrameRects( rect, innerRect );      
   293                        
   291                        
   294     // status icon
   292     // status icon
   295     TAknWindowComponentLayout statusIconLayout( 
   293     const TAknWindowComponentLayout statusIconLayout( 
   296             AknLayoutScalable_Apps::phob2_cc_button_pane_g1( aOption ) );
   294             AknLayoutScalable_Apps::phob2_cc_button_pane_g1( aOption ) );
   297     
   295     
   298     TAknLayoutRect statusIconLayoutRect;
   296     TAknLayoutRect statusIconLayoutRect;
   299     statusIconLayoutRect.LayoutRect( Rect(), statusIconLayout.LayoutLine() );
   297     statusIconLayoutRect.LayoutRect( Rect(), statusIconLayout.LayoutLine() );
   300     TRect statusIconRect( statusIconLayoutRect.Rect() );
   298     const TRect statusIconRect( statusIconLayoutRect.Rect() );
   301     iStatusIconSize = statusIconRect.Size();
   299     iStatusIconSize = statusIconRect.Size();
   302     iStatusImage->SetRect( statusIconRect );
   300     iStatusImage->SetRect( statusIconRect );
   303       
   301       
   304     // status label 1
   302     // status label 1
   305     AknLayoutUtils::LayoutLabel( 
   303     AknLayoutUtils::LayoutLabel( 
   403     const CCoeControl& aContainer )
   401     const CCoeControl& aContainer )
   404     {
   402     {
   405     CCoeControl::SetContainerWindowL( aContainer );
   403     CCoeControl::SetContainerWindowL( aContainer );
   406 
   404 
   407     // Assign window for child controls too
   405     // Assign window for child controls too
   408     TInt childCount = CountComponentControls();
   406     const TInt childCount = CountComponentControls();
   409     for( TInt i = 0; i < childCount; ++i )
   407     for( TInt i = 0; i < childCount; ++i )
   410         {
   408         {
   411         ComponentControl( i )->SetContainerWindowL( *this );
   409         ComponentControl( i )->SetContainerWindowL( *this );
   412         }
   410         }
   413     
   411     
   450         iState = EStateStatusContent;
   448         iState = EStateStatusContent;
   451         delete iStatusText;
   449         delete iStatusText;
   452         iStatusText = NULL;
   450         iStatusText = NULL;
   453         
   451         
   454         TPbk2IconId iconId;
   452         TPbk2IconId iconId;
   455         CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; 
   453         CSpbContentProvider::TSpbContentType type = 
       
   454                 CSpbContentProvider::ETypeNone; 
   456         iContentProvider.GetContentL( aLink, iStatusText, iconId, type );
   455         iContentProvider.GetContentL( aLink, iStatusText, iconId, type );
   457         
   456         
   458         TInt count( RewrapStatusTextL() );
   457         const TInt count( RewrapStatusTextL() );
   459         TInt option( 1 );
   458         TInt option( 1 );
   460         if( count > 1 )
   459         if( count > 1 )
   461             {
   460             {
   462             option = 0;
   461             option = 0;
   463             }
   462             }
   582 // CCCAppStatusControl::Draw
   581 // CCCAppStatusControl::Draw
   583 // ---------------------------------------------------------------------------
   582 // ---------------------------------------------------------------------------
   584 //
   583 //
   585 void CCCAppStatusControl::Draw( const TRect& /*aRect*/ ) const
   584 void CCCAppStatusControl::Draw( const TRect& /*aRect*/ ) const
   586     {
   585     {
   587     TRect rect( Rect() );
   586     const TRect rect( Rect() );
   588     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   587     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   589     CWindowGc& gc = SystemGc();
   588     CWindowGc& gc = SystemGc();
   590     
   589     
   591     // draw skinned background
   590     // draw skinned background
   592     if( !AknsDrawUtils::Background( skin, iBgContext, NULL, 
   591     if( !AknsDrawUtils::Background( skin, iBgContext, NULL, 
   620             {
   619             {
   621             // update text
   620             // update text
   622             HBufC* txt = iDefaultStatusText->AllocL();
   621             HBufC* txt = iDefaultStatusText->AllocL();
   623             delete iStatusText;
   622             delete iStatusText;
   624             iStatusText = txt;
   623             iStatusText = txt;
   625             RewrapStatusTextL();
   624             const TInt count( RewrapStatusTextL() );
       
   625             TInt option( 1 );
       
   626             if( count > 1 )
       
   627                 {
       
   628                 option = 0;
       
   629                 }
       
   630             SetVariableLayouts( option );
   626             }
   631             }
   627 		}
   632 		}
   628 	}
   633 	}
   629 
   634 
   630 // End of file
   635 // End of file