idlehomescreen/xmluirendering/renderingplugins/xntexteditorfactory/src/xntexteditoradapter.cpp
branchRCL_3
changeset 35 3321d3e205b6
parent 34 5456b4e8b3a8
equal deleted inserted replaced
34:5456b4e8b3a8 35:3321d3e205b6
    48 #include "xnnodepluginif.h"
    48 #include "xnnodepluginif.h"
    49 #include "xneditmode.h"
    49 #include "xneditmode.h"
    50 #include "c_xnutils.h"
    50 #include "c_xnutils.h"
    51 #include "xntexteditor.h" 
    51 #include "xntexteditor.h" 
    52 
    52 
    53 const TInt KMaxLength = 100;
    53 // Constants
    54 
    54 enum EFlags
    55 enum TSplitInputState
    55     {
    56     {
    56     EUsePartialScreenInput = 1,
    57     ESplitInputEnabled = 1,   
    57     EIsAlreadyFocused,
    58     ESplitInputOpen = 2,
    58     EIsFocused,
    59     ESplitInputEditorInStack = 4,
    59     ESetText    
    60     EScreenDeviceChanged = 8
       
    61     };
    60     };
       
    61 
       
    62 const TInt KDefaultLength( 100 );
    62 
    63 
    63 _LIT8( KCpsPublishing, "cpspublishing" );
    64 _LIT8( KCpsPublishing, "cpspublishing" );
    64 _LIT8( KMaxLineAmount, "max-line-amount" );
    65 _LIT8( KMaxLineAmount, "max-line-amount" );
    65 _LIT8( KMaxCharAmount, "max-char-amount" );
    66 _LIT8( KMaxCharAmount, "max-char-amount" );
    66 _LIT8( KEnablePartialInput, "splitinputenabled" );
    67 _LIT8( KEnablePartialInput, "splitinputenabled" );
    67 _LIT8( KSplitScreenEnabledTrigger , "splitscreenenabled" );
       
    68 _LIT8( KSplitScreenDisabledTrigger, "splitscreendisabled" );
       
    69 
    68 
    70 _LIT( KEnterChar, "\x2029" );
    69 _LIT( KEnterChar, "\x2029" );
    71 
    70 
    72 // Local macros
    71 // Macros
    73 #define IS_ARROW_KEY( k ) \
    72 #define IS_ARROW_KEY( k ) \
    74     ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \
    73     ( k == EStdKeyLeftArrow || k == EStdKeyRightArrow || \
    75       k == EStdKeyUpArrow || k == EStdKeyDownArrow ) 
    74       k == EStdKeyUpArrow || k == EStdKeyDownArrow ) 
    76 
    75 
    77 // ============================ LOCAL FUNCTIONS ================================   
    76 // ============================ LOCAL FUNCTIONS ================================   
    78 
    77 
    79 // -----------------------------------------------------------------------------
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 TBool IsFlagSet( TInt aFlags, TInt aFlag )
       
    83     {
       
    84     return aFlags & aFlag;
       
    85     }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void SetFlag( TInt& aFlags, TInt aFlag )
       
    91     {
       
    92     aFlags |= aFlag;
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 void ClearFlag( TInt& aFlags, TInt aFlag )
       
    99     {
       
   100     aFlags &= ~aFlag;
       
   101     }
       
   102 
       
   103 // ============================ MEMBER FUNCTIONS ===============================
    78 // ============================ MEMBER FUNCTIONS ===============================
   104 
       
   105 // -----------------------------------------------------------------------------
    79 // -----------------------------------------------------------------------------
   106 // CXnTextEditorAdapter::NewL
    80 // CXnTextEditorAdapter::NewL
   107 // Symbian static 1st phase constructor
    81 // Symbian static 1st phase constructor
   108 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
   109 //
    83 //
   136 // C++ destructor
   110 // C++ destructor
   137 // -----------------------------------------------------------------------------
   111 // -----------------------------------------------------------------------------
   138 //
   112 //
   139 CXnTextEditorAdapter::~CXnTextEditorAdapter()
   113 CXnTextEditorAdapter::~CXnTextEditorAdapter()
   140     {  
   114     {  
   141     if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )    
   115     if ( iAppui )
   142         {
   116         {
   143         if( iUiEngine )
   117         iAppui->RemoveFromStack( iEditor );
   144             {
   118         }
   145             iUiEngine->EnablePartialTouchInput( iNode, EFalse );    
   119         
   146             }
   120     if ( iFlags.IsSet( EIsFocused ) )
   147         }
   121         {
   148 
   122         RProperty::Set( KPSUidAiInformation, 
   149     if ( iAvkonAppUi )
   123             KActiveIdleForwardNumericKeysToPhone, 
   150         {
   124             EPSAiForwardNumericKeysToPhone );                    
   151         iAvkonAppUi->RemoveFromStack( iEditor );
       
   152         }
   125         }
   153     
   126     
   154     if( iFont && iReleaseFont )
   127     if( iFont && iReleaseFont )
   155         {
   128         {
   156         CWsScreenDevice* dev( iCoeEnv->ScreenDevice() );
   129         CWsScreenDevice* dev( iCoeEnv->ScreenDevice() );
   157         dev->ReleaseFont( iFont );
   130         dev->ReleaseFont( iFont );
   158         }
   131         }
   159 
   132 
   160     delete iEditorPublisher;
   133     delete iEditor;
   161     delete iEditor;   
   134     
       
   135     delete iEditorPublisher;       
   162     }
   136     }
   163 
   137 
   164 // -----------------------------------------------------------------------------
   138 // -----------------------------------------------------------------------------
   165 // CXnTextEditorAdapter::ConstructL
   139 // CXnTextEditorAdapter::ConstructL
   166 // Symbian 2nd phase constructor can leave.
   140 // Symbian 2nd phase constructor can leave.
   167 // -----------------------------------------------------------------------------
   141 // -----------------------------------------------------------------------------
   168 //
   142 //
   169 void CXnTextEditorAdapter::ConstructL()
   143 void CXnTextEditorAdapter::ConstructL()
   170     {
   144     {
   171     CXnControlAdapter::ConstructL( iNode );    
   145     CXnControlAdapter::ConstructL( iNode );    
       
   146     
   172     iUiEngine = iNode.UiEngineL();
   147     iUiEngine = iNode.UiEngineL();
   173 
   148 
   174     iAppui = static_cast< CXnAppUiAdapter* >( iAvkonAppUi );
   149     iAppui = static_cast< CXnAppUiAdapter* >( iAvkonAppUi );
   175     
   150     
   176     // Max line amount
   151     // Max line amount
   181     if ( maxlinesProp )
   156     if ( maxlinesProp )
   182         {
   157         {
   183         iMaxLines = maxlinesProp->FloatValueL();
   158         iMaxLines = maxlinesProp->FloatValueL();
   184         }
   159         }
   185 
   160 
   186     // Max char amount
   161     // Default char amount
   187     TInt maxChars( KMaxLength );
   162     TInt maxChars( KDefaultLength );
   188     
   163     
   189     CXnProperty* maxcharsProp( iNode.GetPropertyL( KMaxCharAmount ) );    
   164     CXnProperty* maxcharsProp( iNode.GetPropertyL( KMaxCharAmount ) );    
   190     
   165     
   191     if ( maxcharsProp )
   166     if ( maxcharsProp )
   192         {
   167         {
   194         }
   169         }
   195     
   170     
   196     iEditor = new ( ELeave ) CEikEdwin;
   171     iEditor = new ( ELeave ) CEikEdwin;
   197 
   172 
   198     iEditor->SetContainerWindowL( *iParent );
   173     iEditor->SetContainerWindowL( *iParent );
   199     iEditor->ConstructL( 0, maxChars, maxChars, iMaxLines );
   174     
       
   175     TInt flags( CEikEdwin::ENoAutoSelection | CEikEdwin::EJustAutoCurEnd |
       
   176         CEikEdwin::EAllowUndo | CEikEdwin::EAvkonEditor );
       
   177     
       
   178     iEditor->ConstructL( flags, maxChars, maxChars, iMaxLines );
   200     iEditor->SetBackground( this );
   179     iEditor->SetBackground( this );
   201     
   180     
   202     // Set allowed input modes
   181     // Set allowed input modes
   203     iEditor->SetAknEditorAllowedInputModes( EAknEditorAllInputModes );
   182     iEditor->SetAknEditorAllowedInputModes( EAknEditorAllInputModes );
   204 
   183 
   209     // Set allowed case modes
   188     // Set allowed case modes
   210     iEditor->SetAknEditorPermittedCaseModes( EAknEditorAllCaseModes );
   189     iEditor->SetAknEditorPermittedCaseModes( EAknEditorAllCaseModes );
   211 
   190 
   212     // Set the default case mode
   191     // Set the default case mode
   213     iEditor->SetAknEditorCase( EAknEditorTextCase );
   192     iEditor->SetAknEditorCase( EAknEditorTextCase );
   214         
   193                                              
   215     iEditor->AddFlagToUserFlags( 
       
   216         CEikEdwin::ENoAutoSelection | CEikEdwin::EAllowUndo );
       
   217                                      
       
   218     // Set numeric keymap
   194     // Set numeric keymap
   219     iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap );
   195     iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap );
   220 
   196 
   221     // Enable partial Screen
   197     // Enable partial Screen
   222     CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) );
   198     CXnProperty* prop( iNode.GetPropertyL( KEnablePartialInput ) );
   223     iSplitInputFlags = 0;
   199                
   224      
   200     if ( prop && prop->StringValue() == XnPropertyNames::KTrue )          
   225     if ( enablepartialinput && 
       
   226          enablepartialinput->StringValue() == XnPropertyNames::KTrue )
       
   227         {
   201         {
   228         iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen );
   202         iEditor->SetAknEditorFlags( EAknEditorFlagEnablePartialScreen );
   229         SetFlag( iSplitInputFlags, ESplitInputEnabled );
   203                         
   230         }
   204         iFlags.Set( EUsePartialScreenInput );        
   231 
   205         }
   232     // for RTL languages
   206         
   233     iEditor->SetAknEditorLocalLanguage( User::Language() );
   207     iEditor->SetAlignment( AknLayoutUtils::LayoutMirrored() ? 
   234     ( AknLayoutUtils::LayoutMirrored() ? 
   208         EAknEditorAlignRight : EAknEditorAlignLeft ); 
   235                         iEditor->SetAlignment( EAknEditorAlignRight ) : 
   209                                                 
   236                         iEditor->SetAlignment( EAknEditorAlignLeft ) );
   210     iEditor->CreateTextViewL();
   237 
   211     
   238     iEditor->SetObserver( this );
       
   239                                         
       
   240     // Default not focused                                  
       
   241     iEditor->SetFocus( EFalse );                              
       
   242         
       
   243     SetPropertiesL();
   212     SetPropertiesL();
   244 	}
   213 	}
   245  
   214  
   246 // -----------------------------------------------------------------------------
   215 // -----------------------------------------------------------------------------
   247 // CXnTextEditorAdapter::CountComponentControls
   216 // CXnTextEditorAdapter::CountComponentControls
   301     ret = iEditor->OfferKeyEventL( aKeyEvent, aType );                    
   270     ret = iEditor->OfferKeyEventL( aKeyEvent, aType );                    
   302 
   271 
   303     if ( IS_ARROW_KEY( aKeyEvent.iScanCode ) )    
   272     if ( IS_ARROW_KEY( aKeyEvent.iScanCode ) )    
   304         {                        
   273         {                        
   305         if ( ret == EKeyWasNotConsumed && aType == EEventKey )
   274         if ( ret == EKeyWasNotConsumed && aType == EEventKey )
   306             {            
   275             {                  
   307             iRefusesFocusLoss = EFalse;
       
   308             
       
   309             ret = CXnControlAdapter::OfferKeyEventL( aKeyEvent, aType );
   276             ret = CXnControlAdapter::OfferKeyEventL( aKeyEvent, aType );
   310             }                    
   277             }                    
   311         }
   278         }
   312 
   279 
   313     if ( aKeyEvent.iCode == EKeyEnter )
   280     if ( aKeyEvent.iCode == EKeyEnter )
   329             }
   296             }
   330         }
   297         }
   331 
   298 
   332     return ret;        
   299     return ret;        
   333     }
   300     }
   334  
       
   335 // -----------------------------------------------------------------------------
       
   336 // CXnTextEditorAdapter::RefusesFocusLoss
       
   337 // (other items were commented in a header).
       
   338 // -----------------------------------------------------------------------------
       
   339 // 
       
   340 TBool CXnTextEditorAdapter::RefusesFocusLoss() const
       
   341     {    
       
   342     return iRefusesFocusLoss;
       
   343     }
       
   344 
   301 
   345 // -----------------------------------------------------------------------------
   302 // -----------------------------------------------------------------------------
   346 // CXnTextEditorAdapter::FocusChanged
   303 // CXnTextEditorAdapter::FocusChanged
   347 // (other items were commented in a header).
   304 // (other items were commented in a header).
   348 // -----------------------------------------------------------------------------
   305 // -----------------------------------------------------------------------------
   349 // 
   306 // 
   350 void CXnTextEditorAdapter::FocusChanged( TDrawNow aDrawNow )
   307 void CXnTextEditorAdapter::FocusChanged( TDrawNow /*aDrawNow*/ )
   351     {
   308     {
   352     TBool isFocused( IsFocused() ? ETrue : EFalse );
   309     TBool isFocused( IsFocused() ? ETrue : EFalse );
   353     TInt value;
   310     TBool wasFocused( iFlags.IsSet( EIsFocused ) ? ETrue : EFalse );
   354 
   311     
   355     if ( isFocused )
   312     if ( isFocused != wasFocused )
   356         {      
   313         {
   357         value = EPSAiDontForwardNumericKeysToPhone;
   314         TInt value;
   358 
   315         
   359         if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) )
   316         if ( isFocused )
       
   317             {      
       
   318             value = EPSAiDontForwardNumericKeysToPhone;
       
   319             
       
   320             iFlags.Set( EIsFocused );
       
   321             
       
   322             TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) );
       
   323             }
       
   324         else
   360             {
   325             {
   361             TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) );  
   326             value = EPSAiForwardNumericKeysToPhone;
   362             // AddToStackL calls iEditor->SetFocus( ETrue ); 
   327             
   363             }
   328             iFlags.Clear( EIsFocused );
   364         else if( !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   329             
   365             {
       
   366             TRAP_IGNORE( iAppui->AddToStackL( iAppui->View(), iEditor ) ); 
       
   367             SetFlag( iSplitInputFlags, ESplitInputEditorInStack );
       
   368             }
       
   369         }
       
   370     else
       
   371         {
       
   372         value = EPSAiForwardNumericKeysToPhone;
       
   373                                       
       
   374         if( !IsFlagSet( iSplitInputFlags, ESplitInputEnabled ) )
       
   375             {    
       
   376             iAppui->RemoveFromStack( iEditor );            
   330             iAppui->RemoveFromStack( iEditor );            
   377             iEditor->SetFocus( EFalse, aDrawNow );
   331             iEditor->SetFocus( EFalse );                       
   378             }
   332             } 
   379         
   333         
   380         // Remove editor from stack if it has not beed removed AND split screen has been closed
   334         RProperty::Set( KPSUidAiInformation, 
   381         else if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) &&
   335             KActiveIdleForwardNumericKeysToPhone, value );                    
   382                  !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   336         }        
   383             {
       
   384             iAppui->RemoveFromStack( iEditor );            
       
   385             iEditor->SetFocus( EFalse, aDrawNow );
       
   386             ClearFlag( iSplitInputFlags, ESplitInputEditorInStack );            
       
   387             }            
       
   388         }
       
   389 
       
   390     if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
       
   391         {
       
   392         value = EPSAiDontForwardNumericKeysToPhone;
       
   393         } 
       
   394 
       
   395     iRefusesFocusLoss = isFocused;
       
   396     
       
   397     RProperty::Set( KPSUidAiInformation,            
       
   398                     KActiveIdleForwardNumericKeysToPhone,
       
   399                     value );    
       
   400     }
   337     }
   401     
   338     
   402 // -----------------------------------------------------------------------------
   339 // -----------------------------------------------------------------------------
   403 // CXnTextEditorAdapter::Draw
   340 // CXnTextEditorAdapter::Draw
   404 // Draws the editor component
   341 // Draws the editor component
   409     // Do nothing. 
   346     // Do nothing. 
   410     // Background is drawn through MCoeControlBackground of CEikEdwin. 
   347     // Background is drawn through MCoeControlBackground of CEikEdwin. 
   411     }
   348     }
   412 
   349 
   413 // -----------------------------------------------------------------------------
   350 // -----------------------------------------------------------------------------
   414 // CXnTextEditorAdapter::HandleResourceChange
   351 // CXnTextEditorAdapter::HandlePointerEventL
   415 //
   352 //
   416 // -----------------------------------------------------------------------------
   353 // -----------------------------------------------------------------------------
   417 //
   354 //
   418 void CXnTextEditorAdapter::HandleResourceChange( TInt aType )
   355 void CXnTextEditorAdapter::HandlePointerEventL( 
   419     {
   356     const TPointerEvent& aPointerEvent )
   420     if ( aType == KAknSplitInputEnabled ) 
   357     {       
   421         {
   358     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
   422         if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && 
   359         {
   423             !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   360         iFlags.Clear( EIsAlreadyFocused );
       
   361         
       
   362         if ( IsFocused() )
   424             {
   363             {
   425             iUiEngine->EnablePartialTouchInput( iNode, ETrue );
   364             iFlags.Set( EIsAlreadyFocused );
   426             SetFlag( iSplitInputFlags, ESplitInputOpen );
       
   427             if ( !IsFlagSet( iSplitInputFlags, EScreenDeviceChanged ) )
       
   428                 {
       
   429                 TRAP_IGNORE( iNode.ReportTriggerEventL( KSplitScreenEnabledTrigger, 
       
   430                     KNullDesC8, KNullDesC8) );
       
   431                 }
       
   432             else
       
   433                 {
       
   434                 ClearFlag( iSplitInputFlags, EScreenDeviceChanged );
       
   435                 }
       
   436             }
   365             }
   437         }    
   366         }
   438     
   367     
   439      if ( aType == KAknSplitInputDisabled ) 
   368     if ( iFlags.IsSet( EIsAlreadyFocused ) )
   440         {
   369         {
   441         if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )    
   370         CCoeControl::HandlePointerEventL( aPointerEvent );
       
   371         }
       
   372     else
       
   373         {
       
   374         TPointerEvent pointerEvent( aPointerEvent ); 
       
   375         TRect rect( iEditor->TextView()->ViewRect() );
       
   376         TPoint point( aPointerEvent.iPosition );
       
   377         
       
   378         // this opens partial screen also when margin is tapped
       
   379         if ( iFlags.IsSet( EUsePartialScreenInput ) )    
   442             {
   380             {
   443             iUiEngine->EnablePartialTouchInput( iNode, EFalse );
   381             if( point.iX < rect.iTl.iX )
   444             ClearFlag( iSplitInputFlags, ESplitInputOpen );
   382                 {
   445             
   383                 pointerEvent.iPosition.iX = rect.iTl.iX;
   446             // Note that after orientation switch, split screen is first closed and  
   384                 }
   447             // then opened again. Therefore these must be discarded
   385             else if( point.iX > rect.iBr.iX )
   448             if ( !IsFlagSet( iSplitInputFlags, EScreenDeviceChanged ) )
   386                 {
   449                 {
   387                 pointerEvent.iPosition.iX = rect.iBr.iX;
   450                 TRAP_IGNORE( iNode.ReportTriggerEventL( KSplitScreenDisabledTrigger, 
   388                 }
   451                     KNullDesC8, KNullDesC8) );
   389             
   452             
   390             if( point.iY < rect.iTl.iY )
   453                 // If editor is not focused anymore, remove if from stack
   391                 {
   454                 CXnNodePluginIf* focusedNode( NULL );
   392                 pointerEvent.iPosition.iY = rect.iTl.iY;
   455                 TRAP_IGNORE( focusedNode = iUiEngine->FocusedNodeL() );
   393                 }
   456                 if( focusedNode != &iNode && 
   394             else if( point.iY > rect.iBr.iY )
   457                     IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) )
   395                 {
   458                     {
   396                 pointerEvent.iPosition.iY = rect.iBr.iY;
   459                     iAppui->RemoveFromStack( iEditor );
       
   460                     iEditor->SetFocus( EFalse );
       
   461                     ClearFlag( iSplitInputFlags, ESplitInputEditorInStack );
       
   462     
       
   463                     // Forward keys to phone again    
       
   464                     RProperty::Set( KPSUidAiInformation,            
       
   465                                     KActiveIdleForwardNumericKeysToPhone,
       
   466                                     EPSAiForwardNumericKeysToPhone );
       
   467                     }
       
   468                 }
   397                 }
   469             }
   398             }
   470         }
   399         
   471     CCoeControl::HandleResourceChange( aType );
   400         CXnControlAdapter::HandlePointerEventL( pointerEvent );    
   472     }
   401         }         
   473 
       
   474 // -----------------------------------------------------------------------------
       
   475 // CXnTextEditorAdapter::HandlePointerEventL
       
   476 //
       
   477 // -----------------------------------------------------------------------------
       
   478 //
       
   479 void CXnTextEditorAdapter::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   480     {
       
   481     TPointerEvent pointerEvent( aPointerEvent ); 
       
   482     TRect rect( iEditor->TextView()->ViewRect() );
       
   483     TPoint point( aPointerEvent.iPosition );
       
   484     
       
   485     // this opens partial screen also when margin is tapped
       
   486     if( !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
       
   487         {
       
   488         if( point.iX < rect.iTl.iX )
       
   489             {
       
   490             pointerEvent.iPosition.iX = rect.iTl.iX;
       
   491             }
       
   492         else if( point.iX > rect.iBr.iX )
       
   493             {
       
   494             pointerEvent.iPosition.iX = rect.iBr.iX;
       
   495             }
       
   496         
       
   497         if( point.iY < rect.iTl.iY )
       
   498             {
       
   499             pointerEvent.iPosition.iY = rect.iTl.iY;
       
   500             }
       
   501         else if( point.iY > rect.iBr.iY )
       
   502             {
       
   503             pointerEvent.iPosition.iY = rect.iBr.iY;
       
   504             }
       
   505         }
       
   506     
       
   507     CXnControlAdapter::HandlePointerEventL( pointerEvent );
       
   508     }
       
   509 
       
   510 // -----------------------------------------------------------------------------
       
   511 // CXnTextEditorAdapter::HandleScreenDeviceChangedL
       
   512 //
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 void CXnTextEditorAdapter::HandleScreenDeviceChangedL()
       
   516     {
       
   517     if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
       
   518         {
       
   519         SetFlag( iSplitInputFlags, EScreenDeviceChanged );
       
   520         }
       
   521     }
   402     }
   522 
   403 
   523 // -----------------------------------------------------------------------------
   404 // -----------------------------------------------------------------------------
   524 // From MCoeControlBackground
   405 // From MCoeControlBackground
   525 // CXnTextEditorAdapter::Draw
   406 // CXnTextEditorAdapter::Draw
   533         CXnControlAdapter::Draw( aRect, aGc );    
   414         CXnControlAdapter::Draw( aRect, aGc );    
   534         }
   415         }
   535     }
   416     }
   536 
   417 
   537 // -----------------------------------------------------------------------------
   418 // -----------------------------------------------------------------------------
       
   419 // CXnTextEditorAdapter::Editor
       
   420 // Gets underlying CEikEdwin
       
   421 // -----------------------------------------------------------------------------
       
   422 //
       
   423 CEikEdwin* CXnTextEditorAdapter::Editor() const       
       
   424     {
       
   425     return iEditor;
       
   426     }
       
   427 
       
   428 // -----------------------------------------------------------------------------
   538 // CXnTextEditorAdapter::SetTextL
   429 // CXnTextEditorAdapter::SetTextL
   539 // Sets the new content to the underlying CEikEdwin
   430 // Sets the new content to the underlying CEikEdwin
   540 // -----------------------------------------------------------------------------
   431 // -----------------------------------------------------------------------------
   541 //
   432 //
   542 void CXnTextEditorAdapter::SetTextL( const TDesC& aText )
   433 void CXnTextEditorAdapter::SetTextL( const TDesC& aText )
   543     {
   434     {
   544     iEditor->SetTextL( &aText );
   435     HBufC* text( Text() );
   545     iNode.SetDirtyL();
   436     
       
   437     TBool update( EFalse );
       
   438     
       
   439     if ( !text || *text != aText )
       
   440         {
       
   441         update = ETrue;
       
   442         }
       
   443     
       
   444     delete text;
       
   445     text = NULL;
       
   446     
       
   447     if ( update )
       
   448         {
       
   449         iFlags.Set( ESetText );
       
   450         
       
   451         TRAP_IGNORE( iEditor->SetTextL( &aText ) );
       
   452         
       
   453         iFlags.Clear( ESetText );
       
   454         
       
   455         iNode.SetDirtyL();        
       
   456         }
       
   457     }
       
   458 
       
   459 // -----------------------------------------------------------------------------
       
   460 // CXnTextEditorAdapter::IsSetText
       
   461 // Queries whether SetText API has generated edwin content change
       
   462 // -----------------------------------------------------------------------------
       
   463 //
       
   464 TBool CXnTextEditorAdapter::IsSetText() const
       
   465     {
       
   466     return iFlags.IsSet( ESetText ) ? ETrue : EFalse;
   546     }
   467     }
   547     
   468     
   548 // -----------------------------------------------------------------------------
   469 // -----------------------------------------------------------------------------
   549 // CXnTextEditorAdapter::Text
   470 // CXnTextEditorAdapter::Text
   550 // Returns the text contained in the underlying CEikEdwin
   471 // Returns the text contained in the underlying CEikEdwin
   556     
   477     
   557     TRAP_IGNORE( text = iEditor->GetTextInHBufL() );
   478     TRAP_IGNORE( text = iEditor->GetTextInHBufL() );
   558     
   479     
   559     // Ownership is transfered to the calller
   480     // Ownership is transfered to the calller
   560     return text;
   481     return text;
   561     }
       
   562 
       
   563 // -----------------------------------------------------------------------------
       
   564 // CXnTextEditorAdapter::HandleEditorEvent
       
   565 // -----------------------------------------------------------------------------
       
   566 //
       
   567 void CXnTextEditorAdapter::HandleEditorEvent( TInt aReason )
       
   568     {
       
   569     if( aReason == CXnTextEditor::KDeactivateTextEditor &&
       
   570         IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
       
   571         {
       
   572         iAppui->RemoveFromStack( iEditor );
       
   573         iEditor->SetFocus( EFalse );
       
   574         ClearFlag( iSplitInputFlags, ESplitInputEditorInStack ); 
       
   575         iRefusesFocusLoss = EFalse;
       
   576         }
       
   577     }
   482     }
   578 
   483 
   579 // -----------------------------------------------------------------------------
   484 // -----------------------------------------------------------------------------
   580 // CXnTextEditorAdapter::SetPropertiesL
   485 // CXnTextEditorAdapter::SetPropertiesL
   581 // Sets text properties
   486 // Sets text properties