idlehomescreen/xmluirendering/uiengine/src/xnnodeimpl.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 15 ff572dfe6d86
child 19 5c691ca535f0
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    49 #include "xnpanic.h"
    49 #include "xnpanic.h"
    50 #include "xnlistquerydialogadapter.h"
    50 #include "xnlistquerydialogadapter.h"
    51 #include "xneffectmanager.h"
    51 #include "xneffectmanager.h"
    52 #include "xnviewadapter.h"
    52 #include "xnviewadapter.h"
    53 #include "xnbackgroundmanager.h"
    53 #include "xnbackgroundmanager.h"
       
    54 #include "xntexteditor.h"
    54 
    55 
    55 // Local constants
    56 // Local constants
    56 _LIT8( KRef, "ref" );
    57 _LIT8( KRef, "ref" );
    57 _LIT8( KId, "id" );
    58 _LIT8( KId, "id" );
    58 _LIT8( KName, "name" );
    59 _LIT8( KName, "name" );
    59 _LIT8( KToolTip, "tooltip" );
    60 _LIT8( KToolTip, "tooltip" );
    60 _LIT8( KMenuBar, "menubar" );
    61 _LIT8( KMenuBar, "menubar" );
       
    62 _LIT8( KTextEditor, "texteditor" );
    61 
    63 
    62 _LIT8( KActionsHandler, "actionshandler" );
    64 _LIT8( KActionsHandler, "actionshandler" );
    63 
    65 
    64 const TReal KS60ScrollbarDefaultWidth = 1.5;
    66 const TReal KS60ScrollbarDefaultWidth = 1.5;
    65 const TReal KS60ScrollbarDefaultMargin = 0.25;
    67 const TReal KS60ScrollbarDefaultMargin = 0.25;
   295 static void RunAppExit( CXnUiEngine& aEngine );
   297 static void RunAppExit( CXnUiEngine& aEngine );
   296 static void RunFullScreenEffectL(
   298 static void RunFullScreenEffectL(
   297     CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   299     CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   298 static void RunActivateViewL(
   300 static void RunActivateViewL(
   299     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   301     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   300 static void RunActivateNextViewL( CXnUiEngine& aEngine );
   302 static void RunActivateNextViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   301 static void RunActivatePreviousViewL( CXnUiEngine& aEngine );
   303 static void RunActivatePreviousViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   302 static void RunAddViewL( CXnUiEngine& aEngine );
   304 static void RunAddViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   303 static void RunRemoveViewL( CXnUiEngine& aEngine );
   305 static void RunRemoveViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   304 static void RunActivateL(
   306 static void RunActivateL(
   305     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   307     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
       
   308 static void RunActivateEditorL( CXnNodeImpl* aThis, CXnNode& aLayoutNode,
       
   309     CXnUiEngine& aEngine, CXnDomNode& aEventNode, TBool aActivate );
   306 static void RunDeactivateL(
   310 static void RunDeactivateL(
   307     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   311     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
   308 static void RunSystemSetPCDataL(
   312 static void RunSystemSetPCDataL(
   309     CXnNodeImpl* aThis, CXnUiEngine& aEngine, const TDesC8& aId,
   313     CXnNodeImpl* aThis, CXnUiEngine& aEngine, const TDesC8& aId,
   310     const TDesC8& aData );
   314     const TDesC8& aData );
   459     CXnNode& aEventData, CXnDomNode& aTriggerNode );
   463     CXnNode& aEventData, CXnDomNode& aTriggerNode );
   460 
   464 
   461 // ============================= LOCAL FUNCTIONS ===============================
   465 // ============================= LOCAL FUNCTIONS ===============================
   462 
   466 
   463 // -----------------------------------------------------------------------------
   467 // -----------------------------------------------------------------------------
       
   468 // ResolveEffectId
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 static TInt ResolveEffectId( CXnDomNode& aEventNode )
       
   472     {
       
   473     TInt effect( 0 );
       
   474     const TDesC8& value( aEventNode.AttributeValue( 
       
   475         XnPropertyNames::common::KEffectId ) );
       
   476     if( value != KNullDesC8 )
       
   477         {
       
   478         TLex8 lex( value );
       
   479         lex.Val( effect );    
       
   480         }
       
   481     return effect;
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
   464 // Checks whether trigger is runnable
   485 // Checks whether trigger is runnable
   465 // -----------------------------------------------------------------------------
   486 // -----------------------------------------------------------------------------
   466 //
   487 //
   467 TBool IsTriggerRunnableL( CXnDomNode& aTriggerNode )
   488 TBool IsTriggerRunnableL( CXnDomNode& aTriggerNode )
   468     {
   489     {
  3102                         aEngine.RemovePassiveFocusedNodeL( node );
  3123                         aEngine.RemovePassiveFocusedNodeL( node );
  3103                         }
  3124                         }
  3104                     else if ( aString == XnPropertyNames::action::event::KSetActiveFocus )
  3125                     else if ( aString == XnPropertyNames::action::event::KSetActiveFocus )
  3105                         {
  3126                         {
  3106                         CXnNode* previousNode = aEngine.FocusedNode();
  3127                         CXnNode* previousNode = aEngine.FocusedNode();
  3107                         if ( previousNode != node )
  3128                         if ( previousNode && previousNode != node )
  3108                             {
  3129                             {
  3109                             if ( IsNodeNavigableL( *node ) )
  3130                             if ( IsNodeNavigableL( *node ) )
  3110                                 {
  3131                                 {
  3111                                 node->SetStateL( XnPropertyNames::style::common::KFocus );
  3132                                 node->SetStateL( XnPropertyNames::style::common::KFocus );
  3112                                 aEngine.AddPassiveFocusedNodeL( previousNode );
  3133                                 aEngine.AddPassiveFocusedNodeL( previousNode );
  3152 // RunFullScreenEffectL
  3173 // RunFullScreenEffectL
  3153 // -----------------------------------------------------------------------------
  3174 // -----------------------------------------------------------------------------
  3154 //
  3175 //
  3155 static void RunFullScreenEffectL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3176 static void RunFullScreenEffectL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3156     {
  3177     {
  3157     CXnDomList& list( aEventNode.AttributeList() );
  3178     TInt effectId = ResolveEffectId( aEventNode ); 
  3158     const TDesC8& effectid( XnPropertyNames::common::KEffectId );
  3179     if( effectId )
  3159     CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
  3180         {
  3160         ( list.FindByName( effectid ) ) );
       
  3161 
       
  3162     if ( attribute )
       
  3163         {
       
  3164         
       
  3165         const TDesC8& value( attribute->Value() );
       
  3166         TLex8 lex( value );
       
  3167         TInt effect;
       
  3168         lex.Val( effect );
       
  3169         
       
  3170         aEngine.AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
  3181         aEngine.AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
  3171                 effect, aEngine.ViewManager()->ActiveViewData() );
  3182             effectId, aEngine.ViewManager()->ActiveViewData() );        
  3172         
       
  3173         }
  3183         }
  3174     }
  3184     }
  3175 
  3185 
  3176 // -----------------------------------------------------------------------------
  3186 // -----------------------------------------------------------------------------
  3177 // RunActivateViewL
  3187 // RunActivateViewL
  3208 
  3218 
  3209 // -----------------------------------------------------------------------------
  3219 // -----------------------------------------------------------------------------
  3210 // RunActivateNextViewL
  3220 // RunActivateNextViewL
  3211 // -----------------------------------------------------------------------------
  3221 // -----------------------------------------------------------------------------
  3212 //
  3222 //
  3213 static void RunActivateNextViewL( CXnUiEngine& aEngine )
  3223 static void RunActivateNextViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3214     {
  3224     {
  3215     aEngine.ViewManager()->ActivateNextViewL();
  3225     TInt effectid = ResolveEffectId( aEventNode );
       
  3226     aEngine.ViewManager()->ActivateNextViewL( effectid );
  3216     }
  3227     }
  3217 
  3228 
  3218 // -----------------------------------------------------------------------------
  3229 // -----------------------------------------------------------------------------
  3219 // RunActivatePreviousViewL
  3230 // RunActivatePreviousViewL
  3220 // -----------------------------------------------------------------------------
  3231 // -----------------------------------------------------------------------------
  3221 //
  3232 //
  3222 static void RunActivatePreviousViewL( CXnUiEngine& aEngine )
  3233 static void RunActivatePreviousViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3223     {
  3234     {
  3224     aEngine.ViewManager()->ActivatePreviousViewL();
  3235     TInt effectid = ResolveEffectId( aEventNode );
       
  3236     aEngine.ViewManager()->ActivatePreviousViewL( effectid );
  3225     }
  3237     }
  3226 
  3238 
  3227 // -----------------------------------------------------------------------------
  3239 // -----------------------------------------------------------------------------
  3228 // RunAddViewL
  3240 // RunAddViewL
  3229 // -----------------------------------------------------------------------------
  3241 // -----------------------------------------------------------------------------
  3230 //
  3242 //
  3231 static void RunAddViewL( CXnUiEngine& aEngine )
  3243 static void RunAddViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3232     {
  3244     {
  3233     aEngine.ViewManager()->AddViewL();
  3245     TInt effectid = ResolveEffectId( aEventNode );
       
  3246     aEngine.ViewManager()->AddViewL( effectid );
  3234     }
  3247     }
  3235 
  3248 
  3236 // -----------------------------------------------------------------------------
  3249 // -----------------------------------------------------------------------------
  3237 // RunRemoveViewL
  3250 // RunRemoveViewL
  3238 // -----------------------------------------------------------------------------
  3251 // -----------------------------------------------------------------------------
  3239 //
  3252 //
  3240 static void RunRemoveViewL( CXnUiEngine& aEngine )
  3253 static void RunRemoveViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
  3241     {
  3254     {
  3242     aEngine.ViewManager()->RemoveViewL();
  3255     TInt effectid = ResolveEffectId( aEventNode );
       
  3256     aEngine.ViewManager()->RemoveViewL( effectid );
  3243     }
  3257     }
  3244 
  3258 
  3245 // -----------------------------------------------------------------------------
  3259 // -----------------------------------------------------------------------------
  3246 // RunActivateL
  3260 // RunActivateL
  3247 // -----------------------------------------------------------------------------
  3261 // -----------------------------------------------------------------------------
  3272     CXnNode* focused( aEngine.FocusedNode() );
  3286     CXnNode* focused( aEngine.FocusedNode() );
  3273 
  3287 
  3274     if ( focused )
  3288     if ( focused )
  3275         {
  3289         {
  3276         focused->SetStateL( XnPropertyNames::style::common::KActive );
  3290         focused->SetStateL( XnPropertyNames::style::common::KActive );
       
  3291         }
       
  3292     }
       
  3293 
       
  3294 // -----------------------------------------------------------------------------
       
  3295 // RunActivateEditorL
       
  3296 // -----------------------------------------------------------------------------
       
  3297 //
       
  3298 static void RunActivateEditorL(
       
  3299     CXnNodeImpl* aThis,
       
  3300     CXnNode& aLayoutNode,
       
  3301     CXnUiEngine& aEngine,
       
  3302     CXnDomNode& aEventNode,
       
  3303     TBool aActivate )
       
  3304     {
       
  3305     CXnNode* editorNode( NULL );
       
  3306     CXnDomList& children = aEventNode.ChildNodes();
       
  3307     TInt count = children.Length();
       
  3308     for ( TInt i = 0; i < count; ++i )
       
  3309         {
       
  3310         CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
       
  3311         const TDesC8& type = dnode->Name();
       
  3312         if ( type == XnPropertyNames::action::KProperty )
       
  3313             {
       
  3314             const TDesC8& id = dnode->AttributeValue( KId );
       
  3315             CXnNode* node = aEngine.FindNodeByIdL( id, aThis->Namespace() );
       
  3316             if( node && node->Type()->Type() == KTextEditor )
       
  3317                 {
       
  3318                 editorNode = node;
       
  3319                 break;
       
  3320                 }
       
  3321             }
       
  3322         }
       
  3323 
       
  3324     if( !editorNode && aLayoutNode.Type()->Type() == KTextEditor )
       
  3325         {
       
  3326         editorNode = &aLayoutNode;
       
  3327         }
       
  3328     
       
  3329     if( editorNode )
       
  3330         {
       
  3331         XnTextEditorInterface::MXnTextEditorInterface* editorControl = NULL;
       
  3332         
       
  3333         XnComponentInterface::MakeInterfaceL( editorControl, editorNode->AppIfL() );
       
  3334         if( editorControl )
       
  3335             {
       
  3336             if( aActivate )
       
  3337                 {
       
  3338                 editorControl->HandleEditorEvent(CXnTextEditor::KActivateTextEditor);
       
  3339                 }
       
  3340             else
       
  3341                 {
       
  3342                 editorControl->HandleEditorEvent(CXnTextEditor::KDeactivateTextEditor);
       
  3343                 }
       
  3344             }    
  3277         }
  3345         }
  3278     }
  3346     }
  3279 
  3347 
  3280 // -----------------------------------------------------------------------------
  3348 // -----------------------------------------------------------------------------
  3281 // RunEditL
  3349 // RunEditL
  3410                     XnPropertyNames::style::common::visibility::KVisible );                    
  3478                     XnPropertyNames::style::common::visibility::KVisible );                    
  3411                 }                                              
  3479                 }                                              
  3412             }
  3480             }
  3413         
  3481         
  3414         aEngine.EditMode()->SetEditModeL( CXnEditMode::EDragAndDrop );        
  3482         aEngine.EditMode()->SetEditModeL( CXnEditMode::EDragAndDrop );        
       
  3483         aEngine.AppUiAdapter().ViewAdapter().BgManager().DrawNow();
  3415         }
  3484         }
  3416 
  3485 
  3417     CleanupStack::PopAndDestroy();
  3486     CleanupStack::PopAndDestroy();
  3418     
  3487     
  3419     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
  3488     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
  3519                     XnPropertyNames::style::common::visibility::KBlank );                    
  3588                     XnPropertyNames::style::common::visibility::KBlank );                    
  3520                 }
  3589                 }
  3521             }                
  3590             }                
  3522         }
  3591         }
  3523     
  3592     
  3524     aEngine.EditMode()->SetEditModeL( CXnEditMode::ENone );    
  3593     aEngine.EditMode()->SetEditModeL( CXnEditMode::ENone );   
       
  3594     aEngine.AppUiAdapter().ViewAdapter().BgManager().DrawNow();
  3525 
  3595 
  3526     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
  3596     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
  3527     }
  3597     }
  3528 
  3598 
  3529 // -----------------------------------------------------------------------------
  3599 // -----------------------------------------------------------------------------
  3869                 }
  3939                 }
  3870             else if ( name == XnPropertyNames::action::event::systemset::KClass )
  3940             else if ( name == XnPropertyNames::action::event::systemset::KClass )
  3871                 {
  3941                 {
  3872                 *aClassId = &value;
  3942                 *aClassId = &value;
  3873                 }
  3943                 }
       
  3944             else
       
  3945                 {
       
  3946                 // Everyting is within the same property tag
       
  3947                 // e.g. <property name="display" value="block" type="string" id="my_id"/>
       
  3948 
       
  3949                 // Save name...
       
  3950                 *aName = &name;
       
  3951 
       
  3952                 // ...and value
       
  3953                 if ( aValues )
       
  3954                     {
       
  3955                     HBufC8* valueH = HBufC8::NewLC( value.Length() + KUnitMaxLen );
       
  3956                     TPtr8 ptr( valueH->Des() );
       
  3957                     ptr.Append( value );
       
  3958                     aValues->AppendL( valueH );     //take ownership
       
  3959                     CleanupStack::Pop( valueH );
       
  3960                     }
       
  3961                 
       
  3962                 // ...and type
       
  3963                 const TDesC8& type = node->AttributeValue(
       
  3964                     XnPropertyNames::action::event::systemset::KType );
       
  3965                 *aType = &type;
       
  3966 
       
  3967                 // ...and id
       
  3968                 const TDesC8& id = node->AttributeValue(
       
  3969                     XnPropertyNames::action::event::systemset::KId );
       
  3970                 HBufC8* utfName = HBufC8::NewL( id.Length() );
       
  3971                 TPtr8 ptr = utfName->Des();
       
  3972                 ptr = id;
       
  3973                 aId = utfName;
       
  3974                 }
  3874             }
  3975             }
  3875         }
  3976         }
  3876     }
  3977     }
  3877 
  3978 
  3878 // -----------------------------------------------------------------------------
  3979 // -----------------------------------------------------------------------------
  4320         }
  4421         }
  4321     else if ( nameString == XnPropertyNames::action::event::KRemoveFocusedWidget )
  4422     else if ( nameString == XnPropertyNames::action::event::KRemoveFocusedWidget )
  4322         {
  4423         {
  4323         aEngine.Editor()->RemoveWidgetL( aEngine.FocusedNode() );               
  4424         aEngine.Editor()->RemoveWidgetL( aEngine.FocusedNode() );               
  4324         }
  4425         }
  4325     else if ( nameString == XnPropertyNames::action::event::KRunFullScreenEffect )
       
  4326         {
       
  4327         TInt viewCount( aEngine.ViewManager()->ViewAmount() );
       
  4328 
       
  4329         if ( viewCount > KOneView )
       
  4330             {
       
  4331             RunFullScreenEffectL( aEngine, aEventNode );
       
  4332             }
       
  4333         }
       
  4334     else if ( nameString == XnPropertyNames::action::event::KActivateNextView )
  4426     else if ( nameString == XnPropertyNames::action::event::KActivateNextView )
  4335         {
  4427         {
  4336         RunActivateNextViewL( aEngine );
  4428         RunActivateNextViewL( aEngine, aEventNode );
  4337         }
  4429         }
  4338     else if ( nameString == XnPropertyNames::action::event::KActivatePreviousView )
  4430     else if ( nameString == XnPropertyNames::action::event::KActivatePreviousView )
  4339         {
  4431         {
  4340         RunActivatePreviousViewL( aEngine );
  4432         RunActivatePreviousViewL( aEngine, aEventNode );
  4341         }
  4433         }
  4342     else if ( nameString == XnPropertyNames::action::event::KAddView )
  4434     else if ( nameString == XnPropertyNames::action::event::KAddView )
  4343         {
  4435         {
  4344         RunAddViewL( aEngine );
  4436         RunAddViewL( aEngine, aEventNode );
  4345         }
  4437         }
  4346     else if ( nameString == XnPropertyNames::action::event::KRemoveView )
  4438     else if ( nameString == XnPropertyNames::action::event::KRemoveView )
  4347         {
  4439         {
  4348         RunRemoveViewL( aEngine );
  4440         RunRemoveViewL( aEngine, aEventNode );
  4349         }
  4441         }
  4350     else if ( nameString == XnPropertyNames::action::event::KActivateView )
  4442     else if ( nameString == XnPropertyNames::action::event::KActivateView )
  4351         {
  4443         {
  4352         RunActivateViewL( aThis, aEngine, aEventNode );
  4444         RunActivateViewL( aThis, aEngine, aEventNode );
  4353         }
  4445         }
  4406         return ETrue;
  4498         return ETrue;
  4407         }
  4499         }
  4408     else if ( nameString == XnPropertyNames::action::event::KReportEnterEditMode ) 
  4500     else if ( nameString == XnPropertyNames::action::event::KReportEnterEditMode ) 
  4409             
  4501             
  4410         {
  4502         {
       
  4503         RunFullScreenEffectL( aEngine, aEventNode );
       
  4504         
  4411         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
  4505         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
  4412             XnPropertyNames::action::trigger::name::KEditMode ) );
  4506             XnPropertyNames::action::trigger::name::KEditMode ) );
  4413         CleanupStack::PushL( trigger );
  4507         CleanupStack::PushL( trigger );
  4414 
  4508 
  4415         CXnDomStringPool* sp( aEngine.ODT()->DomDocument().StringPool() );
  4509         CXnDomStringPool* sp( aEngine.ODT()->DomDocument().StringPool() );
  4429 
  4523 
  4430         return ETrue;
  4524         return ETrue;
  4431         }
  4525         }
  4432     else if( nameString == XnPropertyNames::action::event::KReportExitEditMode )
  4526     else if( nameString == XnPropertyNames::action::event::KReportExitEditMode )
  4433         {
  4527         {
       
  4528         RunFullScreenEffectL( aEngine, aEventNode );
       
  4529 
  4434         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
  4530         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
  4435             XnPropertyNames::action::trigger::name::KEditMode ) );
  4531             XnPropertyNames::action::trigger::name::KEditMode ) );
  4436         CleanupStack::PushL( trigger );
  4532         CleanupStack::PushL( trigger );
  4437         
  4533         
  4438         CXnDomStringPool* sp( aEngine.ODT()->DomDocument().StringPool() );
  4534         CXnDomStringPool* sp( aEngine.ODT()->DomDocument().StringPool() );
  4478     else if ( nameString == XnPropertyNames::action::event::KSetWallpaper )
  4574     else if ( nameString == XnPropertyNames::action::event::KSetWallpaper )
  4479         {
  4575         {
  4480         aEngine.AppUiAdapter().ViewAdapter().BgManager().SetWallpaperL();
  4576         aEngine.AppUiAdapter().ViewAdapter().BgManager().SetWallpaperL();
  4481         return ETrue;
  4577         return ETrue;
  4482         }
  4578         }
  4483            
  4579     else if ( nameString == XnPropertyNames::action::event::KActivateTextEditor)
       
  4580         {
       
  4581         RunActivateEditorL( aThis, aNode, aEngine, aEventNode, ETrue );
       
  4582         return ETrue;
       
  4583         }
       
  4584     else if ( nameString == XnPropertyNames::action::event::KDeactivateTextEditor)
       
  4585         {
       
  4586         RunActivateEditorL( aThis, aNode, aEngine, aEventNode, EFalse );
       
  4587         return ETrue;
       
  4588         }    
  4484     return EFalse;
  4589     return EFalse;
  4485     }
  4590     }
  4486 
  4591 
  4487 // -----------------------------------------------------------------------------
  4592 // -----------------------------------------------------------------------------
  4488 // RunEventsL
  4593 // RunEventsL