uifw/EikStd/coctlsrc/AknButton.cpp
branchRCL_3
changeset 51 fcdfafb36fe7
parent 50 a1caeb42b3a3
child 55 aecbbf00d063
equal deleted inserted replaced
50:a1caeb42b3a3 51:fcdfafb36fe7
   262     // Fetches bitmaps from resource provider (if one exists)
   262     // Fetches bitmaps from resource provider (if one exists)
   263     TBool FetchProviderPressedBmpsL();
   263     TBool FetchProviderPressedBmpsL();
   264 
   264 
   265     // Sets bitmaps to resource provider (if one exists)
   265     // Sets bitmaps to resource provider (if one exists)
   266     void SetProviderPressedBmpsL();
   266     void SetProviderPressedBmpsL();
       
   267     
       
   268     //Verify new rectagle size equals to the original
       
   269     TBool TextRectSizeChanged( TRect aNewRect );
   267    
   270    
   268 private: // Data
   271 private: // Data
   269 
   272 
   270     CAknButton& iButton;
   273     CAknButton& iButton;
   271     CAknButton::TTooltipPosition iTooltipPosition;
   274     CAknButton::TTooltipPosition iTooltipPosition;
   291     // buffer for visually ordered text
   294     // buffer for visually ordered text
   292     TBuf<255 + KAknBidiExtraSpacePerLine> iVisualText; 
   295     TBuf<255 + KAknBidiExtraSpacePerLine> iVisualText; 
   293     TBool iFeedbackEnabled;
   296     TBool iFeedbackEnabled;
   294     TAknsItemID iBackgroundSkinIID;
   297     TAknsItemID iBackgroundSkinIID;
   295     TRect iBgFrameRect;
   298     TRect iBgFrameRect;
       
   299     TRect iTextRect;
   296     };
   300     };
   297 
   301 
   298 // ============================ MEMBER FUNCTIONS ===============================
   302 // ============================ MEMBER FUNCTIONS ===============================
   299 
   303 
   300 // -----------------------------------------------------------------------------
   304 // -----------------------------------------------------------------------------
   325     layoutRect.LayoutRect( rect, 
   329     layoutRect.LayoutRect( rect, 
   326         AknLayoutScalable_Avkon::toolbar_button_pane_g10().LayoutLine() );
   330         AknLayoutScalable_Avkon::toolbar_button_pane_g10().LayoutLine() );
   327     iIconSize = layoutRect.Rect().Size();
   331     iIconSize = layoutRect.Rect().Size();
   328     iFlags.Set( EUseDefaultIconSize );
   332     iFlags.Set( EUseDefaultIconSize );
   329     iFlags.Set( EUseDefaultMargins );
   333     iFlags.Set( EUseDefaultMargins );
       
   334     iTextRect = TRect::EUninitialized;
   330     }
   335     }
   331 
   336 
   332 // -----------------------------------------------------------------------------
   337 // -----------------------------------------------------------------------------
   333 // CAknButtonExtension::~CAknButtonExtension
   338 // CAknButtonExtension::~CAknButtonExtension
   334 // Destructor.
   339 // Destructor.
   515             KPressedFrameId, 
   520             KPressedFrameId, 
   516             static_cast<MAknResourceItem*>( resourceItem ) );
   521             static_cast<MAknResourceItem*>( resourceItem ) );
   517         }
   522         }
   518     }
   523     }
   519     
   524     
       
   525 //Verify new rectangle size equals to the original
       
   526 TBool CAknButtonExtension::TextRectSizeChanged( TRect aNewRect )
       
   527     {
       
   528     TBool result( ETrue );
       
   529     if ( !iTextRect.IsEmpty() && !aNewRect.IsEmpty() )
       
   530         {
       
   531         if ( iTextRect.Width() == aNewRect.Width() 
       
   532                 && iTextRect.Height() == aNewRect.Height() )
       
   533             {
       
   534             result = EFalse;
       
   535             }
       
   536         }
       
   537     return result;
       
   538     }
   520     
   539     
   521 
   540 
   522 //
   541 //
   523 TBool CAknButtonExtension::HitRegionContains( const TPoint &aPoint, 
   542 TBool CAknButtonExtension::HitRegionContains( const TPoint &aPoint, 
   524     const CCoeControl& /*aControl*/ ) const
   543     const CCoeControl& /*aControl*/ ) const
  1680         {
  1699         {
  1681         iHorizontalAlignment = CGraphicsContext::ELeft;
  1700         iHorizontalAlignment = CGraphicsContext::ELeft;
  1682         }
  1701         }
  1683     iExtension->HandleFeedbackAreaChange();
  1702     iExtension->HandleFeedbackAreaChange();
  1684     SetFrameIDs(); 
  1703     SetFrameIDs(); 
  1685     ConvertTextToVisualAndClip();
       
  1686     }
  1704     }
  1687 
  1705 
  1688 // -----------------------------------------------------------------------------
  1706 // -----------------------------------------------------------------------------
  1689 // CAknButton::ConstructL
  1707 // CAknButton::ConstructL
  1690 // Symbian 2nd phase constructor for 1 state button.
  1708 // Symbian 2nd phase constructor for 1 state button.
  2255     if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame ) 
  2273     if ( iFlags & KAknButtonNoFrame && iFlags & KAknButtonPressedDownFrame ) 
  2256        {
  2274        {
  2257         TRAP_IGNORE( CreatePressedDownFrameL() );
  2275         TRAP_IGNORE( CreatePressedDownFrameL() );
  2258         }
  2276         }
  2259     SetFrameRects(); 
  2277     SetFrameRects(); 
  2260     ConvertTextToVisualAndClip(); 
       
  2261 
  2278 
  2262     iExtension->HandleFeedbackAreaChange();
  2279     iExtension->HandleFeedbackAreaChange();
  2263     }
  2280     }
  2264 
  2281 
  2265 // -----------------------------------------------------------------------------
  2282 // -----------------------------------------------------------------------------
  2827 // CAknButton::SetFlags
  2844 // CAknButton::SetFlags
  2828 // Sets the button flags
  2845 // Sets the button flags
  2829 // -----------------------------------------------------------------------------
  2846 // -----------------------------------------------------------------------------
  2830 //
  2847 //
  2831 EXPORT_C void CAknButton::SetButtonFlags( const TInt aFlags )
  2848 EXPORT_C void CAknButton::SetButtonFlags( const TInt aFlags )
  2832     {
  2849     {    
  2833     if ( !( iFlags & KAknButtonNoFrame ) )
  2850     if ( !( iFlags & KAknButtonNoFrame ) )
  2834         {
  2851         {
  2835         if ( aFlags & KAknButtonNoFrame ) 
  2852         if ( aFlags & KAknButtonNoFrame ) 
  2836             {
  2853             {
  2837             iExtension->iMargins.SetAllValuesTo( 0 );
  2854             iExtension->iMargins.SetAllValuesTo( 0 );         
  2838             ConvertTextToVisualAndClip();
       
  2839             }
       
  2840         // aFlags does not include KAknButtonNoFrame
       
  2841         else if ( iFlags & KAknButtonTextInsideFrame != 
       
  2842                 aFlags & KAknButtonTextInsideFrame )
       
  2843             {
       
  2844             ConvertTextToVisualAndClip(); 
       
  2845             }
  2855             }
  2846         }
  2856         }
  2847     if ( aFlags & KAknButtonHitTest )
  2857     if ( aFlags & KAknButtonHitTest )
  2848         {
  2858         {
  2849         SetHitTest( iExtension );
  2859         SetHitTest( iExtension );
  2850         iExtension->HandleFeedbackAreaChange();
  2860         iExtension->HandleFeedbackAreaChange();
  2851         }
  2861         }
  2852     if ( aFlags & KAknButtonNoFrame && aFlags & KAknButtonPressedDownFrame )
  2862     if ( aFlags & KAknButtonNoFrame && aFlags & KAknButtonPressedDownFrame )
  2853         {
  2863         {
  2854         TRAP_IGNORE ( CreatePressedDownFrameL() );
  2864         TRAP_IGNORE ( CreatePressedDownFrameL() );
  2855         }
       
  2856     if ( iFlags & KAknButtonNoFrame && !( aFlags & KAknButtonNoFrame ) )
       
  2857         {
       
  2858         SetFrameIDs(); 
       
  2859         if ( aFlags & KAknButtonTextInsideFrame )
       
  2860             {
       
  2861             ConvertTextToVisualAndClip(); 
       
  2862             }
       
  2863         }
  2865         }
  2864     iFlags = aFlags;
  2866     iFlags = aFlags;
  2865     }
  2867     }
  2866 
  2868 
  2867 // -----------------------------------------------------------------------------
  2869 // -----------------------------------------------------------------------------
  2955 // -----------------------------------------------------------------------------
  2957 // -----------------------------------------------------------------------------
  2956 //
  2958 //
  2957 EXPORT_C void CAknButton::SetTextFont( const CFont* aFont )
  2959 EXPORT_C void CAknButton::SetTextFont( const CFont* aFont )
  2958     {
  2960     {
  2959     iFont = aFont;
  2961     iFont = aFont;
  2960     ConvertTextToVisualAndClip(); 
  2962     ConvertTextToVisualAndClip( iExtension->iTextRect ); 
  2961     }
  2963     }
  2962 
  2964 
  2963 // -----------------------------------------------------------------------------
  2965 // -----------------------------------------------------------------------------
  2964 // CAknButton::SetTextColorIds
  2966 // CAknButton::SetTextColorIds
  2965 // Sets the color table and color index for the button text.
  2967 // Sets the color table and color index for the button text.
  3520 // Continues drawing of the button which has only text
  3522 // Continues drawing of the button which has only text
  3521 // -----------------------------------------------------------------------------
  3523 // -----------------------------------------------------------------------------
  3522 //
  3524 //
  3523 void CAknButton::DrawTextButton( CWindowGc& aGc ) const
  3525 void CAknButton::DrawTextButton( CWindowGc& aGc ) const
  3524     {
  3526     {
       
  3527     TRect textRect;
       
  3528     
       
  3529     TRect iconRect; //this is no use
       
  3530     GetCurrentStateTextAndIconRect( iconRect, textRect );
       
  3531       
  3525     CAknButtonState* state = State();
  3532     CAknButtonState* state = State();
  3526     if ( !state || !state->HasText() )
  3533     if ( state->TextChanged() || iExtension->TextRectSizeChanged( textRect ) )
  3527         return;
  3534         {
  3528 
  3535         ConvertTextToVisualAndClip( textRect ); 
  3529     if ( state->TextChanged() )
       
  3530         {
       
  3531         ConvertTextToVisualAndClip(); 
       
  3532         }
       
  3533 
       
  3534     TRect textRect = iExtension->iMargins.InnerRect( Rect() );
       
  3535 
       
  3536     if ( !( iFlags & KAknButtonNoFrame ) && 
       
  3537          ( iFlags & KAknButtonTextInsideFrame ) )
       
  3538         {
       
  3539         TAknLayoutRect center;
       
  3540         center.LayoutRect( Rect(), 
       
  3541             AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  3542 
       
  3543         textRect = center.Rect();
       
  3544         }
  3536         }
  3545     DrawText( aGc, textRect ); 
  3537     DrawText( aGc, textRect ); 
  3546     }
  3538     }
  3547 
  3539 
  3548 // -----------------------------------------------------------------------------
  3540 // -----------------------------------------------------------------------------
  3606 // Continues drawing of the button which has only an icon in it
  3598 // Continues drawing of the button which has only an icon in it
  3607 // -----------------------------------------------------------------------------
  3599 // -----------------------------------------------------------------------------
  3608 //
  3600 //
  3609 void CAknButton::DrawIconButton( CWindowGc& aGc ) const
  3601 void CAknButton::DrawIconButton( CWindowGc& aGc ) const
  3610     {
  3602     {
  3611     TRect iconRect( iExtension->iMargins.InnerRect( Rect() ) );
  3603     TRect iconRect;
       
  3604     TRect textRect; 
       
  3605     GetCurrentStateTextAndIconRect( iconRect, textRect );
  3612     
  3606     
  3613     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  3607     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  3614 
  3608 
  3615     const CGulIcon* icon = GetCurrentIcon();
  3609     const CGulIcon* icon = GetCurrentIcon();
  3616     if ( !icon )
       
  3617         return;
       
  3618 
  3610 
  3619     CFbsBitmap* buttonBmp = icon->Bitmap();
  3611     CFbsBitmap* buttonBmp = icon->Bitmap();
  3620     CFbsBitmap* buttonMask = icon->Mask();
  3612     CFbsBitmap* buttonMask = icon->Mask();
  3621 
  3613 
  3622     TPoint iconPoint;
  3614     TPoint iconPoint;
  3694     {
  3686     {
  3695     CAknButtonState* state = State();
  3687     CAknButtonState* state = State();
  3696     if ( !state  || !state->HasText() )
  3688     if ( !state  || !state->HasText() )
  3697         {
  3689         {
  3698         return;
  3690         return;
  3699         }
  3691         }   
  3700     if ( state->TextChanged() )
       
  3701         {
       
  3702         ConvertTextToVisualAndClip(); 
       
  3703         }
       
  3704     
  3692     
  3705     const CGulIcon* icon = GetCurrentIcon();
  3693     const CGulIcon* icon = GetCurrentIcon();
  3706     if ( !icon )
  3694 
  3707         {
  3695    
  3708         return;
       
  3709         }
       
  3710 
       
  3711     TRect rect = iExtension->iMargins.InnerRect( Rect() );
       
  3712     TRect iconRect;
  3696     TRect iconRect;
  3713     TRect textRect;
  3697     TRect textRect;
  3714     
  3698     GetCurrentStateTextAndIconRect( iconRect, textRect );
  3715     if ( !( iFlags & KAknButtonNoFrame ) &&
  3699     
  3716           ( iFlags & KAknButtonTextInsideFrame ))
       
  3717         {
       
  3718         TAknLayoutRect centerLayout;
       
  3719         centerLayout.LayoutRect( rect,
       
  3720         AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  3721         rect = centerLayout.Rect();
       
  3722         }
       
  3723 
       
  3724     CFbsBitmap* buttonBmp = icon->Bitmap();
  3700     CFbsBitmap* buttonBmp = icon->Bitmap();
  3725     CFbsBitmap* buttonMask = icon->Mask();
  3701     CFbsBitmap* buttonMask = icon->Mask();
  3726     TSize iconSize ( buttonBmp->SizeInPixels());
  3702     TSize iconSize ( buttonBmp->SizeInPixels());
  3727     
  3703     
  3728     // Set rects for icon and text according to their positioning
  3704    
  3729     // First icon rect according to icon size - rest is for text
  3705     if ( state->TextChanged() || iExtension->TextRectSizeChanged( textRect ) )
  3730     
  3706         {
  3731     switch ( iExtension->iTextAndIconAlignment )        
  3707         ConvertTextToVisualAndClip( textRect ); 
  3732         {
  3708         }
  3733         case EIconBeforeText:
       
  3734             if ( AknLayoutUtils::LayoutMirrored() ) 
       
  3735                 {
       
  3736                 textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3737                 rect.iBr.iX - iconSize.iWidth, rect.iBr.iY);
       
  3738                 iconRect.SetRect( rect.iTl.iX + 
       
  3739                     rect.Width() -iconSize.iWidth,
       
  3740                 rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  3741                 }
       
  3742             else
       
  3743                 {
       
  3744                 iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3745                 rect.iTl.iX + iconSize.iWidth, rect.iBr.iY);
       
  3746                 textRect.SetRect( rect.iTl.iX + iconSize.iWidth,
       
  3747                 rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  3748                 }
       
  3749             
       
  3750             break;
       
  3751             
       
  3752         case EIconAfterText:
       
  3753             if ( AknLayoutUtils::LayoutMirrored() ) 
       
  3754                 {
       
  3755                 iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3756                 rect.iTl.iX + iconSize.iWidth, rect.iBr.iY);
       
  3757                 textRect.SetRect( rect.iTl.iX + iconSize.iWidth,
       
  3758                 rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  3759                 }
       
  3760             else
       
  3761                 {
       
  3762                 textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3763                 rect.iBr.iX - iconSize.iWidth, rect.iBr.iY);
       
  3764                 iconRect.SetRect( rect.iTl.iX + 
       
  3765                     rect.Width() -iconSize.iWidth,
       
  3766                 rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );
       
  3767                 }
       
  3768             break;
       
  3769         
       
  3770         case EIconOverText:
       
  3771             iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3772             rect.iBr.iX, rect.iTl.iY + iconSize.iHeight );
       
  3773             textRect.SetRect( rect.iTl.iX, rect.iTl.iY + iconSize.iHeight,
       
  3774             rect.iBr.iX, rect.iBr.iY );
       
  3775             break;
       
  3776             
       
  3777         case EIconUnderText:
       
  3778             textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  3779             rect.iBr.iX, rect.iBr.iY - iconSize.iHeight );
       
  3780             iconRect.SetRect( rect.iTl.iX, rect.iBr.iY - iconSize.iHeight,
       
  3781             rect.iBr.iX, rect.iBr.iY );
       
  3782             break;
       
  3783 
       
  3784         case EOverlay:
       
  3785             {
       
  3786             textRect = rect;
       
  3787             iconRect = rect;
       
  3788             }
       
  3789             break;
       
  3790             
       
  3791         default:
       
  3792             return;
       
  3793         }
       
  3794 
       
  3795     // Draw icon
  3709     // Draw icon
  3796     TPoint iconPoint;
  3710     TPoint iconPoint;
  3797     switch ( iExtension->iHorizontalIconAlignment )
  3711     switch ( iExtension->iHorizontalIconAlignment )
  3798         {
  3712         {
  3799         case ERight:
  3713         case ERight:
  4539             }
  4453             }
  4540         iHelpNote = CAknInfoPopupNoteController::NewL();
  4454         iHelpNote = CAknInfoPopupNoteController::NewL();
  4541         iHelpNote->SetTimeDelayBeforeShow( iHelpNoteWaitInterval );
  4455         iHelpNote->SetTimeDelayBeforeShow( iHelpNoteWaitInterval );
  4542         iHelpNote->SetTimePopupInView( iHelpNoteInViewInterval );
  4456         iHelpNote->SetTimePopupInView( iHelpNoteInViewInterval );
  4543         iHelpNote->SetTooltipModeL( ETrue );
  4457         iHelpNote->SetTooltipModeL( ETrue );
       
  4458         
       
  4459         //When state changed, empty rect to enable recalculate the 
       
  4460         //visual text if text exists in current state.
       
  4461         if ( !(iExtension->iTextRect.IsEmpty()) )
       
  4462             {
       
  4463             iExtension->iTextRect = TRect::EUninitialized;
       
  4464             }
  4544         }
  4465         }
  4545     }
  4466     }
  4546 
  4467 
  4547 // -----------------------------------------------------------------------------
  4468 // -----------------------------------------------------------------------------
  4548 // CAknButton::SetFrameIDs
  4469 // CAknButton::SetFrameIDs
  4623 
  4544 
  4624 // -----------------------------------------------------------------------------
  4545 // -----------------------------------------------------------------------------
  4625 // CAknButton::ConvertTextToVisualAndClip
  4546 // CAknButton::ConvertTextToVisualAndClip
  4626 // -----------------------------------------------------------------------------
  4547 // -----------------------------------------------------------------------------
  4627 //
  4548 //
  4628 void CAknButton::ConvertTextToVisualAndClip() const
  4549 void CAknButton::ConvertTextToVisualAndClip( const TRect& aRect ) const
  4629     {
  4550     {
  4630     CAknButtonState* state = State();
  4551     CAknButtonState* state = State();
  4631     if ( !state || !state->HasText() )
  4552     if ( !state || !state->HasText() )
  4632         {
  4553         {
  4633         if ( state ) 
  4554         if ( state ) 
  4635             state->ResetTextChanged();
  4556             state->ResetTextChanged();
  4636             } 
  4557             } 
  4637         return;
  4558         return;
  4638         }
  4559         }
  4639 
  4560 
  4640     TRect textRect = iExtension->iMargins.InnerRect( Rect() );
  4561     TRect textRect( aRect );
  4641 
  4562     //Using given rect to calculate the visual text if it's not empty.
  4642     if ( !( iFlags & KAknButtonNoFrame ) && 
  4563     if ( !textRect.IsEmpty() )
  4643          ( iFlags & KAknButtonTextInsideFrame ) )
  4564         {
  4644         {
  4565         iExtension->iTextRect = textRect;
  4645         TAknLayoutRect center;
  4566         }
  4646         center.LayoutRect( Rect(), 
  4567     //Calculate text area.
  4647             AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
  4568     //This branch means that it's the first calling after the state changed
  4648 
  4569     //or client using new font before this is shown. 
  4649         textRect = center.Rect();
  4570     else 
  4650         }
  4571         {
  4651 
  4572         TRect iconRect;
       
  4573         GetCurrentStateTextAndIconRect( iconRect, textRect );
       
  4574         iExtension->iTextRect = textRect;
       
  4575         }
       
  4576    
  4652     TInt clipWidth = textRect.Width();
  4577     TInt clipWidth = textRect.Width();
  4653 
  4578 
  4654     const CFont* font = iFont;
  4579     const CFont* font = iFont;
  4655     if ( !font )
  4580     if ( !font )
  4656         {
  4581         {
  4663         iExtension->iVisualText,
  4588         iExtension->iVisualText,
  4664         *font,
  4589         *font,
  4665         clipWidth,
  4590         clipWidth,
  4666         clipWidth );
  4591         clipWidth );
  4667     }
  4592     }
       
  4593       
       
  4594 // -----------------------------------------------------------------------------
       
  4595 // CAknButton::GetCurrentStateTextAndIconRect()
       
  4596 // Get rect for icon and text of the current button state .
       
  4597 // -----------------------------------------------------------------------------
       
  4598 //
       
  4599 void CAknButton::GetCurrentStateTextAndIconRect( TRect& aIconRect, 
       
  4600         TRect& aTextRect ) const
       
  4601     {
       
  4602     TRect iconRect( TRect::EUninitialized ) ;
       
  4603     TRect textRect( TRect::EUninitialized );
       
  4604     
       
  4605     CAknButtonState* state = State();
       
  4606     
       
  4607     //Return directly if no state
       
  4608     if ( !state )
       
  4609         {
       
  4610         aIconRect = iconRect;
       
  4611         aTextRect = textRect;
       
  4612         return;
       
  4613         }
       
  4614     
       
  4615     TBool hasText( state->HasText() );
       
  4616     TBool hasIcon( EFalse );  
       
  4617 
       
  4618     const CGulIcon* icon = GetCurrentIcon();
       
  4619     if ( icon )
       
  4620         {
       
  4621         hasIcon = ETrue;
       
  4622         }  
       
  4623     
       
  4624     TRect rect = iExtension->iMargins.InnerRect( Rect() );    
       
  4625     
       
  4626     //Icon area is not effected by the frame flags.
       
  4627     if ( hasIcon )
       
  4628         {
       
  4629         iconRect = rect;
       
  4630         }
       
  4631     
       
  4632     if ( !( iFlags & KAknButtonNoFrame ) &&
       
  4633           ( iFlags & KAknButtonTextInsideFrame ))
       
  4634         {
       
  4635         TAknLayoutRect centerLayout;
       
  4636         centerLayout.LayoutRect( rect,
       
  4637         AknLayoutScalable_Avkon::toolbar_button_pane_g1().LayoutLine() );
       
  4638         rect = centerLayout.Rect();
       
  4639         }
       
  4640     
       
  4641     if ( hasText )
       
  4642         {
       
  4643         textRect = rect;
       
  4644         }
       
  4645  
       
  4646 
       
  4647     if ( hasText && hasIcon )
       
  4648         {
       
  4649         CFbsBitmap* buttonBmp = icon->Bitmap();
       
  4650         CFbsBitmap* buttonMask = icon->Mask();
       
  4651         TSize iconSize ( buttonBmp->SizeInPixels());
       
  4652             
       
  4653             // Set rects for icon and text according to their positioning
       
  4654             // First icon rect according to icon size - rest is for text
       
  4655             
       
  4656         switch ( iExtension->iTextAndIconAlignment )        
       
  4657             {
       
  4658             case CAknButton::EIconBeforeText:
       
  4659                 if ( AknLayoutUtils::LayoutMirrored() ) 
       
  4660                     {
       
  4661                     textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4662                     rect.iBr.iX - iconSize.iWidth, rect.iBr.iY);
       
  4663                     iconRect.SetRect( rect.iTl.iX + 
       
  4664                         rect.Width() -iconSize.iWidth,
       
  4665                     rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  4666                     }
       
  4667                 else
       
  4668                     {
       
  4669                     iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4670                     rect.iTl.iX + iconSize.iWidth, rect.iBr.iY);
       
  4671                     textRect.SetRect( rect.iTl.iX + iconSize.iWidth,
       
  4672                     rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  4673                     }
       
  4674                 
       
  4675                 break;
       
  4676                 
       
  4677             case CAknButton::EIconAfterText:
       
  4678                 if ( AknLayoutUtils::LayoutMirrored() ) 
       
  4679                     {
       
  4680                     iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4681                     rect.iTl.iX + iconSize.iWidth, rect.iBr.iY);
       
  4682                     textRect.SetRect( rect.iTl.iX + iconSize.iWidth,
       
  4683                     rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );    
       
  4684                     }
       
  4685                 else
       
  4686                     {
       
  4687                     textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4688                     rect.iBr.iX - iconSize.iWidth, rect.iBr.iY);
       
  4689                     iconRect.SetRect( rect.iTl.iX + 
       
  4690                         rect.Width() -iconSize.iWidth,
       
  4691                     rect.iTl.iY, rect.iBr.iX, rect.iBr.iY );
       
  4692                     }
       
  4693                 break;
       
  4694             
       
  4695             case CAknButton::EIconOverText:
       
  4696                 iconRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4697                 rect.iBr.iX, rect.iTl.iY + iconSize.iHeight );
       
  4698                 textRect.SetRect( rect.iTl.iX, rect.iTl.iY + iconSize.iHeight,
       
  4699                 rect.iBr.iX, rect.iBr.iY );
       
  4700                 break;
       
  4701                 
       
  4702             case CAknButton::EIconUnderText:
       
  4703                 textRect.SetRect( rect.iTl.iX, rect.iTl.iY,
       
  4704                 rect.iBr.iX, rect.iBr.iY - iconSize.iHeight );
       
  4705                 iconRect.SetRect( rect.iTl.iX, rect.iBr.iY - iconSize.iHeight,
       
  4706                 rect.iBr.iX, rect.iBr.iY );
       
  4707                 break;
       
  4708 
       
  4709             case CAknButton::EOverlay:
       
  4710                 {
       
  4711                 textRect = rect;
       
  4712                 iconRect = rect;
       
  4713                 }
       
  4714                 break;
       
  4715             default:
       
  4716                 break; //Do nothing.
       
  4717             }            
       
  4718         }
       
  4719     aTextRect = textRect;
       
  4720     aIconRect = iconRect;
       
  4721     }
  4668 // -----------------------------------------------------------------------------
  4722 // -----------------------------------------------------------------------------
  4669 // CAknButton::TouchArea
  4723 // CAknButton::TouchArea
  4670 // Returns the button touchable area.
  4724 // Returns the button touchable area.
  4671 // -----------------------------------------------------------------------------
  4725 // -----------------------------------------------------------------------------
  4672 //
  4726 //