phoneuis/dialer/src/cdialerkeypadbutton.cpp
branchRCL_3
changeset 14 24062c24fe38
parent 9 8871b09be73b
child 17 38529f706030
equal deleted inserted replaced
9:8871b09be73b 14:24062c24fe38
    34 #include "dialercommon.h"
    34 #include "dialercommon.h"
    35 #include "dialertrace.h"
    35 #include "dialertrace.h"
    36 #include "cdialerkeypadbutton.h"
    36 #include "cdialerkeypadbutton.h"
    37 
    37 
    38 _LIT( KDialerMifFileName, "dialer.mif" );
    38 _LIT( KDialerMifFileName, "dialer.mif" );
    39 static const TInt KIconMarginPercent = 5;
    39 
       
    40 // Keypad icon size relative to height of button.
       
    41 static const TInt KIconSizePercent = 40;
       
    42 
       
    43 // Keypad icon size used when key has already two lines
       
    44 // of text, and the icon needs to be squeezed into smaller space.
       
    45 static const TInt KSmallIconSizePercent = 30;
       
    46 
       
    47 // Horizontal icon margin relative to button width. 
       
    48 static const TInt KIconMarginXPercent = 10;
       
    49 
       
    50 // Vertical icon margin relative to button height. 
       
    51 static const TInt KIconMarginYPercent = 5;
       
    52 
    40 static const TInt KCent = 100;
    53 static const TInt KCent = 100;
    41 
    54 
    42 // ---------------------------------------------------------------------------
    55 // ---------------------------------------------------------------------------
    43 // C++ default constructor
    56 // C++ default constructor
    44 // ---------------------------------------------------------------------------
    57 // ---------------------------------------------------------------------------
   200             }
   213             }
   201         else
   214         else
   202             {
   215             {
   203             iPrimaryAlphaLayout.LayoutText( buttonRect, 
   216             iPrimaryAlphaLayout.LayoutText( buttonRect, 
   204                 AknLayoutScalable_Apps::cell_dia3_key_num_pane_t2( iVariety ) );
   217                 AknLayoutScalable_Apps::cell_dia3_key_num_pane_t2( iVariety ) );
   205             }
   218             }   
   206 
       
   207         // Icon layout
       
   208         iconLayout.LayoutRect( buttonRect, 
       
   209             AknLayoutScalable_Apps::cell_dialer2_keypad_pane_g2( 1 ) );
       
   210         iIconRect = iconLayout.Rect();
       
   211 
       
   212         // Icon doesn't fit to location set in the layout if key has any alpha label.
       
   213         // In that case, move the icon to upper-right corner.
       
   214         if ( iPrimaryAlphaLabel.Length() || iSecondaryAlphaLabel.Length() )
       
   215             {
       
   216             TSize iconSize = iIconRect.Size();
       
   217             TInt xMargin = buttonRect.Width() * KIconMarginPercent / KCent;
       
   218             TInt yMargin = buttonRect.Height() * KIconMarginPercent / KCent;
       
   219             TPoint iconPos( buttonRect.iBr.iX - iconSize.iWidth - xMargin, 
       
   220                             buttonRect.iTl.iY + yMargin );
       
   221             iIconRect.SetRect( iconPos, iconSize );
       
   222             }
       
   223         }
   219         }
   224     else if ( iOperationMode == EModeDialer )
   220     else if ( iOperationMode == EModeDialer )
   225         {
   221         {
   226         // Number layout
   222         // Number layout
   227         iNumberLayout.LayoutText( buttonRect, 
   223         iNumberLayout.LayoutText( buttonRect, 
   228             AknLayoutScalable_Apps::cell_dialer2_keypad_pane_t1() );
   224             AknLayoutScalable_Apps::cell_dialer2_keypad_pane_t1() );
   229     
       
   230         // Icon layout
       
   231         iconLayout.LayoutRect( buttonRect,
       
   232             AknLayoutScalable_Apps::cell_dialer2_keypad_pane_g2( 1 ) );
       
   233         iIconRect = iconLayout.Rect();
       
   234         }
   225         }
   235     else // video mode layout
   226     else // video mode layout
   236         {
   227         {
   237         // Number layout
   228         // Number layout
   238         iNumberLayout.LayoutText( buttonRect, 
   229         iNumberLayout.LayoutText( buttonRect, 
   239             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() );
   230             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() );        
   240         
   231         }
   241         // Icon layout
   232 
   242         iconLayout.LayoutRect( buttonRect, 
   233     SetIconLayout( buttonRect );
   243             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_g2( 2 ) );
       
   244         iIconRect = iconLayout.Rect();
       
   245         }
       
   246 
       
   247     SetIconSize( iIconRect.Size() );
       
   248     }
   234     }
   249 
   235 
   250 // -----------------------------------------------------------------------------
   236 // -----------------------------------------------------------------------------
   251 // Gets the correct text color.
   237 // Gets the correct text color.
   252 // -----------------------------------------------------------------------------
   238 // -----------------------------------------------------------------------------
   369 // ---------------------------------------------------------------------------
   355 // ---------------------------------------------------------------------------
   370 //    
   356 //    
   371 TInt CDialerKeyPadButton::KeyCode() const
   357 TInt CDialerKeyPadButton::KeyCode() const
   372     {
   358     {
   373     return iKeyCode;
   359     return iKeyCode;
   374     }    
   360     }
       
   361 
       
   362 
   375 // ---------------------------------------------------------------------------
   363 // ---------------------------------------------------------------------------
   376 // 
   364 // 
   377 // ---------------------------------------------------------------------------
   365 // ---------------------------------------------------------------------------
   378 //
   366 //
   379 void CDialerKeyPadButton::MapDialerIconToSkinIcon( 
   367 void CDialerKeyPadButton::MapDialerIconToSkinIcon( 
   386             break; 
   374             break; 
   387         default:
   375         default:
   388             break;
   376             break;
   389         }
   377         }
   390     }   
   378     }   
       
   379 
       
   380 
       
   381 // ---------------------------------------------------------------------------
       
   382 // 
       
   383 // ---------------------------------------------------------------------------
       
   384 //
       
   385 void CDialerKeyPadButton::SetIconLayout( const TRect& aRect )
       
   386     {
       
   387     // Calculate icon size and placement.
       
   388     TInt iconSize = aRect.Height() * KIconSizePercent / KCent;             
       
   389     TInt xMargin = aRect.Width() * KIconMarginXPercent / KCent;
       
   390     TInt yMargin = aRect.Height() * KIconMarginYPercent / KCent;
       
   391     
       
   392     // Adapt icon size and vertical margin. If the button has 
       
   393     // already two lines of text, use smaller icon size
       
   394     if ( iOperationMode == EModeEasyDialing && iSecondaryAlphaLabel.Length() ) 
       
   395         {
       
   396         iconSize = aRect.Height() * KSmallIconSizePercent / KCent;
       
   397         yMargin = 0;
       
   398         }
       
   399     
       
   400     if ( AknLayoutUtils::LayoutMirrored() ) 
       
   401         {
       
   402         iIconRect.SetRect( aRect.iTl.iX + xMargin,
       
   403                 aRect.iTl.iY + yMargin, 
       
   404                 aRect.iTl.iX + xMargin + iconSize, 
       
   405                 aRect.iTl.iY + iconSize + yMargin );       
       
   406         }
       
   407     else 
       
   408         {
       
   409         iIconRect.SetRect( aRect.iBr.iX - iconSize - xMargin,
       
   410                 aRect.iTl.iY + yMargin, 
       
   411                 aRect.iBr.iX - xMargin, 
       
   412                 aRect.iTl.iY + iconSize + yMargin );        
       
   413         }
       
   414     SetIconSize( iIconRect.Size() );
       
   415     }
       
   416 
   391 
   417 
   392 // ---------------------------------------------------------------------------
   418 // ---------------------------------------------------------------------------
   393 // Update icon when skin is changed
   419 // Update icon when skin is changed
   394 // ---------------------------------------------------------------------------
   420 // ---------------------------------------------------------------------------
   395 //   
   421 //