idlehomescreen/xmluirendering/uiengine/src/xnnodeimpl.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 15 ff572dfe6d86
child 19 5c691ca535f0
--- a/idlehomescreen/xmluirendering/uiengine/src/xnnodeimpl.cpp	Tue Feb 02 00:04:13 2010 +0200
+++ b/idlehomescreen/xmluirendering/uiengine/src/xnnodeimpl.cpp	Fri Feb 19 22:42:37 2010 +0200
@@ -51,6 +51,7 @@
 #include "xneffectmanager.h"
 #include "xnviewadapter.h"
 #include "xnbackgroundmanager.h"
+#include "xntexteditor.h"
 
 // Local constants
 _LIT8( KRef, "ref" );
@@ -58,6 +59,7 @@
 _LIT8( KName, "name" );
 _LIT8( KToolTip, "tooltip" );
 _LIT8( KMenuBar, "menubar" );
+_LIT8( KTextEditor, "texteditor" );
 
 _LIT8( KActionsHandler, "actionshandler" );
 
@@ -297,12 +299,14 @@
     CXnUiEngine& aEngine, CXnDomNode& aEventNode );
 static void RunActivateViewL(
     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
-static void RunActivateNextViewL( CXnUiEngine& aEngine );
-static void RunActivatePreviousViewL( CXnUiEngine& aEngine );
-static void RunAddViewL( CXnUiEngine& aEngine );
-static void RunRemoveViewL( CXnUiEngine& aEngine );
+static void RunActivateNextViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
+static void RunActivatePreviousViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
+static void RunAddViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
+static void RunRemoveViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode );
 static void RunActivateL(
     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
+static void RunActivateEditorL( CXnNodeImpl* aThis, CXnNode& aLayoutNode,
+    CXnUiEngine& aEngine, CXnDomNode& aEventNode, TBool aActivate );
 static void RunDeactivateL(
     CXnNodeImpl* aThis, CXnUiEngine& aEngine, CXnDomNode& aEventNode );
 static void RunSystemSetPCDataL(
@@ -461,6 +465,23 @@
 // ============================= LOCAL FUNCTIONS ===============================
 
 // -----------------------------------------------------------------------------
+// ResolveEffectId
+// -----------------------------------------------------------------------------
+//
+static TInt ResolveEffectId( CXnDomNode& aEventNode )
+    {
+    TInt effect( 0 );
+    const TDesC8& value( aEventNode.AttributeValue( 
+        XnPropertyNames::common::KEffectId ) );
+    if( value != KNullDesC8 )
+        {
+        TLex8 lex( value );
+        lex.Val( effect );    
+        }
+    return effect;
+    }
+
+// -----------------------------------------------------------------------------
 // Checks whether trigger is runnable
 // -----------------------------------------------------------------------------
 //
@@ -3104,7 +3125,7 @@
                     else if ( aString == XnPropertyNames::action::event::KSetActiveFocus )
                         {
                         CXnNode* previousNode = aEngine.FocusedNode();
-                        if ( previousNode != node )
+                        if ( previousNode && previousNode != node )
                             {
                             if ( IsNodeNavigableL( *node ) )
                                 {
@@ -3154,22 +3175,11 @@
 //
 static void RunFullScreenEffectL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
     {
-    CXnDomList& list( aEventNode.AttributeList() );
-    const TDesC8& effectid( XnPropertyNames::common::KEffectId );
-    CXnDomAttribute* attribute( static_cast< CXnDomAttribute* >
-        ( list.FindByName( effectid ) ) );
-
-    if ( attribute )
-        {
-        
-        const TDesC8& value( attribute->Value() );
-        TLex8 lex( value );
-        TInt effect;
-        lex.Val( effect );
-        
+    TInt effectId = ResolveEffectId( aEventNode ); 
+    if( effectId )
+        {
         aEngine.AppUiAdapter().EffectManager()->BeginFullscreenEffectL(
-                effect, aEngine.ViewManager()->ActiveViewData() );
-        
+            effectId, aEngine.ViewManager()->ActiveViewData() );        
         }
     }
 
@@ -3210,36 +3220,40 @@
 // RunActivateNextViewL
 // -----------------------------------------------------------------------------
 //
-static void RunActivateNextViewL( CXnUiEngine& aEngine )
-    {
-    aEngine.ViewManager()->ActivateNextViewL();
+static void RunActivateNextViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
+    {
+    TInt effectid = ResolveEffectId( aEventNode );
+    aEngine.ViewManager()->ActivateNextViewL( effectid );
     }
 
 // -----------------------------------------------------------------------------
 // RunActivatePreviousViewL
 // -----------------------------------------------------------------------------
 //
-static void RunActivatePreviousViewL( CXnUiEngine& aEngine )
-    {
-    aEngine.ViewManager()->ActivatePreviousViewL();
+static void RunActivatePreviousViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
+    {
+    TInt effectid = ResolveEffectId( aEventNode );
+    aEngine.ViewManager()->ActivatePreviousViewL( effectid );
     }
 
 // -----------------------------------------------------------------------------
 // RunAddViewL
 // -----------------------------------------------------------------------------
 //
-static void RunAddViewL( CXnUiEngine& aEngine )
-    {
-    aEngine.ViewManager()->AddViewL();
+static void RunAddViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
+    {
+    TInt effectid = ResolveEffectId( aEventNode );
+    aEngine.ViewManager()->AddViewL( effectid );
     }
 
 // -----------------------------------------------------------------------------
 // RunRemoveViewL
 // -----------------------------------------------------------------------------
 //
-static void RunRemoveViewL( CXnUiEngine& aEngine )
-    {
-    aEngine.ViewManager()->RemoveViewL();
+static void RunRemoveViewL( CXnUiEngine& aEngine, CXnDomNode& aEventNode )
+    {
+    TInt effectid = ResolveEffectId( aEventNode );
+    aEngine.ViewManager()->RemoveViewL( effectid );
     }
 
 // -----------------------------------------------------------------------------
@@ -3278,6 +3292,60 @@
     }
 
 // -----------------------------------------------------------------------------
+// RunActivateEditorL
+// -----------------------------------------------------------------------------
+//
+static void RunActivateEditorL(
+    CXnNodeImpl* aThis,
+    CXnNode& aLayoutNode,
+    CXnUiEngine& aEngine,
+    CXnDomNode& aEventNode,
+    TBool aActivate )
+    {
+    CXnNode* editorNode( NULL );
+    CXnDomList& children = aEventNode.ChildNodes();
+    TInt count = children.Length();
+    for ( TInt i = 0; i < count; ++i )
+        {
+        CXnDomNode* dnode = static_cast< CXnDomNode* >( children.Item( i ) );
+        const TDesC8& type = dnode->Name();
+        if ( type == XnPropertyNames::action::KProperty )
+            {
+            const TDesC8& id = dnode->AttributeValue( KId );
+            CXnNode* node = aEngine.FindNodeByIdL( id, aThis->Namespace() );
+            if( node && node->Type()->Type() == KTextEditor )
+                {
+                editorNode = node;
+                break;
+                }
+            }
+        }
+
+    if( !editorNode && aLayoutNode.Type()->Type() == KTextEditor )
+        {
+        editorNode = &aLayoutNode;
+        }
+    
+    if( editorNode )
+        {
+        XnTextEditorInterface::MXnTextEditorInterface* editorControl = NULL;
+        
+        XnComponentInterface::MakeInterfaceL( editorControl, editorNode->AppIfL() );
+        if( editorControl )
+            {
+            if( aActivate )
+                {
+                editorControl->HandleEditorEvent(CXnTextEditor::KActivateTextEditor);
+                }
+            else
+                {
+                editorControl->HandleEditorEvent(CXnTextEditor::KDeactivateTextEditor);
+                }
+            }    
+        }
+    }
+
+// -----------------------------------------------------------------------------
 // RunEditL
 // -----------------------------------------------------------------------------
 //
@@ -3412,6 +3480,7 @@
             }
         
         aEngine.EditMode()->SetEditModeL( CXnEditMode::EDragAndDrop );        
+        aEngine.AppUiAdapter().ViewAdapter().BgManager().DrawNow();
         }
 
     CleanupStack::PopAndDestroy();
@@ -3521,7 +3590,8 @@
             }                
         }
     
-    aEngine.EditMode()->SetEditModeL( CXnEditMode::ENone );    
+    aEngine.EditMode()->SetEditModeL( CXnEditMode::ENone );   
+    aEngine.AppUiAdapter().ViewAdapter().BgManager().DrawNow();
 
     aEngine.AppUiAdapter().ViewAdapter().UpdateRskByModeL();
     }
@@ -3871,6 +3941,37 @@
                 {
                 *aClassId = &value;
                 }
+            else
+                {
+                // Everyting is within the same property tag
+                // e.g. <property name="display" value="block" type="string" id="my_id"/>
+
+                // Save name...
+                *aName = &name;
+
+                // ...and value
+                if ( aValues )
+                    {
+                    HBufC8* valueH = HBufC8::NewLC( value.Length() + KUnitMaxLen );
+                    TPtr8 ptr( valueH->Des() );
+                    ptr.Append( value );
+                    aValues->AppendL( valueH );     //take ownership
+                    CleanupStack::Pop( valueH );
+                    }
+                
+                // ...and type
+                const TDesC8& type = node->AttributeValue(
+                    XnPropertyNames::action::event::systemset::KType );
+                *aType = &type;
+
+                // ...and id
+                const TDesC8& id = node->AttributeValue(
+                    XnPropertyNames::action::event::systemset::KId );
+                HBufC8* utfName = HBufC8::NewL( id.Length() );
+                TPtr8 ptr = utfName->Des();
+                ptr = id;
+                aId = utfName;
+                }
             }
         }
     }
