uifw/EikStd/coctlsrc/EIKEDWIN.CPP
branchRCL_3
changeset 38 c52421ed5f07
parent 29 a8834a2e9a96
child 50 a1caeb42b3a3
equal deleted inserted replaced
29:a8834a2e9a96 38:c52421ed5f07
   100 
   100 
   101 #include "smileymanager.h"
   101 #include "smileymanager.h"
   102 #include "smileycustomwrap.h"
   102 #include "smileycustomwrap.h"
   103 #include <touchfeedback.h>
   103 #include <touchfeedback.h>
   104 
   104 
       
   105 // declare function
       
   106 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId );
       
   107 void ReadSCTHeadPane( TResourceReader& aReader );
       
   108 
   105 GLDEF_C void Panic(TEikEdwinPanic aPanic)
   109 GLDEF_C void Panic(TEikEdwinPanic aPanic)
   106     {
   110     {
   107     _LIT(KPanicCat,"EIKON-EDWIN");
   111     _LIT(KPanicCat,"EIKON-EDWIN");
   108     User::Panic(KPanicCat,aPanic);
   112     User::Panic(KPanicCat,aPanic);
   109     }
   113     }
   146 const TInt KAdditionalPixels = 0x400;
   150 const TInt KAdditionalPixels = 0x400;
   147 
   151 
   148 const TInt KFullFormatLengthForSmiley = 5000;
   152 const TInt KFullFormatLengthForSmiley = 5000;
   149 
   153 
   150 const TInt KContentThreshold = 8;
   154 const TInt KContentThreshold = 8;
       
   155 
       
   156 const TInt KNmericSCTLimit( 256 );
       
   157 const TInt KTInt16Length( sizeof( TInt16 ) );
       
   158 const TInt KTInt32Length( sizeof( TInt32 ) );
       
   159 const TInt KTUint32Length( sizeof( TUint32 ) );
   151 
   160 
   152 //
   161 //
   153 // class CEikEdwin::CUndoBuffer
   162 // class CEikEdwin::CUndoBuffer
   154 //
   163 //
   155 
   164 
   639 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   648 void CEikEdwinFepSupport::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection)
   640     {
   649     {
   641     TCursorSelection select( aCursorSelection.iCursorPos, aCursorSelection.iAnchorPos );
   650     TCursorSelection select( aCursorSelection.iCursorPos, aCursorSelection.iAnchorPos );
   642     iEdwin.HandleSelectionForSmiley( select );
   651     iEdwin.HandleSelectionForSmiley( select );
   643     iEdwin.iTextView->SetSelectionL( select );
   652     iEdwin.iTextView->SetSelectionL( select );
   644     iEdwin.ReportEdwinEventL(MEikEdwinObserver::EEventNavigation);
   653     iEdwin.UpdateVertScrollBarThumbL();
       
   654     iEdwin.UpdateHorizScrollBarThumb();
       
   655     iEdwin.ReportEdwinEventL( MEikEdwinObserver::EEventNavigation );
   645     }
   656     }
   646 
   657 
   647 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   658 void CEikEdwinFepSupport::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const
   648     {
   659     {
   649     aCursorSelection=iEdwin.Selection();
   660     aCursorSelection=iEdwin.Selection();
   665                 {
   676                 {
   666                 TRAP_IGNORE( smiley->ConvertTextForSmileyL( aDocumentPosition, aEditorContent, 
   677                 TRAP_IGNORE( smiley->ConvertTextForSmileyL( aDocumentPosition, aEditorContent, 
   667                     EFalse ); )
   678                     EFalse ); )
   668                 }
   679                 }
   669             }
   680             }
       
   681         // Replace all 'i' following smiley code to invisbile placeholder for
       
   682         // Touch Input can not recognize it as part of smiley code string.
   670         TInt smileyEndPos( 0 );
   683         TInt smileyEndPos( 0 );
   671         for ( TInt i( 0 ); i < length; i++ )
   684         for ( TInt i( 0 ); i < length; i++ )
   672             {
   685             {
   673             if ( aEditorContent[i] == CSmileyManager::KCompensateChar && 
   686             if ( aEditorContent[i] == CSmileyManager::KCompensateChar )
   674                 i < smileyEndPos )
   687                 {
   675                 {
   688                 // when 'i' is the first character, it is unkonwn whether it is
   676                 aEditorContent[i] = CSmileyManager::KPlaceHolder;
   689                 // part of a smiley code string or not, so we have to use another 
       
   690                 // function to decide.
       
   691                 if ( ( i > 0 && i < smileyEndPos ) ||
       
   692                      ( i == 0 && smiley->SmileyCodeByPos( aDocumentPosition ) > 0 ) )
       
   693                     {
       
   694                     aEditorContent[i] = CSmileyManager::KPlaceHolder;
       
   695                     }
   677                 }
   696                 }
   678             else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
   697             else if ( smiley->IsSmileyCode( aEditorContent[i] ) )
   679                 {
   698                 {
   680                 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
   699                 smileyEndPos = i + smiley->SmileyLength( aDocumentPosition + i );
   681                 }
   700                 }
   705 
   724 
   706 void CEikEdwinFepSupport::DoCommitFepInlineEditL()
   725 void CEikEdwinFepSupport::DoCommitFepInlineEditL()
   707     {
   726     {
   708     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing
   727     __ASSERT_ALWAYS(iPositionOfInlineTextInDocument>=0,Panic(EEikPanicBadInlineEditingState9)); // assert that we're currently inline editing
   709     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10));
   728     __ASSERT_DEBUG((iOriginalSelection.iCursorPos>=0) && (iOriginalSelection.iAnchorPos>=0) && (iPositionOfInsertionPointInDocument>=0) && (iPositionOfInlineTextInDocument>=0) && (iLengthOfInlineText>=0) && (iPointerEventHandlerDuringInlineEdit!=NULL),Panic(EEikPanicBadInlineEditingState10));
   710     iEdwin.iEdwinExtension->iInlineEditing = EFalse;
       
   711     iCharsInserted = 0;
   729     iCharsInserted = 0;
   712     iCharsDeleted = 0;
   730     iCharsDeleted = 0;
   713     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   731     TBool paragraphContainingStartPositionOfInlineTextHasChangedFormat=EFalse;
   714     TInt numberOfCharactersSuccessfullyDeleted=0;
   732     TInt numberOfCharactersSuccessfullyDeleted=0;
   715     TInt numberOfCharactersSuccessfullyInserted=0;
   733     TInt numberOfCharactersSuccessfullyInserted=0;
   719         numberOfCharactersSuccessfullyInserted, iPositionOfInlineTextInDocument );
   737         numberOfCharactersSuccessfullyInserted, iPositionOfInlineTextInDocument );
   720     if (iEdwin.iUndoStore!=NULL)
   738     if (iEdwin.iUndoStore!=NULL)
   721         {
   739         {
   722         iEdwin.iUndoStore->SetNewText( select );
   740         iEdwin.iUndoStore->SetNewText( select );
   723         }    
   741         }    
       
   742 
       
   743     iEdwin.iEdwinExtension->iInlineEditing = EFalse;
       
   744 
   724     if ( iEdwin.IsSmileyEnabled() )
   745     if ( iEdwin.IsSmileyEnabled() )
   725         {
   746         {
   726         CAknEdwinState* state( iEdwin.EditorState() );
   747         CAknEdwinState* state( iEdwin.EditorState() );
   727         TCursorSelection inlineSpan( state->CurrentInlineEditSpan() );
   748         TCursorSelection inlineSpan( state->CurrentInlineEditSpan() );
   728         if ( inlineSpan.Length() == 0 || iShowCursor )
   749         if ( inlineSpan.Length() == 0 || iShowCursor )
   739                     {
   760                     {
   740                     iEdwin.HandleSelectionForSmiley( iEdwin.Selection() );
   761                     iEdwin.HandleSelectionForSmiley( iEdwin.Selection() );
   741                     }
   762                     }
   742                 }
   763                 }
   743             iEdwin.SetAmountToFormatL( EFalse, ETrue );
   764             iEdwin.SetAmountToFormatL( EFalse, ETrue );
   744             iEdwin.DrawDeferred();
   765 
       
   766             CAknEdwinState* edwinState = 
       
   767                     static_cast<CAknEdwinState*>( iEdwin.iEdwinFepSupport->State( KNullUid ) );
       
   768             
       
   769             if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
       
   770                 {
       
   771                 iEdwin.DrawDeferred();
       
   772                 }
   745             }
   773             }
   746         }
   774         }
   747     iOriginalSelection.SetSelection(-1,-1);
   775     iOriginalSelection.SetSelection(-1,-1);
   748     iPositionOfInsertionPointInDocument=-1;
   776     iPositionOfInsertionPointInDocument=-1;
   749     iPositionOfInlineTextInDocument=-1;
   777     iPositionOfInlineTextInDocument=-1;
  2960             {
  2988             {
  2961             if ( !focused )
  2989             if ( !focused )
  2962                 {
  2990                 {
  2963                 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  2991                 TRAP_IGNORE( edwinState->ReportAknEdStateEventL( 
  2964                     MAknEdStateObserver::EAknSyncEdwinState ) );
  2992                     MAknEdStateObserver::EAknSyncEdwinState ) );
       
  2993                 if ( edwinState->Flags() & EAknEditorFlagHideTextView )
       
  2994                     {
       
  2995                     iTextView->MakeVisible( ETrue );
       
  2996                     edwinState->SetFlags( edwinState->Flags() & 
       
  2997                         ~EAknEditorFlagHideTextView );
       
  2998                     }
  2965                 }
  2999                 }
  2966             else
  3000             else
  2967                 {
  3001                 {
  2968                 if ( edwinState->Flags() & EAknEditorFlagLaunchPenInputAutomatic &&
  3002                 if ( edwinState->Flags() & EAknEditorFlagLaunchPenInputAutomatic &&
  2969                     !IsReadOnly() && !IsDimmed() && !( iEdwinUserFlags & EDisplayOnly ) )
  3003                     !IsReadOnly() && !IsDimmed() && !( iEdwinUserFlags & EDisplayOnly ) )
  6021         iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
  6055         iEdwinExtension->iScrollbarPosition = thumbSpaceAbove;
  6022         iEdwinExtension->iScrolledByScrollBar = ETrue;
  6056         iEdwinExtension->iScrolledByScrollBar = ETrue;
  6023         
  6057         
  6024         // Actual scrolling is done by calling MoveScrollIndex
  6058         // Actual scrolling is done by calling MoveScrollIndex
  6025         iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
  6059         iEdwinExtension->iPhysicsHandler->MoveScrollIndex( -textMovePixels );
       
  6060         iEdwinExtension->iEndBorderExceeded = EFalse; 
       
  6061         iEdwinExtension->iStartBorderExceeded = EFalse; 
  6026         
  6062         
  6027         iEdwinExtension->iScrolledByScrollBar = EFalse;
  6063         iEdwinExtension->iScrolledByScrollBar = EFalse;
  6028     	}
  6064     	}
  6029     }
  6065     }
  6030 
  6066 
  6703             iEdwinExtension->iPhysicsHandler->DisableDragging();
  6739             iEdwinExtension->iPhysicsHandler->DisableDragging();
  6704             }
  6740             }
  6705         if ( iEdwinExtension )
  6741         if ( iEdwinExtension )
  6706         	{
  6742         	{
  6707 			iEdwinExtension->iThumbPos = KErrNotFound;
  6743 			iEdwinExtension->iThumbPos = KErrNotFound;
       
  6744 	        iEdwinExtension->iEndBorderExceeded = EFalse; 
       
  6745 	        iEdwinExtension->iStartBorderExceeded = EFalse; 
  6708         	}
  6746         	}
  6709         SizeChanged();
  6747         SizeChanged();
  6710         if ( !IsReadOnly() && !IsNonFocusing() 
  6748         if ( !IsReadOnly() && !IsNonFocusing() 
  6711                 && !( iEdwinUserFlags & EDisplayOnly )
  6749                 && !( iEdwinUserFlags & EDisplayOnly )
  6712                 && !KineticScrollingEnabled() )
  6750                 && !KineticScrollingEnabled() )
  7427             default:
  7465             default:
  7428                 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP;
  7466                 resId = R_EIK_ALLOWED_FIXEDDIALLINGNUMBERMODEKEYMAP;
  7429                 break;
  7467                 break;
  7430             }
  7468             }
  7431 
  7469 
  7432         return iEikonEnv->AllocReadResourceLC(resId);
  7470 	    // get special character table resource ID
       
  7471         TInt sctResourceId = state->SpecialCharacterTableResourceId();
       
  7472 		if ( sctResourceId && ( state->Flags() & EAknEditorFlagUseSCTNumericCharmap ) )
       
  7473 			{
       
  7474 		    // numericSCTBuf containing number and special characters
       
  7475 			HBufC* numericSCTBuf = HBufC::NewLC( KNmericSCTLimit );
       
  7476 			TPtr numericSCTPtr( numericSCTBuf->Des() );
       
  7477 			
       
  7478 			// read number characters and add them to numericSCTBuf
       
  7479 			HBufC* numberResource = iEikonEnv->AllocReadResourceLC( resId );
       
  7480 			TPtr numberResPtr( numberResource->Des() );
       
  7481 			numericSCTPtr.Append( numberResPtr );
       
  7482 			CleanupStack::PopAndDestroy( numberResource ); // numberResource
       
  7483 			
       
  7484 		    // read special characters from SCT by dialog ID
       
  7485 		    ReadSpecialCharFromSCTL( numericSCTPtr, sctResourceId );
       
  7486 		    
       
  7487 		    return numericSCTBuf;
       
  7488 			}
       
  7489 		else
       
  7490 			{
       
  7491 		    return iEikonEnv->AllocReadResourceLC( resId );
       
  7492 			}
  7433         }
  7493         }
  7434     else
  7494     else
  7435         {
  7495         {
  7436         User::Leave(KErrNoMemory);
  7496         User::Leave(KErrNoMemory);
  7437         return NULL;
  7497         return NULL;
  8285     // for chinese popup flag
  8345     // for chinese popup flag
  8286     TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup );
  8346     TInt chinesePopup( aOldFlags & EAknEditorFlagChinesePopup );
  8287     if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) )
  8347     if ( chinesePopup != ( aNewFlags & EAknEditorFlagChinesePopup ) )
  8288         {
  8348         {
  8289         TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) );
  8349         TRAP_IGNORE( ReportChinesePopupEventL( chinesePopup == 0 ) );
  8290         }    
  8350         }
       
  8351     
       
  8352     if ( iTextView )
       
  8353         {
       
  8354         if ( ( aNewFlags & EAknEditorFlagHideTextView )
       
  8355                 && !( aOldFlags & EAknEditorFlagHideTextView ) )
       
  8356             {
       
  8357             iTextView->MakeVisible( EFalse );
       
  8358             }
       
  8359         else if ( ( aOldFlags & EAknEditorFlagTouchInputModeOpened )
       
  8360                 && !( aNewFlags & EAknEditorFlagTouchInputModeOpened ) )
       
  8361             {
       
  8362             iTextView->MakeVisible( ETrue );
       
  8363             DrawNow();
       
  8364             }
       
  8365         }
  8291     }
  8366     }
  8292 
  8367 
  8293 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen )
  8368 void CEikEdwin::ReportChinesePopupEventL( TBool aChinesePopupOpen )
  8294     {
  8369     {
  8295     if ( aChinesePopupOpen )
  8370     if ( aChinesePopupOpen )
  8421             iText->InsertL( start, ptr );            
  8496             iText->InsertL( start, ptr );            
  8422             }
  8497             }
  8423         CleanupStack::PopAndDestroy( buf );
  8498         CleanupStack::PopAndDestroy( buf );
  8424         if ( aRedraw )
  8499         if ( aRedraw )
  8425             {
  8500             {
  8426             DrawDeferred();
  8501             CAknEdwinState* edwinState = 
       
  8502                 static_cast<CAknEdwinState*>( iEdwinFepSupport->State( KNullUid ) );
       
  8503 
       
  8504             if ( !( edwinState->Flags() & EAknEditorFlagHideTextView ) )
       
  8505                 {
       
  8506                 DrawDeferred();
       
  8507                 }
  8427             }
  8508             }
  8428         }
  8509         }
  8429     }
  8510     }
  8430     
  8511     
  8431 void CEikEdwin::TrimText( TDes& aText )
  8512 void CEikEdwin::TrimText( TDes& aText )
  8970 
  9051 
  8971     return EFalse;
  9052     return EFalse;
  8972     }
  9053     }
  8973 
  9054 
  8974 
  9055 
       
  9056 // ---------------------------------------------------------------------------
       
  9057 // ReadSpecialCharFromSCTL
       
  9058 // ---------------------------------------------------------------------------
       
  9059 //
       
  9060 void ReadSpecialCharFromSCTL( TPtr& ptr, TInt sctResourceId )
       
  9061 	{
       
  9062 	TResourceReader aReader;
       
  9063 	CCoeEnv::Static()->CreateResourceReaderLC( aReader, sctResourceId );
       
  9064 	aReader.Advance( KTInt32Length ); // Diaog Flag
       
  9065 	HBufC* titleBar = aReader.ReadHBufCL(); // title bar
       
  9066 	// for titleBar useless, release it.
       
  9067 	delete titleBar;
       
  9068 	titleBar = NULL;
       
  9069 	// Page Selector Resource Id, Button Group Container Resource Id
       
  9070 	aReader.Advance( KTInt32Length + KTInt32Length );
       
  9071 	TInt lineCount = aReader.ReadInt16(); // line Count
       
  9072 	for ( TInt ii = 0; ii < lineCount; ii++ )
       
  9073 		{
       
  9074         TInt controlType = aReader.ReadInt16(); // control Type
       
  9075 	    if ( controlType == EAknCtPopupHeadingPane )
       
  9076 	    	{
       
  9077 	        // read HeadPane
       
  9078 	    	ReadSCTHeadPane( aReader );
       
  9079 	    	}
       
  9080 	    else if ( controlType == EAknCtSpecialCharacterMap )
       
  9081 	    	{
       
  9082 	        aReader.ReadTPtrC(); // caption text
       
  9083 			aReader.Advance( KTInt16Length + KTInt32Length ); // captioned control ID, item flags
       
  9084 			
       
  9085 			TInt component_count = aReader.ReadInt16();
       
  9086 			for ( TInt jj = 0; jj < component_count; jj++ )
       
  9087 				{
       
  9088 				TInt component_id = aReader.ReadInt16();
       
  9089 				if ( component_id == EAknSCTLowerCase || component_id == EAknSCTUpperCase ||
       
  9090 					component_id == EAknSCTNumeric )
       
  9091 					{
       
  9092 					HBufC* specialChar = aReader.ReadHBufCL();
       
  9093 					ptr.Append( specialChar->Des() );
       
  9094 					delete specialChar;
       
  9095 					}
       
  9096 				}
       
  9097 	    	}
       
  9098 	    else
       
  9099 	    	{
       
  9100 	        break;
       
  9101 	    	}
       
  9102 		}
       
  9103 	CleanupStack::PopAndDestroy(); // aReader
       
  9104 	}
       
  9105 
       
  9106 // ---------------------------------------------------------------------------
       
  9107 // ReadSCTHeadPane
       
  9108 // ---------------------------------------------------------------------------
       
  9109 //
       
  9110 void ReadSCTHeadPane( TResourceReader& aReader )
       
  9111 	{
       
  9112 	aReader.ReadTPtrC(); // caption text
       
  9113 	// captioned control ID, item flags
       
  9114 	aReader.Advance( KTInt16Length + KTInt32Length );
       
  9115 	aReader.ReadTPtrC(); // text of head pane
       
  9116 	aReader.ReadTPtrC(); // bitmap File Name of head pane
       
  9117 	// bitmap Id, bitmap Mask Id,animation Id, layout of head pane
       
  9118 	aReader.Advance( KTInt16Length + KTInt16Length + KTUint32Length + KTUint32Length );
       
  9119 	aReader.ReadTPtrC(); // trailer
       
  9120 	aReader.ReadTPtrC(); // bitmap File Name of captioned control
       
  9121 	// bitmap Id, bitmap Mask Id of captioned control
       
  9122 	aReader.Advance( KTInt16Length + KTInt16Length );
       
  9123 	aReader.ReadTPtrC(); // Process ToolTip
       
  9124 	}
       
  9125 
  8975 // End of File
  9126 // End of File
  8976 
  9127