uifw/eikctl/src/EIKSECED.CPP
branchRCL_3
changeset 19 aecbbf00d063
parent 18 fcdfafb36fe7
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
   228     TRect iTextRect;
   228     TRect iTextRect;
   229     TBool iCursorEnabled;
   229     TBool iCursorEnabled;
   230     TBool iWindowSet;
   230     TBool iWindowSet;
   231     TBool iLaunchPenInputAutomatic;
   231     TBool iLaunchPenInputAutomatic;
   232     TBool iPartialScreenInput;
   232     TBool iPartialScreenInput;
   233     TBool iLockQuerySCT;
       
   234     };
   233     };
   235 
   234 
   236 EXPORT_C void CEikSecretEditor::AknSetFont(const CFont &aFont)
   235 EXPORT_C void CEikSecretEditor::AknSetFont(const CFont &aFont)
   237     { 
   236     { 
   238     iFont = &aFont;
   237     iFont = &aFont;
   581     
   580     
   582     gc.SetPenColor(textColor);
   581     gc.SetPenColor(textColor);
   583     gc.UseFont(iFont);
   582     gc.UseFont(iFont);
   584 
   583 
   585     TSize size=iBorder.SizeDelta();
   584     TSize size=iBorder.SizeDelta();
   586     if ( iExtension )
   585 
   587     	{
   586     if ( iRevealSecretText )
   588 		if ( iRevealSecretText )
   587         {
   589 			{
   588         gc.DrawText( iSecCharArr->Des(), iExtension->iTextRect, 
   590 			gc.DrawText( iSecCharArr->Des(), iExtension->iTextRect, 
   589             iAscent, iAlign, 0 );
   591 				iAscent, iAlign, 0 );
   590         }
   592 			}
   591     else
   593 		else
   592         {
   594 			{
   593         gc.DrawText(iBuf, iExtension->iTextRect, iAscent, iAlign, 0);
   595 			gc.DrawText(iBuf, iExtension->iTextRect, iAscent, iAlign, 0);
   594         }
   596 			}
       
   597     	}
       
   598         
   595         
   599     gc.DiscardFont();    
   596     gc.DiscardFont();    
   600     }
   597     }
   601 
   598 
   602 void CEikSecretEditor::InsertChar()
   599 void CEikSecretEditor::InsertChar()
   624     return ((ret <= 1)? ret : ret-1); // there might be chars wider than asterisk visible.
   621     return ((ret <= 1)? ret : ret-1); // there might be chars wider than asterisk visible.
   625     }
   622     }
   626 
   623 
   627 void CEikSecretEditor::ReportUpdate()
   624 void CEikSecretEditor::ReportUpdate()
   628     {
   625     {
   629 	if ( iExtension )
   626     TRAP_IGNORE (
   630 		{
   627         iExtension->iExtendedInputCapabilities->ReportEventL(
   631         TRAP_IGNORE (
   628         CAknExtendedInputCapabilities::MAknEventObserver::EControlContentUpdatedInternally,
   632             iExtension->iExtendedInputCapabilities->ReportEventL(
   629         NULL );
   633             CAknExtendedInputCapabilities::MAknEventObserver::EControlContentUpdatedInternally,
   630         )
   634             NULL );
       
   635             )
       
   636 		}
       
   637     }
   631     }
   638 
   632 
   639 EXPORT_C void CEikSecretEditor::AppendCharacterL( TInt aKeyCode )
   633 EXPORT_C void CEikSecretEditor::AppendCharacterL( TInt aKeyCode )
   640     { // Replace this if a timer is not needed.
   634     { // Replace this if a timer is not needed.
   641     if (!iTimer)
   635     if (!iTimer)
   732     {
   726     {
   733 
   727 
   734     TBool oldShown = iRevealSecretText;
   728     TBool oldShown = iRevealSecretText;
   735     iRevealSecretText = aReveal;
   729     iRevealSecretText = aReveal;
   736 
   730 
   737     if ( !COMPARE_BOOLS( oldShown, iRevealSecretText ) && iExtension )
   731     if ( !COMPARE_BOOLS( oldShown, iRevealSecretText ) )
   738         {
   732         {
   739         TInt caps = iExtension->iExtendedInputCapabilities->Capabilities();
   733         TInt caps = iExtension->iExtendedInputCapabilities->Capabilities();
   740         if ( iRevealSecretText )
   734         if ( iRevealSecretText )
   741             {            
   735             {            
   742             caps |= CAknExtendedInputCapabilities::EInputEditorRevealSecretText;
   736             caps |= CAknExtendedInputCapabilities::EInputEditorRevealSecretText;
   788     iExtension->iBgContextSet = ETrue;
   782     iExtension->iBgContextSet = ETrue;
   789     }
   783     }
   790     
   784     
   791 EXPORT_C void CEikSecretEditor::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   785 EXPORT_C void CEikSecretEditor::HandlePointerEventL(const TPointerEvent& aPointerEvent) 
   792     { 
   786     { 
   793     if ( iFepState && iExtension )
   787     if ( iFepState )
   794         {
   788         {
   795         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   789         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   796             {
   790             {
   797             if ( iExtension->iFeedback )
   791             if ( iExtension 
       
   792               && iExtension->iFeedback )
   798                 {
   793                 {
   799                 // tactile feedback is always given on down event
   794                 // tactile feedback is always given on down event
   800                 iExtension->iFeedback->InstantFeedback( this, ETouchFeedbackEdit );
   795                 iExtension->iFeedback->InstantFeedback( this, ETouchFeedbackEditor );
   801                 }
   796                 }
   802             
   797             
   803             CAknExtendedInputCapabilities::
   798             CAknExtendedInputCapabilities::
   804                 MAknEventObserver::TPointerEventReceivedParams params;
   799                 MAknEventObserver::TPointerEventReceivedParams params;
   805             params.iPointerEvent = aPointerEvent;
   800             params.iPointerEvent = aPointerEvent;
   812                         &params );
   807                         &params );
   813                       )
   808                       )
   814                 }
   809                 }
   815             }
   810             }
   816         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && 
   811         else if ( aPointerEvent.iType == TPointerEvent::EButton1Up && 
   817                   !iExtension->iDisablePenInput )
   812             iExtension && !iExtension->iDisablePenInput)
   818             {
   813             {
   819             if ( iExtension->iFeedback )
   814             if (iExtension && iExtension->iFeedback)
   820                 {
   815                 {
   821                 // Edit feedback is given if PenInput will open on up event
   816                 // Edit feedback is given if PenInput will open on up event
   822                 iExtension->iFeedback->InstantFeedback( this,
   817                 iExtension->iFeedback->InstantFeedback( this,
   823                                                         ETouchFeedbackEdit,
   818                                                         ETouchFeedbackEditor,
   824                                                         ETouchFeedbackVibra,
   819                                                         ETouchFeedbackVibra,
   825                                                         aPointerEvent );
   820                                                         aPointerEvent );
   826                 }
   821                 }
   827             TRAP_IGNORE( 
   822             TRAP_IGNORE( 
   828                 static_cast<CAknEdwinState*>(iFepState)->ReportAknEdStateEventL( 
   823                 static_cast<CAknEdwinState*>(iFepState)->ReportAknEdStateEventL( 
   940     // The status of AknLayoutUtils::Variant() is no longer checked -> Both
   935     // The status of AknLayoutUtils::Variant() is no longer checked -> Both
   941     // European and APAC variants enable EAknEditorFlagLatinInputModesOnly.
   936     // European and APAC variants enable EAknEditorFlagLatinInputModesOnly.
   942     editorState->SetFlags( EAknEditorFlagNoLRNavigation |
   937     editorState->SetFlags( EAknEditorFlagNoLRNavigation |
   943                            EAknEditorFlagLatinInputModesOnly |
   938                            EAknEditorFlagLatinInputModesOnly |
   944                            EAknEditorFlagNoT9 |
   939                            EAknEditorFlagNoT9 |
   945                            EAknEditorFlagUseSCTNumericCharmap |
   940                            EAknEditorFlagUseSCTNumericCharmap );
   946                            EAknEditorFlagAvkonSecretEditor );
       
   947 
   941 
   948     editorState->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
   942     editorState->SetDefaultInputMode(EAknEditorSecretAlphaInputMode);
   949     editorState->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
   943     editorState->SetCurrentInputMode(EAknEditorSecretAlphaInputMode);
   950     editorState->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
   944     editorState->SetPermittedCases(EAknEditorLowerCase|EAknEditorUpperCase);
   951     editorState->SetCurrentCase(EAknEditorLowerCase);    
   945     editorState->SetCurrentCase(EAknEditorLowerCase);    
  1053                 else
  1047                 else
  1054                     {
  1048                     {
  1055                     ret = KErrGeneral;
  1049                     ret = KErrGeneral;
  1056                     }
  1050                     }
  1057                 break;
  1051                 break;
  1058             case ELockQuerySCT:
  1052 
  1059                 {
       
  1060                 if ( iExtension )
       
  1061                     {
       
  1062                     iExtension->iLockQuerySCT = aFeatureParam;
       
  1063                     CAknEdwinState* edwinState = STATIC_CAST( CAknEdwinState*,State(KNullUid) );
       
  1064                     if ( iExtension->iLockQuerySCT && edwinState )
       
  1065                         {
       
  1066                         edwinState->SetSpecialCharacterTableResourceId(
       
  1067                                 R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG_FOR_LOCKCODE_SYMBOL_INPUT );
       
  1068                         TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
       
  1069                             MAknEdStateObserver::EAknEdwinStateEventStateUpdate ) );
       
  1070                         }
       
  1071                     }
       
  1072                 else
       
  1073                     {
       
  1074                     ret = KErrGeneral;
       
  1075                     }
       
  1076                 }
       
  1077                 break;
       
  1078             default:
  1053             default:
  1079                 ret = KErrNotSupported;
  1054                 ret = KErrNotSupported;
  1080                 break;
  1055                 break;
  1081             }
  1056             }
  1082         }
  1057         }
  1124                 else
  1099                 else
  1125                     {
  1100                     {
  1126                     ret = KErrGeneral;
  1101                     ret = KErrGeneral;
  1127                     }
  1102                     }
  1128                 break;
  1103                 break;
  1129             case ELockQuerySCT:
  1104 
  1130                 {
       
  1131                 if ( iExtension )
       
  1132                     {
       
  1133                     aFeatureParam = iExtension->iLockQuerySCT;
       
  1134                     }
       
  1135                 else
       
  1136                     {
       
  1137                     ret = KErrGeneral;
       
  1138                     }
       
  1139                 }
       
  1140                 break;
       
  1141             default:
  1105             default:
  1142                 ret = KErrNotSupported;
  1106                 ret = KErrNotSupported;
  1143                 break;
  1107                 break;
  1144             }
  1108             }
  1145         }
  1109         }
  1153     // for simplified BC that will probably never be done.
  1117     // for simplified BC that will probably never be done.
  1154     const TInt supportedFeatures[] = 
  1118     const TInt supportedFeatures[] = 
  1155         {
  1119         {
  1156         EDisablePenInput,
  1120         EDisablePenInput,
  1157         ELaunchPenInputAutomatic,
  1121         ELaunchPenInputAutomatic,
  1158         EPartialScreenInput,
  1122         EPartialScreenInput
  1159         ELockQuerySCT       
       
  1160         };
  1123         };
  1161         
  1124         
  1162     TBool ret = EFalse;
  1125     TBool ret = EFalse;
  1163     
  1126     
  1164     for ( TInt i = 0; i < sizeof( supportedFeatures ) / sizeof( TInt ); ++i )
  1127     for ( TInt i = 0; i < sizeof( supportedFeatures ) / sizeof( TInt ); ++i )
  1172          
  1135          
  1173     return ret;   
  1136     return ret;   
  1174     }
  1137     }
  1175 
  1138 
  1176 void CEikSecretEditor::SetCursorFormat()
  1139 void CEikSecretEditor::SetCursorFormat()
  1177     { 
  1140     {    
  1178 	if ( iExtension )
  1141     iExtension->iCursor.iType = TTextCursor::ETypeRectangle;        
  1179 		{
  1142     iExtension->iCursor.iFlags = 0;    
  1180 		iExtension->iCursor.iType = TTextCursor::ETypeRectangle;        
  1143     iExtension->iCursor.iHeight = AknLayoutUtils::CursorHeightFromFont( 
  1181 		iExtension->iCursor.iFlags = 0;    
  1144         iFont->FontSpecInTwips() );
  1182 		iExtension->iCursor.iHeight = AknLayoutUtils::CursorHeightFromFont( 
  1145     iExtension->iCursor.iAscent = AknLayoutUtils::CursorAscentFromFont( 
  1183 			iFont->FontSpecInTwips() );
  1146         iFont->FontSpecInTwips() );
  1184 		iExtension->iCursor.iAscent = AknLayoutUtils::CursorAscentFromFont( 
  1147     iExtension->iCursor.iWidth  = AknLayoutUtils::CursorWidthFromFont ( 
  1185 			iFont->FontSpecInTwips() );
  1148         iFont->FontSpecInTwips() );
  1186 		iExtension->iCursor.iWidth  = AknLayoutUtils::CursorWidthFromFont ( 
  1149     iExtension->iCursor.iColor = KRgbWhite;
  1187 			iFont->FontSpecInTwips() );
  1150     if ( !iExtension->iWindowSet )
  1188 		iExtension->iCursor.iColor = KRgbWhite;
  1151         {
  1189 		if ( !iExtension->iWindowSet )
  1152 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
  1190 			{
  1153         CRedirectionListener* listener = ( CRedirectionListener* )
  1191 	#ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
  1154         CAknTransitionUtils::GetData( (TInt) this );
  1192 			CRedirectionListener* listener = ( CRedirectionListener* )
  1155         listener->SetWindows( &( iCoeEnv->RootWin() ), DrawableWindow() );
  1193 			CAknTransitionUtils::GetData( (TInt) this );
  1156 #else           
  1194 			listener->SetWindows( &( iCoeEnv->RootWin() ), DrawableWindow() );
  1157         iExtension->iWg = &( iCoeEnv->RootWin() );
  1195 	#else           
  1158         iExtension->iWindow = DrawableWindow();
  1196 			iExtension->iWg = &( iCoeEnv->RootWin() );
  1159 #endif
  1197 			iExtension->iWindow = DrawableWindow();
  1160         iExtension->iWindowSet = ETrue;
  1198 	#endif
  1161         }
  1199 			iExtension->iWindowSet = ETrue;
       
  1200 			}
       
  1201 		}
       
  1202     }
  1162     }
  1203 
  1163 
  1204 TPoint CEikSecretEditor::CursorPos()
  1164 TPoint CEikSecretEditor::CursorPos()
  1205     {
  1165     {
  1206     TInt charsFit = CharsFitOnEditor();
  1166     TInt charsFit = CharsFitOnEditor();
  1207     TInt pos = ( iSecCharArr->Length() < charsFit ? 
  1167     TInt pos = ( iSecCharArr->Length() < charsFit ? 
  1208         iSecCharArr->Length() : charsFit );
  1168         iSecCharArr->Length() : charsFit );
  1209     TInt textWidth( iRevealSecretText ? 
  1169     TInt textWidth( iRevealSecretText ? 
  1210         iFont->TextWidthInPixels( *iSecCharArr ) : 
  1170         iFont->TextWidthInPixels( *iSecCharArr ) : 
  1211         iFont->CharWidthInPixels( KSecretChar ) * pos );
  1171         iFont->CharWidthInPixels( KSecretChar ) * pos );
  1212     TInt x( 0 );
  1172     TInt x;
  1213     if ( iExtension )
  1173     if ( iAlign == CGraphicsContext::ELeft )
  1214     	{
  1174     	{
  1215 		if ( iAlign == CGraphicsContext::ELeft )
  1175         x = iExtension->iTextRect.iTl.iX + textWidth;
  1216 			{
  1176     	}
  1217 			x = iExtension->iTextRect.iTl.iX + textWidth;
  1177     else if (iAlign == CGraphicsContext::ECenter)
  1218 			}
  1178     	{
  1219 		else if (iAlign == CGraphicsContext::ECenter )
  1179         x = iExtension->iTextRect.iTl.iX +
  1220 			{
  1180             (iExtension->iTextRect.Width() + textWidth) / 2;
  1221 			x = iExtension->iTextRect.iTl.iX +
  1181     	}
  1222 				(iExtension->iTextRect.Width() + textWidth) / 2;
  1182     else
  1223 			}
  1183     	{
  1224 		else
  1184     	x = iExtension->iTextRect.iBr.iX;
  1225 			{
       
  1226 			x = iExtension->iTextRect.iBr.iX;
       
  1227 			}
       
  1228     	}
  1185     	}
  1229     TInt y( Rect().iTl.iY + iAscent );    
  1186     TInt y( Rect().iTl.iY + iAscent );    
  1230     return TPoint( x, y );
  1187     return TPoint( x, y );
  1231     }
  1188     }
  1232 
  1189 
  1277         CAknEdwinState* edwinState( static_cast<CAknEdwinState*>(
  1234         CAknEdwinState* edwinState( static_cast<CAknEdwinState*>(
  1278             iFepState ) );
  1235             iFepState ) );
  1279         TInt flags( edwinState->Flags() );
  1236         TInt flags( edwinState->Flags() );
  1280         if ( aEnable )
  1237         if ( aEnable )
  1281             {
  1238             {
  1282             flags |= EAknEditorFlagTextCursorVisible;
  1239             flags &= ~EEikEdwinAvkonDisableCursor;
  1283             }
  1240             }
  1284         else
  1241         else
  1285             {
  1242             {
  1286             flags &= ~EAknEditorFlagTextCursorVisible;
  1243             flags |= EEikEdwinAvkonDisableCursor;
  1287             }
  1244             }
  1288         edwinState->SetFlags( flags );
  1245         edwinState->SetFlags( flags );
  1289         }    
  1246         }    
  1290     }
  1247     }
  1291 
  1248 
  1292 void CEikSecretEditor::UpdateCursor()
  1249 void CEikSecretEditor::UpdateCursor()
  1293     {
  1250     {
  1294     if ( iExtension )
  1251 #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
  1295         {
  1252     CRedirectionListener* listener = ( CRedirectionListener* )
  1296     #ifdef RD_UI_TRANSITION_EFFECTS_PHASE2
  1253         CAknTransitionUtils::GetData( (TInt) this );
  1297         CRedirectionListener* listener = ( CRedirectionListener* )
  1254     listener->UpdateCursor( iExtension->iCursor );
  1298             CAknTransitionUtils::GetData( (TInt) this );
  1255 #else
  1299         listener->UpdateCursor( iExtension->iCursor );
  1256     if ( iExtension->iCursorEnabled )
  1300     #else
  1257         {                
  1301         if ( iExtension->iCursorEnabled )
  1258         if ( iExtension->iWindow )
  1302             {                
  1259             {            
  1303             if ( iExtension->iWindow )
  1260             iExtension->iWg->SetTextCursor( *iExtension->iWindow, CursorPos(), 
  1304                 {            
  1261                 iExtension->iCursor );            
  1305                 iExtension->iWg->SetTextCursor( *iExtension->iWindow, CursorPos(), 
  1262             }
  1306                     iExtension->iCursor );            
  1263         iExtension->iCursorEnabled = ETrue;
  1307                 }
  1264         }
  1308             iExtension->iCursorEnabled = ETrue;
  1265 #endif       
  1309             }
       
  1310     #endif   
       
  1311         }
       
  1312     }
  1266     }
  1313 
  1267 
  1314 EXPORT_C void CEikSecretEditor::FocusChanged( TDrawNow /*aDrawNow*/ )
  1268 EXPORT_C void CEikSecretEditor::FocusChanged( TDrawNow /*aDrawNow*/ )
  1315     {
  1269     {
  1316     EnableCursor( IsFocused() );        
  1270     EnableCursor( IsFocused() );