193 TAknLayoutRect iconLayout; |
193 TAknLayoutRect iconLayout; |
194 const CGulIcon* icon = GetCurrentIcon(); |
194 const CGulIcon* icon = GetCurrentIcon(); |
195 |
195 |
196 if ( iOperationMode == EModeEasyDialing ) |
196 if ( iOperationMode == EModeEasyDialing ) |
197 { |
197 { |
198 // Number layout. |
198 // Number layout |
199 iNumberLayout.LayoutText( buttonRect, |
199 TAknTextComponentLayout numLayout = |
200 AknLayoutScalable_Apps::cell_dia3_key_num_pane_t1( iVariety ) ); |
200 AknLayoutScalable_Apps::cell_dia3_key_num_pane_t1( iVariety ); |
201 // Use different number layout if key doens't contain any alphabets or icon. |
201 // Center the number label if key doens't contain any alphabets or icon. |
202 if ( !icon && !iPrimaryAlphaLabel.Length() && !iSecondaryAlphaLabel.Length() ) |
202 if ( !icon && !iPrimaryAlphaLabel.Length() && !iSecondaryAlphaLabel.Length() ) |
203 { |
203 { |
204 iNumberLayout.LayoutText( buttonRect, |
204 // eliminate margins, alignment takes care of correct position |
205 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_t1(), |
205 numLayout.Setl( 0 ); |
206 iNumberLayout.Font() ); |
206 numLayout.Setr( 0 ); |
207 } |
207 numLayout.SetJ( 1 ); // ID for center alignment |
|
208 } |
|
209 iNumberLayout.LayoutText( buttonRect, numLayout ); |
208 |
210 |
209 // Alphabet layout is different if two rows of alphabets are given |
211 // Alphabet layout is different if two rows of alphabets are given |
210 if ( iSecondaryAlphaLabel.Length() ) |
212 if ( iSecondaryAlphaLabel.Length() ) |
211 { |
213 { |
212 iPrimaryAlphaLayout.LayoutText( buttonRect, |
214 iPrimaryAlphaLayout.LayoutText( buttonRect, |
221 } |
223 } |
222 } |
224 } |
223 else if ( iOperationMode == EModeDialer ) |
225 else if ( iOperationMode == EModeDialer ) |
224 { |
226 { |
225 // Number layout |
227 // Number layout |
226 iNumberLayout.LayoutText( buttonRect, |
228 // Center number labels as only numbers are shown |
227 AknLayoutScalable_Apps::cell_dialer2_keypad_pane_t1() ); |
229 TAknTextComponentLayout numLayout = |
|
230 AknLayoutScalable_Apps::cell_dia3_key_num_pane_t1( iVariety ); |
|
231 // eliminate margins, alignment takes care of correct position |
|
232 numLayout.Setl( 0 ); |
|
233 numLayout.Setr( 0 ); |
|
234 numLayout.SetJ( 1 ); // ID for center alignment |
|
235 iNumberLayout.LayoutText( buttonRect, numLayout ); |
228 } |
236 } |
229 else // video mode layout |
237 else // video mode layout |
230 { |
238 { |
231 // Number layout |
239 // Number layout |
232 iNumberLayout.LayoutText( buttonRect, |
240 iNumberLayout.LayoutText( buttonRect, |
233 AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() ); |
241 AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_t1() ); |
234 } |
242 } |
235 |
243 |
236 SetIconLayout( buttonRect ); |
244 SetIconLayout( buttonRect ); |
237 } |
245 } |
238 |
246 |
393 // |
401 // |
394 TInt CDialerKeyPadButton::ScanCode() const |
402 TInt CDialerKeyPadButton::ScanCode() const |
395 { |
403 { |
396 return iScanCode; |
404 return iScanCode; |
397 } |
405 } |
398 |
406 |
399 // --------------------------------------------------------------------------- |
407 // --------------------------------------------------------------------------- |
400 // |
408 // |
401 // --------------------------------------------------------------------------- |
409 // --------------------------------------------------------------------------- |
402 // |
410 // |
403 TInt CDialerKeyPadButton::KeyCode() const |
411 TInt CDialerKeyPadButton::KeyCode() const |
404 { |
412 { |
405 return iKeyCode; |
413 return iKeyCode; |
406 } |
414 } |
407 |
|
408 |
415 |
409 // --------------------------------------------------------------------------- |
416 // --------------------------------------------------------------------------- |
410 // |
417 // |
411 // --------------------------------------------------------------------------- |
418 // --------------------------------------------------------------------------- |
412 // |
419 // |
421 default: |
428 default: |
422 break; |
429 break; |
423 } |
430 } |
424 } |
431 } |
425 |
432 |
426 |
|
427 // --------------------------------------------------------------------------- |
433 // --------------------------------------------------------------------------- |
428 // |
434 // |
429 // --------------------------------------------------------------------------- |
435 // --------------------------------------------------------------------------- |
430 // |
436 // |
431 void CDialerKeyPadButton::SetIconLayout( const TRect& aRect ) |
437 void CDialerKeyPadButton::SetIconLayout( const TRect& aRect ) |
432 { |
438 { |
433 // Calculate icon size and placement. |
439 // Calculate icon size and placement. |
434 TInt iconSize = aRect.Height() * KIconSizePercent / KCent; |
440 TInt iconSize = aRect.Height() * KIconSizePercent / KCent; |
435 TInt xMargin = aRect.Width() * KIconMarginXPercent / KCent; |
441 TInt xMargin = aRect.Width() * KIconMarginXPercent / KCent; |
436 TInt yMargin = aRect.Height() * KIconMarginYPercent / KCent; |
442 TInt yMargin = aRect.Height() * KIconMarginYPercent / KCent; |
437 |
443 |
438 // Adapt icon size and vertical margin. If the button has |
444 // Adapt icon size and vertical margin. If the button has |
439 // already two lines of text, use smaller icon size |
445 // already two lines of text, use smaller icon size |
440 if ( iOperationMode == EModeEasyDialing && iSecondaryAlphaLabel.Length() ) |
446 if ( iOperationMode == EModeEasyDialing && iSecondaryAlphaLabel.Length() ) |
441 { |
447 { |
442 iconSize = aRect.Height() * KSmallIconSizePercent / KCent; |
448 iconSize = aRect.Height() * KSmallIconSizePercent / KCent; |
443 yMargin = 0; |
449 yMargin = 0; |
444 } |
450 } |
445 |
451 |
446 if ( AknLayoutUtils::LayoutMirrored() ) |
452 if ( AknLayoutUtils::LayoutMirrored() ) |
447 { |
453 { |
448 iIconRect.SetRect( aRect.iTl.iX + xMargin, |
454 iIconRect.SetRect( aRect.iTl.iX + xMargin, |
449 aRect.iTl.iY + yMargin, |
455 aRect.iTl.iY + yMargin, |
450 aRect.iTl.iX + xMargin + iconSize, |
456 aRect.iTl.iX + xMargin + iconSize, |
451 aRect.iTl.iY + iconSize + yMargin ); |
457 aRect.iTl.iY + iconSize + yMargin ); |
452 } |
458 } |
453 else |
459 else |
454 { |
460 { |
455 iIconRect.SetRect( aRect.iBr.iX - iconSize - xMargin, |
461 iIconRect.SetRect( aRect.iBr.iX - iconSize - xMargin, |
456 aRect.iTl.iY + yMargin, |
462 aRect.iTl.iY + yMargin, |
457 aRect.iBr.iX - xMargin, |
463 aRect.iBr.iX - xMargin, |
458 aRect.iTl.iY + iconSize + yMargin ); |
464 aRect.iTl.iY + iconSize + yMargin ); |
459 } |
465 } |
460 SetIconSize( iIconRect.Size() ); |
466 SetIconSize( iIconRect.Size() ); |
461 } |
467 } |
462 |
468 |
463 |
|
464 // --------------------------------------------------------------------------- |
469 // --------------------------------------------------------------------------- |
465 // Update icon when skin is changed |
470 // Update icon when skin is changed |
466 // --------------------------------------------------------------------------- |
471 // --------------------------------------------------------------------------- |
467 // |
472 // |
468 void CDialerKeyPadButton::UpdateIconL() |
473 void CDialerKeyPadButton::UpdateIconL() |
469 { |
474 { |
470 if ( KDialerNoIcon != iButtonIconId ) |
475 if ( KDialerNoIcon != iButtonIconId ) |
471 { |
476 { |
472 TFileName mifPath( KDriveZ ); |
477 TFileName mifPath( KDriveZ ); |