uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 15 08e69e956a8c
parent 10 9f56a4e1b8ab
child 16 71dd06cfe933
equal deleted inserted replaced
10:9f56a4e1b8ab 15:08e69e956a8c
  1132     }
  1132     }
  1133 
  1133 
  1134 // ---------------------------------------------------------------------------
  1134 // ---------------------------------------------------------------------------
  1135 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  1135 // CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL
  1136 // ---------------------------------------------------------------------------
  1136 // ---------------------------------------------------------------------------
  1137 //   
  1137 //
  1138 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL()
  1138 void CEikEdwin::CEikEdwinExtension::EnableKineticScrollingL( CAknPhysics* aPhysics )
  1139     {
  1139     {
  1140     iFlags.Set( EKineticScrollingEnabled );
  1140     iFlags.Set( EKineticScrollingEnabled );
  1141     EnablePhysicsL();
  1141     EnablePhysicsL( aPhysics );
  1142     }
  1142     }
  1143 
  1143 
  1144 // ---------------------------------------------------------------------------
  1144 // ---------------------------------------------------------------------------
  1145 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL
  1145 // CEikEdwin::CEikEdwinExtension::EnablePhysicsL
  1146 // ---------------------------------------------------------------------------
  1146 // ---------------------------------------------------------------------------
  1147 //   
  1147 //   
  1148 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL()
  1148 void CEikEdwin::CEikEdwinExtension::EnablePhysicsL( CAknPhysics* aPhysics )
  1149     {
  1149     {
  1150     if ( iFlags.IsSet( EKineticScrollingEnabled )
  1150     if ( iFlags.IsSet( EKineticScrollingEnabled )
  1151         && !iPhysicsHandler && iEdwin->DrawableWindow() )
  1151         && !iPhysicsHandler && iEdwin->DrawableWindow() )
  1152         {
  1152         {
  1153         iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin );
  1153         iPhysicsHandler = CAknEdwinPhysicsHandler::NewL( *iEdwin, aPhysics );
  1154         
  1154         
  1155         InitPhysicsL();   
  1155         InitPhysicsL();   
  1156         if ( iEdwin->iLayout )
  1156         if ( iEdwin->iLayout )
  1157             {
  1157             {
  1158             iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse );
  1158             iEdwin->iLayout->RestrictScrollToTopsOfLines( EFalse );
  2874                     }
  2874                     }
  2875                 else  if ( selectionChanged && 
  2875                 else  if ( selectionChanged && 
  2876                        ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
  2876                        ( ( aPointerEvent.iType == TPointerEvent::EDrag ) ||
  2877                          ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) )
  2877                          ( aPointerEvent.iType == TPointerEvent::EButtonRepeat ) ) )
  2878                     {
  2878                     {
  2879                     
  2879                     TInt readPos = ( selectionAfter.iCursorPos >= selectionBefore.iCursorPos ) ?
  2880                     // selectionAfter.iCursorPos-1 below is because we need to select the previous char
  2880                                           selectionBefore.iCursorPos : selectionAfter.iCursorPos ;
  2881                     TBool ltr = ( selectionAfter.iCursorPos >= selectionBefore.iCursorPos );
       
  2882                     TInt readPos = selectionAfter.iCursorPos;
       
  2883                     if (ltr && readPos > 0)
       
  2884                         {
       
  2885                         readPos -= 1; // read previous char
       
  2886                         }
       
  2887                     TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; 
  2881                     TChar currentSelectedChar = Text()->Read( readPos, 1 )[0]; 
  2888                     TBool isSpace = currentSelectedChar.IsSpace();
  2882                     TBool isSpace = currentSelectedChar.IsSpace();
  2889                     TBool isText = currentSelectedChar.IsAlpha() 
  2883                     TBool isSmiley = CSmileyManager::IsSmileyCode(currentSelectedChar);
  2890                                 || currentSelectedChar.IsDigit();
  2884                     TBool isText = currentSelectedChar.IsGraph();
  2891                     
  2885                     
  2892                     // case line
  2886                     // case line
  2893                     TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos);
  2887                     TInt prevLineNr = TextLayout()->GetLineNumber(selectionBefore.iCursorPos);
  2894                     TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos);
  2888                     TInt lineNr = TextLayout()->GetLineNumber(selectionAfter.iCursorPos);
  2895                     if ( prevLineNr != lineNr && ( selection.Length() != 0 ) )
  2889                     if ( prevLineNr != lineNr && ( selection.Length() != 0 ) )
  2904                     else if (isSpace)
  2898                     else if (isSpace)
  2905                         {
  2899                         {
  2906                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection );
  2900                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackBlankSelection );
  2907                         }
  2901                         }
  2908                     // case text
  2902                     // case text
  2909                     else if (isText)    
  2903                     else if ( isText || isSmiley )    
  2910                         {
  2904                         {
  2911                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection );
  2905                         iEdwinFepSupport->iFeedback->InstantFeedback( this, ETouchFeedbackTextSelection );
  2912                         }
  2906                         }
  2913                     }
  2907                     }
  2914                 }
  2908                 }
  4831            }
  4825            }
  4832         }
  4826         }
  4833     
  4827     
  4834     if (reportChange)
  4828     if (reportChange)
  4835         {
  4829         {
       
  4830         iEdwinExtension->iThumbPos = KErrNotFound;
  4836         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  4831         ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
  4837         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  4832         DoReportEventL( MCoeControlObserver::EEventStateChanged );
  4838         NotifyEditorStateObserverOfStateChangeL();
  4833         NotifyEditorStateObserverOfStateChangeL();
  4839         UpdateScrollBarsL();
  4834         UpdateScrollBarsL();
  4840         }
  4835         }
  8050 
  8045 
  8051 EXPORT_C void CEikEdwin::EnableKineticScrollingL( TBool aEnable )
  8046 EXPORT_C void CEikEdwin::EnableKineticScrollingL( TBool aEnable )
  8052     {
  8047     {
  8053     if ( iEdwinExtension && aEnable )
  8048     if ( iEdwinExtension && aEnable )
  8054         {
  8049         {
  8055         iEdwinExtension->EnableKineticScrollingL();
  8050         iEdwinExtension->EnableKineticScrollingL( NULL );
       
  8051         }
       
  8052     }
       
  8053 
       
  8054 EXPORT_C void CEikEdwin::EnableKineticScrollingL( CAknPhysics* aPhysics )
       
  8055     {
       
  8056     if ( iEdwinExtension )
       
  8057         {
       
  8058         iEdwinExtension->EnableKineticScrollingL( aPhysics );
  8056         }
  8059         }
  8057     }
  8060     }
  8058 
  8061 
  8059 TBool CEikEdwin::NeedToChangeFormattingModeL() const
  8062 TBool CEikEdwin::NeedToChangeFormattingModeL() const
  8060     {
  8063     {
  8571 		if (text[i] == ' ')
  8574 		if (text[i] == ' ')
  8572 			return ETrue;
  8575 			return ETrue;
  8573 		
  8576 		
  8574 		TChar::TCategory category = character.GetCategory();
  8577 		TChar::TCategory category = character.GetCategory();
  8575 		
  8578 		
  8576 		if ( !((category&TChar::ESeparatorGroup == TChar::ESeparatorGroup) ||
  8579 		if ( !( ( ( category & TChar::ESeparatorGroup ) == TChar::ESeparatorGroup ) ||
  8577 			   (text[i]>=0x200B && text[i]<=0xFFFC)) )
  8580 			   ( text[i] >= 0x200B && text[i] <= 0xFFFC ) ) )
  8578 			{
  8581 			{
  8579 			ret = ETrue;
  8582 			ret = ETrue;
  8580 			break;
  8583 			break;
  8581 			}
  8584 			}
  8582 		}
  8585 		}