@@ -4322,30 +4423,21 @@
         {
         aEngine.Editor()->RemoveWidgetL( aEngine.FocusedNode() );               
         }
-    else if ( nameString == XnPropertyNames::action::event::KRunFullScreenEffect )
-        {
-        TInt viewCount( aEngine.ViewManager()->ViewAmount() );
-
-        if ( viewCount > KOneView )
-            {
-            RunFullScreenEffectL( aEngine, aEventNode );
-            }
-        }
     else if ( nameString == XnPropertyNames::action::event::KActivateNextView )
         {
-        RunActivateNextViewL( aEngine );
+        RunActivateNextViewL( aEngine, aEventNode );
         }
     else if ( nameString == XnPropertyNames::action::event::KActivatePreviousView )
         {
-        RunActivatePreviousViewL( aEngine );
+        RunActivatePreviousViewL( aEngine, aEventNode );
         }
     else if ( nameString == XnPropertyNames::action::event::KAddView )
         {
-        RunAddViewL( aEngine );
+        RunAddViewL( aEngine, aEventNode );
         }
     else if ( nameString == XnPropertyNames::action::event::KRemoveView )
         {
-        RunRemoveViewL( aEngine );
+        RunRemoveViewL( aEngine, aEventNode );
         }
     else if ( nameString == XnPropertyNames::action::event::KActivateView )
         {
@@ -4408,6 +4500,8 @@
     else if ( nameString == XnPropertyNames::action::event::KReportEnterEditMode ) 
             
         {
+        RunFullScreenEffectL( aEngine, aEventNode );
+        
         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
             XnPropertyNames::action::trigger::name::KEditMode ) );
         CleanupStack::PushL( trigger );
@@ -4431,6 +4525,8 @@
         }
     else if( nameString == XnPropertyNames::action::event::KReportExitEditMode )
         {
+        RunFullScreenEffectL( aEngine, aEventNode );
+
         CXnNode* trigger( BuildTriggerNodeL( aEngine,                    
             XnPropertyNames::action::trigger::name::KEditMode ) );
         CleanupStack::PushL( trigger );
@@ -4480,7 +4576,16 @@
         aEngine.AppUiAdapter().ViewAdapter().BgManager().SetWallpaperL();
         return ETrue;
         }
-           
+    else if ( nameString == XnPropertyNames::action::event::KActivateTextEditor)
+        {
+        RunActivateEditorL( aThis, aNode, aEngine, aEventNode, ETrue );
+        return ETrue;
+        }
+    else if ( nameString == XnPropertyNames::action::event::KDeactivateTextEditor)
+        {
+        RunActivateEditorL( aThis, aNode, aEngine, aEventNode, EFalse );
+        return ETrue;
+        }    
     return EFalse;
     }