phoneuis/dialer/src/cdialernumberentry.cpp
branchRCL_3
changeset 6 38529f706030
parent 4 24062c24fe38
child 7 544e34b3255a
equal deleted inserted replaced
5:2a26698d78ba 6:38529f706030
    90     TResourceReader reader;
    90     TResourceReader reader;
    91     iCoeEnv->CreateResourceReaderLC( reader, R_INPUTFIELD );
    91     iCoeEnv->CreateResourceReaderLC( reader, R_INPUTFIELD );
    92     ConstructEditorFromResourceL( reader );
    92     ConstructEditorFromResourceL( reader );
    93     
    93     
    94     iFrameContext = CAknsFrameBackgroundControlContext::NewL(
    94     iFrameContext = CAknsFrameBackgroundControlContext::NewL(
    95             KAknsIIDNone, TRect(0,0,4,4), TRect(1,1,3,3), EFalse );    
    95             KAknsIIDNone, TRect(0,0,4,4), TRect(1,1,3,3), EFalse );
    96             
    96             
    97     iFrameContext->SetFrame( KAknsIIDQsnFrCall2Rect );      
    97     iFrameContext->SetFrame( KAknsIIDQsnFrCall2Rect );
    98     
    98     
    99     iFrameContext->SetParentContext( 
    99     iFrameContext->SetParentContext( 
   100         AknsDrawUtils::ControlContextOfParent(this) );           
   100         AknsDrawUtils::ControlContextOfParent(this) );
   101                 
   101                 
   102     CleanupStack::PopAndDestroy();    // reader    
   102     CleanupStack::PopAndDestroy();    // reader
   103     iEditor->SetObserver( this );
   103     iEditor->SetObserver( this );
   104     
   104     
   105     iLabel = new( ELeave ) CEikLabel;
   105     iLabel = new( ELeave ) CEikLabel;
   106     iLabel->SetContainerWindowL( *this );
   106     iLabel->SetContainerWindowL( *this );
   107     iLabel->SetParent( this );
   107     iLabel->SetParent( this );
   108     iLabel->SetMopParent( this ); 
   108     iLabel->SetMopParent( this ); 
   109     iLabel->SetTextL( KNullDesC );
   109     iLabel->SetTextL( KNullDesC );
   110     iLabel->MakeVisible( EFalse );    
   110     iLabel->MakeVisible( EFalse );
   111     CheckLabelSkinningColor();
   111     CheckLabelSkinningColor();
   112     
   112     
   113     iAppUi = iEikonEnv->EikAppUi();
   113     iAppUi = iEikonEnv->EikAppUi();
   114     __ASSERT_ALWAYS( iAppUi, DialerPanic( EDialerPanicNoApplicationInstance ) );
   114     __ASSERT_ALWAYS( iAppUi, DialerPanic( EDialerPanicNoApplicationInstance ) );
   115      
   115      
   213 //
   213 //
   214 void CDialerNumberEntry::SetTextToNumberEntry( const TDesC& aDesC )
   214 void CDialerNumberEntry::SetTextToNumberEntry( const TDesC& aDesC )
   215     {
   215     {
   216     DIALER_PRINT("numberentry::SetTextToNumberEntry<");
   216     DIALER_PRINT("numberentry::SetTextToNumberEntry<");
   217     
   217     
   218     iEditor->SetText( aDesC );   
   218     iEditor->SetText( aDesC );
   219     
   219     
   220     if ( iEasyDialer && iOperationMode == EModeEasyDialing )
   220     if ( iEasyDialer && iOperationMode == EModeEasyDialing )
   221         {
   221         {
   222         TRAP_IGNORE( iEasyDialer->SetInputL( aDesC ) );
   222         TRAP_IGNORE( iEasyDialer->SetInputL( aDesC ) );
   223         }
   223         }
   323     
   323     
   324     if ( aControl == iEditor && aEventType == EEventStateChanged )
   324     if ( aControl == iEditor && aEventType == EEventStateChanged )
   325         {
   325         {
   326         HandleEditorFormatting();
   326         HandleEditorFormatting();
   327         
   327         
   328         InformNumberEntryState();        
   328         InformNumberEntryState();
   329         
   329         
   330         iEditor->DrawDeferred();
   330         iEditor->DrawDeferred();
   331         }
   331         }
   332     
   332     
   333     DIALER_PRINT("numberentry::HandleControlEventL>");                
   333     DIALER_PRINT("numberentry::HandleControlEventL>");
   334     }
   334     }
   335 
   335 
   336 // ---------------------------------------------------------------------------
   336 // ---------------------------------------------------------------------------
   337 // CDialerNumberEntry::OfferKeyEventL
   337 // CDialerNumberEntry::OfferKeyEventL
   338 // ---------------------------------------------------------------------------
   338 // ---------------------------------------------------------------------------
   492     TInt maxChars = aReader.ReadInt16();
   492     TInt maxChars = aReader.ReadInt16();
   493     TInt maxLines = aReader.ReadInt16();
   493     TInt maxLines = aReader.ReadInt16();
   494     HBufC* truncation = aReader.ReadHBufCL();
   494     HBufC* truncation = aReader.ReadHBufCL();
   495     CleanupStack::PushL( truncation );
   495     CleanupStack::PushL( truncation );
   496     TInt formatCount = aReader.ReadInt16();
   496     TInt formatCount = aReader.ReadInt16();
   497     iEditor->ConstructL( maxChars, maxLines, formatCount, *truncation );  
   497     iEditor->ConstructL( maxChars, maxLines, formatCount, *truncation );
   498     CleanupStack::PopAndDestroy( truncation );       
   498     CleanupStack::PopAndDestroy( truncation );
   499     iFormatCount = formatCount;
   499     iFormatCount = formatCount;
   500 
   500 
   501     for ( TInt ii = 0; ii < iFormatCount; ii++ )
   501     for ( TInt ii = 0; ii < iFormatCount; ii++ )
   502         {
   502         {
   503         CAknPhoneNumberEditor::TFormat format( aReader );
   503         CAknPhoneNumberEditor::TFormat format( aReader );
   504 	    CalculateLayout( format, ii );
   504         CalculateLayout( format, ii );
   505         iEditor->AddFormat( format );
   505         iEditor->AddFormat( format );
   506         }
   506         }
   507 
   507 
   508     iEditor->SetFormat( KDialerNELayoutLargeFont );
   508     iEditor->SetFormat( KDialerNELayoutLargeFont );
   509     }
   509     }
   518     TInt currentFormat = iEditor->CurrentFormatIndex();
   518     TInt currentFormat = iEditor->CurrentFormatIndex();
   519 
   519 
   520     for ( TInt ii = 0; ii < iFormatCount; ii++ )
   520     for ( TInt ii = 0; ii < iFormatCount; ii++ )
   521         {
   521         {
   522         CAknPhoneNumberEditor::TFormat format( iEditor->Format( ii ) );
   522         CAknPhoneNumberEditor::TFormat format( iEditor->Format( ii ) );
   523 		CalculateLayout( format, ii );
   523         CalculateLayout( format, ii );
   524         iEditor->Format( ii ) = format;
   524         iEditor->Format( ii ) = format;
   525         }
   525         }
   526 
   526 
   527     iEditor->SetFormat( currentFormat );
   527     iEditor->SetFormat( currentFormat );
   528     DIALER_PRINT("numberentry::UpdateNumberEntryFormats>");
   528     DIALER_PRINT("numberentry::UpdateNumberEntryFormats>");
   618     // focus. This is to prevent accidental cursor movements as putting the
   618     // focus. This is to prevent accidental cursor movements as putting the
   619     // cursor back to the end of the text is difficult for right-aligned
   619     // cursor back to the end of the text is difficult for right-aligned
   620     // text.
   620     // text.
   621     if ( iEditor->IsFocused() )
   621     if ( iEditor->IsFocused() )
   622         {
   622         {
   623         CCoeControl::HandlePointerEventL( aPointerEvent );
   623         // If user hits the margin area between this control and the actual editor
       
   624         // control, then the event position is moved to be inside the editor region.
       
   625         // This makes it easier to move cursor with finger touch, especially in
       
   626         // both ends of the number field.
       
   627         TPoint eventPos( aPointerEvent.iPosition );
       
   628         TRect editorRect( iEditor->Rect() );
       
   629         editorRect.Shrink( 1, 1 ); // take rect which is fully inside the editor rect
       
   630         eventPos.iX = Min( eventPos.iX, editorRect.iBr.iX );
       
   631         eventPos.iX = Max( eventPos.iX, editorRect.iTl.iX );
       
   632         eventPos.iY = Min( eventPos.iY, editorRect.iBr.iY );
       
   633         eventPos.iY = Max( eventPos.iY, editorRect.iTl.iY );
       
   634     
       
   635         TPointerEvent modEvent( aPointerEvent );
       
   636         modEvent.iPosition = eventPos;
       
   637         
       
   638         CCoeControl::HandlePointerEventL( modEvent );
   624         }
   639         }
   625     }
   640     }
   626 
   641 
   627 // ---------------------------------------------------------------------------
   642 // ---------------------------------------------------------------------------
   628 // CDialerNumberEntry::HandleEditorFormatting  
   643 // CDialerNumberEntry::HandleEditorFormatting  
   638         }
   653         }
   639    
   654    
   640     if ( iEditor->CurrentFormatIndex() != format )
   655     if ( iEditor->CurrentFormatIndex() != format )
   641         {
   656         {
   642         iEditor->DrawDeferred();
   657         iEditor->DrawDeferred();
   643         iEditor->SetFormat( format );              
   658         iEditor->SetFormat( format );
   644         iFrameContext->SetRect( Rect() );                
   659         iFrameContext->SetRect( Rect() );
   645         }
   660         }
   646     
   661     
   647     }
   662     }
   648 
   663 
   649 // ---------------------------------------------------------------------------
   664 // ---------------------------------------------------------------------------
   685         {
   700         {
   686         aOuterRect = Rect();
   701         aOuterRect = Rect();
   687         TAknLayoutRect innerRectLayout;
   702         TAknLayoutRect innerRectLayout;
   688         innerRectLayout.LayoutRect( aOuterRect, AknLayoutScalable_Apps::bg_dia3_numentry_pane_g1() );
   703         innerRectLayout.LayoutRect( aOuterRect, AknLayoutScalable_Apps::bg_dia3_numentry_pane_g1() );
   689         aInnerRect = innerRectLayout.Rect();
   704         aInnerRect = innerRectLayout.Rect();
       
   705         
       
   706         // Add a bit of margin to left and right ends of the entry field if layout
       
   707         // doens't define enough. This is to enhance the touch usability.
       
   708         static const TInt KMinMargin( 10 );
       
   709         aInnerRect.iTl.iX = Max( aInnerRect.iTl.iX, aOuterRect.iTl.iX + KMinMargin );
       
   710         aInnerRect.iBr.iX = Min( aInnerRect.iBr.iX, aOuterRect.iBr.iX - KMinMargin );
   690         }
   711         }
   691     else
   712     else
   692         {
   713         {
   693         if ( Layout_Meta_Data::IsMirrored() )
   714         if ( Layout_Meta_Data::IsMirrored() )
   694             {
   715             {
   695             TAknLayoutRect frameTopRight;        
   716             TAknLayoutRect frameTopRight;
   696             frameTopRight.LayoutRect( 
   717             frameTopRight.LayoutRect( 
   697              aFrameRect, 
   718              aFrameRect, 
   698              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() );                
   719              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() );
   699                     
   720                     
   700             TAknLayoutRect frameBottomLeft;        
   721             TAknLayoutRect frameBottomLeft;
   701             frameBottomLeft.LayoutRect( 
   722             frameBottomLeft.LayoutRect( 
   702              aFrameRect, 
   723              aFrameRect, 
   703              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() );                        
   724              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() );
   704     
   725     
   705             aOuterRect = TRect( frameTopRight.Rect().iTl, 
   726             aOuterRect = TRect( frameTopRight.Rect().iTl, 
   706                                 frameBottomLeft.Rect().iBr );
   727                                 frameBottomLeft.Rect().iBr );
   707                     
   728                     
   708             aInnerRect = TRect( frameTopRight.Rect().iBr, 
   729             aInnerRect = TRect( frameTopRight.Rect().iBr, 
   709                                 frameBottomLeft.Rect().iTl );    
   730                                 frameBottomLeft.Rect().iTl );
   710             }
   731             }
   711         else
   732         else
   712             {
   733             {
   713             TAknLayoutRect frameTopLeft;        
   734             TAknLayoutRect frameTopLeft;
   714             frameTopLeft.LayoutRect( 
   735             frameTopLeft.LayoutRect( 
   715              aFrameRect, 
   736                 aFrameRect, 
   716              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g2().LayoutLine() );
   737                 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g2().LayoutLine() );
   717     
   738     
   718             TAknLayoutRect frameBottomRight;        
   739             TAknLayoutRect frameBottomRight;
   719             frameBottomRight.LayoutRect( 
   740             frameBottomRight.LayoutRect( 
   720              aFrameRect, 
   741                 aFrameRect, 
   721              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g5().LayoutLine() );
   742                 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g5().LayoutLine() );
   722             
   743             
   723             aOuterRect = TRect( frameTopLeft.Rect().iTl, 
   744             aOuterRect = TRect( frameTopLeft.Rect().iTl, 
   724                                 frameBottomRight.Rect().iBr );
   745                                 frameBottomRight.Rect().iBr );
   725             aInnerRect = TRect( frameTopLeft.Rect().iBr, 
   746             aInnerRect = TRect( frameTopLeft.Rect().iBr, 
   726                                 frameBottomRight.Rect().iTl );    
   747                                 frameBottomRight.Rect().iTl );
   727             }
   748             }
   728         }
   749         }
   729     }    
   750     }    
   730     
   751     
   731 // -----------------------------------------------------------------------------
   752 // -----------------------------------------------------------------------------
   797         {
   818         {
   798         // Ignore error
   819         // Ignore error
   799         TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, skinColor ) );
   820         TRAP_IGNORE( iLabel->OverrideColorL( EColorLabelText, skinColor ) );
   800         }   
   821         }   
   801     }
   822     }
   802     
   823 
   803     
       
   804 // -----------------------------------------------------------------------------
   824 // -----------------------------------------------------------------------------
   805 // CDialerNumberEntry::MakeVisible( TBool aVisible )
   825 // CDialerNumberEntry::MakeVisible( TBool aVisible )
   806 // -----------------------------------------------------------------------------
   826 // -----------------------------------------------------------------------------
   807 //	
   827 //	
   808 void CDialerNumberEntry::MakeVisible( TBool aVisible )
   828 void CDialerNumberEntry::MakeVisible( TBool aVisible )
   809 	{
   829 	{
   810 	CCoeControl::MakeVisible( aVisible );
   830 	CCoeControl::MakeVisible( aVisible );
   811 	iEditor->MakeVisible( aVisible );
   831 	iEditor->MakeVisible( aVisible );
   812 	}
   832 	}
   813 	
   833 
   814 	
       
   815 // -----------------------------------------------------------------------------
   834 // -----------------------------------------------------------------------------
   816 // CDialerNumberEntry::SetEasyDialingPlugin
   835 // CDialerNumberEntry::SetEasyDialingPlugin
   817 // -----------------------------------------------------------------------------
   836 // -----------------------------------------------------------------------------
   818 //
   837 //
   819 void CDialerNumberEntry::SetEasyDialingPlugin(CDialingExtensionInterface* aEasyDialer)
   838 void CDialerNumberEntry::SetEasyDialingPlugin(CDialingExtensionInterface* aEasyDialer)