phoneuis/dialer/src/cdialernumberentry.cpp
branchRCL_3
changeset 25 91c2fb4b78df
parent 19 544e34b3255a
child 34 b68fcd923911
equal deleted inserted replaced
19:544e34b3255a 25:91c2fb4b78df
    48 #include    <phoneappcommands.hrh>
    48 #include    <phoneappcommands.hrh>
    49 
    49 
    50 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    50 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    51 
    51 
    52 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
    52 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
       
    53 const TInt KKeyCtrlA( 1 );
       
    54 const TInt KKeyCtrlC( 3 );
       
    55 const TInt KKeyCtrlV( 22 );
       
    56 const TInt KKeyCtrlX( 24 );
    53 
    57 
    54 // ========================= MEMBER FUNCTIONS ================================
    58 // ========================= MEMBER FUNCTIONS ================================
    55 
    59 
    56 // ---------------------------------------------------------------------------
    60 // ---------------------------------------------------------------------------
    57 // NewL
    61 // NewL
   155     {
   159     {
   156     DIALER_PRINT("numberentry::SetFocus<");
   160     DIALER_PRINT("numberentry::SetFocus<");
   157     
   161     
   158     CCoeControl::SetFocus( aFocus, aDrawNow );
   162     CCoeControl::SetFocus( aFocus, aDrawNow );
   159     iEditor->SetFocus( aFocus );
   163     iEditor->SetFocus( aFocus );
   160      
   164     
   161     DIALER_PRINT("numberentry::SetFocus>");    
   165     DIALER_PRINT("numberentry::SetFocus>");
   162     }
   166     }
   163 
   167 
   164 
   168 
   165 // ---------------------------------------------------------------------------
   169 // ---------------------------------------------------------------------------
   166 // CDialerNumberEntry::TextLength 
   170 // CDialerNumberEntry::TextLength 
   338 // ---------------------------------------------------------------------------
   342 // ---------------------------------------------------------------------------
   339 //
   343 //
   340 TKeyResponse CDialerNumberEntry::OfferKeyEventL( 
   344 TKeyResponse CDialerNumberEntry::OfferKeyEventL( 
   341                                             const TKeyEvent& aKeyEvent, 
   345                                             const TKeyEvent& aKeyEvent, 
   342                                             TEventCode aType )
   346                                             TEventCode aType )
   343     {       
   347     {
   344     TKeyResponse handled = EKeyWasNotConsumed;
   348     TKeyResponse handled = EKeyWasNotConsumed;
   345         
   349         
   346     // First, offer keyevent to easy dialer.
   350     // First, offer keyevent to easy dialer.
   347     if (iEasyDialer)
   351     if (iEasyDialer)
   348         {
   352         {
   350         }
   354         }
   351         
   355         
   352     // Then to number entry editor. 
   356     // Then to number entry editor. 
   353     if (handled == EKeyWasNotConsumed)
   357     if (handled == EKeyWasNotConsumed)
   354         {
   358         {
   355         handled = iEditor->OfferKeyEventL(aKeyEvent, aType);
   359         // Clipboard support
   356         }
   360         if ( aKeyEvent.iCode == KKeyCtrlA ) // CTRL + A
   357         
   361             {
       
   362             iEditor->SelectAllL();
       
   363             handled = EKeyWasConsumed;
       
   364             }
       
   365         else if ( aKeyEvent.iCode == KKeyCtrlC ) // CTRL + C
       
   366             {
       
   367             iEditor->CcpuCopyL();
       
   368             handled = EKeyWasConsumed;
       
   369             }
       
   370         else if ( aKeyEvent.iCode == KKeyCtrlV ) // CTRL + V
       
   371             {
       
   372             iEditor->CcpuPasteL();
       
   373             handled = EKeyWasConsumed;
       
   374             }
       
   375         else if ( aKeyEvent.iCode == KKeyCtrlX ) // CTRL + X
       
   376             {
       
   377             iEditor->CcpuCutL();
       
   378             handled = EKeyWasConsumed;
       
   379             }
       
   380         // Key events 1 - 28 can be generated by CTRL + key combinations.
       
   381         // Filter all unwanted key events, only BS is accepted by editor.
       
   382         else if ( aKeyEvent.iCode == EKeyBackspace || aKeyEvent.iCode >= EKeySpace )
       
   383             {
       
   384             handled = iEditor->OfferKeyEventL(aKeyEvent, aType);
       
   385             }
       
   386         }
       
   387     
   358     return handled;
   388     return handled;
   359     }
   389     }
   360     
   390 
   361 // ---------------------------------------------------------------------------
   391 // ---------------------------------------------------------------------------
   362 // CDialerNumberEntry::CountComponentControls 
   392 // CDialerNumberEntry::CountComponentControls 
   363 // ---------------------------------------------------------------------------
   393 // ---------------------------------------------------------------------------
   364 //
   394 //
   365 TInt CDialerNumberEntry::CountComponentControls() const
   395 TInt CDialerNumberEntry::CountComponentControls() const
   408                              KAknsIIDDefault ))
   438                              KAknsIIDDefault ))
   409         {
   439         {
   410         DIALER_PRINT("numberentry::Draw.Frame.failed"); 
   440         DIALER_PRINT("numberentry::Draw.Frame.failed"); 
   411         }
   441         }
   412                             
   442                             
   413     gc.SetBrushStyle( CGraphicsContext::ENullBrush );        
   443     gc.SetBrushStyle( CGraphicsContext::ENullBrush );
   414     }
   444     }
   415 
   445 
   416 
   446 
   417 // ---------------------------------------------------------------------------
   447 // ---------------------------------------------------------------------------
   418 // CDialerNumberEntry::SetVariety
   448 // CDialerNumberEntry::SetVariety
   696                                               TRect& aOuterRect,
   726                                               TRect& aOuterRect,
   697                                               TRect& aInnerRect )
   727                                               TRect& aInnerRect )
   698     {
   728     {
   699     if ( iOperationMode == EModeEasyDialing )
   729     if ( iOperationMode == EModeEasyDialing )
   700         {
   730         {
   701         aOuterRect = Rect();
   731         aOuterRect = aFrameRect;
   702         TAknLayoutRect innerRectLayout;
   732         TAknLayoutRect innerRectLayout;
   703         innerRectLayout.LayoutRect( aOuterRect, AknLayoutScalable_Apps::bg_dia3_numentry_pane_g1() );
   733         innerRectLayout.LayoutRect( aOuterRect, AknLayoutScalable_Apps::bg_dia3_numentry_pane_g1() );
   704         aInnerRect = innerRectLayout.Rect();
   734         aInnerRect = innerRectLayout.Rect();
   705         
   735         
   706         // Add a bit of margin to left and right ends of the entry field if layout
   736         // 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.
   737         // doens't define enough. This is to enhance the touch usability.
   708         static const TInt KMinMargin( 10 );
   738         static const TInt KMinMargin( 15 );
   709         aInnerRect.iTl.iX = Max( aInnerRect.iTl.iX, aOuterRect.iTl.iX + KMinMargin );
   739         aInnerRect.iTl.iX = Max( aInnerRect.iTl.iX, aOuterRect.iTl.iX + KMinMargin );
   710         aInnerRect.iBr.iX = Min( aInnerRect.iBr.iX, aOuterRect.iBr.iX - KMinMargin );
   740         aInnerRect.iBr.iX = Min( aInnerRect.iBr.iX, aOuterRect.iBr.iX - KMinMargin );
   711         }
   741         }
   712     else
   742     else
   713         {
   743         {
   714         if ( Layout_Meta_Data::IsMirrored() )
   744         if ( Layout_Meta_Data::IsMirrored() )
   715             {
   745             {
   716             TAknLayoutRect frameTopRight;
   746             TAknLayoutRect frameTopRight;
   717             frameTopRight.LayoutRect( 
   747             frameTopRight.LayoutRect( 
   718              aFrameRect, 
   748                 aFrameRect, 
   719              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() );
   749                 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g3().LayoutLine() );
   720                     
   750                     
   721             TAknLayoutRect frameBottomLeft;
   751             TAknLayoutRect frameBottomLeft;
   722             frameBottomLeft.LayoutRect( 
   752             frameBottomLeft.LayoutRect( 
   723              aFrameRect, 
   753                 aFrameRect, 
   724              AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() );
   754                 AknLayoutScalable_Apps::bg_popup_call2_rect_pane_g4().LayoutLine() );
   725     
   755     
   726             aOuterRect = TRect( frameTopRight.Rect().iTl, 
   756             aOuterRect = TRect( frameTopRight.Rect().iTl, 
   727                                 frameBottomLeft.Rect().iBr );
   757                                 frameBottomLeft.Rect().iBr );
   728                     
   758                     
   729             aInnerRect = TRect( frameTopRight.Rect().iBr, 
   759             aInnerRect = TRect( frameTopRight.Rect().iBr, 
   758     if ( !iNumberContents && iEditor->TextLength() )
   788     if ( !iNumberContents && iEditor->TextLength() )
   759         {
   789         {
   760         // Hide prompt text
   790         // Hide prompt text
   761         if ( iLabel->Text()->Length() )
   791         if ( iLabel->Text()->Length() )
   762             {
   792             {
   763             iLabel->MakeVisible( EFalse );     
   793             iLabel->MakeVisible( EFalse );
   764             }         
   794             }         
   765         iNumberContents = ETrue;
   795         iNumberContents = ETrue;
   766         }
   796         }
   767     else if ( iNumberContents && !iEditor->TextLength() )
   797     else if ( iNumberContents && !iEditor->TextLength() )
   768         {  
   798         {  
   769         // Show prompt text
   799         // Show prompt text
   770         if ( iLabel->Text()->Length() )
   800         if ( iLabel->Text()->Length() )
   771             {
   801             {
   772             iLabel->MakeVisible( ETrue );     
   802             iLabel->MakeVisible( ETrue );
   773             } 
   803             } 
   774         iNumberContents = EFalse;
   804         iNumberContents = EFalse;
   775         } 
   805         } 
   776 
   806 
   777     if ( iPreviousNumberEntryContent.Compare( iEditor->Text() ) != 0 )
   807     if ( iPreviousNumberEntryContent.Compare( iEditor->Text() ) != 0 )