phonebookui/Speeddial/src/SpdiaContainer.cpp
changeset 0 e686773b3f54
child 8 5586b4d2ec3e
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2002-2004 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:     Declares container control for application.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include <AknGrid.h>
       
    25 #include <eikapp.h>
       
    26 #include <gulicon.h>
       
    27 #include <avkon.rsg>
       
    28 #include <aknkeys.h>
       
    29 #include <eikmenub.h>
       
    30 #include <eikimage.h>
       
    31 #include <csxhelp/sdm.hlp.hrh>
       
    32 #include <bldvariant.hrh>
       
    33 
       
    34 #include <StringLoader.h>
       
    35 #include <aknnotewrappers.h>
       
    36 #include <SpdCtrl.rsg>
       
    37 #include <AknsUtils.h>
       
    38 #include <AknIconUtils.h>
       
    39 #include <aknViewAppUi.h>
       
    40 #include <AknFepInternalCRKeys.h>
       
    41 #include <aknlists.h>
       
    42 
       
    43 #include <SpeedDial.rsg>
       
    44 
       
    45 #include "speeddial.hrh" 
       
    46 #include "SpdiaControl.hrh"
       
    47 #include "speeddialprivate.h"
       
    48 #include "SpdiaView.h"
       
    49 #include "SpdiaContainer.h"
       
    50 #include "SpdiaApplication.h"
       
    51 #include "SpdiaNote.h"
       
    52 #include "Speeddial.laf"
       
    53 #include <applayout.cdl.h>
       
    54 #include <layoutmetadata.cdl.h>
       
    55 #include <aknlayoutscalable_avkon.cdl.h>
       
    56 #include <aknlayoutscalable_apps.cdl.h>
       
    57 #include <vmnumber.h>
       
    58 #include "SpdiaAppUi.h"
       
    59 
       
    60 #include <featmgr.h>
       
    61 #include <NumberGrouping.h>
       
    62 
       
    63 #include <CVPbkContactStoreUriArray.h>
       
    64 #include <CPbk2StoreConfiguration.h>
       
    65 #include <voicemailboxdomaincrkeys.h>
       
    66 #include <telvmbxsettingscrkeys.h>
       
    67 
       
    68 
       
    69 // LOCAL CONSTANTS AND MACROS
       
    70 const TUint KShortcutKey0('0');
       
    71 const TInt KCellRowCount(3);
       
    72 const TInt KCellColCount(3);
       
    73 const TInt KMaxIndex(8);
       
    74 const TInt KInvalidIndex(10);
       
    75 const TInt KPhoneNumberMaxLen = 100;
       
    76 
       
    77 // ================= MEMBER FUNCTIONS =======================
       
    78 // Constructor
       
    79 CSpdiaContainer::CSpdiaContainer(CSpeedDialPrivate *aSpeedPrivate):iSpeedPrivate( aSpeedPrivate ),
       
    80     iLongTapUsed( EFalse ), iNoAssignedShown( EFalse ), iButton1DownIndex( 0 )
       
    81     {
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CSpdiaContainer::ConstructL
       
    86 // Symbian two phased constructor
       
    87 // 
       
    88 // ---------------------------------------------------------
       
    89 //
       
    90 void CSpdiaContainer::ConstructL(CAknView* aView)
       
    91     {
       
    92     CreateWindowL();
       
    93 
       
    94     iView = STATIC_CAST(CSpdiaView*, aView);
       
    95 
       
    96     CSpdiaAppUi* spdialUi = static_cast< CSpdiaAppUi* >( CEikonEnv::Static()->AppUi() );
       
    97     if ( !spdialUi->IsSettingType() )
       
    98         {
       
    99         iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION );
       
   100         }
       
   101     iAlreadyActive = EFalse;
       
   102 
       
   103     FeatureManager::InitializeLibL();
       
   104     if ( FeatureManager::FeatureSupported( KFeatureIdPhoneNumberGrouping ) )
       
   105         {
       
   106         iNumberGrouping = CPNGNumberGrouping::NewL( KPhoneNumberMaxLen );
       
   107         }
       
   108     // Create Grid
       
   109     iGrid = new(ELeave) CAknQdialStyleGrid;
       
   110     iGrid->SetContainerWindowL( *this );
       
   111     iGrid->ConstructL( this, CEikListBox::EMultipleSelection );
       
   112     iGrid->SetBorder(TGulBorder::ENone);
       
   113 
       
   114     iGrid->CreateScrollBarFrameL(ETrue);
       
   115     iGrid->SetListBoxObserver( this );
       
   116     // Create Grid-info
       
   117 
       
   118     TInt error = iSpeedPrivate->GetSpdCtrlLastError();
       
   119     if ( error != KErrNone )
       
   120         {
       
   121         CSpdiaAppUi* spdialUi = static_cast< CSpdiaAppUi* >( CEikonEnv::Static()->AppUi() );
       
   122         spdialUi->LaunchInfoNoteL();
       
   123         return ;
       
   124         }
       
   125     // Using KInvalidIndex here is not to init index in CreateGridDataL().
       
   126     iSpeedPrivate->CreateGridDataL( iGrid, KInvalidIndex );
       
   127     iSpeedPrivate->SetContainerWindowL( *this );
       
   128     iSpeedPrivate->SetRefreshObserver( this );
       
   129 
       
   130     // shortcut value must be set after adding items the the list.
       
   131     iGrid->SetShortcutValueFromPrevList( iGrid->ShortcutValueForNextList() );
       
   132     
       
   133     SetStatusPaneL();
       
   134 
       
   135     if ( AknLayoutUtils::LayoutMirrored() )
       
   136         {
       
   137         iGrid->SetCurrentDataIndex(0);
       
   138         }
       
   139     ActivateL();
       
   140     iAlreadyActive = EFalse;
       
   141     ivmbxvariation = CRepository::NewL( KCRUidVideoMailbox );
       
   142     ivmbxvariation->Get( KVideoMbxSupport, iVmbxsupported );
       
   143     delete ivmbxvariation;
       
   144     ivmbxvariation = NULL;
       
   145     LongTapDetectorL();
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------
       
   149 // CSpdiaContainer::RefreshGrid
       
   150 // It calls spdctrl CreateGridDataL to draw the grid on skin change.
       
   151 // 
       
   152 // ---------------------------------------------------------
       
   153 void CSpdiaContainer::RefreshGrid()
       
   154     {
       
   155 		TRAP_IGNORE( iSpeedPrivate->CreateGridDataL( iGrid, -1 ) );
       
   156     }
       
   157 
       
   158 // Destructor
       
   159 CSpdiaContainer::~CSpdiaContainer()
       
   160     {
       
   161     delete iGrid;
       
   162     if ( iSpeedPrivate )
       
   163         {    
       
   164         iSpeedPrivate->SetGridDataAsNull();
       
   165         }
       
   166     delete iNumberGrouping;        
       
   167     FeatureManager::UnInitializeLib();
       
   168 
       
   169     if ( iDialog )
       
   170         {
       
   171         delete iDialog;
       
   172         }
       
   173     delete iLongTapDetector;
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------
       
   177 // CSpdiaContainer::Control
       
   178 // Get a grid-model reference
       
   179 // ---------------------------------------------------------
       
   180 CSpeedDialPrivate& CSpdiaContainer::Control()
       
   181     {
       
   182     return *iSpeedPrivate;
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------
       
   186 // CSpdiaContainer::IsVoiceMailBox
       
   187 // Check Voice Mail Box number
       
   188 // ---------------------------------------------------------
       
   189 TBool CSpdiaContainer::IsVoiceMailBox(TInt aIndex) const
       
   190     {
       
   191     if (aIndex < 0)
       
   192         {
       
   193         aIndex = iGrid->CurrentDataIndex();
       
   194         }
       
   195     return  iSpeedPrivate->VMBoxPosition() == aIndex? ETrue: EFalse;
       
   196     }
       
   197 // ---------------------------------------------------------
       
   198 // CSpdiaContainer::IsVdoMailBox
       
   199 // Check Voice Mail Box number
       
   200 // ---------------------------------------------------------
       
   201 TBool CSpdiaContainer::IsVdoMailBox(TInt aIndex) const
       
   202     {
       
   203     if ( !iVmbxsupported )
       
   204         {
       
   205         // Video Mailbox feature is disabled
       
   206         return EFalse;
       
   207         }
       
   208         
       
   209     if ( aIndex < 0 )
       
   210         {
       
   211         aIndex = iGrid->CurrentDataIndex();
       
   212         }
       
   213 
       
   214     return iSpeedPrivate->VdoMBoxPosition() == aIndex ? ETrue : EFalse;
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CSpdiaContainer::CurGridPosition
       
   219 // Get Current grid position
       
   220 // ---------------------------------------------------------
       
   221 TInt CSpdiaContainer::CurGridPosition() const
       
   222     {
       
   223    	return iGrid->CurrentDataIndex();
       
   224     }
       
   225 
       
   226 // ----------------------------------------------------
       
   227 // CSpdiaContainer::UpdatePhoneNumberL
       
   228 // 
       
   229 // ----------------------------------------------------
       
   230 //
       
   231 void CSpdiaContainer::UpdatePhoneNumberL(TInt aIndex)
       
   232     {
       
   233     //STATIC_CAST(CDesCArray* ,iGrid->Model()->ItemTextArray())->Reset();
       
   234     iSpeedPrivate->CreateGridDataL(iGrid, aIndex);
       
   235     iView->LoadCba(MenuResourceID());
       
   236     }
       
   237 
       
   238 // ---------------------------------------------------------
       
   239 // CSpdiaContainer::GetHelpContext
       
   240 // This function is called when Help application is launched.  
       
   241 // (other items were commented in a header).
       
   242 // ---------------------------------------------------------
       
   243 //
       
   244 void CSpdiaContainer::GetHelpContext(TCoeHelpContext& aContext) const
       
   245     {
       
   246     aContext.iMajor = KUidSpdia;
       
   247     aContext.iContext = KSDM_HLP_APP;
       
   248     }
       
   249 // ---------------------------------------------------------
       
   250 // CSpdiaContainer::HandleResourceChange()
       
   251 // Handle layout and skin change event.  
       
   252 // ---------------------------------------------------------
       
   253 //
       
   254 void CSpdiaContainer::HandleResourceChange( TInt aType )
       
   255     {   
       
   256     if ( aType == KEikDynamicLayoutVariantSwitch )
       
   257         {
       
   258         // Refresh when grid is in foreground 
       
   259         if ( iSpeedPrivate->State() == CSpeedDialPrivate::STATE_IDLE && 
       
   260              iSpeedPrivate->GridStatus() == CSpeedDialPrivate::EGridUse )
       
   261             {
       
   262             // if refresh grid here, termination will be interrupt when edit type is full screen QWERTY.
       
   263             RefreshGrid();
       
   264             iGrid->HandleResourceChange( aType );
       
   265 
       
   266             // Reload menubar when swap between landscape and portrait mode.
       
   267             iView->LoadCba( MenuResourceID() );
       
   268             DrawDeferred();
       
   269             }
       
   270         TRAP_IGNORE( SetStatusPaneL() );
       
   271         }
       
   272     else
       
   273         {
       
   274         CCoeControl::HandleResourceChange( aType );
       
   275         TRAP_IGNORE( SetLayoutL() );
       
   276         }
       
   277 
       
   278     // To hide the scrollbar of the grid
       
   279     TRAP_IGNORE( iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   280         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ) );
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------
       
   284 // CSpdiaContainer::SizeChanged
       
   285 // Called by framework when the view size is changed
       
   286 // ---------------------------------------------------------
       
   287 //
       
   288 void CSpdiaContainer::SizeChanged()
       
   289     {
       
   290     iView->iStatusPane->DrawNow();
       
   291     
       
   292     TRAP_IGNORE( SetLayoutL() );
       
   293     DrawNow();
       
   294     }
       
   295 // ---------------------------------------------------------
       
   296 // CSpdiaContainer::SetLayoutL
       
   297 // Called by framework when the view size is changed
       
   298 // ---------------------------------------------------------
       
   299 //
       
   300 void CSpdiaContainer::SetLayoutL()
       
   301     {
       
   302     TAknLayoutRect areaRect;
       
   303     TAknLayoutRect gridQdialPaneRect;
       
   304     TAknLayoutRect mainQdialPaneRect;
       
   305     TRect        mainPaneRect ;
       
   306     TRect        statusPaneRect;
       
   307     TRect        mainRect;
       
   308     TInt         width = 0;
       
   309     TInt         height =0;
       
   310  	
       
   311     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   312         {
       
   313         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   314             {
       
   315             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   316             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
   317             if( !AknLayoutUtils::PenEnabled() )
       
   318                 {
       
   319                 mainPaneRect.iTl = statusPaneRect.iTl;
       
   320                 mainRect = mainPaneRect;
       
   321                 mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
   322                 }
       
   323             else
       
   324                 {
       
   325                 mainPaneRect.iTl.iY -= mainPaneRect.iTl.iY;
       
   326                 mainPaneRect.iTl.iX -=statusPaneRect.iTl.iY;
       
   327                 mainRect = mainPaneRect;
       
   328                 }
       
   329             mainQdialPaneRect.LayoutRect( mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane().LayoutLine() );
       
   330             gridQdialPaneRect.LayoutRect( mainQdialPaneRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   331             AknLayoutUtils::LayoutControl( iGrid, mainQdialPaneRect.Rect(), AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   332             TAknWindowComponentLayout areaNew = AknLayoutScalable_Apps::cell_qdial_pane( 0, 0 ).LayoutLine();
       
   333   
       
   334             areaRect.LayoutRect( mainQdialPaneRect.Rect() ,areaNew.LayoutLine() );
       
   335 		 
       
   336             width  = areaRect.Rect().Width();
       
   337             height = areaRect.Rect().Height();
       
   338             }
       
   339         else
       
   340             {
       
   341             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
   342             AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
   343             mainPaneRect.iTl= statusPaneRect.iTl;
       
   344             mainRect = mainPaneRect;
       
   345             mainQdialPaneRect.LayoutRect( mainPaneRect,AknLayoutScalable_Apps::main_qdial_pane().LayoutLine() );
       
   346             gridQdialPaneRect.LayoutRect( mainQdialPaneRect.Rect(),AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   347             AknLayoutUtils::LayoutControl( iGrid, mainQdialPaneRect.Rect(), AknLayoutScalable_Apps::grid_qdial_pane().LayoutLine() );
       
   348             TAknWindowComponentLayout areaNew = AknLayoutScalable_Apps::cell_qdial_pane( 0, 0 ).LayoutLine();
       
   349             areaRect.LayoutRect( mainQdialPaneRect.Rect() ,areaNew.LayoutLine() );
       
   350 		 
       
   351             width  = ( mainPaneRect.Width() / 3 ) - 1;
       
   352             height = ( mainPaneRect.Height() / 3 ) - 7;
       
   353             }		
       
   354         }
       
   355     else
       
   356         {
       
   357         AknLayoutUtils::LayoutControl( iGrid, Rect(), AppLayout::Speed_Dial_descendants_Line_1() );
       
   358         TAknWindowLineLayout area = AppLayout::cell_qdial_pane( 0, 0 );		        
       
   359         areaRect.LayoutRect( Rect(), area );			
       
   360         }
       
   361     TInt language = User::Language();
       
   362     TBool LeftToRight( ETrue );
       
   363 
       
   364     // When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order
       
   365     // is not followed. Instead, the browsing order is the same as in Western variants.
       
   366     if ( language == ELangUrdu /*|| language == ELangArabic*/ )
       
   367         {
       
   368         LeftToRight = EFalse;
       
   369         }
       
   370     TRAP_IGNORE( iGrid->SetLayoutL(
       
   371             EFalse,                // aVerticalOrientation
       
   372             LeftToRight,           // aLeftToRight
       
   373             ETrue,                 // aTopToBottom
       
   374             KCellRowCount,         // aNumOfItemsInPrimaryOrient
       
   375             KCellColCount,         // aNumOfItemsInSecondaryOrient
       
   376             TSize( width, height ) // NewScalableUI changes
       
   377             )
       
   378         );
       
   379       
       
   380     TRAP_IGNORE( iGrid->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   381         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ) );
       
   382     CFormattedCellListBoxData* data = iGrid->ItemDrawer()->FormattedCellData();
       
   383 
       
   384     data->SetTransparentSubCellL( SDM_TN_CIF_TURNED, ETrue );  //5
       
   385     data->SetTransparentSubCellL( SDM_TN_CIF, ETrue );         //7
       
   386     data->SetTransparentSubCellL( SDM_TN_VGA_TURNED, ETrue );  //9
       
   387     data->SetTransparentSubCellL( SDM_TN_VGA, ETrue );         //11
       
   388     data->SetTransparentSubCellL( SDM_TN_OTHER, ETrue );       //13
       
   389 
       
   390     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   391         {
       
   392         data->SetBackgroundSkinStyle( &KAknsIIDQsnBgAreaMainQdial, mainRect );
       
   393         data->SetSkinStyle( &KAknsIIDQsnBgAreaMainQdial, mainRect );
       
   394         iSpeedPrivate->SetLayout( mainPaneRect );
       
   395         }
       
   396     else
       
   397         {
       
   398         data->SetBackgroundSkinStyle( &KAknsIIDQsnBgAreaMainQdial, Rect() );
       
   399         data->SetSkinStyle( &KAknsIIDQsnBgAreaMainQdial, Rect() );
       
   400         iSpeedPrivate->SetLayout( Rect() );
       
   401         }
       
   402     }
       
   403 
       
   404 // ---------------------------------------------------------
       
   405 // CSpdiaContainer::CountComponentControls
       
   406 //
       
   407 //  
       
   408 // ---------------------------------------------------------
       
   409 //
       
   410 TInt CSpdiaContainer::CountComponentControls() const
       
   411     {
       
   412     return 2; // return nbr of controls inside this container
       
   413     }
       
   414 
       
   415 // ---------------------------------------------------------
       
   416 // CSpdiaContainer::ComponentControl
       
   417 //
       
   418 // ---------------------------------------------------------
       
   419 //
       
   420 CCoeControl* CSpdiaContainer::ComponentControl(TInt aIndex) const
       
   421     {
       
   422     switch ( aIndex )
       
   423         {
       
   424         case 0:
       
   425             return iSpeedPrivate;
       
   426         case 1:
       
   427             return iGrid;
       
   428 
       
   429         default:
       
   430             return NULL;
       
   431         }
       
   432     }
       
   433 
       
   434 // ---------------------------------------------------------
       
   435 // CSpdiaContainer::Draw
       
   436 // 
       
   437 // ---------------------------------------------------------
       
   438 //
       
   439 void CSpdiaContainer::Draw(const TRect& aRect) const
       
   440     {
       
   441     iSpeedPrivate->Draw( aRect );
       
   442     }
       
   443 
       
   444 // ---------------------------------------------------------
       
   445 // CSpeedContainer::OfferKeyEventL
       
   446 // processing of a key event
       
   447 // ---------------------------------------------------------
       
   448 //
       
   449 TKeyResponse CSpdiaContainer::OfferKeyEventL(
       
   450                     const TKeyEvent& aKeyEvent, TEventCode aType)
       
   451     {
       
   452     if ( iSpeedPrivate->GetWait()->IsStarted() )
       
   453         {    
       
   454         return EKeyWasConsumed;
       
   455         }
       
   456 
       
   457     TInt index( 0 );
       
   458     
       
   459     if ( ( iView->IsFocused() ) && ( aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyDevice3 ) /*|| aKeyEvent.iCode == EKeyDevice3*/ )
       
   460         {
       
   461         index = iGrid->CurrentDataIndex();
       
   462         if ( !IsVoiceMailBox() && !IsVdoMailBox() && !iSpeedPrivate->Contact( index ) )
       
   463             {
       
   464             iView->CmdAssignNumberL();
       
   465             }
       
   466         else
       
   467             {
       
   468             CEikMenuBar* menuBar = iView->MenuBar();
       
   469             TInt barId( R_SPDIA_MENUBAR_VIEW_OK_ASSIGN );
       
   470             if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   471                 {
       
   472                 barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
   473                 }
       
   474             else if ( iSpeedPrivate->Contact( index ) )
       
   475                 {
       
   476                 barId = R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO;                
       
   477                 }
       
   478             menuBar->SetMenuType( CEikMenuBar::EMenuContext );
       
   479             menuBar->SetMenuTitleResourceId( barId );
       
   480 
       
   481             menuBar->TryDisplayMenuBarL();
       
   482             // For the reason at the time of being canceled, a menu is changed.
       
   483             menuBar->SetMenuTitleResourceId( MenuResourceID() );
       
   484             menuBar->SetMenuType( CEikMenuBar::EMenuOptions );
       
   485             }
       
   486         return EKeyWasConsumed;
       
   487         }
       
   488     // Check whether the focus exists.
       
   489     // If not, updated the option menu
       
   490     else if ( !iView->IsFocused() )
       
   491     	{
       
   492     	// LOGTEXT( _L("CR addition: handle HW key shortcuts event in OfferKeyEventL()") );
       
   493     	iGrid->SetCurrentDataIndex( 0 );
       
   494         iView->LoadCba( MenuResourceID() );
       
   495         MiddleSoftKeyL();
       
   496     	}
       
   497 
       
   498     TKeyResponse exitCode( EKeyWasNotConsumed );
       
   499     TChar code( aKeyEvent.iCode );
       
   500     MiddleSoftKeyL();
       
   501     TInt language = User::Language();
       
   502     // When Arabic and Hebrew input is in use, the Arabic and Hebrew browsing order
       
   503     // is not followed. Instead, the browsing order is the same as in Western variants.
       
   504     if ( language == ELangUrdu /*|| language == ELangArabic*/ )
       
   505         {
       
   506         if ( code == EKeyLeftArrow )
       
   507             {
       
   508             index = iGrid->CurrentDataIndex();
       
   509             if ( index == KMaxIndex )
       
   510                 {
       
   511                 iGrid->SetCurrentDataIndex( 0 );
       
   512                 iView->LoadCba( MenuResourceID() );
       
   513                 return EKeyWasConsumed; 
       
   514                 }
       
   515             }
       
   516 		
       
   517         if ( code == EKeyRightArrow )
       
   518             {
       
   519             index = iGrid->CurrentDataIndex();
       
   520             if ( index == 0 )
       
   521                 {
       
   522                 iGrid->SetCurrentDataIndex( KMaxIndex );
       
   523                 iView->LoadCba( MenuResourceID() );
       
   524                 return EKeyWasConsumed; 
       
   525                 }
       
   526             }	
       
   527         }
       
   528     else
       
   529         {
       
   530         if ( code == EKeyRightArrow )
       
   531             {
       
   532             index = iGrid->CurrentDataIndex();
       
   533             if ( index == KMaxIndex )
       
   534                 {
       
   535                 iGrid->SetCurrentDataIndex( 0 );
       
   536                 iView->LoadCba( MenuResourceID() );
       
   537                 return EKeyWasConsumed; 
       
   538                 }
       
   539             }
       
   540 	
       
   541         if ( code == EKeyLeftArrow )
       
   542             {
       
   543             index = iGrid->CurrentDataIndex();
       
   544             if ( index == 0 )
       
   545                 {
       
   546                 iGrid->SetCurrentDataIndex( KMaxIndex );
       
   547                 iView->LoadCba( MenuResourceID() );
       
   548                 return EKeyWasConsumed; 
       
   549                 }
       
   550             }
       
   551         }
       
   552 
       
   553     if ( aKeyEvent.iScanCode == EStdKeyYes )
       
   554         {
       
   555         // Send key is pressed, when menu or dialog is displayed, the call won't be created.
       
   556         if ( aType == EEventKey 
       
   557 		     && !static_cast<CSpdiaAppUi*>( CEikonEnv::Static()->AppUi() )->IsDisplayingDialog() 
       
   558 		     && !iView->MenuBar()->IsDisplayed() )
       
   559             {
       
   560             CallCreateL();
       
   561             }
       
   562         return EKeyWasConsumed;
       
   563         }
       
   564         
       
   565     exitCode = iGrid->OfferKeyEventL( aKeyEvent, aType );
       
   566     if ( exitCode != EKeyWasNotConsumed )
       
   567         {
       
   568         DrawDeferred();
       
   569         if ( code.IsDigit() )
       
   570             {
       
   571             if ( aKeyEvent.iCode - KShortcutKey0 > 0 )
       
   572                 {
       
   573                 iGrid->SetCurrentDataIndex( 
       
   574                         iSpeedPrivate->Index( aKeyEvent.iCode - KShortcutKey0 ) );
       
   575                 MiddleSoftKeyL();
       
   576                 iView->LoadCba( MenuResourceID() );
       
   577                 exitCode = EKeyWasConsumed;
       
   578                 }
       
   579             }
       
   580         else if ( code == EKeyLeftArrow ||
       
   581                 code == EKeyRightArrow ||
       
   582                 code == EKeyUpArrow ||
       
   583                 code == EKeyDownArrow )
       
   584             {
       
   585             iView->LoadCba( MenuResourceID() );
       
   586             MiddleSoftKeyL();
       
   587             }
       
   588         }
       
   589     return exitCode;
       
   590     }
       
   591 
       
   592 // ---------------------------------------------------------
       
   593 // CSpdiaContainer::HandleDatabaseEventL
       
   594 // Handles an database event of type aEventType.
       
   595 // ---------------------------------------------------------
       
   596 //
       
   597 void CSpdiaContainer::HandleDatabaseEventL(
       
   598          TContactDbObserverEvent aEvent)
       
   599     {
       
   600     switch( aEvent.iType )
       
   601         {
       
   602         case EContactDbObserverEventContactChanged:
       
   603         case EContactDbObserverEventContactDeleted:
       
   604         case EContactDbObserverEventContactAdded:
       
   605             break;
       
   606         case EContactDbObserverEventSpeedDialsChanged:
       
   607             if ( iDialog )
       
   608                 {
       
   609                 UpdatePhoneNumberL();
       
   610                 }
       
   611             iNeedUpdate = ETrue;
       
   612             break;
       
   613         default:
       
   614             break;
       
   615         }
       
   616     }
       
   617 
       
   618 // ---------------------------------------------------------
       
   619 // CSpdiaContainer::CallCreateL
       
   620 // Handles send key press.
       
   621 // ---------------------------------------------------------
       
   622 //
       
   623 void CSpdiaContainer::CallCreateL()
       
   624     {
       
   625     TPhCltTelephoneNumber number;
       
   626     TInt index( iGrid->CurrentDataIndex() );
       
   627     TInt numberType( ESpDialPbkFieldIdNone );
       
   628     TBool call( EFalse );
       
   629 
       
   630     // voice mailbox
       
   631     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   632         {
       
   633         //  call = iSpeedPrivate->VoiceMailL(number);
       
   634         iView->CmdNumberCallL(KAiwCmdCall, ETrue );
       
   635         TInt type = iSpeedPrivate->VoiceMailType();
       
   636         if( type == EVmbxIP )
       
   637             {
       
   638             numberType = ESpDialPbkFieldIdVOIP;
       
   639             }
       
   640         else if( type == EVmbxVideo )
       
   641             {
       
   642             numberType = ESpDialPbkFieldIdPhoneNumberVideo;
       
   643             }
       
   644         }
       
   645     else
       
   646         {
       
   647         // if contact does not exit call should not be created.
       
   648         if ( iSpeedPrivate->Contact( index ) != NULL )
       
   649             {
       
   650             call = ETrue;
       
   651             }
       
   652         
       
   653         if ( !iNoAssignedShown && iSpeedPrivate->Contact( index ) == NULL )
       
   654             {
       
   655             CAknQueryDialog* dlg = 
       
   656                         CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
       
   657             iNoAssignedShown = ETrue;
       
   658             
       
   659             // Assign it now?
       
   660             if ( !dlg->ExecuteLD( R_SPDIA_QUERY_ASSIGN ) || 
       
   661                                     !iView->CmdAssignNumberL() )
       
   662                 {
       
   663                 call = EFalse;
       
   664                 }
       
   665             else
       
   666                 {
       
   667                 call = ETrue;
       
   668                 }
       
   669             
       
   670             iNoAssignedShown = EFalse;
       
   671             }
       
   672         if ( call )
       
   673             {
       
   674             number = iSpeedPrivate->PhoneNumber( index );
       
   675             numberType = iSpeedPrivate->NumberType( index );
       
   676             }
       
   677         }
       
   678 
       
   679     if ( call )
       
   680         {
       
   681         iView->NumberCallL( number, numberType);
       
   682         }
       
   683     }
       
   684 
       
   685 // ----------------------------------------------------
       
   686 // CSpdiaContainer::MenuResourceID
       
   687 // 
       
   688 // ----------------------------------------------------
       
   689 //
       
   690 TInt CSpdiaContainer::MenuResourceID()
       
   691     {
       
   692     TInt id( R_SPDIA_MENUBAR_VIEW_VOICE );
       
   693     TInt index( iGrid->CurrentDataIndex() );
       
   694 
       
   695     if ( ( !IsVoiceMailBox() ) && ( !IsVdoMailBox() ) )
       
   696         {
       
   697         id = iSpeedPrivate->Contact(index) != NULL ?
       
   698             R_SPDIA_MENUBAR_VIEW : R_SPDIA_MENUBAR_VIEW_ASSIGN;
       
   699         }
       
   700     return id;
       
   701     }
       
   702 
       
   703 // ---------------------------------------------------------
       
   704 // CSpdiaContainer::ShowViewNumberL
       
   705 // 
       
   706 // ---------------------------------------------------------
       
   707 void CSpdiaContainer::ShowViewNumberL()
       
   708     {
       
   709     TInt gridIndex( CurGridPosition() );
       
   710     TInt textWidth( SDM_VIEW_NUMBER_TEXT_MAXWIDTH );
       
   711     MVPbkStoreContact* contact( iSpeedPrivate->Contact( gridIndex ) );
       
   712     
       
   713     iSpeedPrivate->SetCurrentGridIndex( gridIndex );
       
   714 
       
   715     if ( contact == NULL )
       
   716         {
       
   717         if( iDialog )
       
   718             {
       
   719             delete iDialog;
       
   720             }
       
   721         iDialog = NULL;
       
   722         iDialog = new( ELeave ) CSpdiaNoteDialog( &iDialog );
       
   723         iDialog->PrepareLC( R_SPDIA_NOTE_VIEWNUMBER );
       
   724         iDialog->RunLD();
       
   725         if ( iDialog )
       
   726             {
       
   727             delete iDialog;
       
   728             }
       
   729         iDialog = NULL;
       
   730         return;
       
   731         }	
       
   732     // The assign was deleted while the view number was displayed.
       
   733     delete iDialog;
       
   734     iDialog = NULL;
       
   735 
       
   736     iDialog = new(ELeave) CSpdiaNoteDialog( &iDialog );
       
   737     iDialog->PrepareLC( R_SPDIA_NOTE_VIEWNUMBER );
       
   738 
       
   739     CArrayPtr<CGulIcon>* imgArray = iSpeedPrivate->IconArray();
       
   740 
       
   741     // icon
       
   742     TInt imgIndex( iSpeedPrivate->SpdIconIndex(gridIndex) );
       
   743 
       
   744     if(imgIndex >= 0)
       
   745         {
       
   746         iDialog->SetIconL( CreateBitmapL(*(*imgArray)[imgIndex]) );
       
   747         textWidth -= SDM_ADDITIONAL_MARGIN_FOR_NUMBER_TYPE_ICON; 
       
   748         }
       
   749 
       
   750     // thumbnail
       
   751     imgIndex = iSpeedPrivate->ThumbIndex( gridIndex );
       
   752     CEikImage* image;
       
   753 		if ( imgIndex >= 0 )
       
   754         {
       
   755         image = CreateScaledBitmapL( *(*imgArray)[imgIndex] );
       
   756         iDialog->SetImageL( image );
       
   757         TSize size(image->Bitmap()->SizeInPixels());
       
   758         textWidth -= size.iWidth + SDM_MARGIN_BETWEEN_TEXT_AND_IMAGE;
       
   759         }
       
   760 
       
   761     HBufC* title = iSpeedPrivate->ContactTitleL( contact, ETrue);
       
   762     CleanupStack::PushL(title);
       
   763 
       
   764     // Information
       
   765     CDesCArray* locStr = new(ELeave) CDesCArrayFlat( 2 );
       
   766     CleanupStack::PushL( locStr );
       
   767     const CFont* font = iEikonEnv->NormalFont();
       
   768     if ( AknLayoutUtils::Variant() == EApacVariant )
       
   769         {
       
   770         font = ApacPlain16();
       
   771         }
       
   772 
       
   773     TPtr ptr = title->Des();
       
   774     TAknLayoutRect dialogRect;
       
   775     TAknLayoutText textLayout;
       
   776     TAknTextComponentLayout area;
       
   777     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   778         {
       
   779         TAknWindowLineLayout tempWidth = AknLayoutScalable_Avkon::popup_note_image_window().LayoutLine();
       
   780         dialogRect.LayoutRect(Rect(), tempWidth);
       
   781         area = AknLayoutScalable_Avkon::popup_note_image_window_t2((imgIndex >= 0) ? 2 : 0 );
       
   782 			
       
   783         textLayout.LayoutText( dialogRect.Rect() ,area );
       
   784         textWidth = textLayout.TextRect().Width();
       
   785         TextUtils::ClipToFit ( ptr, *AknLayoutUtils::FontFromId( area.Font()), textWidth );
       
   786         }
       
   787     else
       
   788         {
       
   789         TextUtils::ClipToFit ( ptr, *font,textWidth);
       
   790         }
       
   791     locStr->AppendL( title->Des() );
       
   792 
       
   793     const TDesC& phoneNumber = iSpeedPrivate->PhoneNumber( gridIndex );
       
   794     HBufC* phoneNumberBuf;
       
   795 	
       
   796     if ( iNumberGrouping )
       
   797         {
       
   798         iNumberGrouping->Set(phoneNumber);
       
   799         phoneNumberBuf = iNumberGrouping->FormattedNumber().AllocLC();			
       
   800         }        
       
   801     else
       
   802         {
       
   803         phoneNumberBuf = phoneNumber.AllocLC();
       
   804         }
       
   805     TPtr phoneNumberPtr = phoneNumberBuf->Des();
       
   806     AknTextUtils::LanguageSpecificNumberConversion( phoneNumberPtr );
       
   807 
       
   808     locStr->AppendL( phoneNumberPtr );
       
   809     HBufC* addprompt = StringLoader::LoadLC(R_SPDIA_TEXT_PROMPT, *locStr);
       
   810     
       
   811     HBufC* prompt = StringLoader::LoadL( R_SPDIA_TEXT_VIEWNUM, iSpeedPrivate->Number(gridIndex) );
       
   812     prompt = prompt->ReAlloc( prompt->Length() + addprompt->Length() );
       
   813     CleanupStack::PushL(prompt);
       
   814     prompt->Des().Append( addprompt->Des() );
       
   815 
       
   816     iDialog->SetTextL( *prompt );
       
   817     iDialog->SetPhoneNumberL( (*locStr)[1] );
       
   818 
       
   819     CleanupStack::PopAndDestroy( 5 ); // title, locStr, prompt, addprompt, phoneNumberBuf
       
   820     if ( AknLayoutUtils::ScalableLayoutInterfaceAvailable() )
       
   821         {
       
   822         TAknWindowLineLayout tempWidth = AknLayoutScalable_Avkon::popup_note_image_window().LayoutLine();
       
   823         dialogRect.LayoutRect(Rect(), tempWidth);
       
   824         area = AknLayoutScalable_Avkon::popup_note_image_window_t3((imgIndex >= 0) ? 2 : 0 );
       
   825 		
       
   826         textLayout.LayoutText(dialogRect.Rect() ,area );
       
   827         textWidth = textLayout.TextRect().Width();
       
   828         }
       
   829     iDialog->ClipPhoneNumberFromBeginningL( textWidth , 0 );
       
   830     iDialog->RunLD();
       
   831     }
       
   832 
       
   833 // ---------------------------------------------------------
       
   834 // CSpdiaContainer::DoUpdate
       
   835 // 
       
   836 // ---------------------------------------------------------
       
   837 void CSpdiaContainer::DoUpdateL()
       
   838     {
       
   839     MiddleSoftKeyL();
       
   840     if ( iSpeedPrivate && iSpeedPrivate->UpdateFlag() )
       
   841         { 
       
   842         DrawNow();        
       
   843         if ( iDialog )
       
   844             {
       
   845             ShowViewNumberL();   
       
   846             iSpeedPrivate->SetUpdateFlag( EFalse );
       
   847             }     
       
   848         iView->LoadCba( MenuResourceID() );
       
   849         }   
       
   850     }
       
   851 
       
   852 // ---------------------------------------------------------
       
   853 // CSpdiaContainer::Grid
       
   854 // 
       
   855 // ---------------------------------------------------------
       
   856 CAknQdialStyleGrid* CSpdiaContainer::Grid()
       
   857     {
       
   858     return iGrid;
       
   859     }
       
   860 
       
   861 // ---------------------------------------------------------
       
   862 // CSpdiaContainer::CreateBitmapL
       
   863 // 
       
   864 // ---------------------------------------------------------
       
   865 CEikImage* CSpdiaContainer::CreateBitmapL(const CGulIcon& aSrc)
       
   866     {
       
   867     if( aSrc.Bitmap() == NULL || aSrc.Mask() == NULL )
       
   868     	{
       
   869     	return NULL;
       
   870     	}
       
   871     CEikImage* image = new(ELeave) CEikImage;
       
   872     image->SetPictureOwnedExternally(EFalse);
       
   873     CFbsBitmap* bitmap = new(ELeave) CFbsBitmap;
       
   874     image->SetBitmap(bitmap);
       
   875     User::LeaveIfError(bitmap->Duplicate(aSrc.Bitmap()->Handle()));
       
   876     CFbsBitmap* bmpMask = aSrc.Mask();
       
   877     if ( bmpMask )
       
   878         {
       
   879         CFbsBitmap* mask = new(ELeave) CFbsBitmap;
       
   880         image->SetMask(mask);
       
   881         User::LeaveIfError( mask->Duplicate( aSrc.Mask()->Handle() ) );
       
   882         }
       
   883     return image;
       
   884     }
       
   885     
       
   886 // ---------------------------------------------------------
       
   887 // CSpdiaContainer::FocusChanged
       
   888 // 
       
   889 // ---------------------------------------------------------
       
   890 void CSpdiaContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   891     {
       
   892     if( iGrid )
       
   893         {
       
   894         iGrid->SetFocus( IsFocused() );
       
   895         }
       
   896     }
       
   897 // ---------------------------------------------------------
       
   898 // CSpdiaContainer::CreateScaledBitmapL
       
   899 // 
       
   900 // ---------------------------------------------------------
       
   901 CEikImage* CSpdiaContainer::CreateScaledBitmapL(const CGulIcon& aSrc)
       
   902     {
       
   903     TRect 		   mainPaneRect ;
       
   904     TRect 		   statusPaneRect;
       
   905     TRect 		   mainRect;
       
   906     TAknLayoutRect windowParentRect;
       
   907     TAknLayoutRect imageRect;
       
   908     
       
   909     if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   910         {
       
   911         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
   912         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
   913         mainPaneRect.iTl = statusPaneRect.iTl;
       
   914         mainRect = mainPaneRect;
       
   915         mainPaneRect.iBr.iY = mainPaneRect.iBr.iY - statusPaneRect.iTl.iY;
       
   916         windowParentRect.LayoutRect(mainRect, AknLayoutScalable_Avkon::popup_note_image_window(0));
       
   917         imageRect.LayoutRect(windowParentRect.Rect(), AknLayoutScalable_Avkon::popup_note_image_window_g2(1));
       
   918         }
       
   919     else
       
   920         {	
       
   921         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane,mainPaneRect);
       
   922         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EStatusPane,statusPaneRect);
       
   923         mainPaneRect.iTl= statusPaneRect.iTl;
       
   924         mainRect = mainPaneRect;
       
   925         windowParentRect.LayoutRect(mainRect, AknLayoutScalable_Avkon::popup_note_image_window(0));
       
   926         imageRect.LayoutRect(windowParentRect.Rect(), AknLayoutScalable_Avkon::popup_note_image_window_g2(1));;
       
   927         }
       
   928      
       
   929     TSize imagesize(imageRect.Rect().Size());
       
   930      
       
   931     CFbsBitmap* bmporg= new (ELeave) CFbsBitmap();
       
   932     bmporg->Create(aSrc.Bitmap()->SizeInPixels(), aSrc.Bitmap()->DisplayMode() );
       
   933     bmporg->Duplicate(aSrc.Bitmap()->Handle());
       
   934        
       
   935     CAknIcon* tmpIcon = CAknIcon::NewL();
       
   936     tmpIcon->SetBitmap( bmporg);
       
   937     CAknIcon* scaledIcon = AknIconUtils::CreateIconL(tmpIcon);
       
   938     AknIconUtils::SetSize(scaledIcon->Bitmap(),imagesize,EAspectRatioNotPreserved);
       
   939 
       
   940     CFbsBitmap* bmp = new (ELeave) CFbsBitmap();
       
   941     TInt err1 = bmp->Duplicate( scaledIcon->Bitmap()->Handle() );
       
   942 
       
   943     // CEikImage	
       
   944     CEikImage* image = new(ELeave) CEikImage;
       
   945     image->SetPictureOwnedExternally( EFalse );
       
   946     image->SetBitmap( bmp );
       
   947     delete scaledIcon;
       
   948   
       
   949     return image;
       
   950     }
       
   951 
       
   952 // ---------------------------------------------------------
       
   953 // CSpdiaContainer::VoiceMailDialogLaunched(
       
   954 // 
       
   955 // ---------------------------------------------------------
       
   956 void CSpdiaContainer::VoiceMailDialogLaunched(TBool aBool)
       
   957     {
       
   958     iVoiceDialog = aBool;
       
   959     }
       
   960 // ------------------------------------------------------
       
   961 // CSpdiaContainer::MiddleSoftKeyL
       
   962 // 
       
   963 // ----------------------------------------------------------
       
   964 
       
   965 void CSpdiaContainer::MiddleSoftKeyL()
       
   966     {
       
   967     TInt index( Grid()->CurrentDataIndex() );
       
   968     if ( ( index < 0 ) || ( index > 8 ) )
       
   969         {
       
   970         return;
       
   971         }
       
   972     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
   973         {
       
   974         //If cba is not changed back here, changing to context sensitive menu does not work
       
   975         if ( iView->IsSettingType() )
       
   976             {
       
   977             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
   978             }
       
   979         else
       
   980             {
       
   981             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
   982             }
       
   983         iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_CALL );
       
   984         }
       
   985     else if ( Control().Contact( index ) != NULL )
       
   986         {
       
   987         if ( iView->IsSettingType() )
       
   988             {
       
   989             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
   990             }
       
   991         else
       
   992             {
       
   993             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
   994             }
       
   995         iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO );
       
   996         }
       
   997     else
       
   998         {
       
   999         //when number not assigned in 5.0, MSK versions, display "Assign"
       
  1000         if ( AknLayoutUtils::MSKEnabled() )
       
  1001             {
       
  1002             if ( iView->IsSettingType()  )
       
  1003                 {
       
  1004                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_BACK_ASSIGN );
       
  1005                 }
       
  1006             else
       
  1007                 {
       
  1008                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_EXIT_ASSIGN ); 
       
  1009                 }
       
  1010             }
       
  1011         else if(AknLayoutUtils::PenEnabled())
       
  1012             {
       
  1013             if ( iView->IsSettingType() )
       
  1014                 {
       
  1015                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_BACK );
       
  1016                 }
       
  1017             else
       
  1018                 {
       
  1019                 iView->SetCba( R_SPDIA_VIEW_OPTIONS_EXIT ); 
       
  1020                 }
       
  1021             }
       
  1022         else
       
  1023             {
       
  1024             iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION );
       
  1025             if ( iView->IsSettingType()  )
       
  1026                 {
       
  1027                 iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_BACK_OPTION );
       
  1028                 }
       
  1029             else
       
  1030                 {
       
  1031                 iView->SetCba( R_SPDIA_SOFTKEYS_OPTION_EXIT_OPTION ); 
       
  1032                 }
       
  1033             iView->MenuBar()->SetContextMenuTitleResourceId( R_SPDIA_MENUBAR_VIEW_OK_ASSIGN );
       
  1034             }
       
  1035         }
       
  1036     }
       
  1037 		
       
  1038 // ----------------------------------------------------------------------------
       
  1039 // CSpdiaContainer::HandlePointerEventL
       
  1040 // Function to handle all touch (pointer events)
       
  1041 // ----------------------------------------------------------------------------
       
  1042 void CSpdiaContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  1043     {
       
  1044     if ( !iView->IsAssignCompleted() )
       
  1045         {
       
  1046         return;
       
  1047         }
       
  1048 
       
  1049     // Check if touch is enabled or not.
       
  1050     if ( !AknLayoutUtils::PenEnabled() )
       
  1051         {
       
  1052         return;
       
  1053         }
       
  1054   
       
  1055     if ( iLongTapDetector )
       
  1056         {
       
  1057         iLongTapDetector->PointerEventL( aPointerEvent );
       
  1058         }
       
  1059     // Process only once when the grid control has been pressed
       
  1060     if ( ( aPointerEvent.iType == TPointerEvent::EButton1Down ) ||
       
  1061          ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
       
  1062          ( aPointerEvent.iType == TPointerEvent::EButton1Up ) )
       
  1063         {        
       
  1064         // Ask the grid to process the handlepointerevent
       
  1065         iGrid->HandlePointerEventL( aPointerEvent );
       
  1066         
       
  1067         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1068         	{
       
  1069         	iButton1DownIndex = iGrid->CurrentDataIndex();
       
  1070         	}
       
  1071         // If already highlighted, activate the grid element
       
  1072         if ( iGrid->CurrentDataIndex() == iButton1DownIndex ) 
       
  1073             {
       
  1074             TInt pointedItemIndex;
       
  1075             if ( ( aPointerEvent.iType == TPointerEvent::EButton1Up ) &&
       
  1076                 iGrid->View()->XYPosToItemIndex(
       
  1077                     aPointerEvent.iPosition, pointedItemIndex ) &&
       
  1078                 ( pointedItemIndex == iButton1DownIndex ) )
       
  1079                 {
       
  1080                 if ( iLongTapUsed == EFalse )
       
  1081                     {
       
  1082                     // Need filtrate IsVoiceMailBox and IsVdoMailBox
       
  1083                     if ( !IsVoiceMailBox() && !IsVdoMailBox() 
       
  1084                          && iSpeedPrivate->Contact( iButton1DownIndex ) == NULL )
       
  1085                         {
       
  1086                         // Open phonebook fetch list
       
  1087                         iView->CmdAssignNumberL();	
       
  1088                         // No need to launch the menu
       
  1089                         return;
       
  1090                         }
       
  1091                     else if ( iSpeedPrivate->Contact( iButton1DownIndex ) != NULL )
       
  1092                         {
       
  1093                         CallCreateL( );
       
  1094                         return;
       
  1095                         }
       
  1096                     CEikMenuBar* menuBar = iView->MenuBar();
       
  1097                     TInt barId(R_SPDIA_MENUBAR_VIEW_OK_ASSIGN);
       
  1098             
       
  1099                     // If focus is on voicemailbox
       
  1100                     if ( IsVoiceMailBox() || IsVdoMailBox() )
       
  1101                         {
       
  1102                         barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
  1103                         }
       
  1104                     // If a number is assigned then provide call option
       
  1105                     else if ( iSpeedPrivate->Contact( iButton1DownIndex ) != NULL )
       
  1106                         {
       
  1107                         barId = R_SPDIA_MENUBAR_VIEW_OK_CALL_VIDEO;
       
  1108                         }
       
  1109                     menuBar->StopDisplayingMenuBar();
       
  1110                     menuBar->SetMenuType( CEikMenuBar::EMenuContext );
       
  1111                     menuBar->SetMenuTitleResourceId( barId );
       
  1112                     menuBar->TryDisplayMenuBarL();
       
  1113                     // At the time of being canceled, a menu is changed.
       
  1114                     menuBar->SetMenuTitleResourceId( MenuResourceID() );
       
  1115                     menuBar->SetMenuType( CEikMenuBar::EMenuOptions );
       
  1116                     }
       
  1117                 iLongTapUsed = EFalse;
       
  1118                 }
       
  1119             }
       
  1120         // Else just reload the cba buttons based on the context
       
  1121         else 
       
  1122             {
       
  1123             MiddleSoftKeyL();
       
  1124             iView->LoadCba( MenuResourceID() );
       
  1125             }
       
  1126         }
       
  1127     }
       
  1128 
       
  1129 // --------------------------------------------------------------------------
       
  1130 // CSpdiaContainer::LongTapDetectorL
       
  1131 // --------------------------------------------------------------------------
       
  1132 //    
       
  1133 CAknLongTapDetector& CSpdiaContainer::LongTapDetectorL()
       
  1134     {
       
  1135     if ( !iLongTapDetector )
       
  1136         {
       
  1137         iLongTapDetector = CAknLongTapDetector::NewL( this );
       
  1138         }
       
  1139     return *iLongTapDetector;
       
  1140     }
       
  1141     
       
  1142 // --------------------------------------------------------------------------
       
  1143 // CSpdiaContainer::HandleLongTapEventL
       
  1144 // --------------------------------------------------------------------------
       
  1145 //    
       
  1146  void CSpdiaContainer::HandleLongTapEventL(
       
  1147         const TPoint& /*aPenEventLocation*/, 
       
  1148         const TPoint& /*aPenEventScreenLocation*/ )
       
  1149     {
       
  1150     //Get the Current Data Index
       
  1151     if ( AknLayoutUtils::PenEnabled() )
       
  1152         {
       
  1153         iLongTapUsed = ETrue;   	    
       
  1154         TInt index = iGrid->CurrentDataIndex();
       
  1155         if ( IsVoiceMailBox() || IsVdoMailBox())
       
  1156             {
       
  1157             CEikMenuBar* menuBar = iView->MenuBar();
       
  1158             TInt barId = R_SPDIA_MENUBAR_VIEW_OK_CALL;
       
  1159             
       
  1160             menuBar->StopDisplayingMenuBar();
       
  1161             menuBar->SetMenuType(CEikMenuBar::EMenuContext);
       
  1162             menuBar->SetMenuTitleResourceId(barId);
       
  1163             menuBar->TryDisplayMenuBarL();
       
  1164             //For the reason at the time of being canceled, a menu is changed.
       
  1165             menuBar->SetMenuTitleResourceId(MenuResourceID());
       
  1166             menuBar->SetMenuType(CEikMenuBar::EMenuOptions);
       
  1167             }
       
  1168         }
       
  1169     }
       
  1170     
       
  1171 // --------------------------------------------------------------------------
       
  1172 // CSpdiaContainer::SetStatusPaneL
       
  1173 // --------------------------------------------------------------------------
       
  1174 //    
       
  1175  void CSpdiaContainer::SetStatusPaneL()
       
  1176      {
       
  1177      CEikStatusPane* statusPane = iView->iStatusPane;
       
  1178 
       
  1179      if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
  1180          {
       
  1181          statusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
  1182          statusPane->MakeVisible( ETrue );
       
  1183          statusPane->DrawNow();
       
  1184          }
       
  1185      else
       
  1186          {
       
  1187          TInt resouceId = statusPane->CurrentLayoutResId();
       
  1188 
       
  1189          if ( resouceId != R_AVKON_STATUS_PANE_LAYOUT_USUAL && 
       
  1190              resouceId != R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT )
       
  1191              {
       
  1192              statusPane->SwitchLayoutL( R_AVKON_STATUS_PANE_LAYOUT_USUAL );
       
  1193              }
       
  1194 
       
  1195          if ( !statusPane->IsVisible() )
       
  1196              {
       
  1197              statusPane->MakeVisible( ETrue );
       
  1198              }
       
  1199 
       
  1200          TRect mainPaneRect;
       
  1201          AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect );
       
  1202 
       
  1203          TRect statusPaneRect;
       
  1204          AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, statusPaneRect );
       
  1205          if ( !iView->IsShowMsgDlg() && !iView->IsShowVmbxDlg())
       
  1206              {
       
  1207              mainPaneRect.iTl = statusPaneRect.iTl;
       
  1208              }
       
  1209          SetRect( mainPaneRect );
       
  1210          }
       
  1211      }
       
  1212 
       
  1213  // --------------------------------------------------------------------------
       
  1214  // CSpdiaContainer::RefreshDialog
       
  1215  // from MRefreshObserver
       
  1216  // --------------------------------------------------------------------------
       
  1217  // 
       
  1218  void CSpdiaContainer::RefreshDialog()
       
  1219      {
       
  1220      if ( iDialog )
       
  1221          {
       
  1222          TRAP_IGNORE( DoUpdateL() );
       
  1223          }
       
  1224      }
       
  1225  
       
  1226  // --------------------------------------------------------------------------
       
  1227  // CSpdiaContainer::RefreshDialog
       
  1228  // From MEikListBoxObserver, Handles an event of listbox.
       
  1229  // --------------------------------------------------------------------------
       
  1230  // 
       
  1231  void CSpdiaContainer::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType)
       
  1232     {
       
  1233     switch(aEventType)
       
  1234         {
       
  1235         case EEventPenDownOnItem:
       
  1236             iView->LoadCba( MenuResourceID() );
       
  1237             MiddleSoftKeyL();
       
  1238             break;
       
  1239         }
       
  1240     }
       
  1241  // End of File