phoneuis/dialer/src/cdialerkeypadcontainer.cpp
branchRCL_3
changeset 3 8871b09be73b
parent 0 5f000ab63145
child 4 24062c24fe38
equal deleted inserted replaced
2:c84cf270c54f 3:8871b09be73b
     1 /*
     1 /*
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2007 - 2010 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    19 
    19 
    20 // INCLUDE FILES
    20 // INCLUDE FILES
    21 #include <e32event.h>
    21 #include <e32event.h>
    22 #include <gulicon.h>
    22 #include <gulicon.h>
    23 #include <eikapp.h>
    23 #include <eikapp.h>
    24 #include <AknUtils.h>
       
    25 #include <aknbutton.h>
    24 #include <aknbutton.h>
    26 #include <AknControl.h>
    25 #include <AknControl.h>
    27 #include <AknsUtils.h>
    26 #include <AknsUtils.h>
    28 #include <AknsSkinInstance.h>
    27 #include <AknsSkinInstance.h>
    29 #include <AknsDrawUtils.h>
    28 #include <AknsDrawUtils.h>
    31 #include <AknLayout2Def.h>
    30 #include <AknLayout2Def.h>
    32 #include <aknlayoutscalable_apps.cdl.h>
    31 #include <aknlayoutscalable_apps.cdl.h>
    33 #include <layoutmetadata.cdl.h>
    32 #include <layoutmetadata.cdl.h>
    34 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    33 #include <data_caging_path_literals.hrh> // for KDC_APP_RESOURCE_DIR
    35 #include <touchfeedback.h>
    34 #include <touchfeedback.h>
       
    35 #include <aknlayoutscalable_avkon.cdl.h>
       
    36 #include <aknsframebackgroundcontrolcontext.h>
    36 
    37 
    37 #include "cdialerkeypadcontainer.h"
    38 #include "cdialerkeypadcontainer.h"
    38 #include "dialercommon.h"
    39 #include "dialercommon.h"
    39 #include "dialertrace.h"
    40 #include "dialertrace.h"
    40 
    41 
    41 #include "cdialerkeypadbutton.h"
    42 #include "cdialerkeypadbutton.h"
    42 _LIT( KDialerMifFileName, "dialer.mif" );
       
    43 
    43 
    44 // Number of buttons in this container
    44 // Number of buttons in this container
    45 const TInt KNumberOfButtons = 12; 
    45 const TInt KNumberOfButtons = 12; 
    46 
    46 
    47 // Keypad button images
    47 struct TDialerButton
    48 const TMifDialer KKeyPadButtons[] =
    48     {
    49     {
    49     TMifDialer iBitmap;
    50     EMbmDialerQgn_indi_dialer_one,
    50     TMifDialer iBitmapMask;
    51     EMbmDialerQgn_indi_dialer_two,
    51     TInt iScanCode;
    52     EMbmDialerQgn_indi_dialer_three,
    52     TInt iKeyCode;
    53     EMbmDialerQgn_indi_dialer_four,
    53     };  
    54     EMbmDialerQgn_indi_dialer_five,
    54 
    55     EMbmDialerQgn_indi_dialer_six,
    55 const TDialerButton KKeyPadButtons[ KNumberOfButtons ] =
    56     EMbmDialerQgn_indi_dialer_seven,
    56 
    57     EMbmDialerQgn_indi_dialer_eight,
    57     {
    58     EMbmDialerQgn_indi_dialer_nine,
    58         { EMbmDialerQgn_indi_dialer_voicemail,
    59     EMbmDialerQgn_indi_dialer_prefix,
    59           EMbmDialerQgn_indi_dialer_voicemail_mask, 
    60     EMbmDialerQgn_indi_dialer_zero,
    60           '1',
    61     EMbmDialerQgn_indi_dialer_hash
    61           '1'
       
    62         },
       
    63         { KDialerNoIcon, KDialerNoIcon, 
       
    64           '2', '2' },
       
    65         { KDialerNoIcon, KDialerNoIcon,  
       
    66           '3', '3' },
       
    67         { KDialerNoIcon, KDialerNoIcon,  
       
    68           '4', '4' },
       
    69         { KDialerNoIcon, KDialerNoIcon,  
       
    70           '5', '5' },
       
    71         { KDialerNoIcon, KDialerNoIcon,  
       
    72           '6', '6' },
       
    73         { KDialerNoIcon, KDialerNoIcon, 
       
    74           '7', '7' },
       
    75         { KDialerNoIcon, KDialerNoIcon,  
       
    76           '8', '8' },
       
    77         { KDialerNoIcon, KDialerNoIcon,  
       
    78           '9', '9' },
       
    79         { KDialerNoIcon, KDialerNoIcon,  
       
    80           EStdKeyNkpAsterisk, '*'  },
       
    81         { KDialerNoIcon, KDialerNoIcon,  
       
    82           '0', '0' },
       
    83         { KDialerNoIcon, KDialerNoIcon,      
       
    84           EStdKeyHash, '#' }
    62     };
    85     };
    63 
    86 
    64 // Keypad button image masks
    87 
    65 const TMifDialer KKeyPadButtonsMasks[] =
       
    66     {
       
    67     EMbmDialerQgn_indi_dialer_one_mask,
       
    68     EMbmDialerQgn_indi_dialer_two_mask,
       
    69     EMbmDialerQgn_indi_dialer_three_mask,
       
    70     EMbmDialerQgn_indi_dialer_four_mask,
       
    71     EMbmDialerQgn_indi_dialer_five_mask,
       
    72     EMbmDialerQgn_indi_dialer_six_mask,
       
    73     EMbmDialerQgn_indi_dialer_seven_mask,
       
    74     EMbmDialerQgn_indi_dialer_eight_mask,
       
    75     EMbmDialerQgn_indi_dialer_nine_mask,
       
    76     EMbmDialerQgn_indi_dialer_prefix_mask,
       
    77     EMbmDialerQgn_indi_dialer_zero_mask,
       
    78     EMbmDialerQgn_indi_dialer_hash_mask
       
    79     };
       
    80 
       
    81 // Match keypresses to keyevents send to the phone
       
    82 //
       
    83 const TInt TDialerButtonToKeypadMap[12][2] = 
       
    84         {  
       
    85             { 49, // ScanCode
       
    86               49  // KeyCode
       
    87             },
       
    88             { 50,
       
    89               50
       
    90             },
       
    91             { 51,
       
    92               51
       
    93             },
       
    94             { 52,
       
    95               52
       
    96             },    
       
    97             { 53,
       
    98               53
       
    99             },
       
   100             { 54,
       
   101               54
       
   102             },
       
   103             { 55,
       
   104               55
       
   105             },
       
   106             { 56,
       
   107               56
       
   108             },
       
   109             { 57,
       
   110               57
       
   111             },                        
       
   112             { EStdKeyNkpAsterisk,
       
   113               42
       
   114             },
       
   115             { '0',
       
   116               '0'
       
   117             }, 
       
   118             { EStdKeyHash,
       
   119               35
       
   120             }                                                                                                       
       
   121         };   
       
   122 
       
   123 // Class declaration for CDialerKeyPadButton separated to cdialerkeypadbutton.h.
       
   124 
       
   125 // ---------------------------------------------------------------------------
       
   126 // C++ default constructor
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 CDialerKeyPadButton::CDialerKeyPadButton()
       
   130     {
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // Destructor
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 CDialerKeyPadButton::~CDialerKeyPadButton()
       
   138     {
       
   139     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   140     if ( feedback )
       
   141         {
       
   142         feedback->RemoveFeedbackForControl( iButton );
       
   143         }
       
   144     delete iButton;   
       
   145     }
       
   146         
       
   147 // ---------------------------------------------------------------------------
       
   148 // Creates number keypad button
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CDialerKeyPadButton::CreateButtonL( const TInt aScanCode, 
       
   152                                          const TInt aKeyCode,
       
   153                                          const TMifDialer aButtonIcon, 
       
   154                                          const TMifDialer aButtonIconMask )
       
   155     {
       
   156     iScanCode = aScanCode;
       
   157     iKeyCode  = aKeyCode;
       
   158     iButtonIcon = aButtonIcon;
       
   159     iButtonIconMask = aButtonIconMask;
       
   160     
       
   161     TFileName mifPath( KDriveZ );
       
   162     mifPath.Append( KDC_APP_BITMAP_DIR );
       
   163     mifPath.Append( KDialerMifFileName );
       
   164 
       
   165     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   166     CFbsBitmap* bitmap (NULL);
       
   167     CFbsBitmap* mask (NULL);
       
   168 
       
   169     // Get icon ids.
       
   170     TAknsItemID skinItemId( KAknsIIDNone );  
       
   171     
       
   172     // Create button image.
       
   173     MapDialerIconToSkinIcon( aButtonIcon ,skinItemId );
       
   174     AknsUtils::CreateColorIconLC( 
       
   175         skin, 
       
   176         skinItemId,
       
   177         KAknsIIDQsnIconColors, 
       
   178         EAknsCIQsnIconColorsCG30,
       
   179         bitmap, 
       
   180         mask, 
       
   181         mifPath, 
       
   182         aButtonIcon, 
       
   183         aButtonIconMask,
       
   184         KRgbBlack
       
   185         );
       
   186 
       
   187     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   188     CleanupStack::Pop( 2 );
       
   189     CleanupStack::PushL( icon );
       
   190     iButton = CAknButton::NewL(
       
   191         icon , // ownership taken
       
   192         NULL, NULL, NULL, _L(""), _L(""), 0, 0 );
       
   193     iButton->SetButtonFlags( KAknButtonReportOnLongPress|
       
   194                             KAknButtonReportOnKeyDown  |
       
   195                             KAknButtonRequestExitOnButtonUpEvent );
       
   196     iButton->SetIconScaleMode( EAspectRatioPreserved );
       
   197     iButton->SetMargins( TMargins8(0,0,0,0) );    
       
   198     CleanupStack::Pop( icon ); 
       
   199     }
       
   200     
       
   201 // ---------------------------------------------------------------------------
       
   202 // 
       
   203 // ---------------------------------------------------------------------------
       
   204 //    
       
   205 TInt CDialerKeyPadButton::ScanCode() const
       
   206     {
       
   207     return iScanCode;
       
   208     }
       
   209     
       
   210 // ---------------------------------------------------------------------------
       
   211 // 
       
   212 // ---------------------------------------------------------------------------
       
   213 //    
       
   214 TInt CDialerKeyPadButton::KeyCode() const
       
   215     {
       
   216     return iKeyCode;
       
   217     }    
       
   218 // ---------------------------------------------------------------------------
       
   219 // 
       
   220 // ---------------------------------------------------------------------------
       
   221 //
       
   222 void CDialerKeyPadButton::MapDialerIconToSkinIcon( const TInt aDialerIcon, 
       
   223                                          TAknsItemID& aItemId ) const
       
   224     {    
       
   225     switch ( aDialerIcon )
       
   226         {
       
   227         case EMbmDialerQgn_indi_dialer_one:
       
   228             aItemId = KAknsIIDQgnIndiDialerOne;
       
   229             break;
       
   230         case EMbmDialerQgn_indi_dialer_two:
       
   231             aItemId = KAknsIIDQgnIndiDialerTwo;
       
   232             break;
       
   233         case EMbmDialerQgn_indi_dialer_three:
       
   234             aItemId = KAknsIIDQgnIndiDialerThree;
       
   235             break;
       
   236         case EMbmDialerQgn_indi_dialer_four:
       
   237             aItemId = KAknsIIDQgnIndiDialerFour;
       
   238             break;
       
   239         case EMbmDialerQgn_indi_dialer_five:
       
   240             aItemId = KAknsIIDQgnIndiDialerFive;
       
   241             break;
       
   242         case EMbmDialerQgn_indi_dialer_six:
       
   243             aItemId = KAknsIIDQgnIndiDialerSix;
       
   244             break;
       
   245         case EMbmDialerQgn_indi_dialer_seven:
       
   246             aItemId = KAknsIIDQgnIndiDialerSeven;
       
   247             break;    
       
   248         case EMbmDialerQgn_indi_dialer_eight:
       
   249             aItemId = KAknsIIDQgnIndiDialerEight;
       
   250             break;
       
   251         case EMbmDialerQgn_indi_dialer_nine:
       
   252             aItemId = KAknsIIDQgnIndiDialerNine;
       
   253             break;
       
   254         case EMbmDialerQgn_indi_dialer_zero:
       
   255             aItemId = KAknsIIDQgnIndiDialerZero;
       
   256             break;
       
   257         case EMbmDialerQgn_indi_dialer_prefix:
       
   258             aItemId = KAknsIIDQgnIndiDialerPrefix;
       
   259             break;
       
   260         case EMbmDialerQgn_indi_dialer_hash:
       
   261             aItemId = KAknsIIDQgnIndiDialerHash;
       
   262             break;                        
       
   263         default:
       
   264             break;
       
   265         }
       
   266     }   
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // 
       
   270 // ---------------------------------------------------------------------------
       
   271 //   
       
   272 void CDialerKeyPadButton::SetIconSize( TSize& aSize )
       
   273     {
       
   274     iButton->SetIconSize( aSize );
       
   275     }  
       
   276     
       
   277 // ---------------------------------------------------------------------------
       
   278 // 
       
   279 // ---------------------------------------------------------------------------
       
   280 //   
       
   281 void CDialerKeyPadButton::UpdateIconL()
       
   282     {
       
   283     TFileName mifPath( KDriveZ );
       
   284     mifPath.Append( KDC_APP_BITMAP_DIR );
       
   285     mifPath.Append( KDialerMifFileName );
       
   286     
       
   287     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   288     CFbsBitmap* bitmap (NULL);
       
   289     CFbsBitmap* mask (NULL);
       
   290         
       
   291     // Get icon id.
       
   292     TAknsItemID skinItemId( KAknsIIDNone );  
       
   293     MapDialerIconToSkinIcon( iButtonIcon, skinItemId );
       
   294     
       
   295     AknsUtils::CreateColorIconLC( 
       
   296             skin, 
       
   297             skinItemId,
       
   298             KAknsIIDQsnIconColors, 
       
   299             EAknsCIQsnIconColorsCG30,
       
   300             bitmap, 
       
   301             mask, 
       
   302             mifPath, 
       
   303             iButtonIcon, 
       
   304             iButtonIconMask,
       
   305             KRgbBlack
       
   306             );
       
   307     
       
   308     CGulIcon* icon = CGulIcon::NewL( bitmap, mask );
       
   309     CleanupStack::Pop( 2 );
       
   310     
       
   311     iButton->State()->SetIcon( icon ); // icon ownership transfered
       
   312     
       
   313     }  
       
   314 
       
   315 // ---------------------------------------------------------------------------
       
   316 // 
       
   317 // Enable or disable audio but keep vibra feedback 
       
   318 // ---------------------------------------------------------------------------
       
   319 //   
       
   320 void CDialerKeyPadButton::EnableAudioFeedback( const TBool aEnable )
       
   321     {
       
   322     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   323     if ( feedback )
       
   324         {
       
   325         feedback->EnableFeedbackForControl( iButton, ETrue, aEnable );
       
   326         }
       
   327     }
       
   328 // ---------------------------------------------------------------------------
       
   329 // 
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 void CDialerKeyPadButton::HandleResourceChange( TInt aType )
       
   333     {
       
   334     if ( aType == KAknsMessageSkinChange )
       
   335         {
       
   336         TRAP_IGNORE( UpdateIconL() );
       
   337         iButton->HandleResourceChange( aType );
       
   338         }    
       
   339     }
       
   340 
    88 
   341 // ========================= MEMBER FUNCTIONS ================================
    89 // ========================= MEMBER FUNCTIONS ================================
   342 
    90 
   343 // ---------------------------------------------------------------------------
    91 // ---------------------------------------------------------------------------
   344 // Symbian OS two phased constructor
    92 // Symbian OS two phased constructor
   364 //
   112 //
   365 void CDialerKeyPadContainer::ConstructL()
   113 void CDialerKeyPadContainer::ConstructL()
   366     {    
   114     {    
   367     DIALER_PRINT("KeyPadContainer::ConstructL<");
   115     DIALER_PRINT("KeyPadContainer::ConstructL<");
   368     BaseConstructL();
   116     BaseConstructL();
       
   117     iKeyLabelManager = CDialerKeyPadLabelManager::NewL( *iCoeEnv, *this );
   369     CreateButtonsL();
   118     CreateButtonsL();
   370     CCoeEnv* env = CCoeEnv::Static();
   119     iCoeEnv->AddForegroundObserverL( *this );
   371     env->AddForegroundObserverL( *this );
       
   372     DIALER_PRINT("KeyPadContainer::ConstructL>");
   120     DIALER_PRINT("KeyPadContainer::ConstructL>");
   373     }
   121     }
   374 
   122 
   375 // Constructor
   123 // Constructor
   376 CDialerKeyPadContainer::CDialerKeyPadContainer( 
   124 CDialerKeyPadContainer::CDialerKeyPadContainer( 
   385     
   133     
   386 // Destructor
   134 // Destructor
   387 CDialerKeyPadContainer::~CDialerKeyPadContainer()
   135 CDialerKeyPadContainer::~CDialerKeyPadContainer()
   388     {
   136     {
   389     for ( TInt i = 0; i < iButtonCount; i++ )
   137     for ( TInt i = 0; i < iButtonCount; i++ )
   390         {
   138         {   
   391         AknsUtils::DeregisterControlPosition( 
       
   392                    ((CDialerKeyPadButton*)iButtons[i])->Control());   
       
   393         delete iButtons[i];
   139         delete iButtons[i];
   394         }
   140         }
   395     iButtons.Close();
   141     iButtons.Close();
   396     CCoeEnv* env = CCoeEnv::Static();
   142     iCoeEnv->RemoveForegroundObserver( *this );
   397     env->RemoveForegroundObserver( *this );
   143     delete iKeyLabelManager;
   398     }
   144     }
   399 
   145 
   400 // ---------------------------------------------------------------------------
   146 // ---------------------------------------------------------------------------
   401 // CDialerKeyPadContainer::CountComponentControls
   147 // CDialerKeyPadContainer::CountComponentControls
   402 //
   148 //
   415 CCoeControl* CDialerKeyPadContainer::ComponentControl( TInt aIndex ) const
   161 CCoeControl* CDialerKeyPadContainer::ComponentControl( TInt aIndex ) const
   416     {
   162     {
   417     __ASSERT_DEBUG( aIndex < KNumberOfButtons, 
   163     __ASSERT_DEBUG( aIndex < KNumberOfButtons, 
   418     _L("CDialerKeyPadContainer::ComponentControl, index out of range."));
   164     _L("CDialerKeyPadContainer::ComponentControl, index out of range."));
   419     
   165     
   420     return ((CDialerKeyPadButton*)iButtons[aIndex])->Control();
   166     return iButtons[aIndex];
   421     }
   167     }
   422     
   168     
   423 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   424 // CDialerKeyPadContainer::HandlePointerEventL
   170 // CDialerKeyPadContainer::HandlePointerEventL
   425 //
   171 //
   463 // Set layout for video dtmf or phone dialer 
   209 // Set layout for video dtmf or phone dialer 
   464 // ---------------------------------------------------------------------------
   210 // ---------------------------------------------------------------------------
   465 //
   211 //
   466 void CDialerKeyPadContainer::SetLayout()
   212 void CDialerKeyPadContainer::SetLayout()
   467     {
   213     {
   468     if ( iOperatingMode == EModeDialer )
   214     if ( iOperatingMode == EModeDialer ||
   469         {
   215          iOperatingMode == EModeEasyDialing )
   470         SetPhoneLayout();
   216         {
       
   217         // Same renewed layout is used regardless of the status
       
   218         // of Easy Dialing
       
   219         SetEasyDialingLayout();
   471         }
   220         }
   472     else
   221     else
   473         {
   222         {
   474         SetVideoLayout();
   223         SetVideoLayout();
   475         }
   224         }
   495     inline TAknLayoutScalableParameterLimits cell_dialer2_keypad_pane_g1_ParamLimits()
   244     inline TAknLayoutScalableParameterLimits cell_dialer2_keypad_pane_g1_ParamLimits()
   496     */
   245     */
   497     
   246     
   498     TRect parentRect( Rect() );
   247     TRect parentRect( Rect() );
   499 
   248 
   500     // Icon size - all in same size
       
   501     TAknLayoutRect functionGraphics;  
       
   502              
       
   503     functionGraphics.LayoutRect( 
       
   504         parentRect,
       
   505         TAknWindowComponentLayout::Compose(
       
   506             AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety ),
       
   507             AknLayoutScalable_Apps::cell_dialer2_keypad_pane_g1( 
       
   508                                                         iVariety ) ) );
       
   509     TSize iconSize = functionGraphics.Rect().Size();
       
   510     
       
   511     // Layout buttons
   249     // Layout buttons
   512     TAknLayoutScalableParameterLimits limits = 
   250     TAknLayoutScalableParameterLimits limits = 
   513     AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety );
   251         AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety );
   514     
   252     
   515     TInt i = 0;
   253     TInt i = 0;
   516     for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ )
   254     for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ )
   517         {
   255         {
   518         for ( TInt col = limits.FirstColumn(); 
   256         for ( TInt col = limits.FirstColumn(); 
   519               col <= limits.LastColumn(); col++ )
   257               col <= limits.LastColumn(); col++ )
   520             {
   258             {
       
   259             iButtons[i]->SetVariety( iVariety );
       
   260             iButtons[i]->SetOperationMode( iOperatingMode );
       
   261     
       
   262             AknLayoutUtils::LayoutControl( iButtons[i], parentRect, TAknWindowComponentLayout::Compose( 
       
   263                     AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety, col, row ), 
       
   264                     AknLayoutScalable_Apps::bg_button_pane_pane_cp04( iVariety ) ) );
       
   265             i++;
       
   266             }
       
   267         }
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------------------------
       
   271 // CDialerKeyPadContainer::SetEasyDialingLayout
       
   272 //
       
   273 // ---------------------------------------------------------------------------
       
   274 //
       
   275 void CDialerKeyPadContainer::SetEasyDialingLayout()
       
   276     {
       
   277     TRect parentRect( Rect() );
       
   278     
       
   279     // Layout buttons
       
   280     TAknLayoutScalableParameterLimits limits = 
       
   281         AknLayoutScalable_Apps::cell_dialer2_keypad_pane_ParamLimits( iVariety );
       
   282     
       
   283     // Rectangle of the first button
       
   284     TAknLayoutRect buttonLayoutRect;
       
   285     buttonLayoutRect.LayoutRect( parentRect, 
       
   286             AknLayoutScalable_Apps::cell_dia3_key_num_pane( iVariety ) );
       
   287     TRect firstButtonRect = buttonLayoutRect.Rect();
       
   288     // Move the first button rect to top-left-corner of the keypad area, 
       
   289     // the default place is wrong in mirrored layout.
       
   290     firstButtonRect.SetRect( parentRect.iTl, firstButtonRect.Size() );
       
   291     
       
   292     TInt colCount = limits.LastColumn() - limits.FirstColumn() + 1;
       
   293 
       
   294     for ( TInt row = limits.FirstRow() ; row <= limits.LastRow() ; row++ )
       
   295         {
       
   296         for ( TInt col = limits.FirstColumn() ; col <= limits.LastColumn() ; col++ )
       
   297             {
       
   298             // Calculate corresponding index in iButtons array
       
   299             TInt idx = col + row * colCount;
       
   300             
       
   301             // Set mode and variety so that correct button internal layout will be used
       
   302             iButtons[idx]->SetVariety( iVariety );
       
   303             iButtons[idx]->SetOperationMode( iOperatingMode );
       
   304             
   521             // Layout button
   305             // Layout button
   522             AknLayoutUtils::LayoutControl(
   306             TRect buttonRect = firstButtonRect;
   523                 ((CDialerKeyPadButton*)iButtons[i])->Control(), parentRect, 
   307             buttonRect.Move( col * buttonRect.Width(), row * buttonRect.Height() );
   524                 TAknWindowComponentLayout::Compose( 
   308             buttonRect.Shrink( 1, 1 ); // to create small gap between buttons
   525                     AknLayoutScalable_Apps::cell_dialer2_keypad_pane( iVariety,
   309             iButtons[idx]->SetRect( buttonRect );
   526                                                 col, row ), 
       
   527                     AknLayoutScalable_Apps::bg_button_pane_pane_cp04( 
       
   528                                                 iVariety ) ) );
       
   529             
       
   530             // Set icon size
       
   531             ((CDialerKeyPadButton*)iButtons[i++])->SetIconSize( iconSize );
       
   532             }
   310             }
   533         }
   311         }
       
   312     
   534     }
   313     }
   535 
   314 
   536 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   537 // CDialerKeyPadContainer::SetVideoLayout
   316 // CDialerKeyPadContainer::SetVideoLayout
   538 //
   317 //
   540 //
   319 //
   541 void CDialerKeyPadContainer::SetVideoLayout()
   320 void CDialerKeyPadContainer::SetVideoLayout()
   542     {
   321     {
   543     TRect parentRect( Rect() );
   322     TRect parentRect( Rect() );
   544     
   323     
   545     // Icon size - all in same size
       
   546     TAknLayoutRect functionGraphics;  
       
   547              
       
   548     functionGraphics.LayoutRect( 
       
   549         parentRect,
       
   550         TAknWindowComponentLayout::Compose(
       
   551             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane( iVariety, 
       
   552                                         0, 0 ),
       
   553             AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_g1( 
       
   554                                         iVariety ) ) );
       
   555     TSize iconSize = functionGraphics.Rect().Size();
       
   556     
       
   557     TAknLayoutScalableParameterLimits limits = 
   324     TAknLayoutScalableParameterLimits limits = 
   558         AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_ParamLimits( 
   325         AknLayoutScalable_Apps::cell_video_dialer_keypad_pane_ParamLimits( iVariety ) ;
   559                                         iVariety ) ;
       
   560     
   326     
   561     TInt i = 0;
   327     TInt i = 0;
   562     for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ )
   328     for ( TInt row = limits.FirstRow(); row <= limits.LastRow(); row++ )
   563         {
   329         {
   564         for ( TInt col = limits.FirstColumn(); 
   330         for ( TInt col = limits.FirstColumn(); 
   565               col <= limits.LastColumn(); 
   331               col <= limits.LastColumn(); 
   566               col++ )
   332               col++ )
   567             {
   333             {
       
   334             iButtons[i]->SetVariety( iVariety );
       
   335             iButtons[i]->SetOperationMode( iOperatingMode );
       
   336         
   568             // Layout button
   337             // Layout button
   569             AknLayoutUtils::LayoutControl(
   338             AknLayoutUtils::LayoutControl(
   570                 ((CDialerKeyPadButton*)iButtons[i])->Control(), parentRect, 
   339                 iButtons[i], parentRect, 
   571                 TAknWindowComponentLayout::Compose( 
   340                 TAknWindowComponentLayout::Compose( 
   572                     AknLayoutScalable_Apps::cell_video_dialer_keypad_pane( 
   341                     AknLayoutScalable_Apps::cell_video_dialer_keypad_pane( 
   573                         iVariety, col, row ), 
   342                         iVariety, col, row ),             
   574                     AknLayoutScalable_Apps::bg_button_pane_cp08( 
   343                     AknLayoutScalable_Apps::bg_button_pane_cp08( iVariety ) ) );
   575                                         iVariety ) ) );
   344             i++;
   576             
       
   577             // Set icon size
       
   578             iButtons[i++]->SetIconSize( iconSize );
       
   579             }
   345             }
   580         }
   346         }
   581     }
   347     }
   582 
   348 
   583 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   588 //
   354 //
   589 void CDialerKeyPadContainer::CreateButtonsL()
   355 void CDialerKeyPadContainer::CreateButtonsL()
   590     {
   356     {
   591     DIALER_PRINT("KeyPadContainer::CreateButtonsL<");
   357     DIALER_PRINT("KeyPadContainer::CreateButtonsL<");
   592     
   358     
   593     for ( TInt i=0; i < KNumberOfButtons; i++ )
   359     TInt flags ( KAknButtonReportOnLongPress|
   594         {
   360                  KAknButtonReportOnKeyDown  |
   595         CDialerKeyPadButton* button = new (ELeave) CDialerKeyPadButton();
   361                  KAknButtonRequestExitOnButtonUpEvent );
   596         CleanupStack::PushL( button );
   362     
   597         button->CreateButtonL( TDialerButtonToKeypadMap[i][0],
   363     for ( TInt i = 0; i < KNumberOfButtons; i++ )
   598                                TDialerButtonToKeypadMap[i][1],         
   364         {
   599                                KKeyPadButtons[i],
   365         const TPtrC numLabel = iKeyLabelManager->ButtonNumLabel( i );
   600                                KKeyPadButtonsMasks[i] );
   366 
       
   367         const TPtrC alphaLabel = iKeyLabelManager->ButtonFirstAlphaLabel( i );
       
   368 
       
   369         const TPtrC secondAlphaLabel = iKeyLabelManager->ButtonSecondAlphaLabel( i );
       
   370         
       
   371         CDialerKeyPadButton* button = CDialerKeyPadButton::NewLC( 
       
   372             numLabel,
       
   373             alphaLabel,
       
   374             secondAlphaLabel,
       
   375             KKeyPadButtons[i].iScanCode,
       
   376             KKeyPadButtons[i].iKeyCode,
       
   377             KKeyPadButtons[i].iBitmap,
       
   378             KKeyPadButtons[i].iBitmapMask,
       
   379             flags );
       
   380         iButtons.AppendL( button );
   601         CleanupStack::Pop( button );
   381         CleanupStack::Pop( button );
   602         iButtons.Append( button );                      
   382         
   603         button->Control()->SetMopParent( this );
   383         button->SetMopParent( this );
   604         button->Control()->SetParent( this );    
   384         button->SetParent( this );
   605         button->Control()->SetContainerWindowL( *this );
   385         button->SetContainerWindowL( *this );
   606         button->Control()->SetObserver( this );    
   386         button->SetObserver( this );
   607         button->Control()->ActivateL();
   387         button->ActivateL();
   608         AknsUtils::RegisterControlPosition( button->Control() );   
       
   609         }     
   388         }     
   610     DIALER_PRINT("KeyPadContainer::CreateButtonsL>");        
   389     DIALER_PRINT("KeyPadContainer::CreateButtonsL>");
   611     }
   390     }
   612 
   391 
   613 // ---------------------------------------------------------------------------
   392 // ---------------------------------------------------------------------------
   614 // CDialerKeyPadContainer::HandleControlEventL
   393 // CDialerKeyPadContainer::HandleControlEventL
   615 //
   394 //
   633         // Find tapped control 
   412         // Find tapped control 
   634 
   413 
   635         CDialerKeyPadButton* tappedButton = NULL;
   414         CDialerKeyPadButton* tappedButton = NULL;
   636         for ( TInt i=0; i < iButtons.Count(); i++ )
   415         for ( TInt i=0; i < iButtons.Count(); i++ )
   637             {
   416             {
   638             if ( iButtons[i]->Control() == aControl )
   417             if ( iButtons[i] == aControl )
   639                 {
   418                 {
   640                 tappedButton = iButtons[i];
   419                 tappedButton = iButtons[i];
   641                 break;
   420                 break;
   642                 }    
   421                 }    
   643             }
   422             }
   644             
   423         
       
   424         __ASSERT_ALWAYS( tappedButton, 
       
   425         _L("CDialerKeyPadContainer::HandleControlEventL, invalid button handle"));
       
   426         
   645         // Send key event to phone.
   427         // Send key event to phone.
   646         TKeyEvent keyEvent;
   428         TKeyEvent keyEvent;
   647         keyEvent.iScanCode = tappedButton->ScanCode();
   429         keyEvent.iScanCode = tappedButton->ScanCode();
   648         keyEvent.iCode = tappedButton->KeyCode();
       
   649         keyEvent.iModifiers = 0;
   430         keyEvent.iModifiers = 0;
   650         keyEvent.iRepeats = 0;  
   431         keyEvent.iRepeats = 0;  
   651              
   432              
   652         switch ( aEventType )
   433         switch ( aEventType )
   653             {
   434             {
   662                 break;
   443                 break;
   663             case EEventStateChanged:
   444             case EEventStateChanged:
   664                 {    
   445                 {    
   665                 DIALER_PRINT("HandleControlEventL.EEventStateChanged");
   446                 DIALER_PRINT("HandleControlEventL.EEventStateChanged");
   666                 iButtonPressedDown = ETrue;
   447                 iButtonPressedDown = ETrue;
   667 
   448                 keyEvent.iCode = tappedButton->KeyCode();
   668                 iParentControl.PrepareForFocusGainL();
   449                 iParentControl.PrepareForFocusGainL();
   669 
   450 
   670                 ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyDown );    
   451                 ControlEnv()->SimulateKeyEventL( keyEvent, EEventKeyDown );    
   671 
   452 
   672                 if( iButtonPressedDown )
   453                 if( iButtonPressedDown )
   694     {
   475     {
   695     if ( aType == KAknsMessageSkinChange )
   476     if ( aType == KAknsMessageSkinChange )
   696         {    
   477         {    
   697         for ( TInt i=0; i < iButtons.Count(); i++ )
   478         for ( TInt i=0; i < iButtons.Count(); i++ )
   698             {
   479             {
   699             (( CDialerKeyPadButton* )iButtons[i])->HandleResourceChange( 
   480             iButtons[i]->HandleResourceChange( aType );
   700                                                                     aType );
       
   701             }
   481             }
   702         }
   482         }
   703     }
   483     }
   704 
   484 
   705 // ---------------------------------------------------------------------------
   485 // ---------------------------------------------------------------------------
   706 // CDialerKeyPadContainer::MakeVisible
   486 // CDialerKeyPadContainer::MakeVisible
   707 //
   487 //
   708 // Called when dialer control come visible or unvisible
   488 // Called when dialer control becomes visible or invisible
   709 //
   489 //
   710 // ---------------------------------------------------------------------------
   490 // ---------------------------------------------------------------------------
   711 //
   491 //
   712 void CDialerKeyPadContainer::MakeVisible( TBool aVisible )
   492 void CDialerKeyPadContainer::MakeVisible( TBool aVisible )
   713     {
   493     {
   721         TRAP_IGNORE( HandlePointerEventL( iPointerEvent ) );
   501         TRAP_IGNORE( HandlePointerEventL( iPointerEvent ) );
   722         }    
   502         }    
   723     CCoeControl::MakeVisible( aVisible );        
   503     CCoeControl::MakeVisible( aVisible );        
   724     }
   504     }
   725 
   505 
       
   506 // ---------------------------------------------------------------------------
       
   507 // CDialerKeyPadContainer::SetOperationMode
       
   508 //
       
   509 // Set new operation mode for the keypad
       
   510 //
       
   511 // ---------------------------------------------------------------------------
       
   512 //
       
   513 void CDialerKeyPadContainer::SetOperationMode( TDialerOperationMode aOperatingMode )
       
   514     {
       
   515     iOperatingMode = aOperatingMode;
       
   516     }
   726 
   517 
   727 // ---------------------------------------------------------------------------
   518 // ---------------------------------------------------------------------------
   728 // CDialerKeyPadContainer::HandleGainingForeground
   519 // CDialerKeyPadContainer::HandleGainingForeground
   729 //
   520 //
   730 //
   521 //
   753         TRAP_IGNORE( HandlePointerEventL( iPointerEvent ) );
   544         TRAP_IGNORE( HandlePointerEventL( iPointerEvent ) );
   754         }    
   545         }    
   755     }
   546     }
   756 
   547 
   757 // ---------------------------------------------------------------------------
   548 // ---------------------------------------------------------------------------
       
   549 // CDialerKeyPadContainer::KeyLabelsChanged
       
   550 //
       
   551 // Reset button labels and update the layout
       
   552 // ---------------------------------------------------------------------------
       
   553 //
       
   554 void CDialerKeyPadContainer::KeyLabelsChanged()
       
   555     {
       
   556     for ( TInt i = 0 ; i < iButtons.Count() ; i++ )
       
   557         {
       
   558         const TPtrC numLabel = iKeyLabelManager->ButtonNumLabel( i );
       
   559         const TPtrC alphaLabel = iKeyLabelManager->ButtonFirstAlphaLabel( i );
       
   560         const TPtrC secondAlphaLabel = iKeyLabelManager->ButtonSecondAlphaLabel( i );
       
   561         
       
   562         iButtons[i]->SetNumLabel( numLabel );
       
   563         iButtons[i]->SetPrimaryAlphaLabel( alphaLabel );
       
   564         iButtons[i]->SetSecondaryAlphaLabel( secondAlphaLabel );
       
   565         
       
   566         // reset layout
       
   567         iButtons[i]->SetSize( iButtons[i]->Size() );
       
   568         }
       
   569     DrawDeferred();
       
   570     }
       
   571 
       
   572 // ---------------------------------------------------------------------------
   758 // CDialerKeyPadContainer::EnableTactileFeedback
   573 // CDialerKeyPadContainer::EnableTactileFeedback
   759 //
   574 //
   760 //
   575 //
   761 // ---------------------------------------------------------------------------
   576 // ---------------------------------------------------------------------------
   762 //
   577 //