uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 10 9f56a4e1b8ab
parent 9 aabf2c525e0f
child 15 08e69e956a8c
equal deleted inserted replaced
9:aabf2c525e0f 10:9f56a4e1b8ab
   570     TInt numberOfCharactersSuccessfullyDeleted=0;
   570     TInt numberOfCharactersSuccessfullyDeleted=0;
   571     TInt numberOfCharactersSuccessfullyInserted=0;
   571     TInt numberOfCharactersSuccessfullyInserted=0;
   572     TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText));
   572     TRAPD(error,iEdwin.iText->UpdateFepInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,iPositionOfInsertionPointInDocument,iPositionOfInlineTextInDocument+aPositionOfInsertionPointInInlineText,aNewInlineText));
   573     iLengthOfInlineText=numberOfCharactersSuccessfullyInserted;
   573     iLengthOfInlineText=numberOfCharactersSuccessfullyInserted;
   574     UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error);
   574     UpdateTextViewAfterChangeInInlineTextL(paragraphContainingStartPositionOfInlineTextHasChangedFormat,numberOfCharactersSuccessfullyDeleted,numberOfCharactersSuccessfullyInserted,error);
   575     iEdwin.ReportEdwinEventL( MEikEdwinObserver::EEventTextUpdate );
       
   576     }
   575     }
   577 
   576 
   578 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
   577 void CEikEdwinFepSupport::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility)
   579     {
   578     {
   580     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState7)); // assert that we're currently inline editing
   579     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState7)); // assert that we're currently inline editing
  1040 
  1039 
  1041         iCenRepNotifyHandler->StartListeningL();
  1040         iCenRepNotifyHandler->StartListeningL();
  1042         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1041         iCenRep->Get(KAknFepClearDirection, iClearDirection);
  1043         }
  1042         }
  1044     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
  1043     iSmileyWrap = new ( ELeave ) CSmileyCustomWrap;
       
  1044     iSkinInstance = AknsUtils::SkinInstance();
  1045     }
  1045     }
  1046 
  1046 
  1047 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1047 void CEikEdwin::CEikEdwinExtension::CreateFormExtendedInterfaceProviderIfNeededL()
  1048     {
  1048     {
  1049     if ( !iFormExtendedInterfaceProvider )
  1049     if ( !iFormExtendedInterfaceProvider )
  2770                 MoveCursorL(TCursorPosition::EFLineUp,select);
  2770                 MoveCursorL(TCursorPosition::EFLineUp,select);
  2771                 rect.Move(0,-(viewRect.Height()+2000));
  2771                 rect.Move(0,-(viewRect.Height()+2000));
  2772                 }
  2772                 }
  2773             Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect);
  2773             Window().RequestPointerRepeatEvent(KPointerRepeatRate,rect);
  2774             navigation = ETrue;
  2774             navigation = ETrue;
  2775             iEdwinExtension->iThumbPos = KErrNotFound;
  2775             if ( iLayout && !iLayout->IsFormattingBand() )
       
  2776                 {
       
  2777                 iEdwinExtension->iThumbPos = KErrNotFound;
       
  2778                 }
  2776             }
  2779             }
  2777         else if (iEdwinInternalFlags&EDragDouble)
  2780         else if (iEdwinInternalFlags&EDragDouble)
  2778             {
  2781             {
  2779             TInt newWordStartPos,newWordLength;
  2782             TInt newWordStartPos,newWordLength;
  2780             GetWordInfo(newCursorPos,newWordStartPos,newWordLength);
  2783             GetWordInfo(newCursorPos,newWordStartPos,newWordLength);
  3377         {
  3380         {
  3378         const TInt count=iObserverArray->Count();
  3381         const TInt count=iObserverArray->Count();
  3379         for (TInt ii=0;ii<count;ii++)
  3382         for (TInt ii=0;ii<count;ii++)
  3380             (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType);
  3383             (*iObserverArray)[ii]->HandleEdwinEventL(this,aEventType);
  3381         }
  3384         }
  3382     if ( aEventType == MEikEdwinObserver::EEventScroll || 
       
  3383         aEventType == MEikEdwinObserver::EEventNavigation 
       
  3384         )
       
  3385         {
       
  3386         HandleScrollForSmileyL();        
       
  3387         }
       
  3388     if ( aEventType == MEikEdwinObserver::EEventTextUpdate )
  3385     if ( aEventType == MEikEdwinObserver::EEventTextUpdate )
  3389         {
  3386         {
  3390         iEdwinExtension->iExtendedInputCapabilities->ReportEventL( 
  3387         iEdwinExtension->iExtendedInputCapabilities->ReportEventL( 
  3391                 CAknExtendedInputCapabilities::
  3388                 CAknExtendedInputCapabilities::
  3392                     MAknEventObserver::EControlContentUpdatedInternally,
  3389                     MAknEventObserver::EControlContentUpdatedInternally,
  5679         else
  5676         else
  5680             {
  5677             {
  5681             aVertModel.iThumbSpan = bottomPos - topPos;
  5678             aVertModel.iThumbSpan = bottomPos - topPos;
  5682             aVertModel.iScrollSpan = totalChars;        
  5679             aVertModel.iScrollSpan = totalChars;        
  5683             aVertModel.iThumbPosition = topPos;
  5680             aVertModel.iThumbPosition = topPos;
       
  5681             iEdwinExtension->iThumbPos = topPos;
  5684             }
  5682             }
  5685         return;
  5683         return;
  5686         }
  5684         }
  5687     else
  5685     else
  5688         {
  5686         {
  8257 TBool CEikEdwin::IsSmileyEnabled() const
  8255 TBool CEikEdwin::IsSmileyEnabled() const
  8258     {
  8256     {
  8259     return ( iEdwinExtension->iSmiley != NULL );
  8257     return ( iEdwinExtension->iSmiley != NULL );
  8260     }
  8258     }
  8261 
  8259 
  8262 void CEikEdwin::DrawSmileyInTextL( CBitmapContext& aGc, CFont& aFont, 
  8260 void CEikEdwin::DrawSmileyInTextL( RRegion& rgn, const TRect& aDrawRect, 
  8263         const TDesC& aText, const TPoint& aPt )
  8261     CBitmapContext& aGc, CFont& aFont, const TDesC& aText, const TPoint& aPt )
  8264     {    
  8262     {    
  8265     TRect viewRect( AdjustedViewRect() );
  8263     TRect viewRect( AdjustedViewRect() );
  8266     TInt topY( aPt.iY - aFont.AscentInPixels() );
  8264     TInt topY( aPt.iY - aFont.AscentInPixels() );
  8267     TInt bottomY( aPt.iY + aFont.DescentInPixels() );
  8265     TInt bottomY( aPt.iY + aFont.DescentInPixels() );
  8268     const TInt KThreshold = 10;
  8266     const TInt KThreshold = 10;
  8288         for ( TInt i( 0 ); i < text.Length(); i++ )
  8286         for ( TInt i( 0 ); i < text.Length(); i++ )
  8289             {
  8287             {
  8290             if ( CSmileyManager::IsSmileyCode( text[i] ) )
  8288             if ( CSmileyManager::IsSmileyCode( text[i] ) )
  8291                 {
  8289                 {
  8292                 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) );
  8290                 TInt x( pt.iX + aFont.TextWidthInPixels( text.Left( i ) ) );
  8293                 TRect rect( x, topY, x + smileyWidth, bottomY );
  8291                 TRect clipRect( x, aDrawRect.iTl.iY, x + smileyWidth, 
  8294                 iEdwinExtension->iSmiley->DrawIconL( aGc, rect, i + pos );
  8292                     aDrawRect.iBr.iY ); 
       
  8293                 rgn.SubRect( clipRect, NULL );
       
  8294                 TRect iconRect( x, topY, x + smileyWidth, bottomY );
       
  8295                 iEdwinExtension->iSmiley->DrawIconL( aGc, iconRect, i + pos );
  8295                 }
  8296                 }
  8296             }
  8297             }
  8297         }
  8298         }
  8298     delete buf;
  8299     delete buf;
  8299     }
  8300     }
  8474         iText->InsertL( lowerPos, ptr );            
  8475         iText->InsertL( lowerPos, ptr );            
  8475         }
  8476         }
  8476     CleanupStack::PopAndDestroy( buf );
  8477     CleanupStack::PopAndDestroy( buf );
  8477     }
  8478     }
  8478 
  8479 
  8479 void CEikEdwin::HandleScrollForSmileyL()
       
  8480     {
       
  8481     if ( !iEdwinExtension->iSmiley )
       
  8482         {
       
  8483         return;
       
  8484         }
       
  8485     TCursorSelection select( GetVisibleTextRangeL() );
       
  8486     if ( select.LowerPos() != iEdwinExtension->iVisibleRange.LowerPos() ||
       
  8487         select.HigherPos() != iEdwinExtension->iVisibleRange.HigherPos() )
       
  8488         {
       
  8489         iEdwinExtension->iVisibleRange.iCursorPos = select.iCursorPos;
       
  8490         iEdwinExtension->iVisibleRange.iAnchorPos = select.iAnchorPos;
       
  8491         }
       
  8492     iEdwinExtension->iSmiley->SetVisibleRange( select.LowerPos(), 
       
  8493         select.Length() );
       
  8494     }
       
  8495 
       
  8496 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect )
  8480 TBool CEikEdwin::AdjustCursorForSmileyL( TInt aOldCursor, TCursorSelection& aSelect )
  8497     {
  8481     {
  8498     TBool ret( EFalse );
  8482     TBool ret( EFalse );
  8499     TCursorSelection select( Selection() );
  8483     TCursorSelection select( Selection() );
  8500     TInt cursor( select.iCursorPos );
  8484     TInt cursor( select.iCursorPos );
  8516     {
  8500     {
  8517     TRect viewRect( AdjustedViewRect() );
  8501     TRect viewRect( AdjustedViewRect() );
  8518     return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY );
  8502     return TRect( viewRect.iTl.iX, aRect.iTl.iY, viewRect.iBr.iX, aRect.iBr.iY );
  8519     }
  8503     }
  8520 
  8504 
  8521 void CEikEdwin::GetClipRegionForSmiley( RRegion& rgn, CFont& aFont, 
       
  8522     const TDesC& aText, const TPoint& aPt, const TRect& aDrawRect ) const
       
  8523     {
       
  8524     TInt smileyWidth( aFont.TextWidthInPixels( KSmileyString ) );
       
  8525     TInt topY( aDrawRect.iTl.iY );
       
  8526     TInt bottomY( aDrawRect.iBr.iY );
       
  8527     for ( TInt i( 0 ); i < aText.Length(); i++ )
       
  8528         {
       
  8529         if ( CSmileyManager::IsSmileyCode( aText[i] ) )
       
  8530             {
       
  8531             TInt x( aPt.iX + aFont.TextWidthInPixels( aText.Left( i ) ) );
       
  8532             TRect rect( x, topY, x + smileyWidth, bottomY );
       
  8533             rgn.SubRect( rect, NULL );
       
  8534             }
       
  8535         }
       
  8536     }
       
  8537 
       
  8538 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, 
  8505 TBool CEikEdwin::AdjustCursorPosByMovementL( TCursorPosition::TMovementType aMovement, 
  8539     TBool aSelect )
  8506     TBool aSelect )
  8540     {
  8507     {
  8541     TBool ret( EFalse );
  8508     TBool ret( EFalse );
  8542     if ( iEdwinExtension->iSmiley )
  8509     if ( iEdwinExtension->iSmiley )
  8559             }
  8526             }
  8560         }
  8527         }
  8561     return ret;
  8528     return ret;
  8562     }
  8529     }
  8563 
  8530 
  8564 void CEikEdwin::SetSelectionVisibilityL( TBool isVisable )
  8531 void CEikEdwin::SetSelectionVisibilityL( TBool aIsVisable )
  8565     {
  8532     {
  8566     iTextView->SetSelectionVisibilityL(isVisable);
  8533     if ( iEdwinExtension->iSmiley && !aIsVisable )
       
  8534         {
       
  8535         iTextView->SetSelectionVisibilityL( aIsVisable );
       
  8536         HandleSelectionForSmiley( TCursorSelection( 0, 0 ) );
       
  8537         }
       
  8538     else 
       
  8539         {
       
  8540         if ( iEdwinExtension->iSmiley )
       
  8541             {
       
  8542             HandleSelectionForSmiley( Selection() );
       
  8543             }
       
  8544         iTextView->SetSelectionVisibilityL( aIsVisable );
       
  8545         }
       
  8546    
  8567     CAknEdwinState*edwinState = EditorState();
  8547     CAknEdwinState*edwinState = EditorState();
  8568     if( !edwinState )
  8548     if ( edwinState )
  8569     	return;
  8549         {
  8570     if(isVisable)
  8550         if ( aIsVisable )
  8571     	{
  8551             {
  8572         SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
  8552             SetAknEditorFlags( edwinState->Flags() | EAknEditorFlagSelectionVisible );
  8573     	}
  8553             }
  8574     else
  8554         else
  8575     	{
  8555             {
  8576         HandleSelectionForSmiley( TCursorSelection( 0, 0 ) );
  8556             SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
  8577     	SetAknEditorFlags( edwinState->Flags() & ~EAknEditorFlagSelectionVisible );
  8557             }
  8578     	}
  8558         }
  8579     return;
  8559     return;
  8580     }
  8560     }
  8581 TBool CEikEdwin::IsSelectionVisible()
  8561 TBool CEikEdwin::IsSelectionVisible()
  8582 	{
  8562 	{
  8583 	TBool ret = EFalse;
  8563 	TBool ret = EFalse;
  8791     {
  8771     {
  8792     return iEdwinExtension && iEdwinExtension->iPhysicsHandler;
  8772     return iEdwinExtension && iEdwinExtension->iPhysicsHandler;
  8793     }
  8773     }
  8794 
  8774 
  8795 
  8775 
       
  8776 // ---------------------------------------------------------------------------
       
  8777 // CEikEdwin::DrawViewBackground
       
  8778 // ---------------------------------------------------------------------------
       
  8779 //
       
  8780 void CEikEdwin::DrawViewBackground( TBool aStart ) const
       
  8781     {
       
  8782     CWindowGc& gc = SystemGc();
       
  8783     RWindow& window = Window();
       
  8784 
       
  8785     if ( aStart )
       
  8786         {
       
  8787         TRect viewRect( iTextView->ViewRect() );
       
  8788         window.Invalidate( viewRect );
       
  8789         window.BeginRedraw( viewRect );
       
  8790         gc.Activate( window );
       
  8791     
       
  8792         if ( !AknsDrawUtils::DrawBackground( 
       
  8793                 iEdwinExtension->iSkinInstance, 
       
  8794                 SkinBackgroundControlContext(),
       
  8795                 this,
       
  8796                 gc,
       
  8797                 viewRect.iTl,
       
  8798                 viewRect,
       
  8799                 KAknsDrawParamNoClearUnderImage ) )
       
  8800             {
       
  8801             gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  8802             gc.SetPenStyle( CGraphicsContext::ESolidPen );
       
  8803     
       
  8804             TRgb dummyColor;
       
  8805             TRgb backgroundColor = EditorBackgroundColor( dummyColor ); 
       
  8806     
       
  8807             gc.SetBrushColor( backgroundColor );
       
  8808             gc.SetPenColor( backgroundColor );
       
  8809             gc.DrawRect( iTextView->ViewRect() );
       
  8810             }
       
  8811         }
       
  8812     else
       
  8813         {
       
  8814         gc.Deactivate();
       
  8815         window.EndRedraw();
       
  8816         }
       
  8817     }
       
  8818 
       
  8819 
  8796 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect )
  8820 void CEikEdwin::HandleSelectionForSmiley( TCursorSelection aSelect )
  8797     {
  8821     {
  8798     if ( !iEdwinExtension->iSmiley )
  8822     if ( !iEdwinExtension->iSmiley )
  8799         {
  8823         {
  8800         return;
  8824         return;