uifw/AvKon/src/AknPhoneNumberEditor.cpp
branchRCL_3
changeset 72 a5e7a4f63858
parent 59 978afdc0236f
equal deleted inserted replaced
64:85902f042028 72:a5e7a4f63858
    30 
    30 
    31 #include <AknTasHook.h>
    31 #include <AknTasHook.h>
    32 #include <touchfeedback.h>
    32 #include <touchfeedback.h>
    33 #include <aknnotedialog.h>
    33 #include <aknnotedialog.h>
    34 
    34 
    35 #include <e32property.h>
       
    36 #include <AvkonInternalCRKeys.h>        // for checking qwerty availability
       
    37 
       
    38 
       
    39 static const TInt KPlainTextPos = 0;
    35 static const TInt KPlainTextPos = 0;
    40 
    36 
    41 typedef CArrayFixFlat<CAknPhoneNumberEditor::TFormat> CFormatArray;
    37 typedef CArrayFixFlat<CAknPhoneNumberEditor::TFormat> CFormatArray;
    42 
    38 
    43 NONSHARABLE_CLASS( CAknPhoneNumberEditorExtension ) : public CBase, 
    39 NONSHARABLE_CLASS( CAknPhoneNumberEditorExtension ) : public CBase, 
    54         CFormatArray* iFormats;
    50         CFormatArray* iFormats;
    55         CAknExtendedInputCapabilities* iExtendedInputCapabilities;
    51         CAknExtendedInputCapabilities* iExtendedInputCapabilities;
    56         TInt iPointPos;
    52         TInt iPointPos;
    57         CAknCcpuSupport* iCcpuSupport; 
    53         CAknCcpuSupport* iCcpuSupport; 
    58         HBufC* iPasteText;       
    54         HBufC* iPasteText;       
    59         TBool iQwertyAllowed;
       
    60         TBool iHybridModeAllowed;
       
    61       };
    55       };
    62 
    56 
    63 CAknPhoneNumberEditorExtension::CAknPhoneNumberEditorExtension()
    57 CAknPhoneNumberEditorExtension::CAknPhoneNumberEditorExtension()
    64     {
    58     {
    65     iFormats = NULL;
    59     iFormats = NULL;
   379         {
   373         {
   380         iExtension->iCcpuSupport->HandleSelectionChangeL();
   374         iExtension->iCcpuSupport->HandleSelectionChangeL();
   381         }
   375         }
   382     if ( cousorChanged )
   376     if ( cousorChanged )
   383     	{
   377     	{
   384         ReportAknEdStateEvent( MAknEdStateObserver::EAknCursorPositionChanged );
   378         ReportAknEdStateEventL( MAknEdStateObserver::EAknCursorPositionChanged );
   385     	}
   379     	}
   386     // see if we want to remember the old cursor X position
   380     // see if we want to remember the old cursor X position
   387     if ( targetPosUsed )
   381     if ( targetPosUsed )
   388         {
   382         {
   389         if ( iTargetCursorPos == CAknPhedView::KNoPos )
   383         if ( iTargetCursorPos == CAknPhedView::KNoPos )
   425         {
   419         {
   426         TRAP_IGNORE( iExtension->iCcpuSupport->HandleFocusChangeL() );        
   420         TRAP_IGNORE( iExtension->iCcpuSupport->HandleFocusChangeL() );        
   427         }    
   421         }    
   428     if ( ! IsFocused() )
   422     if ( ! IsFocused() )
   429         {
   423         {
   430         ReportAknEdStateEvent( MAknEdStateObserver::EAknSyncEdwinState );
   424         TRAP_IGNORE( ReportAknEdStateEventL( MAknEdStateObserver::EAknSyncEdwinState ) );
   431         }
   425         }
   432     if ( aDrawNow )
   426     if ( aDrawNow )
   433         DrawNow();
   427         DrawNow();
   434     }
   428     }
   435 
   429 
   439     iView->Draw( SystemGc(), iFlags[ERedrawAll], this );
   433     iView->Draw( SystemGc(), iFlags[ERedrawAll], this );
   440     }
   434     }
   441 
   435 
   442 EXPORT_C TCoeInputCapabilities CAknPhoneNumberEditor::InputCapabilities() const
   436 EXPORT_C TCoeInputCapabilities CAknPhoneNumberEditor::InputCapabilities() const
   443     {
   437     {
   444     if ( iExtension->iQwertyAllowed )
   438     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
   445         {
   439         {
   446         TCoeInputCapabilities inputCaps(
   440         TCoeInputCapabilities inputCaps(
   447             TCoeInputCapabilities::EWesternAlphabetic | 
   441             TCoeInputCapabilities::EWesternAlphabetic | 
   448             TCoeInputCapabilities::ENavigation, 
   442             TCoeInputCapabilities::ENavigation, 
   449             const_cast<CAknPhoneNumberEditor*>( this ), NULL ); 
   443             const_cast<CAknPhoneNumberEditor*>( this ), NULL ); 
   450             
   444             
   451         //iExtension->iExtendedInputCapabilities->SetEditorType( 
       
   452         //    CAknExtendedInputCapabilities::EPhoneNumberEditor );
       
   453         TInt qwertyActive = 0;
       
   454         RProperty::Get( KCRUidAvkon, KAknQwertyInputModeActive, qwertyActive );
       
   455         if ( qwertyActive && iExtension->iHybridModeAllowed )
       
   456             {
       
   457             iExtension->iExtendedInputCapabilities->SetEditorType(
       
   458                 CAknExtendedInputCapabilities::EHybridAlphaNumericEditor );
       
   459             }
       
   460         else
       
   461             {
       
   462             iExtension->iExtendedInputCapabilities->SetEditorType(
       
   463                     CAknExtendedInputCapabilities::EPhoneNumberEditor );
       
   464             }
       
   465 
       
   466         // Voip-enabled phone editor wants to use edit-key style hash key mode selection.    
   445         // Voip-enabled phone editor wants to use edit-key style hash key mode selection.    
       
   446         iExtension->iExtendedInputCapabilities->SetEditorType( 
       
   447             CAknExtendedInputCapabilities::EPhoneNumberEditor );                    
   467         iExtension->iExtendedInputCapabilities->SetCapabilities(
   448         iExtension->iExtendedInputCapabilities->SetCapabilities(
   468             CAknExtendedInputCapabilities::EForceHashKeySelectionStatusFlagOff |
   449             CAknExtendedInputCapabilities::EForceHashKeySelectionStatusFlagOff |
   469             CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff );              
   450             CAknExtendedInputCapabilities::EForceEditSubmenuStatusFlagOff );              
   470         inputCaps.SetObjectProvider( 
   451         inputCaps.SetObjectProvider( 
   471             const_cast<CAknPhoneNumberEditorExtension*>( iExtension ) );                        
   452             const_cast<CAknPhoneNumberEditorExtension*>( iExtension ) );                        
   517 
   498 
   518 EXPORT_C void CAknPhoneNumberEditor::SetSelectionL( TInt aCursorPos,TInt aAnchorPos )
   499 EXPORT_C void CAknPhoneNumberEditor::SetSelectionL( TInt aCursorPos,TInt aAnchorPos )
   519     {
   500     {
   520     iModel->SetRealCursorPosition(aCursorPos);
   501     iModel->SetRealCursorPosition(aCursorPos);
   521     iModel->SetAnchorPosition( aAnchorPos );
   502     iModel->SetAnchorPosition( aAnchorPos );
   522     ReportAknEdStateEvent( 
   503     ReportAknEdStateEventL( 
   523             MAknEdStateObserver::EAknCursorPositionChanged );
   504             MAknEdStateObserver::EAknCursorPositionChanged );
   524     }
   505     }
   525 
   506 
   526 EXPORT_C void CAknPhoneNumberEditor::SetCursorPosL( TInt aCursorPos,TBool aSelect )
   507 EXPORT_C void CAknPhoneNumberEditor::SetCursorPosL( TInt aCursorPos,TBool aSelect )
   527     {
   508     {
   528     TInt anchor = iModel->AnchorPosition();
   509     TInt anchor = iModel->AnchorPosition();
   529     iModel->SetRealCursorPosition( aCursorPos );
   510     iModel->SetRealCursorPosition( aCursorPos );
   530     if ( aSelect )
   511     if ( aSelect )
   531         iModel->SetAnchorPosition( anchor );
   512         iModel->SetAnchorPosition( anchor );
   532     ReportAknEdStateEvent( 
   513     ReportAknEdStateEventL( 
   533         MAknEdStateObserver::EAknCursorPositionChanged );
   514         MAknEdStateObserver::EAknCursorPositionChanged );
   534     }
   515     }
   535 
   516 
   536 EXPORT_C void CAknPhoneNumberEditor::SelectAllL()
   517 EXPORT_C void CAknPhoneNumberEditor::SelectAllL()
   537     {
   518     {
   661 void CAknPhoneNumberEditor::SetCursorSelectionForFepL( const TCursorSelection& aCursorSelection )
   642 void CAknPhoneNumberEditor::SetCursorSelectionForFepL( const TCursorSelection& aCursorSelection )
   662     {
   643     {
   663     iModel->SetRealCursorPosition( iModel->Uncompensate( aCursorSelection.iCursorPos ) );
   644     iModel->SetRealCursorPosition( iModel->Uncompensate( aCursorSelection.iCursorPos ) );
   664     iModel->SetAnchorPosition( iModel->Uncompensate( aCursorSelection.iAnchorPos  ) );
   645     iModel->SetAnchorPosition( iModel->Uncompensate( aCursorSelection.iAnchorPos  ) );
   665     
   646     
   666     ReportAknEdStateEvent( 
   647     ReportAknEdStateEventL( 
   667             MAknEdStateObserver::EAknCursorPositionChanged );
   648             MAknEdStateObserver::EAknCursorPositionChanged );
   668     DrawNow();
   649     DrawNow();
   669     }
   650     }
   670 
   651 
   671 void CAknPhoneNumberEditor::GetCursorSelectionForFep( TCursorSelection& aCursorSelection ) const
   652 void CAknPhoneNumberEditor::GetCursorSelectionForFep( TCursorSelection& aCursorSelection ) const
   789 //
   770 //
   790 EXPORT_C TInt CAknPhoneNumberEditor::ChangeEditorMode( TBool aDefaultMode )
   771 EXPORT_C TInt CAknPhoneNumberEditor::ChangeEditorMode( TBool aDefaultMode )
   791     {
   772     {
   792     TInt value( EAknEditorNumericInputMode ); // Return value.
   773     TInt value( EAknEditorNumericInputMode ); // Return value.
   793     
   774     
   794     if ( iExtension->iQwertyAllowed )
   775     if ( FeatureManager::FeatureSupported( KFeatureIdCommonVoip ) )
   795         {
   776         {
   796         CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; 
   777         CAknEdwinState* fepState = ( CAknEdwinState* )iFepState; 
   797 
   778 
   798         // Get current input mode.
   779         // Get current input mode.
   799         TInt currentInputMode = fepState->CurrentInputMode();
   780         TInt currentInputMode = fepState->CurrentInputMode();
   893     fepState->SetCurrentCase( EAknEditorLowerCase );
   874     fepState->SetCurrentCase( EAknEditorLowerCase );
   894     fepState->SetPermittedCases( EAknEditorLowerCase | EAknEditorUpperCase );
   875     fepState->SetPermittedCases( EAknEditorLowerCase | EAknEditorUpperCase );
   895     fepState->SetSpecialCharacterTableResourceId( 0 );
   876     fepState->SetSpecialCharacterTableResourceId( 0 );
   896     fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap );
   877     fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap );
   897     
   878     
   898     iExtension->iQwertyAllowed = EFalse;
       
   899     iExtension->iHybridModeAllowed = EFalse;
       
   900 	
       
   901     DrawChanges();
   879     DrawChanges();
   902     }
   880     }
   903 
       
   904 
       
   905 // --------------------------------------------------------------------------
       
   906 // CAknPhoneNumberEditor::SetQwertyAllowed
       
   907 // --------------------------------------------------------------------------
       
   908 //
       
   909 EXPORT_C void CAknPhoneNumberEditor::SetQwertyAllowed( TBool aQwertyAllowed ) 
       
   910     {
       
   911     iExtension->iQwertyAllowed = aQwertyAllowed;
       
   912     }
       
   913 
       
   914 // --------------------------------------------------------------------------
       
   915 // CAknPhoneNumberEditor::SetHybridModeAllowed
       
   916 // --------------------------------------------------------------------------
       
   917 //
       
   918 EXPORT_C void CAknPhoneNumberEditor::SetHybridModeAllowed( TBool aHybridModeAllowed )
       
   919     {
       
   920     iExtension->iHybridModeAllowed = aHybridModeAllowed;
       
   921     }
       
   922 
       
   923 
   881 
   924 // --------------------------------------------------------------------------
   882 // --------------------------------------------------------------------------
   925 // CAknPhoneNumberEditor::HandlePointerEventL
   883 // CAknPhoneNumberEditor::HandlePointerEventL
   926 // --------------------------------------------------------------------------
   884 // --------------------------------------------------------------------------
   927 //
   885 //
  1166 // CAknPhoneNumberEditor::CcpuPasteL
  1124 // CAknPhoneNumberEditor::CcpuPasteL
  1167 // --------------------------------------------------------------------------
  1125 // --------------------------------------------------------------------------
  1168 //
  1126 //
  1169 EXPORT_C void CAknPhoneNumberEditor::CcpuPasteL()
  1127 EXPORT_C void CAknPhoneNumberEditor::CcpuPasteL()
  1170     {
  1128     {
  1171     // When we paste the buffer to phone number editor, we must get the buffer from clipboard first 
       
  1172     // and then insert buffer to phone number editor. As the main job of CcpuCanPaste() is getting and 
       
  1173     // checking the buffer in clipboard, so we must call CcpuCanPaste() first.
       
  1174     // If iExtension->iPasteText is not NULL, it means CcpuCanPaste() has been called before and the 
       
  1175     // buffer in clipboard is valid. No need to call it once again. 
       
  1176     if ( !iExtension->iPasteText )
       
  1177         {
       
  1178         // If the return value of CcpuCanPaste is EFalse, iExtension->iPasteText must be NULL,
       
  1179         // else if the return value of CcpuCanPaste is ETure, iExtension->iPasteText must not be NULL.
       
  1180         // So we don't need to check if the return value is ETure or EFalse, 
       
  1181         // we will check iExtension->iPasteText instead of that.
       
  1182         CcpuCanPaste();
       
  1183         }
       
  1184     if ( iExtension->iPasteText )
  1129     if ( iExtension->iPasteText )
  1185         {
  1130         {
  1186         iModel->Paste( iExtension->iPasteText->Des() );
  1131         iModel->Paste( iExtension->iPasteText->Des() );
  1187         DrawNow();
  1132         DrawNow();
  1188         }
  1133         }
  1306 EXPORT_C void CAknPhoneNumberEditor::OpenVKB( )
  1251 EXPORT_C void CAknPhoneNumberEditor::OpenVKB( )
  1307     {
  1252     {
  1308     TUint cap = iExtension->iExtendedInputCapabilities->Capabilities();
  1253     TUint cap = iExtension->iExtendedInputCapabilities->Capabilities();
  1309     cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  1254     cap &= ~CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  1310     iExtension->iExtendedInputCapabilities->SetCapabilities( cap );
  1255     iExtension->iExtendedInputCapabilities->SetCapabilities( cap );
  1311     ReportAknEdStateEvent( 
  1256     TRAP_IGNORE( ReportAknEdStateEventL( 
  1312     		     MAknEdStateObserver::EAknActivatePenInputRequest );
  1257     		     MAknEdStateObserver::EAknActivatePenInputRequest ) );
  1313     }
  1258     }
  1314 
  1259 
  1315 // --------------------------------------------------------------------------
  1260 // --------------------------------------------------------------------------
  1316 // CAknPhoneNumberEditor::CloseVKB
  1261 // CAknPhoneNumberEditor::CloseVKB
  1317 // --------------------------------------------------------------------------
  1262 // --------------------------------------------------------------------------
  1319 void CAknPhoneNumberEditor::CloseVKB( )
  1264 void CAknPhoneNumberEditor::CloseVKB( )
  1320     {
  1265     {
  1321     TUint cap = iExtension->iExtendedInputCapabilities->Capabilities();
  1266     TUint cap = iExtension->iExtendedInputCapabilities->Capabilities();
  1322     cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  1267     cap |= CAknExtendedInputCapabilities::EInputEditorDisableVKB;
  1323     iExtension->iExtendedInputCapabilities->SetCapabilities( cap );
  1268     iExtension->iExtendedInputCapabilities->SetCapabilities( cap );
  1324     ReportAknEdStateEvent( MAknEdStateObserver::EAknClosePenInputRequest );
  1269     ReportAknEdStateEventL( MAknEdStateObserver::EAknClosePenInputRequest );
  1325     }
  1270     }
  1326 
  1271 
  1327 // --------------------------------------------------------------------------
  1272 // --------------------------------------------------------------------------
  1328 // CAknPhoneNumberEditor::ReportAknEdStateEventL
  1273 // CAknPhoneNumberEditor::ReportAknEdStateEventL
  1329 // --------------------------------------------------------------------------
  1274 // --------------------------------------------------------------------------
  1330 //
  1275 //
  1331 void CAknPhoneNumberEditor::ReportAknEdStateEvent( 
  1276 void CAknPhoneNumberEditor::ReportAknEdStateEventL( 
  1332          MAknEdStateObserver::EAknEdwinStateEvent aStateEvent )
  1277          MAknEdStateObserver::EAknEdwinStateEvent aStateEvent )
  1333     {
  1278     {
  1334     CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*,State(KNullUid) );
  1279     CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*,State(KNullUid) );
  1335     if ( edwinState )
  1280     if ( edwinState )
  1336         {                   
  1281         {