phoneuis/dialer/src/cdialernumberentry.cpp
branchRCL_3
changeset 81 c26cc2a7c548
parent 69 8baf28733c3d
equal deleted inserted replaced
73:e30d4a1b8bad 81:c26cc2a7c548
    23 #include <w32std.h>
    23 #include <w32std.h>
    24 #include <baclipb.h>            // CClipboard
    24 #include <baclipb.h>            // CClipboard
    25 #include <dialer.rsg>
    25 #include <dialer.rsg>
    26 #include <eikimage.h>           // CEikImage
    26 #include <eikimage.h>           // CEikImage
    27 #include <barsread.h>           // TResourceReader
    27 #include <barsread.h>           // TResourceReader
    28 #include <featmgr.h>
       
    29 #include <eiklabel.h> 
    28 #include <eiklabel.h> 
    30 #include <aknappui.h>
    29 #include <aknappui.h>
    31 #include <AknUtils.h>
    30 #include <AknUtils.h>
    32 #include <AknsDrawUtils.h>
    31 #include <AknsDrawUtils.h>
    33 #include <applayout.cdl.h>
    32 #include <applayout.cdl.h>
    34 #include <AknLayoutFont.h>
    33 #include <AknLayoutFont.h>
    35 #include <AknLayout2Def.h>
    34 #include <aknlayout2def.h>
    36 #include <AknPhoneNumberEditor.h>
    35 #include <AknPhoneNumberEditor.h>
    37 #include <AknLayout2ScalableDef.h>
    36 #include <aknlayout2scalabledef.h>
    38 #include <AknsBasicBackgroundControlContext.h>
    37 #include <AknsBasicBackgroundControlContext.h>
    39 #include <AknsFrameBackgroundControlContext.h>
    38 #include <AknsFrameBackgroundControlContext.h>
    40 #include <aknlayoutscalable_apps.cdl.h>
    39 #include <aknlayoutscalable_apps.cdl.h>
    41 #include <layoutmetadata.cdl.h>
    40 #include <layoutmetadata.cdl.h>
    42 
    41 
    49 #include    <phoneappcommands.hrh>
    48 #include    <phoneappcommands.hrh>
    50 
    49 
    51 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    50 const TInt KNumberEntryControlCount = 2; //  = number entry, label
    52 
    51 
    53 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
    52 _LIT( KPhoneValidChars, "0123456789*#+pwPW" );
    54 _LIT( KPhoneVanityValidChars, "0123456789*#+pwABCDEFGHIJKLMNOPQRSTUVWXYZ" );
       
    55 
       
    56 const TInt KKeyCtrlA( 1 );
    53 const TInt KKeyCtrlA( 1 );
    57 const TInt KKeyCtrlC( 3 );
    54 const TInt KKeyCtrlC( 3 );
    58 const TInt KKeyCtrlV( 22 );
    55 const TInt KKeyCtrlV( 22 );
    59 const TInt KKeyCtrlX( 24 );
    56 const TInt KKeyCtrlX( 24 );
    60 
    57 
   190         }
   187         }
   191     else 
   188     else 
   192         {       
   189         {       
   193         DoSetFocus( aFocus, aDrawNow );
   190         DoSetFocus( aFocus, aDrawNow );
   194         }
   191         }
   195 
       
   196     DIALER_PRINT("numberentry::SetFocus>");
   192     DIALER_PRINT("numberentry::SetFocus>");
   197     }
   193     }
   198     
   194 
   199 // ---------------------------------------------------------------------------
   195 // ---------------------------------------------------------------------------
   200 // CDialerNumberEntry::SetLateFocus 
   196 // CDialerNumberEntry::SetLateFocus 
   201 // ---------------------------------------------------------------------------
   197 // ---------------------------------------------------------------------------
   202 //
   198 //
   203 TInt CDialerNumberEntry::SetLateFocus( TAny* aThis )
   199 TInt CDialerNumberEntry::SetLateFocus( TAny* aThis )
   229     if ( aFocus != (iEditor-> IsFocused() ? ETrue : EFalse ) )
   225     if ( aFocus != (iEditor-> IsFocused() ? ETrue : EFalse ) )
   230         {
   226         {
   231         iEditor->SetFocus( aFocus );
   227         iEditor->SetFocus( aFocus );
   232         }
   228         }
   233 
   229 
   234     // Don't allow usage of late focuser until next layout change or Dialer launch
   230     // Don't allow usage of late focuser until next layout change
   235     iLateFocuserCanBeUsed = EFalse;
   231     iLateFocuserCanBeUsed = EFalse;
   236 
   232 
   237     DIALER_PRINT("numberentry::DoSetFocus>");  
   233     DIALER_PRINT("numberentry::DoSetFocus>");  
   238     }
   234     }
   239 
   235 
   579     labelLayout.Setl( neLayout.l() );
   575     labelLayout.Setl( neLayout.l() );
   580     AknLayoutUtils::LayoutLabel( iLabel, parentRect, labelLayout );
   576     AknLayoutUtils::LayoutLabel( iLabel, parentRect, labelLayout );
   581     
   577     
   582     HandleEditorFormatting();
   578     HandleEditorFormatting();
   583     iEditor->DrawDeferred();
   579     iEditor->DrawDeferred();
   584     
   580 
   585     // Allow usage of late focuser
   581     // Allow usage of late focuser
   586     iLateFocuserCanBeUsed = ETrue;
   582     iLateFocuserCanBeUsed = ETrue;
   587     }
   583     }
   588 
   584 
   589 // ---------------------------------------------------------------------------
   585 // ---------------------------------------------------------------------------
   956     iOperationMode = aMode;
   952     iOperationMode = aMode;
   957     }
   953     }
   958 
   954 
   959 // -----------------------------------------------------------------------------
   955 // -----------------------------------------------------------------------------
   960 // CDialerNumberEntry::Validate
   956 // CDialerNumberEntry::Validate
       
   957 //
       
   958 // Copied from cphonekeys.
   961 // -----------------------------------------------------------------------------
   959 // -----------------------------------------------------------------------------
   962 //
   960 //
   963 TBool CDialerNumberEntry::Validate( const TDesC& aString )
   961 TBool CDialerNumberEntry::Validate( const TDesC& aString )
   964     {
   962     {
   965     DIALER_PRINT("numberentry::Validate");
   963     DIALER_PRINT("numberentry::Validate");
   966     
   964     TLex input( aString );
   967     if ( aString.Length() == 0 )
       
   968         {
       
   969         return EFalse;
       
   970         }
       
   971     
       
   972     // check first character
       
   973     TPtrC valid( KPhoneValidChars );
   965     TPtrC valid( KPhoneValidChars );
   974     if ( valid.Locate( aString[0] ) == KErrNotFound )
   966 
   975         {
   967     while ( valid.Locate( input.Peek() ) != KErrNotFound )
   976         return EFalse;
   968         {
   977         }
   969         input.Inc();
   978     
   970         }
   979     // if vanitydialing feature is enabled, also capital A-Z are accepted after first character
   971     
   980     if ( FeatureManager::FeatureSupported( KFeatureIdFfHomeScreenVanityDialing ) )
   972     return !input.Remainder().Length();
   981         {
       
   982         valid.Set( KPhoneVanityValidChars );
       
   983         }
       
   984     
       
   985     // check rest of the string
       
   986     for ( TInt i = 1; i < aString.Length(); i++ )
       
   987         {
       
   988         if ( valid.Locate( aString[i] ) == KErrNotFound )
       
   989             {
       
   990             return EFalse;
       
   991             }
       
   992         }
       
   993     
       
   994     return ETrue;
       
   995     }
   973     }
   996 
   974 
   997 // End of File
   975 // End of File