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