idlehomescreen/xmluirendering/renderingplugins/xntexteditorfactory/src/xntexteditoradapter.cpp
branchRCL_3
changeset 26 1b758917cafc
parent 23 7be2816dbabd
child 28 d721605b30d0
equal deleted inserted replaced
25:137ebc85284b 26:1b758917cafc
    55 enum TSplitInputState
    55 enum TSplitInputState
    56     {
    56     {
    57     ESplitInputEnabled = 1,   
    57     ESplitInputEnabled = 1,   
    58     ESplitInputOpen = 2,
    58     ESplitInputOpen = 2,
    59     ESplitInputEditorInStack = 4,
    59     ESplitInputEditorInStack = 4,
       
    60     EScreenDeviceChanged = 8
    60     };
    61     };
    61 
    62 
    62 _LIT8( KCpsPublishing, "cpspublishing" );
    63 _LIT8( KCpsPublishing, "cpspublishing" );
    63 _LIT8( KMaxLineAmount, "max-line-amount" );
    64 _LIT8( KMaxLineAmount, "max-line-amount" );
    64 _LIT8( KMaxCharAmount, "max-char-amount" );
    65 _LIT8( KMaxCharAmount, "max-char-amount" );
    65 _LIT8( KEnablePartialInput, "splitinputenabled" );
    66 _LIT8( KEnablePartialInput, "splitinputenabled" );
       
    67 _LIT8( KSplitScreenEnabledTrigger , "splitscreenenabled" );
       
    68 _LIT8( KSplitScreenDisabledTrigger, "splitscreendisabled" );
    66 
    69 
    67 _LIT( KEnterChar, "\x2029" );
    70 _LIT( KEnterChar, "\x2029" );
    68 
    71 
    69 // Local macros
    72 // Local macros
    70 #define IS_ARROW_KEY( k ) \
    73 #define IS_ARROW_KEY( k ) \
   192     
   195     
   193     iEditor = new ( ELeave ) CEikEdwin;
   196     iEditor = new ( ELeave ) CEikEdwin;
   194 
   197 
   195     iEditor->SetContainerWindowL( *iParent );
   198     iEditor->SetContainerWindowL( *iParent );
   196     iEditor->ConstructL( 0, maxChars, maxChars, iMaxLines );
   199     iEditor->ConstructL( 0, maxChars, maxChars, iMaxLines );
       
   200     iEditor->SetBackground( this );
   197     
   201     
   198     // Set allowed input modes
   202     // Set allowed input modes
   199     iEditor->SetAknEditorAllowedInputModes( EAknEditorAllInputModes );
   203     iEditor->SetAknEditorAllowedInputModes( EAknEditorAllInputModes );
   200 
   204 
   201     // Set the default input mode
   205     // Set the default input mode
   211     iEditor->AddFlagToUserFlags( 
   215     iEditor->AddFlagToUserFlags( 
   212         CEikEdwin::ENoAutoSelection | CEikEdwin::EAllowUndo );
   216         CEikEdwin::ENoAutoSelection | CEikEdwin::EAllowUndo );
   213                                      
   217                                      
   214     // Set numeric keymap
   218     // Set numeric keymap
   215     iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap );
   219     iEditor->SetAknEditorNumericKeymap( EAknEditorPlainNumberModeKeymap );
   216     
       
   217     iEditor->SetSuppressBackgroundDrawing( ETrue );
       
   218 
   220 
   219     // Enable partial Screen
   221     // Enable partial Screen
   220     CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) );
   222     CXnProperty* enablepartialinput( iNode.GetPropertyL( KEnablePartialInput ) );
   221     iSplitInputFlags = 0;
   223     iSplitInputFlags = 0;
   222      
   224      
   400 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   401 // CXnTextEditorAdapter::Draw
   403 // CXnTextEditorAdapter::Draw
   402 // Draws the editor component
   404 // Draws the editor component
   403 // -----------------------------------------------------------------------------
   405 // -----------------------------------------------------------------------------
   404 //
   406 //
   405 void CXnTextEditorAdapter::Draw( const TRect& aRect ) const
   407 void CXnTextEditorAdapter::Draw( const TRect& /*aRect*/ ) const
   406     {                           
   408     { 
   407     CXnControlAdapter::Draw( aRect );
   409     // Do nothing. 
       
   410     // Background is drawn through MCoeControlBackground of CEikEdwin. 
   408     }
   411     }
   409 
   412 
   410 // -----------------------------------------------------------------------------
   413 // -----------------------------------------------------------------------------
   411 // CXnTextEditorAdapter::HandleResourceChange
   414 // CXnTextEditorAdapter::HandleResourceChange
   412 //
   415 //
   419         if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && 
   422         if( IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) && 
   420             !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   423             !IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   421             {
   424             {
   422             iUiEngine->EnablePartialTouchInput( iNode, ETrue );
   425             iUiEngine->EnablePartialTouchInput( iNode, ETrue );
   423             SetFlag( iSplitInputFlags, ESplitInputOpen );
   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                 }
   424             }
   436             }
   425         }    
   437         }    
   426     
   438     
   427      if ( aType == KAknSplitInputDisabled ) 
   439      if ( aType == KAknSplitInputDisabled ) 
   428         {
   440         {
   429         if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )    
   441         if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )    
   430             {
   442             {
   431             iUiEngine->EnablePartialTouchInput( iNode, EFalse );
   443             iUiEngine->EnablePartialTouchInput( iNode, EFalse );
   432             ClearFlag( iSplitInputFlags, ESplitInputOpen );
   444             ClearFlag( iSplitInputFlags, ESplitInputOpen );
   433             
   445             
   434             // If editor is not focused anymore, remove if from stack
   446             // Note that after orientation switch, split screen is first closed and  
   435             CXnNodePluginIf* focusedNode( NULL );
   447             // then opened again. Therefore these must be discarded
   436             TRAP_IGNORE( focusedNode = iUiEngine->FocusedNodeL() );
   448             if ( !IsFlagSet( iSplitInputFlags, EScreenDeviceChanged ) )
   437             if( focusedNode != &iNode && 
       
   438                 IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) )
       
   439                 {
   449                 {
   440                 iAppui->RemoveFromStack( iEditor );
   450                 TRAP_IGNORE( iNode.ReportTriggerEventL( KSplitScreenDisabledTrigger, 
   441                 iEditor->SetFocus( EFalse );
   451                     KNullDesC8, KNullDesC8) );
   442                 ClearFlag( iSplitInputFlags, ESplitInputEditorInStack );
   452             
   443 
   453                 // If editor is not focused anymore, remove if from stack
   444                 // Forward keys to phone again    
   454                 CXnNodePluginIf* focusedNode( NULL );
   445                 RProperty::Set( KPSUidAiInformation,            
   455                 TRAP_IGNORE( focusedNode = iUiEngine->FocusedNodeL() );
   446                                 KActiveIdleForwardNumericKeysToPhone,
   456                 if( focusedNode != &iNode && 
   447                                 EPSAiForwardNumericKeysToPhone );
   457                     IsFlagSet( iSplitInputFlags, ESplitInputEditorInStack ) )
       
   458                     {
       
   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                     }
   448                 }
   468                 }
   449             }
   469             }
   450         }
   470         }
   451     CCoeControl::HandleResourceChange( aType );
   471     CCoeControl::HandleResourceChange( aType );
   452     }
   472     }
   453     
   473 
   454 // -----------------------------------------------------------------------------
   474 // -----------------------------------------------------------------------------
   455 // CXnTextEditorAdapter::HandleControlEventL
   475 // CXnTextEditorAdapter::HandleScreenDeviceChangedL
   456 // 
   476 //
   457 // -----------------------------------------------------------------------------
   477 // -----------------------------------------------------------------------------
   458 //    
   478 //
   459 void CXnTextEditorAdapter::HandleControlEventL( CCoeControl* aControl, 
   479 void CXnTextEditorAdapter::HandleScreenDeviceChangedL()
   460     TCoeEvent aEventType )
   480     {
   461     {
   481     if( IsFlagSet( iSplitInputFlags, ESplitInputOpen ) )
   462     if ( aControl == iEditor )
   482         {
   463         {
   483         SetFlag( iSplitInputFlags, EScreenDeviceChanged );
   464         // If background drawing is suppressed, then we need to call draw here
   484         }
   465         if ( aEventType == EEventStateChanged )
   485     }
   466             {
   486 
   467             DrawNow();                                    
   487 // -----------------------------------------------------------------------------
   468             }        
   488 // From MCoeControlBackground
       
   489 // CXnTextEditorAdapter::Draw
       
   490 // -----------------------------------------------------------------------------
       
   491 //
       
   492 void CXnTextEditorAdapter::Draw( CWindowGc& aGc, const CCoeControl& aControl, 
       
   493     const TRect& aRect) const
       
   494     {
       
   495     if( &aControl == iEditor )
       
   496         {
       
   497         CXnControlAdapter::Draw( aRect, aGc );    
   469         }
   498         }
   470     }
   499     }
   471 
   500 
   472 // -----------------------------------------------------------------------------
   501 // -----------------------------------------------------------------------------
   473 // CXnTextEditorAdapter::SetTextL
   502 // CXnTextEditorAdapter::SetTextL